display 0-12v battery voltage on LCD

Status
Not open for further replies.

hhhsssmmm

Member level 1
Joined
May 14, 2009
Messages
37
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,732
hello guys

i just want to know the math equations that will be needed to go into my C18 code to display the battery voltage from 0-12V on LCD.

Of course the battery voltage is scaled from 0-5 volts and im using a 10bit adc on PIC18F2420 with VDD as the ref.

MY head has worked out following to put in my C code for the necessary scaling factor conversion.

1 / [(R1+R2)/R2] .... lets say this inverse results of value X

ADC voltage at PIC pin (0- 5V) = X * ADRES .... lets say this product results of value Y.

Now Y is the actual voltage from 0 to 5V on the ADC pin. This of course represents the scaled 0 - 12V via the potential divider.

Now what is the next step after this to get the value of Y to represent the value from 0 - 12V for the battery voltage so i can display
on LCD??

what must i multiply or divide to get my desired result?....

im lost...plz help

Thanks

Haseeb
 

you should scale the input voltage so that it can be adc'd by the mcu between 0 - 0x3ff, corresponding to 0v and 12v.

so, you can map any reading of ADRESH:ADRESL to a voltage between 0 and 12v.

all it is required now have been taught at elementary school.
 

Hi,

Let's say :

R1+R2 = 10k ;
Vo=Vin/3;
R1=6.7k;
R2=3.3k;

you can now measure voltages up to 15V and you have to multiply your result with 3 ...

ex. mikroc c language :

Vin = Adc_Read(0); // Read from channel 0 (AN0)
mV = (Vin * 5000) >> 10; // mv = Vin x 5000 / 1024
mV = 3*mV // multiply with k=3
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…