Hardware/software projects
2022 - ...
rp2040
rp2040 Microcontroller
programming using C-SDK
The C-SDK is open source, has good examples and is very well documented.
The C-SDK directly supports PIO assembly language, DMA transactions, and will support the highest interrupt rate of the development systems.
The instructor for ece4760, Van Hunter Adams, has produced many cool C applications for the rp2040.
My projects are broken down by category below.
- ece4760 Support
General utilities and information relevant to ece4760 at Cornell.
All examples and student code are written using the Protohreads framework for multitasking.
- Protothreads 1.3 (written by Adam Dunkels) to be used 2024
A port to the rp2040, extended for two cores with support for hardware locks, core-safe semaphores, and core-to-core hardware FIFOs. Protothreads provides a simple, cooperative, thread environment with very fast context switch and low memory overhead. Modified thread dispatcher implements priority scheduling in addition the default roundrobin.
- Visual Studio configuration.
Configure VS for editing, programming, debugging using the Pi Debug Probe
- Add program/reset button
A trivial hardware and software addition simplifies programming.
Superceded by using the debugger.
- WIFI setup.
The physical considerations and software necessary for WIFI.
- Fixed point arithmetic
Somewhat faster the floating point on the rp2040. We implemented s15x16 (signed, with 15 bits of integer, and 16 bits of fraction) and s1x14 fixed point.
- Graphics
Graphics input and output using 640x480 VGA, with optional joystick or encoder wheel.
Mouse interface is also shown in the USB section.
The serial interface is not really graphics, but plays around with color and formatting.
- External Memory
Everyone needs more memory. FRAM works well for simple files with bandwidth
requirments below about 1.5 Mbyte/sec.
SD card with FatFS has a larger program size overhead, but is compatable with PC read/write of huge files.
USB FLASH drives are exzplained the the USB MSC example below.
- LWIP on PicoW
LWIP is the supported TCP/IP stack for the PicoW.
LWIP has lots of options and somewhat limited documentation.
This section has lots of examples to exercise some of the options.
Opotions include bringing up the PicoW as an WIFI access point or WIFI station and
data transfer by UDP or TCP.
- TCP protocol
- Network Time Protocol
- UDP protocol
- Symmetric send/receive between two picoWs (access point to station)
Each picoW can send or receive packets.
The code running on the two nodes is almost identical.
- Audio-rate UDP from picow to picow (access point to station)
Sending real-time data from picow to picow with no router involved.
- Data array UDP send/receive (station to station thru hotspot)
Sending an array of data allows performance testing as well as understanding of data sizes, and dealing with packet efficiency.
- UDP send/receive from desktop (station to station thru hotspot)
UDP
protocol is a simple and fast, but does little error checking. It is therefore useful for data streams where a bad value is not a show stopper. You might send music but not code.
- UDP send/receive pico-to-pico. (station to station thru hotspot)
A simple scheme for figuring out IP addresses on the fly allows two picos to send data to each other.
- USB on Pico
USB uses the tinyUSB implementation and is fairly big.
There are lots of ways to use it. Examples are your friend.
- Amusing (to me) computational projects
These may have little general appeal, although the DMA computing machine could be a co-proessor.
- DMA computing machine.
The DMA subsystem is capable of running a compute-universal system.
This implementation uses three channels for fetch/execute, and a list of DMA control blocks as a program.
- Random number generation.
Using the ROSC to make reasonable quality random numbers. Routines for integers, fixed-point uniform and normal distributions, and for single bits.
- Lattice-Boltzmann fluid flow simulation
A strange hybrid of finite difference and cellular automaton using fixed point arithmetic for speed. The fixed point system used is s1x25. The shorter, and faster, 16-bit fixed point did not have enough precision for stable solutions.
- 16-bit floating point,
with similar bit layout to the IEEE standard FP16, but without infinities or NANs. The reason for doing this annoying exercise is to see if ODE solvers run faster in limited precision floating point than in fixed point. The 16-bit floats have a dynamic range similar to s15x16 fiexed point, but are not faster then standard 32-bit floats.
-
- DSP
More numerical flogging of the M0 architecture, with an emphisis on speed using 16-bit fixed point.
The IIR and FIR sections use design implementations which run completely in C on the the M0, at the
cost some slightly non-optimal designs.
- IIR filter designer
Using s1x14 fixed point format. Lowpass, bandpass, and highpass filters design. Plots the Bode plot of the designed filter, and allows the new filter to be used in realtime for audio input.
- FIR filter designer
Using s1x14 fixed point format. Lowpass, bandpass, and highpass filters design. Plots the Bode plot of the designed filter, and allows the new filter to be used in realtime for audio input. Also a version for linear frequency plots.
- Speech compression/playback from IIR filterbank.
Speech sampled at 12.8 Ksample/sec is sent through 32 MEL-distibuted IIR filters.
The filter powers are sampled every 20 mSec and used to reconstruct speech using DDS.
- FFT and FilterBank spectrograms
FFT compared to lower resolution MEL spectrum
for speech input.
- FFT Spectrogram
Plotting the power spectrum, log power spectrum, and spectrogram of voice signals. The spectrogram actually has enough info to decode what is being said.
- DSP development
IIR filters in fixed point s7x24 format. Butterworth lowpass and bandpass filter.
- Sound Synthesis
Since we can do DSP, can we use it to make sounds we might actually want to listen to.
FM synthesis is very 1970's synth kind of sound.
The Karplus-Strong algorithm actually solves the wave equation on a stirng in realtime to make
physically reasonable stringed instrument sounds.
- FM synthesis of sounds.
Some FM synthesis even sounds like music. Widely used in the 1970's, '80s, and even into the 90's. for music and sound effects.
- Karplus-Strong strings
Plucked and bowed string physical synthesis. An approximation of the actual PDE of a string.
- PIO
- Using Verilog to understand the rp2040 PIO processors. The Pi rp2040 microcontroller has 8, single cycle, deterministic, Programmable i/o blocks (PIO). Each PIO is programmed using a 9-instruction assembly language. We have been speculationg about how you make a single-cycle machine (including jump). This project attemptes to answer that, without implementing the entire PIO architercture.
- rp2040 PIO control
Experiments to see if modifing the code of a running PIO channel is feasable.
- Implementing a input capture ability.
To emulate the precise time stamp feature found on AVR and PIC32
With two PIO state machines, you can get single cycle capture resolution.
- rp2040 Interpolator hardware
- Weighted average of two audio signals using blend mode.
- Line generator for VGA using blend mode.
- Tone burst generator using clamp mode.
- DDS and FM waveform synthesis using interpolator peripherial and clamp mode.
Copyright Cornell University
October 1, 2024