Impossible Sensor?

I was planning on using a autometer 2242 oil pressure sender to read water pressure… I don’t know if I can get it to work and wanted to run it by the pros

The characteristics of the sensor are as follows:

0 PSI ------------------100 PSI
250 ohm ---------------50 ohm

I am having a hell of a time trying to figure out how to set up a voltage divider to get this to work!!!.. It seems no matter what combination of resistors I use, I lose a lot of resolution, meaning, I get .25v-1.1v. I have been trying different Vin’s and resistors.

I think I’m over my head here… so any help will make me happy!

p.s. I’m using an Uno.

If you are using the Arduino USB for power only...

You could use an external +9V Wall wart... or Battery...

Then you use a 250---o---250 network. The max voltage should be 4.5V when the sensor is at 250 ohms... You supply a 250 ohm resistor, attach it to the +9V the other end to the sensor... The other sensor lead goes to board ground... if you use a battery you have to attach battery ground to the board as well...

Then you attach the center point of the divider to the ADC...

The when it goes to 50, you get what?... 50/300 * 9V === 0.15V (at minimum) or am I too tired to do arithmetic??? When the sensor is 250 Ohms -- you get 4.5V -- so that is a reasonable swing.

Total R is the 250 Ohm Resistor plus the 50 ohm minimum reading from the sensor... for determining current flow and minimum voltage. If you have a divider with equal resistors you know you get half the voltage at the mid-point.

Your current is 9V/300 ohms = 30ma -- which should be OK even for a battery -- fine for a wall wart 9V supply.

I use a 9V wall supply on my Mega2560 -- sometimes the additional voltage is handy..

Does this make sense to you?

PS: If you want you could put a 5V Zener across the sensor for safety... However, the thing you learn quickly when designing large systems is that doubling the number of components more than doubles the odds of failure... Also -- mostly it is the safety/checking circuits that fail.

You could also do a separate divider (using 1k--o--1k) then take the 4.5V and use it for the Analog Reference -- just read the CAUTIONS first -- on the reference page so you don't fry your analog in pins.

Can you put three resistors in series between 5V and GND like: 5V----1K–A0–sensor----1K----GND? The A0 is analog 0. This way you may get a better resolution, I guess. You can calculate the relative error:
dR/R=4/1024*Ralg^2/Rgeo^2, where Ralg is algebraic average between 1K and 1K+sensor, Rgeo is geometric average between 1K and 1K+sensor, you can use 1K+sensor for R.

With 250Ohm , the error is 2504/1024(2250/2)^2/(1000^2+1250^2)=0.5Ohm.
With 50Ohm, the error is 504/1024(2050/2)^2/(1000^2+1050^2)=0.1Ohm.

This looks good to me. 8)

Also looking at the original circuit will help.

liudr...

If you do that you get a swing between .23 Volts and... .833 volts... I don't think that is what he wants...

WillR,
I’m getting 1.5v for the 50/300 * 9v.

liudr,
Maybe I’m not following you, but when I run your number though Vout=R2/(R2+R1)*Vin, I only get a difference of .8volt.

Is there a way to cut my losses and limit the sampling range to more convenient voltages? Like 2.8v and .75v? lol…

Or even... does someone know a better sensor or way to get water pressure? I'm trying to keep this under \$100 and I know that some pressure transducers can work but they are typically more than \$100 themselves.

Right... too tired.. :P

Considering the water pressure is likely to be about 50 psi... what i suggested would give a swing from 4.5 to 1.5V or three volts... But our water pressure varies typically from 35-55 psi (well system)...

But even from 0-50psi that is a 1.5 v swing... which is OK... 1.5/5 *1024 or about 307 bits on the 10 bit ADC UNO converter...

1.5/4.5 * 1024 = 341 bits if you use the analog reference.

What is the intended purpose? Is that enough range?

Alternatively do the obvious.... use two batteries -- put a -9v at the bottom of the sensor and choose the resistor hooked to the top to bias the sensor output to 0V when the sensor is at 50 ohms... using a resistor to the -9V battery might allow you to do this more easily... it's just Ohms law.... nothing more complicated....

Put the sensor on your desk... put a battery and a resistor on either side and loudly and firmly repeat ohms law... that should smack it into line... :grin:

hmmm...

Maybe I'm seeing this wrong then. I thought with a analog input, I would need to match the 0-1.1v/3.3v/5v range.

Are you saying that I don't have to have one side of the range down to 0v?

Then how would I ensure that when there is 2.6-4.5v (for example), the Uno is reading 0-100 PSI?

Having the resolution to the .3 would be fine... very fine.

Yes the average pressure will be around 50PSI but can be as high as 75 or as low as 8.

Thanks again for the help

WillR: liudr...

If you do that you get a swing between .23 Volts and... .833 volts... I don't think that is what he wants...

Really? I admit I made a mistake with using 1K and not including it in my calculation but my voltage is around 2.5, where best resolution is. Did you see I have two 1K resistor and one on each side? :astonished:

Plus your math needs a shift of the decimal point ]:D

This is an interesting math problem. Will the sensor take what max current? My rechargeable 9V battery has less than 200mAh so with 250 Ohm serial resistor, the battery lasts around only 8 hours. Maybe you should use 1.5 battery with a typical 2000mAh rating and use internal reference of 1.024V?

RobDrizzle: hmmm...

Maybe I'm seeing this wrong then. I thought with a analog input, I would need to match the 0-1.1v/3.3v/5v range.

