18F1220 A/D Converter question


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005
    Location
    Holmfirth England
    Posts
    116

    Default 18F1220 A/D Converter question

    Hi,

    I am a little confused about using the A/D converter.

    I have a 10MHz resonator with PLL enabled.

    This is how I have configured the A/D.
    Code:
    TRISA = 255
    TRISB = %00000111
    ADCON0 = %00000001  'Vref = Vss Vdd, turn on A/D
    ADCON1 = %11111110  'Only Channel 0 analog
    ADCON2 = %10110110  'Right justified, 16 TAD, TOSC/64 (for 40MHz)
    This is how I am taking a reading.
    Code:
    atod:
    ADCON0.1 = 1          'Start A/D conversion
        while ADCON0.1 = 1    'Wait for it to finish
        wend    
        adresult.highbyte = ADRESH
        adresult.lowbyte = ADRESL
        angletime = adresult * multiplier
        temp = (adresult * decimal1) / 10
        angletime = angletime + temp
        temp = (adresult * decimal2) / 100
        angletime = angletime + temp ' We now have phase angle delay
    return
    The results are a little jittery, even though the signal looks stable on the scope.
    In the data sheet there is talk of taking readings in sleep mode, but I am not sure if this is just for the RC clock source. If I do need to be in sleep mode then the clock will be off, so do I need to set FOSC, and tad differently?

    Best regards
    Bob.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 A/D Converter question

    Not sure about the sleep mode, but do you have a capacitor between the ADC pin and VDD?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Feb 2005
    Location
    Holmfirth England
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 A/D Converter question

    Hi,

    Yes I do have a 1uF cap on the input, but between input, and Vss. Reading the data sheet a few times it is only necessary to sleep if using the RC osc.

    The problem must be due to interference. My prototype boards do have quite a few wires all over the place, no ground plane, and when the welder is running at 2000A there must be large magnetic fields all over the place.

    Strange though, even when idle the signal will be rock solid for 30 seconds or so, then it jumps all over the place for a bit, then solid again. No signs of anything on the input when using the scope in glitch detect mode. I suspect it would work fine on a propper pcb, with ground planes.

    Regards
    Bob.
    Last edited by BobEdge; - 28th July 2011 at 09:09.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts