The MPS020N0040D pressure sensor is a cheap component readily available for purchase on sites like eBay.
I recently needed to create a blow activated switch and, as I already had a few of these at hand, decided to design a minimal circuit that would provide a digital output when a threshold pressure was detected by the sensor.
How does the pressure sensor work?
A pressure transducer converts an applied pressure into an electrical signal that can be measured.
The majority of transducers are made up of two main components – an elastic part that deforms when exposed to pressure and an electrical part that detects that deformation.
The most common form of elastic material is formed into a thin flexible membrane called a diaphragm. The electrical device that detects the deformation of the diaphragm can be based on a resistive, capacitive or inductive principle of operation.
The datasheet for the MPS020N0400D indicates that this a resistive device. This type of pressure transducer has strain gauges bonded or embedded into the surface of the diaphragm so that any change in pressure will cause a change in the electrical resistance of each strain gauge.
The datasheet shows that the resistive device inside the sensor acts like a Wheatstone Bridge. It measures differential pressure between ‘atmospheric’ pressure
(nominally 101.3kPa) and the pressure on the diaphragm, with full scale output at 40kPa.
This Wheatstone Bridge arrangement is frequently used in strain gauges. In this case it will produce a a voltage that varies proportionally to the change in resistance caused by the diaphragm’s deformation.
I measured the resistance between nodes inside the sensor at about 5kΩ. Testing the bridge with a 5V supply also showed that I would be getting about 10mV output for the type of pressure I was creating by blowing into the sensor. Clearly some sort of amplification would be required on the output signal before it could be used to as a switch.
Also, I was not interested actually measuring the force of the pressure, just that the pressure had been applied. So there was no need for any calibration or other signal filtering capability.
Designing the circuit
An Operational Amplifier (OpAmp) is designed to do exactly what is needed. Texas Instruments has a good Application Note on using OpAmps in signal conditioning for resistive pressure sensors (see here).
The OpAmp amplifies the difference between voltages applied to their two inputs. The voltage to only one input is amplified if the second input is grounded. Both of these properties are used to create the pressure switch circuit.
If I need an output voltage required of about 5V for an input of 10mV, then I need to amplify the signal 500 times (5000mV/10mV). Using the OpAmp as a Differential Amplifier I calculated the resistances that would give me the needed gain using this specialised calculator.
Once I had the amplified output, I then needed put that through another OpAmp that will ‘infinitely’ amplify any slight difference between an arbitrary setpoint voltage (achieved using a trimpot as a voltage divider on one of the inputs) and the amplified pressure voltage signal from the first stage of the circuit. This second OpAmp effectively produces a digital output of either 0V (for no pressure) or 5V (for pressure) at the output, with a trimpot setting the voltage threshold at which this transition occurs.
The final circuit is shown below. The circuit uses a LM358 OpAmp because they are inexpensive I had these at hand but just about OpAmp will do in this application.
Making the PCB
For testing, I make my own prototype PCBs using my Shapeoko 2 CNC mill controlled using a TinyG Controller and Chilipeppr software combination. Chilipeppr has developed nice features to auto-level the board and can read an Eagle CAD file directly to and produce a milling path. With no intermediate steps the workflow is straight from CAD design to PCB milling!
As you can see in the PCB layout, when I design for my desktop CNC machine, I make the pads extra big with wide traces for easy manufacture, soldering and handling, especially as the board is generally not solder masked for a one-off build.
The actual prototype board at manufactured and completed stages is shown below.