Electronics, Robotics and Computing Tutorials for Everyone!
Thursday, 9 June 2016
Designing a pressure sensor using Velostat
In the previous post I designed a circuit which was supposed to read in when pressure was applied to a custom sensor made from velostat.
The first post on the Piano conversion
I made a sensor out of some single sided FR4 printed circuit board material, some foam tape, two pieces of wire, a small 1 cm x 1 cm piece of velostat and some sticky tape!
Custom Pressure Sensor using Velostat
This is just a prototype and may not be my final version of the sensor. I wanted to see how well velostat worked and how it would behave. It seems to work really well!
I found from measurements with my multimeter that when the pressure sensor is not touched the resistance across the wires is 30 kΩ. When pressure is applied it drops to 1 kΩ. That should be more than good enough for the purposes of detecting a key-press!
The constructed pressure sensor
Next the PCB designed in the previous post was etched, drilled and populated. It etched well and I populated it with the designed components:
The Underside of the PCB
The topside of the PCB with components
I then wrote some quick test code for the arduino because I'm leaning towards using an arduino for the microcontroller:
/*
Pressure Sensor test CodeFor Electronic Piano(c) A. Lang 2016*/// These constants won't change. They're used to give names// to the pins used:constint analogInPin = A0; // Pressure Sensor connected to A0int sensorValue = 0; // value read from the pressure sensor via the amplifier stagefloat outputValue = 0; // value output to the Serial portvoidsetup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
voidloop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.println();
// wait 10 milliseconds before the next loop// for the analog-to-digital converter to settle// after the last reading:
delay(10);
}
The code is very similar to code I had written before - what is it with me and pressure sensors at the moment! I then uploaded the code to the arduino and tested it - It didn't work as planned - I may have been a little disappointed at this point....
I then thought about my circuit and looked at the schematic:
The original Key Press schematic
I realised I had made a mistake. I didn't account for how the velostat would behave in terms of it's resistance. I thought it would have a resistance of around 1 kΩ and vary....it doesn't it's resistance is
30 kΩ and varies down from that when pressure is applied. Because of this I need to tweak my circuit from behaving as a two stage buffer to a simple analogue comparator and buffer. Luckily it won't be too hard to change things!
Here is the new circuit:
Add caption
The Key Press Schematic Version 2
The new circuits works in a similar fashion as the previous one. The velostat pressure sensor makes up a voltage divider. The output of the voltage divider is connected to an analogue comparator made with the first op-amp in an LM358 dual op-amp IC. The negative input has a 2.75 V reference set by the 8.2 kΩ resistor and the 10 kΩ resistor. The output of the 1st op-amp is then connected to a buffer amplifier with a gain of two and then the output is connected to a FET and an LED. The output will be sent to the ADC of the micro-controller which will probably be an Arduino.
To test the circuit I removed a 10 kΩ resistor and then added a 7.5 kΩ resistor (because I couldn't find an 8.2 kΩ resistor). Here is a photo of the modification:
Here is the modified PCB layout although I probably won't etch this board again. I'm going to re-design it to use surface mount components and be a smaller form factor. It would be nice if each board fit snugly under each piano key.
The New Key Press Layout
I then connected the circuit back up to the arduino and pressed the sensor! It worked. The LED lit up - although I wish I had used a brighter LED...but SUCCESS!! So sweet...
Here is a graph I made from the serial monitor results. It looks very similar to the simulated oscilloscope trace from the first post!
The results from the serial monitor
So now we have a valid method of reading key presses we need to scale things up - and shrink a few things down. I will redesign the key press PCB layout to use surface mount components to take up as little room as possible. Then we need to look at multiplexing all of the signals together...and for that I'm going to use the 74HC4076 integrated circuit breakout board.
No comments:
Post a Comment