Binary to Decimal from ADC
Hi i need help with converting the Binary numbers coming as the result from the ADC onmy pic so i can display the result to 2 decimal places on my lcd...
I require a simple routine to convert 255 to a decimal (5.00000) and then multiply it by 3 (15.00) to two places...
im using a 16F767 clocked to 20mhz.
Thx :)
(and thanks all especially melanie for the many informative posts)
1 Attachment(s)
Resistor Potential Divider
Consider the appended drawing.
Assuming a 3:1 ratio (ratio determined by R1+R2:R2), Resistor R1 has to drop 2 volts for every one volt appearing across R2. So, if we have 15v input, R1 has to drop 10v across it for R2 to drop 5v. Apply the same ratio for your Resistor Values... if we have 10K for R2, we will need 20K for R1.
The voltage the PIC will see will be Vin/(R1+R2)*R2... so if we have... R1=22K, R2=10K and Vin=12, we get...
12/(22000+10000)*10000 and the PIC sees 3.75v
10K is a good value for R2. Choose R1 so that the PIC never gets more than Vdd (most probably 5v) at the maximum possible applied input voltage to the divider.
info about dec dig and dec3 ?
Where can I find information on dec dig and dec3 modifiers? I searched through the PBP manual but came up empty.