Need help with pressure sensor

Hello,

I'm really really new to all this stuff. I've successfully completed an LM34 temperature sensor project with no problems thanks to the great tutorials available. However, I'm having a difficult time interfacing an analog pressure sensor to an Arduino UNO board.

I have an SSI P51-1000-A-B-I36-5-R pressure sensor (Digi-Key # 734-1069-ND) which measures PSIA. Here are links to data information about the sensor. http://search.digikey.com/scripts/DkSearch/dksus.dll?lang=en&site=us&KeyWords=734-1069 http://www.ssitechnologies.com/PDF/Application%20Notes/PS_AN2_MediaSensor_P51_Product_Overview.pdf

Note that the sensor requires 8-30vdc input so I have to use external power instead of taking power directly from the UNO board. I'm currently using a spare laptop AC adapter that according to my voltmeter is delivering a steady 18.74vdc. The sensor uses three wires Vin, Vout, and GND.

My voltmeter shows that the sensor output is a very steady 1.05v however the value returned by analogRead() is jumping around between 203 and 210 which doesn't make sense to me since it seems the UNO should be returning a consistent value from analogRead given the very consistent output from the sensor. This also makes sense since the atmospheric pressure being measured from the sensor (sitting on my workbench) isn't changin enough to cause such values from the UNO.

I'm also having trouble determining a formula for converting the analogRead() value to PSI. This particular sensor is calibrated to output 1vdc at 0psi. Since it is measuring PSIA it will output something above 1vdc just sitting on my workbench due to atmospheric pressure and that voltage is currently 1.05vc, and it will never output less than 1vdc because that indicates a perfect vacuum. The maximum output is 5vdc at 1000psi. So the voltage output range is 1-5vdc representing a span of 0-1000psi.

What is causing the analogRead() value to drift so much and how do I derive a formula that converts tha adc output to a PSI value?

Any help appreciated.

Check - http://arduino.cc/en/Reference/AnalogReference?from=Reference.AREF - to increase the range of the analogRead().

Furthermore be carefull to check the range of the device as the Arduino can handle 5V max. Consider optocoupling to prevent a smokling IC...

Tried analogReference but it didn’t help, neither did mapping the value from analogRead to various scales.

The drift continues regardless of vref or scale. At a 5v reference (which should work in this case) the analogRead is drifting between 199 and 209 on a steady unchanging 1.050 input voltage from the sensor. Given that each step of the ADC should be 5v / 1024 = .0048828125, the maximum drift I should see is between two numbers, not ten.

Air pressure shouldn't be changing very rapidly - couldn't you simply apply some smoothing to the analogue values?

however the value returned by analogRead() is jumping around between 203 and 210

Could be noise on the line, try a 0.1uF capacitor from the arduino input to ground.

AWOL: Correct...atmospheric pressure being what it is, changes very slowly. The sensor in fact is outputting 1.05vdc very steady (hasn't changed in hours) so the ADC should be providing a steady reading as well.

GRUMPY_MIKE: Just read your response so I'll try your suggestion. In the meantime, I did connect a wire between ground on the sensor to ground on the UNO board and that smoothed things out dramatically. Now the ADC drift is about 3 steps with an occasional (once every 10 minutes or so) spike of 5-6 steps. I'll add the capacitor and see if that helps.

So, you're saying you didn't have the grounds connected at all before? But I'll bet when you measured the voltage (presumably with a meter), you connected both the red and the black leads.

Grumpy_Mike: Could be noise on the line, try a 0.1uF capacitor from the arduino input to ground.

@Grumpy_Mike: I have the same problem.

How is this wired? One wire goes from sensor to Arduino's analog pin, than second wire gees from that same analog pin to the above 0.1uF capacitor and third wire goes from the capacitor to Arduino's ground? Isn't it a bit dangerous to connect directly analog pin and ground?

@drobnjak: I think he meant capacitor(+) to analog input, capacitor(-) to power supply ground. In my case I am using a separate power supply (18.72vdc) and not powering the sensor by the UNO board.

I added a 10uF electrolytic capacitor (didn't have a .1uF) as suggested and it did smooth out the drift, but not completely. The ADC is now drifting between 210 and 211 consistently with occasional reads of 209 and 212. In my specific application the 1 step difference is a big hit so I really need to get a steady output from the analog sensor.

This may be anecdotal, but while playing with this last night, and before trying the capacitor, I did have one cycle in which the analogRead was consistent at 211 for a long time. Previous to that run, I had tried to tighten up some connections from the pressure sensor and the wire connecting power ground to UNO ground had popped out. When I reinserted it and ran the code again I got steady unwavering 211 from analogRead. I assumed that perhaps the wire I was using was too small and not making a good connection so I replaced it with a bigger wire. Unfortunately after doing so the analogread drifting came back. So while I don't know what the difference was, I do know that it CAN read the sensor accurately and consistently. I now have to wonder if some of the connections with my breadboard are causing the problem.

This is some stuff I found on the web about smoothing the Arduino's inputs:

Smoothing Analog Sensor's Input to Arduino http://electronics.stackexchange.com/questions/17754/where-to-place-a-capacitor-to-smoothen-ir-sensor-reading http://forum.bildr.org/viewtopic.php?f=20&t=74 http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1232603123 http://www.arduino.cc/en/Tutorial/Smoothing http://en.wikipedia.org/wiki/Low-pass_filter

I am going to try low-pass filter, as suggested, using the formula from Wikipedia. My sensor is attached to the Arduino Duemilanove.

Have you got the grounds connected?

AWOL: Have you got the grounds connected?

The ground wire from my 18.72 power supply is connected to: 1) The ground wire of the pressure sensor 2) The GND pin on the UNO board (next to the 5v power pin) 3) The ground wire of the 10uF capacitor (+ lead going to analog input).

