ADCIN signal conditioning?


Closed Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Nov 2004
    Location
    Calabasas, CA
    Posts
    84

    Default ADCIN signal conditioning?

    I am trying to read a vehicle speed sensor but the LCD output is bouncing all over the place.
    My DMM readout is nice and constant. How can I get good readings?

    What I have done is slow down the sampling time to 20mS.
    Took 25 consecutive samples, and even saved the highest value of the 25, but no help.
    How does the DMM do it?

    I am using a PIC 16F716 on PORTA.

    This is my setup:
    ADCON1 =0 'PIC default, sets PORTA to analog
    DEFINE OSC 3 '3.56 MHz oscilator
    DEFINE ADC_BITS 8 'Result resolution
    DEFINE ADC_CLOCK 3 'Sets internal RC clk(2-6us)
    DEFINE ADC_SAMPLEUS 20000 'Cap sample time of 5us

    I am using this:
    ADCIN 0,vss

    and I've tried this:
    ADC: w2 =0 'Clear var
    For b11 = 1 TO 25
    ADCIN 0,rpm 'Obtain another ADC value
    w2 = w2 max rpm 'save peak vals
    Next b11 'Repeat for 10 samples
    Return

    For a constant DMM reading of say 1.750V, my ADC output bounces between 0 & 186.

    Thanks
    James

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Do you have PORTA set up as inputs?
    Do you have them set up for analog?
    What are you using for your reference (ADCON1) ? Most of the time, Vcc is not good enough.
    If you want really good accuracy, you have to use an external, precision reference.
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Default

    Sometimes a capacitor from the ADC pin to VSS will smooth things out.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Nov 2004
    Location
    Calabasas, CA
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis View Post
    Do you have PORTA set up as inputs?
    Yes, TRISA =255

    Do you have them set up for analog?
    ADCON1 =0 (as noted in my setup above?)

    What are you using for your reference (ADCON1) ?
    ADCON1 =0 sets Vdd as thew ref I believe.

    Most of the time, Vcc is not good enough.
    If you want really good accuracy, you have to use an external, precision reference.
    Really good accuracy would be nice. Right now I have no accuracy.
    James

  5. #5
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    You could try Darrel's averaging include file.

    http://sites.picbasic.net/index.php?...d=70&pageid=25

  6. #6
    Join Date
    Nov 2004
    Location
    Calabasas, CA
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Sometimes a capacitor from the ADC pin to VSS will smooth things out.
    I'll see what a 0.1uF does.

    Thanks
    James

  7. #7
    Join Date
    Nov 2004
    Location
    Calabasas, CA
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scalerobotics View Post
    You could try Darrel's averaging include file.

    http://sites.picbasic.net/index.php?...d=70&pageid=25
    Thanks,
    I'll have a look see.
    James

  8. #8
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    If your value goes to zero, there is something more wrong than a little noise. I have found some chips that don't work properly with ADCIN (18F2221 for example).

    Try the following:

    Code:
    Result = 0
    Channel = 1                     ; Whichever 
    Channel = Channel << 3   ; offset the bits
    
    ADCON0 = %11000001 | Channel  ; OR the channel into the reg.
    
    For X = 0 to 9
    
    PAUSEUS 10
    ADCON0.2 = 1     ; Start conversion
    PAUSEUS 2         ; Guarantee min time
    WHILE ADCON0.2:WEND   ; Wait until done
    Result = Result + ADRES
    Next X
    
    Result = Result/10
    Result is, of course, a WORD var
    Charles Linquist

  9. #9
    Join Date
    Nov 2004
    Location
    Calabasas, CA
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    Charles,

    This sensor pulses hi to low. I suspect some of my sampling is reading on the low part of the cycle. Thats why I slowed way down the sampling time to 20ms.

    ADC has worked well for me on this PIC.

    I will look at your subr.

    Thanks
    James

  10. #10
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by droptail View Post
    Charles,

    This sensor pulses hi to low. I suspect some of my sampling is reading on the low part of the cycle. Thats why I slowed way down the sampling time to 20ms.
    An analog sensor that pulses high to low? I don't understand. What sensor are you using.
    Charles Linquist

  11. #11
    Join Date
    Nov 2004
    Location
    Calabasas, CA
    Posts
    84


    Did you find this post helpful? Yes | No

    Default changing to PULSIN

    I am getting better results using PULSIN since the sensor is pulsing as stated before.
    I still need to condition the results, however.
    James

  12. #12
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    You mean that you weren't concerned with the analog level of the signal at all? Only its duration?
    Charles Linquist

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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