I need your help.

Discussion in 'The Projects Forum' started by JBSPINZ, Apr 12, 2012.

  1. JBSPINZ

    Thread Starter New Member

    Apr 12, 2012
    2
    0
    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
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    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).
     
  3. Felo

    Member

    Feb 20, 2012
    91
    13
    Do you have any code to look at?
     
Loading...