12F675 ADC Problem

Author
Erkan.Arslan
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2013/07/13 14:51:18
  • Location: 0
  • Status: offline
2013/09/07 11:02:55 (permalink)
0

12F675 ADC Problem

Hi,
I'm trying to use ADC (10 bit) of PIC 12F675. I prepared a test code which turns on a led if the voltage in the analog input pin is higher than 3.8V and turns off if lower. Test code runs in a while loop continuously. A voltage source is directly connected to analog input pin and ground. I change the output voltage to test the ADC code. It works fine when I increase the voltage. Nothing happens(led is off) until it reaches 3.8V and then the led turns on.
 
The problem is that when I decrease the voltage led stays on until analog input voltage is below 3.5V. Once it is off it won't turn on until voltage reaches 3.8V. And again it is on until voltage is below 3.5V.
 
Supply voltage of the microcontroller  is 5V. ADC is 10-bit. In my test I noticed that if the value of the resistor in series with the led is increased, "turn on" and "turn off" voltage difference decreases. For example it is on above 3.8V and off below 3.7V. If I connect 10K resistor voltage difference is nearly 0.3V.
 
Thanks
#1

4 Replies Related Threads

    David
    Super Member
    • Total Posts : 1125
    • Reward points : 0
    • Joined: 2007/12/17 23:19:53
    • Location: uk sussex
    • Status: offline
    Re:12F675 ADC Problem 2013/09/07 14:17:59 (permalink)
    +2 (1)
    schematic/code ?

    David
    I support http://picforum.ric323.com because this forum is often too broken to use!
    #2
    wa1vgb
    Super Member
    • Total Posts : 978
    • Reward points : 0
    • Joined: 2011/07/08 12:10:39
    • Location: Which way to East Vassalboro
    • Status: offline
    Re:12F675 ADC Problem 2013/09/08 05:26:03 (permalink)
    +2 (1)
    So it would seem that as the load on the PIC power supply changes, your ADC is reading different values for a constant input voltage.
    #3
    tom maier
    Super Member
    • Total Posts : 2116
    • Reward points : 0
    • Joined: 2013/08/22 15:27:12
    • Location: earth
    • Status: offline
    Re:12F675 ADC Problem 2013/09/08 05:59:58 (permalink)
    +2 (1)
    wa1vgb

    So it would seem that as the load on the PIC power supply changes, your ADC is reading different values for a constant input voltage.



    Yeah, it sounds like the power supply is sagging under load. Vref for the adc is the supply voltage.
     
    #4
    Ian.M
    Super Member
    • Total Posts : 13030
    • Reward points : 0
    • Joined: 2009/07/23 07:02:40
    • Location: UK
    • Status: offline
    Re:12F675 ADC Problem 2013/09/08 06:39:40 (permalink)
    +2 (1)
    A 10 Kiloohm resistor in series with any visible LED powered from a 5V supply will pass no more than 0.38mA.
    If the voltage across your PIC'S power pins is varying significantly when the load changes by less than half a mA, either your power supply is total cr*p or you have a bad contact between your power or ground rail and the PIC's pins.
     
    A schematic with component values + a good clear photo of your assembled circuit would help us help you further.
     
    p.s. WA1VGB is hinting that the PIC's ADC is ratiometric.   Unless you use a PIC that supports using an external ADC reference and enable that feature, the ADC's numeric output is basically proportional to Vin/Vdd.  Change either and the result changes.
    post edited by Ian.M - 2013/09/08 06:43:35
    #5
    Jump to:
    © 2017 APG vNext Commercial Version 4.5