pouchito said:
Hi Everyone,
I am writing a code that takes an analog input (values ranges from 0.5V to 3V ) and displays the result on the LCD
I wrote the code but still needs to scale it to volt.
what i got till now is when the analog input is for example 5V ==>the LCD shows 1022 (decimal)
I guess after reading "Gramo's webpage" I can use this :
Result1 = Result1 * 5 / 1023 ' Scale it to volts
in my case is this right or i must multiply it by 5000?
( I am still a newbie in the ADC world :S )
(I am using PIC simulator IDE compiler)
Thanks in advance
I think this will help u.
i am also beginer, sorry for mistake if any.
Supose u want to make a volt meter it's maximum range will be 5 Volt(as u say)
Ur ADC converter has 10 Bit resulotion it mean in it has maximum value in decimal 1023.
it means as u apply maximum voltage(as u say 5 volt) to ADC it will give u 1023 in decimal.
So the formula is
Code:
Voltage = Applied voltage * maximum range / ADC resulotion
Voltage > measured voltage (we don't know it's value)
Applied Voltage > This is our applied voltage which we apply on ADC leg it rage will be 0 ~ 1023.
Maximum range > for which range u want to scale it( as u say 5 volt)
ADC resulotion > 10 Bit it means it maximum value in binary = (1111111111) or in Decimal 1023.
Now we start,
u want to scale it for 5 Volt( it mean it's maximum reading will 5 volt)
The formula will be
Code:
Voltage = Applied voltage * 5 / 1023
for example u apply 5 volt to ADC.
then ADC will convert this value into binary so it will be (1111111111) or if we see it in decimal then it will be 1023
It means
So we put this value in our formula
Code:
Voltage = 1023 * 5 / 1023
So the answer will be
Now an other example
Supose u apply 2.5 volt to ADC
So it will conver it into binary (0111111111) or it will eqaul to 511 in decimal.
So we put this value in our formula
So the answer will be
I think now u can understand that whis is going on.