Are you saying that I don't have to have one side of the range down to 0v?

Whatever for? As long as the range is sufficient for purposes desired -- who cares???? If you are really fussy you can do this... http://arduino.cc/en/Reference/Map

Then how would I ensure that when there is 2.6-4.5v (for example), the Uno is reading 0-100 PSI?

Arithmetic? See above -- map command to make life easy... you can even have it do the inversion... (Math is a little more complicated --- arithmetic will do... :) --- )

Having the resolution to the .3 would be fine... very fine.

Yes the average pressure will be around 50PSI but can be as high as 75 or as low as 8.

Thanks again for the help

Before I did much I ran every example I could. Modified it tested it etc. Too many people skip this step of the learning process. There is an ADC/MAP example -- check it out...

I have been at this over 40 years and I am not too proud to run examples created by teenagers... I do not have time or inclination to be brilliant -- I would rather copy smarter peoples work... My brain hurts when I think. Anyway, I recommend the approach. :grin:

QUIT THINKING! Copy... what do you think they teach in university... rotflmao!

liudr:

WillR: liudr...

If you do that you get a swing between .23 Volts and... .833 volts... I don't think that is what he wants...

Really? I admit I made a mistake with using 1K and not including it in my calculation but my voltage is around 2.5, where best resolution is. Did you see I have two 1K resistor and one on each side? :astonished:

Plus your math needs a shift of the decimal point ]:D

This is an interesting math problem. Will the sensor take what max current? My rechargeable 9V battery has less than 200mAh so with 250 Ohm serial resistor, the battery lasts around only 8 hours. Maybe you should use 1.5 battery with a typical 2000mAh rating and use internal reference of 1.024V?

Sigh! I know. Arithmetic is not my forte... Thanks.

Put a differential sign in front of it and it may slowly leak into my brain.... but maybe not... :roll_eyes:

And yes we Agree -- you can use the external analog reference to set the top of the range, and use the map command to spread out the readings... The map command just makes the code a little easier to write -- it does not improve accuracy and/or precision... it just puts a pearl necklace on a pig if you get my drift... :D

Another approach is to use a constant current source to feed through the sensor, then measure the voltage.

The map command is the KEY!!!! lol... I'm going to dig into this during lunch but now that I see I don't have to have a perfect 0v - AREF voltage, I see where you guys where coming from!

Please excuse my dumbness when it comes to this stuff... I'm an ME and would rather machine parts all day than work with electronics, not to mention micro processors. I really find this interesting and will continue to learn, but man is it slow going!!!

Thanks guys!

Spent one evening at the reference and tutorial section of www.arduino.cc Just reading to learn what is possible and it will go much faster ..

I got a bit about that on my blog too...

http://captain-slow.dk/2010/10/18/voltage-dividers-and-arduino/

RobDrizzle: The map command is the KEY!!!! lol... I'm going to dig into this during lunch but now that I see I don't have to have a perfect 0v - AREF voltage, I see where you guys where coming from!

Please excuse my dumbness when it comes to this stuff... I'm an ME and would rather machine parts all day than work with electronics, not to mention micro processors. I really find this interesting and will continue to learn, but man is it slow going!!!

Thanks guys!

It just gets slow and difficult at a different level... Nothing Changes! 8)

Best Wishes.

Ok… So I got my voltage divider working well. 0 PSI = 4.60v and 100 PSI = 1.55v (close enough for me). I have the arduino picking up power from the USB and the sensor’s voltage divider is powered by a 9v battery. I get a 4.5v with a multimeter across Vout and ground but the arduino is reading all over the place (2.5 - .88 volts) and is acting like it is just picking up noise.

I didn’t see anything jumping out at me that was wrong so again I’m asking for your help!

I had the Vout plugged into analog pin 0 and was running this program to watch everything.

``````int pressurePin = A0;

void setup()
{
Serial.begin(9600);
}

void loop()
{

//pressureLevel = map(pressureLevel, 0, 1023, 318, 943);
//pressureLevel = constrain(pressureLevel, 318, 943);
//float pressure = pressureLevel;

//pressure = (pressureLevel);

float pressure = getVoltage(pressurePin);

Serial.print("PSI = ");
Serial.println(pressureLevel);
Serial.print("Volt = ");
Serial.println(pressure);
delay(500);

}

float getVoltage(int pin){
}
``````

Am I missing a connection? Do I need to pull a wire the center of the voltage divider to “AREF”?

Have you consider using: analogReference(type) Description

Configures the reference voltage used for analog input (i.e. the value used as the top of the input range). The options are:

• DEFAULT: the default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)
• INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8 (not available on the Arduino Mega)
• INTERNAL1V1: a built-in 1.1V reference (Arduino Mega only)
• INTERNAL2V56: a built-in 2.56V reference (Arduino Mega only)
• EXTERNAL: the voltage applied to the AREF pin (0 to 5V only) is used as the reference.

And check example in IDE->File->Examples->Analog.

Am I missing a connection? Do I need to pull a wire the center of the voltage divider to “AREF”?

My guess is your forgot to wire a jumper between the 9 volt negative terminal and a Arduino ground pin. Without it there is no common reference between the two separate electrical circuits, the voltage divider and the arduino, and floating wandering numbers are likely what you get (and deserve )

Lefty

^^^^That is actually what I was assuming. I didn't do it cause I was unsure if it would be ok to plug the 9v into the ground of the board. I can use any pin labeled ground right?