Although my sensor is connected to the Arduino, both for the power and for the output, I wanted to compliment this thread with solution that worked well for me.

I implemented the low-pass filter that Grumpy_Mike suggested, with 100uF ceramic capacitor and 14.7KOhm resistor, that should eliminate all the frequencies above 100Hz. Resistor goes in series and capacitor in parallel with Arduino's ground. This add-on circuit worked like a charm and completely rid of the Arduino's analog input pin noise.

@DROBNJAK, so how exactly did you wire it up?

The reading you get from calling analogRead depends not only on the voltage on the analog input pin but also on the exact voltage of the +5v supply. If you are powering the Arduino from USB, or you have any high current devices running from +5v, then your +5v line won't be stable and this will cause the reading to vary, even if you eliminate all noise from the analog input pin.

If the pressure range you are interested in means that the output won't go above 3.3v then I suggest you use 3.3v as the analog reference instead, like this:

  • connect the AREF pin to the 3.3v pin
  • in setup() before make any calls to analogRead(), call analogReference() to set the reference to external.

This will also increase the sensitivity by 50%.

The other thing worth doing is separating the analog grounds from other grounds. Use one of the Arduino ground pins to connect the ground side of your sensor and any capacitors you have for filtering the analog inputs. Use a different ground pin for everything else.

Unfortunately none of these suggestions are resolving the situation. To make matters worse, today I notice that when I pull the power wire from the LM34 sensors but leave the LM34 sensors ground wire intact, the ADC reads 0.

When I remove power from the pressure sensor the ADC reads random numbers just as it does if I read an analog input with nothing attached.

Here it is ...

The circuit on the left of the prototype board is left unplugged, it is for sensor. I've done experimenting with a potentiometer, instead with the sensor, because Arduino's input was equally noisy with both of them and pot is less cumbersome. The circuit on the right, one with pot, is plugged live into Arduino. It is very basic, there is a 14.7KOhm resistor in series between the pot's/sensor's output and Arduino's input pin (orange wire). Than there is 100uF ceramic capacitor, in parallel, between the signal wire and Arduino's ground (black wire). Essentially it is the same circuit as shown on the Wikipedia's page about low-pass filters.

This is my general setup, or at least one of previous incarnations. Basically I am producing an air stream with a ducted fan and blowing it onto a Pitot tube, where sensor is Freescale MPXV7002DP. This sensor has a three wire interface: voltage supply, ground and analog voltage output. Both Arduino and voltmeter are measuring sensor's output voltage, as a double check. That is how one can confirm that it is not a sensor that is noisy, but the Arduino's input.

joepekoe: Unfortunately none of these suggestions are resolving the situation.

Have you actually tried using the +3.3v pin as the analog reference? Your existing setup won't give you stable readings because the 5v supply you are getting from the USB port will be too variable.

joepekoe: To make matters worse, today I notice that when I pull the power wire from the LM34 sensors but leave the LM34 sensors ground wire intact, the ADC reads 0.

When I remove power from the pressure sensor the ADC reads random numbers just as it does if I read an analog input with nothing attached.

You've no right to expect any particular reading when you don't connect the sensor in the way it is supposed to be connected. However, if you want a stable reading when the pressure sensor is disconnected, you could try adding a 100K resistor between the sensor output and ground. Unfortunately, the data sheet doesn't give the output resistance of the sensor, so I can't say whether this will affect the reading.

btw your ceramic capacitor can't be 100uF, it might be 100nF but by the look of it in your photo, I suspect it is less than that.

dc42: Have you actually tried using the +3.3v pin as the analog reference? Your existing setup won't give you stable readings because the 5v supply you are getting from the USB port will be too variable.

Frankly, I don't recall, but I don't think I used 3.3v reference. However, I did try using a 12v car battery instead of the USB port and that did not stop the drifting of the ADC reads.

dc42: You've no right to expect any particular reading when you don't connect the sensor in the way it is supposed to be connected. However, if you want a stable reading when the pressure sensor is disconnected, you could try adding a 100K resistor between the sensor output and ground. Unfortunately, the data sheet doesn't give the output resistance of the sensor, so I can't say whether this will affect the reading.

btw your ceramic capacitor can't be 100uF, it might be 100nF but by the look of it in your photo, I suspect it is less than that.

Regarding the 0 reading, I was trying to anticipate how I could account for the sensor not being connected to the analog input. I want to be able to remove the sensor and when it is removed from the circuit the LCD should just display "0". However, it looks like when nothing is connected to the analgo input but you read it anyway, you get random numbers back. Somehow I would have to sense that the sensor is not connected and output "0" with an lcd.print or something. I'd be interested in a better solution.

By the way, the photos are not my setup, but that of DROBNJAK.

Have you tried low pass filter?

It worked like a charm on the Arduino's input in the above circuit.