Measuring voltage between 15+/-V and output to lcd.

Using the analog pins and the ADC i want to measure voltage. So far I can measure positive voltage and get a reading using a potential divider. There is lots of info already on this but not so much on negative voltages. A suggestion i found says instead of grounding one end supply a voltage to that end but when i do this I get very strange readings just using analogRead().If i do this what should i include in my code? I have included the diagram i am trying to follow. The ratio of the divider is 10:1. Could that be the problem? Any suggestions appreciated. (getting values on the lcd is not an issue)

conorsquash:
A suggestion i found says instead of grounding one end supply a voltage to that end

That is the right concept. You need to add a big enough voltage so that the -15v shows up as 0, or a little higher. With your 10:1 voltage divider the -15v should appear as -1.5 so try adding (say) 3.3v from a 3.3v regulator IC. That way the full range of +1.5 to -1.5 will become +4.8 to +1.8 (all within the Arduino's 0-5v range) and you know to use maths to subtract 3.3 to get the correct value.

...R

Something like the enclosed would do the job..

Allan

offset.pdf (18.3 KB)

offset.pdf (18.3 KB)

Robin2:
and you know to use maths to subtract 3.3 to get the correct value.

Thanks for your response Robin.. I have one problem that is i am not sure where to subtract the voltage in the code. If in subtract 682 (3.3 when converted) from the analogRead() value it messes up the result and i get values between -12 and +18v using a 9.4V battery . Any suggestion is appreciated

I hope this is correct ...

Suppose you are measuring -7.5 volts. And you have a 10:1 voltage divider giving -0.75v. And you sit that on top of +3.3v giving +2.55v.

The ADC will read that as 1023 / 5 * 2.55 = 522.

So you need to convert the 522 to 2.55 volts and then subtract 3.3 from it to get back to -0.75v. Something like this (avoiding the need for floating point maths)

adcVal = analogRead(A0);
volt100Val = 5 * 100 * adcVal / 1024; // should give 255 for adcVal = 522
                                                       // divide by 1024 is much easier for Arduino than 1023
trueVolt100Val = (volt100Val - 330) * 10 // should give -750 (or -7.5 * 100)

...R