Abstract

Output devices: using the step response to synthesize a sound.

This week I added the I2S module to my board to synthesize a sound based on the step response received from a large copper plate with a remote processor. In parallel, I built on from my board last week and brought the ATTiny412 step response to a working (albeit kind of clumsily) state. Based on the lessons from last week, I modified both the ATTiny remote processor board, as well as the main RP2350 board, in order to improve wiring layout. The two boards are shown below, and the Kicad files are available below:

  • Main board schematic: here
  • Main board layout: here
  • Remote board schematic: here
  • Remote board layout: here

Pictures of the board layouts are shown below.

Main board Remote board
Main and remote processor boards, version of this week.

The Arduino code used to program the ATTiny412 board, via UPDI, is available here. Essentially, it sets pin PA2 to low, and drives the pin PA1 high and low periodically to measure the step response, and flushes the output to PA6 (the UART connection). The number of cycles measured for one output, as well as the timeout duration (ie., the time after which, if no response is received, is considered invalid) must be synced with those in the code driving the main board. The two pins connected to the board (PA1 and PA2) are allowed to discharge through a resistor, which, in this version, is 5 megaohm.

The MicroPython code running on the main board processor is available here. It integrates an advanced filtering algorithm, which subtracts a slowly moving, dynamic average background, smoothens out sudden variations in the step response (due to random noise in the environment), distinguishing real, robust variations from random noise. It integrates several debugging modes (which are useful for tuning the parameters for the filter), and defines each of the two UART channels as objects which can be read independently/in parallel. Furthermore, the program allows to operate with only one of the channels connected if the other is not to be used.

For the I2S audio synthesis, the Viper decorator is used to compile the code to improve sound data transmission speed. The parameters D_MIN and D_MAX correspond to the filtered step response values corresponding to the minimum and maximum frequencies F_MIN and F_MAX, chosen to represent three octaves in the audible range. It also features a “gliding” allowing to smoothen sound synthesis with the hand sweep and eliminate sharp, unpleasant transitions.

Below is a video of this prototype theremin in action, with only one board connected that controls the pitch of the sound. As you can see, the sound synthesis works well, but the step response sensor isn’t great. The grounding issues also haven’t disappeared. Part of the reason seems to be that the chosen plate size, together with the discharge resistor, are too large. Before background subtraction, the charge built up on the plates is very large, and it changes by less than one percent with the hand sweep. This gives a very bad dynamic range, sensitivity, and noise tolerance. I will experiment with smaller plates and lower resistance. It also seems like using a separate pin for discharge rather than the ground is not a good idea, and I’d be better off discharging through the ground. Finally, I am now on the fence about whether having a remote ATTiny412 is a good idea. When powered at 3.3 V, its clock frequency only goes up to 8 MHz, which makes it very slow compared to the RP2350, whose step response worked very well at 250 MHz. I may try to use another RP2350 as a remote processor. Also in terms of speed, the ability to directly program the PIOs of the RP2350 down to the clock cycle also makes it a much better choice compared to the ATTiny.

AI disclosure: the code for the filtering and for the audio synthesis was generated using Claude Opus 5.5 used inside MIT’s Parley platform.