Abstract

Measuring something: the step response from a large copper board.

In this week, starting from the board I made two weeks ago, I tried to attach two step response sensors to detect the proximity of my hand. In the case of the theremin, these would be the two antennae that would control the sound pitch and loudness. As demo step response sensors I used two double-sided PCB boards, onto which I soldered a jumper wire on each side. The bottom sides of these boards would be connected to the ground of my microcontroller, through 1 MegaOhm discharge resistor each. The top sides of the boards are connected to two of the GPIO pins that pull as output to high, then shift to input and measure the number of clock cycles it takes that the pin reaches back low. As a hand nears the blank circuit boards, the capacitance between them changes and so does the discharge time. You can see below a picture of what the these boards look like.

Step detectors
Copper boards for step response detection.

I then adapted the code for the step response through an external resistor from the course page to work with my two detectors, and through the GPIO pins 26 and 27 that I singled out for this purpose for my microcontroller board. This code is available here. The code is written in MicroPython to allow easy access to clock-cycle level instructions in Assembly.

Below is a video of these boards acting as step response sensors. They work relatively well at detecting hands that are close to them, and have a pretty high resolution/can distinguish well between different hand positions. Ideally, I would like to have them detect hands a bit further away, which could be fixed by using larger discharge resistors. What is not so good about them is cross-talk (one detects signal from the other and vice versa) as well as influence from the environment (as you can see, when I touch my laptop case, I detect a large signal on both!).

Both of the unwanted effects I mentioned above are partly due to them sharing a ground (which means any discharge through the ground will be felt throughout the system) as well as the length of the wires (which pick up signal from a large range in the environment). The two solutions I have in mind are the following:

  • Do not discharge through the ground, but through a separate processor pin, such that a discharge of one sensor isn’t felt by the others.
  • Use a remote processor (such as the ATTiny412) located at the step response board that only processes the signal at the board, and then relays it to the main processor via the UART protocol.

As I am not a fan of trying multiple changes at once, I decided to first try making such a remote processor board, and programming it, while still discharging through the ground. Below are the schematic and the layout of such a board, where I left two holes for connecting the step response board to the ground to the signal line, connected by a 1 MegaOhm resistor. There is also a three pin header to connect to the main processor board (one pin for ground, one for 3.3 V, and one for data transmission via UART). To program the ATTiny412, an additional two-pin header connecting to the ground and to the UPDI port was added. A zero ohm resistor is added in the UPDI net to avoid path crossing. Design files available here and here.

Remote processor schematic Remote processor layout
Schematic and layout of remote PCB board.

I soon realized that programming via UPDI was a bit more complicated than I thought. I milled myself a serial-to-UPDI 2 pin adapter, which is available on the week 2 class page, and I tried to make myself a USB-to-serial adapter following Quentin’s design. Unfortunately this turned out to be one of the few edge cases where an RP2350 microcontroller doesn’t work as a replacement for a RP2040, and there were no RP2040 microcontrollers available in our lab. Fortunately, we had readily-made USB-to-serial adapters that I could use instead. Below you can see the three boards that I milled this week.

Milled boards
The boards I milled this week.

After a ton of debugging, which included realizing that my ground trace on the serial-to-UPDI adapter is broken, as well as the fact that the ATTiny412 needs to be powered by 3.3 V during the programming process, I finally was able to flash an Arduino program onto my ATTiny412. Below you can see the creative mess that allowed me to bypass these issues.

UPDI programming
Creative workarounds for programming ATTiny412 via UPDI.

Unfortunately, by the time I wanted to test whether this processor was actually doing what it was supposed to, I noticed that the main microcontroller board wasn’t working properly. By testing with a voltmeter I noticed that the 3.3 V line was at 1.9 V (relative to the ground) and that the GPIO pins could also only be pulled up to at most 1.9 V. This seemed to not be enough to power up the ATTiny 412, nor the MP3 player + speaker that already existed on the board. My suspicion is that something got fried inside the RP2350 while either resoldering some of its pins or during testing the test response. As of the time of writing this, the issue is still to be figured out, but I would like to fix it soon for my final project.