Skip to main content

Week 7: Input Signals

·767 words·4 mins
Sophie Fan
Author
Sophie Fan

Can I measure my breath? (Part 1)
#

Group Assignment
#

For our group assignment, Eric taught us different techniques to measure input signals. The most useful one was the oscilloscope.

For the student fashion show, I want to make a wearable with blooming flowers that open and close based on the wearer’s breath, so for this week, I wanted to try designing a sensor for diaphragm contraction and expansion.

I explored to idea of trying to make my own force sensor by measure across an elastomer, similar to a strain gauge. I wanted to try my own capacitance sensing, but I realized that was a bit ambitious for the week and I wanted to explore what was already available on the market.

It looks like adafruit supplies a conductive rubber cord that is impregnated with carbon black, so it changes resistance when stretched! Awesome!

The specs say that the resistance is 350 ohms per inch when not stretched, so after taking some measurements, I found that when I have exhaled, the circumference around my ribcage is 28", and after inhale, my ribcage circumference is 29". This means that the nominal resistance for the unstretched length is 9.8 kΩ, and the stretched length is 10.15 kΩ, which should be detectable.

I measured the resistance of the conductive rubber using a multimeter. There was around 41 inches total unstretched, and unstretched it was around 8.7 kΩ, and stretched to 50 inches was around 14.8 kΩ, which roughly agreed with the specs.

The website suggested using a voltage divider to measure Vout and the change in resistance. With the current numbers, I sized the resistor to be 10 kΩ.

I decided to also add an LED to my schematic to visually gauge the stretch of the elastic.

While I could measure the Vout from the resistors, I could not use it to directly power the LED, because that voltage would not be linear. Instead, I had to take care of the math in software.

Final PCB!

I decided that for this week, I would just mill my board on copper and FR1 instead of trying to cut traces with the vinyl cutter for time reasons.

Unfortunately, during the first two mills, the copper clad kept bowing, which resulted in some failed mills where the traces were not cleanly etched and shorted.

Improperly milled pcb

After securing the bottom left corner with more brackets, I was able to get a cleaner PCB. I soldered the components and added a bodge wire to ground because I realized the traces to the ground pad on the xiao were not making a connection. I ended up using a 11 kΩ resistor.

PCB with bodge wire

I soldered some wires to the voltage divider footprint to connect the conductive rubber into the circuit, and I soldered them to some alligator clips. I also realized that I did not make the correct traces to ground the connections, so I had to add a bodge wire for ground.

Then I ran into other issues. When I wrote my script to measure voltage and resistance, I was getting very large values that didn’t actually vary with the stretch of the conductive rubber. I was very confused.

Incorrect Code!

After talking with Quentin, I realized that the raw value read from the analog pin on the xiao was a number in terms of 0-1, but scaled for 16 bits, so scaled by 2^16! And the number measured is not even a factor x raw voltage, which I had initially expected, but simply a value for the 16 bits. I was actually measuring a value in terms of input voltage / output voltage across the divider, which is a normalized voltage!

Incorrect Code!
Fixed Code!

Here is the correct python script.

After fixing my code and my math, the xiao was able to successfully measure my input signal! Here it is vizualized in Arduino’s serial plotter:

Reflections
#

  • Double check that ground is always routed in the pcb, it’s a trace that is easy to neglect because everything in most of the pcbs I make share a ground!
  • Always double check code and specs for reading any type of signal
  • Debug and check along the way! Checking the resistance of the rubber cord and probing different points with a multimeter on my pcb helped me narrow down issues.
  • Again, be mindful of usbc port placement for microcontrollers. I realized that my usbc port on the xiao was still not near the edge of the board enough.

Special thanks to Quentin for helping me debug the input signal code!
#