Impossible Sensor?

liudr...

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

Thanks for the replys gents,

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.. :stuck_out_tongue:

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 ]:smiley:

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... :slight_smile: --- )

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 ]:smiley:

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... :smiley:

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...

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()
{  

int pressureLevel = analogRead(pressurePin);
//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){
  return (analogRead(pin) * .004882814);
}

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 :smiley: )

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?

I connected a ground (quickly) before I went to work.... I was getting the right voltage reading from the serial.print and that looks to have sovled the problem. I'll know more tonight when a run the sensor through the range of pressure but it's looking promising!

Thank you very much for the tip!!!!!

-Rob

Great! Just to chime in on the ground issue.

There is no problem connecting grounds together unless there's a big ground loop, not your problem.

From my limited teaching experience in electronics, 50% of something not working was because it's not turned on, the other 50% is ground not connected :slight_smile: