• AVR Freaks

Hot!Occasional ADC read value errors

Author
nlauer@micropac.com
New Member
  • Total Posts : 8
  • Reward points : 0
  • Joined: 2018/05/22 12:03:23
  • Location: 0
  • Status: offline
2019/11/08 15:20:49 (permalink)
0

Occasional ADC read value errors

I get occasional ADC read errors with PIC24FV32KA302.
 
Occasionally (about 1 time in 3 hours), the first ADC value in the scan will read as 0xfff, or 4095 decimal.
 
MCC was used to configure and create the code to get the 3 channels to read, at 0.002 second intervals.  The ADC scan is interrupt driven.
The reads are I2C in about 0.002 second intervals.  The I2C is interrupt driven.
The main () loop gets the data ready to be read from the ADC values and puts the information into a buffer to be read by I2c.
 
Thanks,
Norrislte
 
#1

4 Replies Related Threads

    MBedder
    Circuit breaker
    • Total Posts : 6808
    • Reward points : 0
    • Joined: 2008/05/30 11:24:01
    • Location: Zelenograd, Russia
    • Status: offline
    Re: Occasional ADC read value errors 2019/11/08 16:59:01 (permalink)
    5 (2)
    There is a severe error in line #47 of your otherwise brilliant code.
    #2
    nlauer@micropac.com
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2018/05/22 12:03:23
    • Location: 0
    • Status: offline
    Re: Occasional ADC read value errors 2019/11/15 09:58:49 (permalink)
    0
    Issue appears to be resolved.
    It appears that the async. RC clock for the A/D causes an occasional read of ADC to have all bits 1.  Using system clock makes this not happen.
     
    #3
    ric
    Super Member
    • Total Posts : 24593
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Occasional ADC read value errors 2019/11/15 14:08:25 (permalink)
    0
    The RC clock is probably much slower than the system clock.
    (I can only say "probably" because you never reveal what ADC clock settings you use.)
     
    Presumably your "wait for conversion complete" code is faulty, and you were sometimes reading it too early with the slower clock.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    nlauer@micropac.com
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2018/05/22 12:03:23
    • Location: 0
    • Status: offline
    Re: Occasional ADC read value errors 2019/11/15 15:07:56 (permalink)
    0
    Thanks for the input.
    The RC clock is a 1.6 usecond period nominal.
    I changed to use the system clock at 16 MHz, with a divisor of 16.
    The read was done via interrupt after the scan was done.
     
    #5
    Jump to:
    © 2019 APG vNext Commercial Version 4.5