Pressure switch

Mark.R

Member
Hi, I’m starting to look at my second ever project with a Picaxe chip probably an 08.
I want to get rid of four mechanical pressure switches and replace them with a single sensor and have four on/off set points with hysteresis for each point.
I have seen the sensor that I would like to use it is 0 to 1 PSI and gives a full scale output of 45mV so I assume it is 45mV per PSI, and a 0 to 5 PSI with a full scale output of 115mV which is 23mV per PSI.
I will fit ether sensor depending on the overall scale that the unit will be expected to read.
I am assuming that I just wire the sensor into an analogue input and then set four outputs, may need an op-amp to lift the input voltages. My main problem is the program side of this project any help would be most appreciated.
 

Mycroft2152

Senior Member
First. don't ASSUME that the mechanical pressure switch has a linear response curve. Check it out at various calibrated pressure. This may save you a lot of headaches later.

Remember the old adage "ASSUME makes an "ASS" out of "U" and "ME"
 

Mark.R

Member
Ok, Ye assume was the wrong word I know that it is 45mV per PSI on that sesnsor and these sensors are linear what the old switches are dosen't mater at this stage.
 

inglewoodpete

Senior Member
Since you provide no details of the pressure sensor vendor/model, I can only discuss a solution in general terms.

First, the PICAXE. Assuming a steady 5v supply to the PICAXE and a 12-bit ADC reading, you end up with increments of 5/1024 or about 5mV per step. If the sensor has a range of 45mV, then you will get a range of about 9 or 10 steps out of the ADC12 readings. Not real good.

Since the output of the sensor is analogue, a DC connected op amp can be used to amplify its output. However, you may need to use +- supplies on the op amp, since most op amps don't let their output swing from rail to rail.
 

demonicpicaxeguy

Senior Member
considering there are many many type of pressure sensor could we have the make,model... etc
a great deal of them have different out methods, which range from i2c,current loops,spi,can ..... etc
 

leftyretro

New Member
Hi, I’m starting to look at my second ever project with a Picaxe chip probably an 08.
I want to get rid of four mechanical pressure switches and replace them with a single sensor and have four on/off set points with hysteresis for each point.
I have seen the sensor that I would like to use it is 0 to 1 PSI and gives a full scale output of 45mV so I assume it is 45mV per PSI, and a 0 to 5 PSI with a full scale output of 115mV which is 23mV per PSI.
I will fit ether sensor depending on the overall scale that the unit will be expected to read.
I am assuming that I just wire the sensor into an analogue input and then set four outputs, may need an op-amp to lift the input voltages. My main problem is the program side of this project any help would be most appreciated.
I think you have a good handle on the steps required. First external scaling of the analog signal to take advantage of the 10 bit 0-5v A/D range on the newer picaxe models, or 8 bits available on all models, if you don't require as much resolution.

In your software program your first going to have to decide if you are going to scale the readings to some engineer units, say psig or work with just the raw A/D 'count' values. If you are just going to set digital outputs on or off depending on pressure value then there is no real reason to do this conversion. However if you are going to display the value to a LCD or send it to a PC then you might as well do the conversion early and do the setpoint calculations using the engineering units.

hysteresis can be a little trickier then might first seem. Real pressure switches are adjusted to trip at a specific pressure value but it also has to be defined if it's a low going pressure alarm or a high going pressure alarm.

A low pressure switch is tested by raising the test pressure significantly above the desired trip point and then the pressure is slowly decreased to see at what pressure value it actually switches at and then adjusted if needed.

If it is a high pressure alarm then the test pressure is started well below the trip value and slowly increased to see the actual trip setting. In the process control industry a typical setpoint alarm specification for a pressure switch that has a total adjustable range of say 10-100 psig might be specified as 50 psig decreasing or 50 psig increasing depending on if it's defined as a low pressure alarm or a high pressure alarm.

All mechanical pressure switches have hysteresis built into them and it is desirable because a pressure value that is right at the trip point would bound to switch on and off continuously as normal process pressure noise brings it above and below the trip value. This is sometimes referred to as deadband and might be as much as 3-5% of total range. So you will need to simulate this hysteresis in your setpoint calculations to determine when it's correct to set or reset the digital output.

So does this help or just add more noise to the topic? ;)

Lefty
 

Mark.R

Member
Thanks to all those who have had a look at the problem I seem more confused now than when I started, but will soldier on.

If it helps at all the sensors I am now looking at using are fron RS, Part No. 216-6253 and 286-686 as these use a 10VDC supply all the rest I have looked at us a 20V supply and with regulators I want the system to run on 12VDC.

If you have a look at rswww.com type the part numbers in there is a data sheet for the sensors and it talks about them being of a Whetstone Bridge Circuit connection which has had me even more.

Thanks again for any help.
 

moxhamj

New Member
Looks like you are stuck with hardware and software. Have a look at http://drvernacula.topcities.com/RFDataLink.htm which contains schematics and pictures and also some completely off-topic photos of two koalas fighting.

Uses a 24PC05 from Farnell which is listed at $23. The wheatstone bridge just needs a differential amplifier to bring it up to roughly 0-5V for a picaxe. This one has a gain of 33. Use a regulated supply. Linearity is good. A few percent drift with temperature through the day. 24PC05 is 0-5psi and Farnell also do the 24PC01 which is 0-1psi. If you have already bought a transducer use the one you have.

Then just use a readadc and a select case routine to pick off the values.
 

