SOLVED: How can I reduce ADC jitter - Page 2


Results 41 to 80 of 96

Threaded View

  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154

    Post SOLVED: How can I reduce ADC jitter

    SOLVED: Noisy VDD/VSS using DC-DC converter. ADC stopped bouncing after using a 7805.

    https://picbasic.co.uk/forum/showthr...527#post156527

    --------------------------------------------------------------------


    16F18877

    - Using fixed input on ADC pin (1K to VDD, 1K to VSS - simulating pot at 50%)
    - The ADC will drift from 498 to 509.

    HSEROUTs on Serial Communicator:
    Low=00498 High=00509

    Is there anything in the registers that I can "tune" for the ADC?

    Code:
    #CONFIG
        __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_ON
        __config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF
        __config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_OFF & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
        __config _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_OFF
        __config _CONFIG5, _CP_OFF & _CPD_OFF
    #ENDCONFIG
    
    DEFINE OSC 32
    
    DEFINE  ADC_BITS 10                 ' 10-bit Analog to digital
    
    define  CCP1_REG     0              ' Must clear unused CCP pins or else unpredictable results
    DEFINE  CCP1_BIT     0
    define  CCP2_REG     0
    DEFINE  CCP2_BIT     0
    DEFINE  CCP3_REG     0
    DEFINE  CCP3_BIT     0
    define  CCP4_REG     0
    DEFINE  CCP4_BIT     0
    define  CCP5_REG     0              ' Must clear unused CCP pins or else unpredictable results
    DEFINE  CCP5_BIT     0
    
    DEFINE  HSER_RXREG PORTC
    DEFINE  HSER_RXBIT 7
    DEFINE  HSER_TXREG PORTC
    DEFINE  HSER_TXBIT 6
    
    DEFINE  HSER_RCSTA 90h              ' Enable serial port & continuous receive
    DEFINE  HSER_TXSTA 24h              ' Enable transmit, BRGH = 1
    Define  HSER_BAUD 115200
    DEFINE  HSER_CLROERR 1              ' Clear overflow automatically
    DEFINE  HSER_SPBRGH  0
    DEFINE  HSER_SPBRG  68
    
    BAUDCON.3 = 1                       ' Enable 16 bit baudrate generator
    
    RA4PPS = 0                          ' Disable CCP5
    RB0PPS = 0                          ' Disable CCP4
    RB5PPS = 0                          ' Disable CCP3
    RC1PPS = 0                          ' Disable CCP2
    RC2PPS = 0                          ' Disable CCP1
    
    IOCAP = %00000000                               'IOC Positive Edge, low-to-high
    IOCAN = %00000000                               'IOC Negative Edge, from high-to-low
    IOCBP = %00000000                               'IOC Positive Edge, low-to-high
    IOCBN = %00000000                               'IOC Negative Edge, from high-to-low
    IOCCP = %00000000                               'IOC Positive Edge, low-to-high
    IOCCN = %00000000                               'IOC Negative Edge, from high-to-low
    'IOCDP = %00000000                              '...not available
    'IOCDN = %00000000                              '...not available
    'IOCEP = %00000000                              '...not available
    'IOCEN = %00000000                              '...not available
    
    WPUA = %00000000                        ' Pull-up resistors
    WPUB = %00000000
    WPUC = %00000000
    WPUD = %00000000
    WPUE = %00000000
    
    INLVLA = %00000000                      ' TTL input level
    INLVLB = %00000000
    INLVLC = %00000000
    INLVLD = %00000000
    'INLVLE = %00000000                      ' ...only available on E3 / MCLR pin
    
    ADCON0 = %10000100                      ' ADC CONTROL REGISTER 0
    ADCLK  = %00111111                      ' ADC CLOCK SELECTION REGISTER
    'ADPCH  = %00011010                      ' Channel 26 - D2
    
    ANSELA = %00000000
    ANSELB = %00000000
    ANSELC = %00000000
    ANSELD = %00000110                      ' Pin D2 = ADC input, NavCom
                                            ' Pin D1 = ADC input, Glareshield
    ANSELE = %00000000
    
    TRISA = %00000000                       
    TRISB = %00000000                       
    TRISC = %00000000                       
    TRISD = %00000110                       
    TRISE = %00000000
    
    include "I:\Project_v2\PBP\PBP_Includes\USART.bas"
    
    ADCInput                var word
    
    LowADC                  var word
    HighADC                 var word
    
        Pause 1                                     ' Let PIC stabilize
    
        LowADC = 1023
        HighADC = 0
        AdcInput = 0
    
    Mainloop:
    
        adcin 26, AdcInput
        
        if AdcInput < LowADC then LowADc = AdcInput
        if AdcInput > HighADC then HighADC = AdcInput
            
        hserout [   "Low=", dec5 LowADC, "  High=", DEC5 HighADC, 10  ]                             
     
        goto mainloop
    end
    I was getting desperate with the drift on the pots, so I thought I'd do a control run using resistors.

    I expected it to remain the same or very close, but I'm still getting drift.
    Last edited by Demon; - 3rd November 2024 at 02:37.
    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