MAS.863/4.140/6.9020
Lleyton Elliott

Return to Assignments page | Return to main page

Week 9 Assignment: Add a Sensor to a Microcontroller Board that you have Designed and Read It

This week began with a redesign of my development board from Weeks 5 and 6. For that assignment, I made a board without any connector pins on it, so I wanted to make a more general-purpose board with which I could mix and match components.

I also specificially wanted to use a force sensor, which I'll need in my final project. Anthony pointed me to Robert Hart's tutorial on capacitive sensing using a step response. Essentially, two pins of the board are each attached to an electrode of a capacitor. One of the pins sends a digital signal to its electrode that alternates between HIGH and LOW. The other pin reads the analog signal from its electrode, calculating and outputting the difference between the HIGH and LOW signals. The closer the electrodes, the higher the difference, and so the system's output is directly correlated to the compression force applied. This design is very nice for me, as I don't need exact force values in Newtons, I only need a signal that changes based on the force, the limits/bounds of which I can derive empirically. Also, there are many different ways to design the physical capacitor, allowing me flexibility in my final design. Hart's diagram of the setup is shown below:

schematic of the force sensing setup
A relatively simple principle being used in a very cool way

There was one design element I needed to add to my PCB based on this: the two resistors (which should each be a Megaohm or larger) needed to be connected to power (Not 5V but 3.3V in my case as I am using a Seeed Xiao RP2040) and ground in parallel with the analog pin. I then put some connectors into a schematic on KiCAD. I decided to have three each of 3.3V, 5V (unneccessary in hindsight, this board will get a redesign later), and GND pins, plus two LEDs directly on the PCB, with every other pin corresponding to a digital pin of the Xiao board. I finally added the resistors and had this schematic:

my new schematic
The angel on my shoulder tells me to use flags but the devil on the other says it's satisfying when the wires connect

At this point, I'm definitely more comfortable with KiCad's PCB design interface, from how to set up my design rules and ensure I'll have a working PCB to minimizing the number of crossings/optimizing the path of all of the wires. In this case, only one crossing was necessary, and I already had a resistor in that path so it worked out really nicely.

the new PCB layout
Suits my specific purposes whilst also having lots of extra breakout pins

After some milling, sanding, and soldering, my new PCB was ready to go:

new PCB completely fabricated
Solder paste is a lifesaver

The next step was to actually make the sensor. For this week on a time crunch, I just wanted to prove I could get relevant results that varied with force. I soldered jumper wires to copper tape on cardboard (my electrodes) and attached them to pins 0 and 1 of my breakout board. I then put a springy/squishy material between them (in this case, it was actually just a foam-like piece of a fan filter from the back room).

makeshift electrodes
Function > form for now

All that was left (I thought) was to run a slightly modified version of Robert Hart's code, where I increased the number of samples before each output to see a more clear causal relationship.

the milled OSB
The sensing loop

I was getting erratic signals that made very little sense to me, even becoming negative at some points. I talked to Anthony and we diagnosed it as a combination of noise and overflow values. He showed me how to overclock the microcontroller in the Arduino IDE (what I use to edit and upload code to the Xiao RP2040) and then it worked quite well! The output values at this point are quite arbitrary, but the graph below shows the effects of me pushing up and down on my makeshift capacitor.

force sensor output graph
Not quite as pretty as I'd hope but we're getting somewhere

I had statistically relevant results! This is exactly what I had hoped for this week; there will be a very similar sensor in my final project and I have a good sense of at least one workflow for making it work, and it was also very nice to get a second go of PCB design. Thus concludes input device week.

Design Files

Development Board KiCAD (Zip File): week_9_final.zip
Capacitive Sensing Code: week_9_code.ino

Thoughts, Lessons, & Takeaways:

I'm very happy I was able to do the electronics design & production assignments justice in addition to completing this week's assignment. Like I said, I see the work from this week being very helpful towards my final project. My sensor still has a ways to go before it's "good", but I'm happy with this given that it's pretty unfamiliar territory for me. There were definitely bumps along the way, many just little microcontroller setup bugs or slight PCB redesigns, so I'm more comfortable with every part of the workflow from this week. That said, I don't think there are too many super deep takeaways from this assignment and I honestly view it as part 1 of a 2-part series to be completed next week (Output Devices).