Mark.R

Member
Thanks Doc thats been a big help. Iv looked at the drawing in the link you posted and at the data seet for the sensor you are using, the data sheet says the supply is 10v but you are running it all from a 5v supply dose this matter.
 

wapo54001

Senior Member
Mark,

A key question which I did not see answered in this thread is the medium that you are measuring. If it's air, you can easily find a highly accurate transducer for very little money.

You might be better off finding a sensor with the analog amplifier built in with sufficient drive to use the picaxe directly. Depending on the medium -- air, inert or corrosive gas, water, gasoline, etc -- it can be pretty cheap or quite expensive to buy new, but there are many sensors out there that will measure 1psi and deliver an output that will drive the picaxe readADC10 directly. I have an application where I use a 15psi sensor that has an output of .5~4.5vdc for zero to full scale. I can measure that directly with a picaxe and get good accuracy.

There are pcb-mounted sensors available for air and non-corrosive gases that are quite cheap and accurate. My sensor (for gasoline) is stainless steel and costs $110 retail and it's hard to find. Digi-key has a range of steel and brass cased sensors for hazardous or corrosive environments that output 0~100mv full scale in a variety of pressure ranges for about $60 each, but you'll be back to using an op-amp preamp to get the resolution you want.

Have you looked on eBay? Do a search on "pressure transducer" -- if you are patient, eventually you will see one in the one or five psi range, and either .5~4.5vdc output or 4~20ma for zero to full scale. Also, devices that measure from -1psi to +1psi seem not uncommon. I have seen some in that range recently.

You can power the device from your Picaxe's regulated 5vdc, and you'll have a four volt full-scale range which will give you good resolution. Keep in mind that the sensors with voltage output are "ratiometric" which means that the +5vdc is the reference for the output, and so your +5vdc should be adjustable to 5.00vdc for best sensor accuracy. I use an adjustable regulator to achieve a exactly 5.00vdc with the regulator (LM2931CM).

You can easily write the code for your four alarm points with hysteresis, but depending on what else is going on (i.e., do you want to be able to see the actual pressure on a DPM?) the lack of available separate outputs may force you to go with a larger chip than an 08M unless you are willing to "code" the output by using LED flash count or some such on one output.

I have used an 08M chip to deliver two data points. The .5~4.5vdc input represents 0~15psi, and I use the 08M to convert that to a 0~1.500vdc output to represent the 15psi pressure on a panel meter (just move the decimal point), and a separate output provides an alarm that flashes a light whenever the pressure drops below 2.0psi.

Hope this helps
 
Last edited:

moxhamj

New Member
If the device is a wheatstone bridge then the supply voltage doesn't matter. 10V, 5V or something round that mark. Don't put too many volts on though as the resistors will burn up. The cheapest devices are wheatstone bridges which are essentially 4 resistors, one of which changes in value. The bridge configureation tends to compensate for power supply variations though I'd still use a regulated supply (5V) rather than, say, 3 AA batteries.

There are other more expensive transducers which have amplifiers in them and these have specific supply voltage requirements.
 

Mark.R

Member
Thank you again to Dr Acula and to Wapo54001. I think that I can sort the hardware side out as it dosen't need to drive a display, would be nice but the program side just to get four outputs and the like is hard enough without displaying it aswell.
I will be consulting my Picaxe book on programing again.
 

moxhamj

New Member
The software shouldn't be hard. Light up some leds in sequence at arbitrary values
main:readadc (whatever input pin you choose),b0
if b0>20 then
high 0
else
low 0
endif
if b0>50 then
high 1
else
low 1
endif
if b0>120 then
high 2
else
low 2
endif
goto main
 

wapo54001

Senior Member
Mark,

Converting the input to an appropriate output and then outputting it to a dpm is actually pretty easy when you know how to do it. Wilf_NV showed me how to use an 08M to drive an integrator circuit to drive a MOSFET to do this maybe eight or nine months ago.

If you are interested, do a search on "wilf_nv" and "integrator" in the archives -- he provided the code and a circuit diagram that works really well for me. It's a great solution.
 

solderman

New Member
pressure transducer

Hi, I have to agree that it would be nice to know what the pressure is, how far away etc.
These transducers produce very little output as you've discovered so twisted wires + shielding are essential in any serious application.
Personally I'd leave the bit that already works ( eg as extreme limits, alarm etc ) until you are happy with the alternative (after a year, say).

If there is a risk of liquid getting into the line, the sensor must be at the highest point and should always have a short-section of air/gas (pref. clear reinforced tubing), this avoids contamination of the sensor and shattering due to water-hammer.
Conventional switches don't have this problem.

Another poster suggested they aren't linear, well I beg to differ - they are for all normal uses since it's a pair of strain gauges ( either side of a thin wafer), so as one goes up the other goes down. Temperature effects cancel.
However, if you are after real accuracy, then they're right and a careful calibration would make sense.

You will realise the system must stand the very worst-case pressure. It might be sensible to check the sensor supply, just to be certain it's always OK.
 

moxhamj

New Member
Yes, I also agree they are very linear. They do go non linear when you put over twice the rated pressure on them but if that were ever happening (water hammer etc) it would be better to get a higher rated module and live with slightly lower resolution. These transducers come in a huge pressure range.
 

Mark.R

Member
Its all sounding good. I have had a play with the program that Dr Acula posted and Im getting a grater understanding.

Thanks again
 
Top