SOLVED: How can I reduce ADC jitter


+ Reply to Thread
Results 1 to 40 of 96

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: SOLVED: How can I reduce ADC drift

    the problem you see does not exist , its the scopes reaction to having an large antenna [YOUR HAND] capacitively coupled to all of its inputs providing an overwhelming signal on it most sensitive ac input range, the scope is unable to provide the dc bias needed to keep the traces aligned in the overwhelmed state
    Warning I'm not a teacher

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170


    Did you find this post helpful? Yes | No

    Default Re: SOLVED: How can I reduce ADC drift

    Quote Originally Posted by richard View Post
    the problem you see does not exist , its the scopes reaction to having an large antenna [YOUR HAND] capacitively coupled to all of its inputs providing an overwhelming signal on it most sensitive ac input range, the scope is unable to provide the dc bias needed to keep the traces aligned in the overwhelmed state
    Excellent, so this won't be an issue since the drop-down circuit will be linked directly the the main board by headers.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: SOLVED: How can I reduce ADC drift

    I try to keep my development code as close to final as possible, cause I know I'll forget to change stuff back. At least this way I can fire and forget the pin initialization
    .


    grounding unused pins and setting them as outputs is pointless , useless and potentially catastrophic


    just leaving them as analog is ten times easier and can never do any harm, setting them as input with wpu on is also ok and can never do any harm

    if the device is not battery powered its not worth any sort of effort
    Last edited by richard; - 4th March 2025 at 04:39.
    Warning I'm not a teacher

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170


    Did you find this post helpful? Yes | No

    Default Re: SOLVED: How can I reduce ADC drift

    - digital input,
    - weak pull-up ON,
    - pin not connected.

    I try to stay away from analog settings; no idea why. Maybe cause I started using only digital way back when.

    https://skills.microchip.com/introdu...tecture/691929

    Unit will always be powered by wall adapter, or possibly USB; but never battery..
    Last edited by Demon; - 4th March 2025 at 21:53.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170


    Did you find this post helpful? Yes | No

    Default Re: SOLVED: How can I reduce ADC drift

    According to this:

    https://skills.microchip.com/introdu...tecture/691929

    The pull-up is disabled automatically when either TRIS is set to an output or the pin is set as an analog input. These changes to TRIS and ANSEL will override WPU settings.

    I can just set all pull-ups ON, leave the unused pins unconnected and forget about them. Then use the others as I wish in ANSEL and TRIS.

    The only times I need to be concerned with WPU is on pins that must not be disturbed for whatever special reason.


    Code:
    WPUA = %11111111    '----------------------------------------------------------------'
    WPUB = %11111111    '           ALWAYS SET WEAK PULL-UPS ON ALL PINS FIRST           '
    WPUC = %11111111    '----------------------------------------------------------------'
                        '       CHANGES TO ANSEL AND TRIS WILL OVERRIDE AS REQUIRED      '
                        '----------------------------------------------------------------'
    
    ANSELA = %00000010                      ' Pin A3 = SW input                 not implemented yet
                                            ' Pin A2 = ADC (B5K)                not implemented yet
                                            ' Pin A1 = ADC (B5K)
                                            ' Pin A0 = ADC (voltage divider)    not implemented yet
    ANSELB = %00000000
    ANSELC = %00000000
    
    TRISA = %00000010                       ' Pin A3 = SW input                 not implemented yet
                                            ' Pin A2 = ADC input 2              not implemented yet
                                            ' Pin A1 = ADC input 1
                                            ' Pin A0 = ADC input 0              not implemented yet
    TRISB = %00000000                       ' Pin B7 = ...not available, ICSPDAT
                                            ' Pin B6 = ...not available, ICSPCLK
    TRISC = %11000000                       ' Pin C7 = RX      *** Datasheet requirement, INPUT ***
                                            ' Pin C6 = TX      *** Datasheet requirement, INPUT ***

    EDIT: I can even leave PORT at the top in case a pin is left as analog output.

    Code:
    PORTA = %00000000                       '-------------------------------------------' 
    PORTB = %00000000                       '       ALWAYS SET PINS LOW FIRST           '
    PORTC = %00000000                       '-------------------------------------------'

    Or did I miss something important...?
    Last edited by Demon; - 4th March 2025 at 22:29.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: SOLVED: How can I reduce ADC drift

    it looks to me that you are creating problems and complications trying to solve a problem that does not exist.
    generic pin control solutions will never work for all chips, there are too many chip variations.

    pic pins to date always default to inputs, analog if possible. leave them that way unless you need one to be different.
    each and every pin you employ needs to configured to suit its usage

    mcc makes it easy
    Name:  demonp.jpg
Views: 3383
Size:  439.6 KB
    Warning I'm not a teacher

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170


    Did you find this post helpful? Yes | No

    Default Re: SOLVED: How can I reduce ADC drift

    Quote Originally Posted by richard View Post
    it looks to me that you are creating problems and complications...

    My memory is getting worse by the year. That's why I try ways to set my code so it's easy to copy and modify for future modules. Of course it rarely works.

    Having WPUA.1 = 1 caused leakage to VSS; it wasn't completely 0; varying in the 1.1mV range. My ADC reading never reached 0.

    I took out the Port = 0 settings, set WPU properly instead of leaving ANSEL/TRIS override it, and now my ADC reading varies from 0 to 1.

    Code:
    WPUA = %11111101    '----------------------------------------------------------------'
    WPUB = %11111111    '           ALWAYS SET WEAK PULL-UPS ON ALL PINS FIRST           '
    WPUC = %11111111    '----------------------------------------------------------------'
                        '       CHANGES TO ANSEL AND TRIS WILL OVERRIDE AS REQUIRED      '
                        '----------------------------------------------------------------'
    
    ANSELA = %00000010                      ' Pin A3 = SW input                 not implemented yet
                                            ' Pin A2 = ADC (B5K)                not implemented yet
                                            ' Pin A1 = ADC (B5K)
                                            ' Pin A0 = ADC (voltage divider)    not implemented yet
    ANSELB = %00000000
    ANSELC = %00000000
    
    TRISA = %00000010                       ' Pin A3 = SW input                 not implemented yet
                                            ' Pin A2 = ADC input 2              not implemented yet
                                            ' Pin A1 = ADC input 1
                                            ' Pin A0 = ADC input 0              not implemented yet
    TRISB = %00000000                       ' Pin B7 = ...not available, ICSPDAT
                                            ' Pin B6 = ...not available, ICSPCLK
    TRISC = %11000000                       ' Pin C7 = RX      *** Datasheet requirement, INPUT ***
                                            ' Pin C6 = TX      *** Datasheet requirement, INPUT ***
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

Similar Threads

  1. SOLVED - IOC works on B0 but not B5
    By Demon in forum General
    Replies: 19
    Last Post: - 26th September 2024, 21:11
  2. Replies: 6
    Last Post: - 5th November 2023, 16:26
  3. trying to reduce current consumption on a 12HV615
    By Max Power in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th November 2011, 14:57
  4. Unwanted output signal jitter
    By LinkMTech in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 18th January 2008, 02:31
  5. Dmx Solved !!!!!!!
    By oscar in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 2nd July 2005, 21:57

Members who have read this thread : 17

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