I need your help.

Thread Starter

JBSPINZ

Joined Apr 12, 2012
2
Okay i need help with a ADC program with a pic12f683.

i need it to have 1 input (analog) and 2outputs.

Now the tricky thing is the input is going to be 0-5volts
and when the voltage hits 2.5volts both outputs are low when the voltage
gets 2.4 or less one output goes hi and when the voltage goes 2.6 or higher the other output goes high. they say its simple hex math but im stuck
can anyone help ? Thanks
 

ErnieM

Joined Apr 24, 2011
8,377
Say you take the A2D and use the 5V VDD supply as a reference. Then as the input ranges between 0 and 5 V the A2D output will range from 0x000 to 0x3FF by the formula:

D2A = Vin/Vref * 1023 (round off the result)

So an input of 2.4V yields a count of ox1EB (491), and an input of 2.6V yields 0x213 (532).
 
Top