Hi !
Im doing a project using the adc (ADRESH(easier) => 8bits) and LCD. I'm using a configuration that in the input of the adc i'm gonna have 5v when im sensing 10Amp. 2.5v when im sensing 5AMP and so on.
so i need the value of the adc in volts and then to multiply that value for 2.
So i i'm thinking that i need to do this.
ADCVal = ( Vin *255 ) / 5
so i need vin..
vin = ( ADCVal * 5 ) / 255
Asumming that my vin is 2.5v the adc will read 7F, 127 in decimal so substituting in the formula.
vin = (127 * 5 ) / 255 = 2.49v
Now i multiply that for 2 to get amps.
2.49 * 2 = 4.9 amps.
i need to send 4.9 amps to the LCD, so im thinking to multiply 4.9 by 10 to have 49 an then by some means, im going to extract the 4 and then convert it to ASCII send it to the LCD, send the " . " and then convert the 9 in ASCII and sen it to the LCD.
The problem is that i dont have any idea on how to begin converting bin to decimal in PIC, and after i have a value like " 49 " how to extrat the 4 and the 9 to send it to the LCD in ASCII.
If any of you coul teach me an easier way to do this it would be cool or some routines to do what i want.
I have encountered some routines to convert binary to BCD but i dont want the digits extracted because i need to substitute the ADCval in Decimal. Well im confused.
Thanks.
Im doing a project using the adc (ADRESH(easier) => 8bits) and LCD. I'm using a configuration that in the input of the adc i'm gonna have 5v when im sensing 10Amp. 2.5v when im sensing 5AMP and so on.
so i need the value of the adc in volts and then to multiply that value for 2.
So i i'm thinking that i need to do this.
ADCVal = ( Vin *255 ) / 5
so i need vin..
vin = ( ADCVal * 5 ) / 255
Asumming that my vin is 2.5v the adc will read 7F, 127 in decimal so substituting in the formula.
vin = (127 * 5 ) / 255 = 2.49v
Now i multiply that for 2 to get amps.
2.49 * 2 = 4.9 amps.
i need to send 4.9 amps to the LCD, so im thinking to multiply 4.9 by 10 to have 49 an then by some means, im going to extract the 4 and then convert it to ASCII send it to the LCD, send the " . " and then convert the 9 in ASCII and sen it to the LCD.
The problem is that i dont have any idea on how to begin converting bin to decimal in PIC, and after i have a value like " 49 " how to extrat the 4 and the 9 to send it to the LCD in ASCII.
If any of you coul teach me an easier way to do this it would be cool or some routines to do what i want.
I have encountered some routines to convert binary to BCD but i dont want the digits extracted because i need to substitute the ADCval in Decimal. Well im confused.
Thanks.