A2D issues on PIC16F876A


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96

    Red face A2D issues on PIC16F876A

    Hello again,
    My newest PCB design includes a PIC16F876a monitoring (2) A2D channels while also recieving serial RF from a LINX rf module; I then ouput all this goodness to an LCD.
    I am monitoring battery (9V) battery, and RSSI from LINX RXM-433-LR with the (2) A2D channels, I will be using a third channel later down the road.

    The RSSI coming in from the module is nice and consistent (compared to other handheld reciever in room, both same distance from transmitter). My readings are a consistently 1.6-1.65 VDC RMS on both handhelds (at this distance 30'). HOWEVER my battery voltage reading (using (2) 4.7k resistors (divider)) is all over the place 2.3~4.3VDC). Keep in mind My reciever is on the table and not changing distance from transmitter.

    This is not my first time around the block with A2D's so I hope I will include enough info as to not come across as well.....dumb. But here we go...

    Code:
    DEFINE ADC_BITS 8 
    ADCON1 = 4 ' AN0,AN1,AN3, are ANALOG, using VDD,VSS, as ref all else digital
    Now for the output to LCD...

    Code:
        ADCIN PORTA.0, sig1
        ADCIN PORTA.1, VALUE1
        PAUSE 1
        GOSUB DISPLAYa
    
    
        DISPLAYa:
        HIGH PORTC.0
        pause 25
        H = ( VALUE1 *100 ) / 51 
        I = H*4   
        LCDOUT 254,Row1,"Batt     ",DEC1 (I / 100 ),".",DEC2 ( I // 100 ),"  V" 
        ; syntax- BARgraph   Value, Row, Col, Width, Range, Style
        @         BARgraph  _Value1,   2,   0,    16,   95,  lines
    
        Y = ( sig1 *100 ) / 51   'divided down from * 255 / 130
        LCDOUT 254,Row3,"Signal   ",DEC1 (Y / 100 ),".",DEC2 ( Y // 100 ),"  V"                    
        ; syntax- BARgraph   Value, Row, Col, Width, Range, Style
        @         BARgraph  _sig1,   4,   0,    16,   95,  lines
        RETURN
    What I would like to know is if this is an rf problem (rf inducing a voltage on my A2D trace or a problem with my resistor values being too high...or something else???) If this is an rf problem, wouldn't my RSSI input also be floating all over the place?
    Thanks for any help/ experience you can share.
    Padawan-78

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Noise is noise, and should affect all A/D inputs. What size are your variables H, I and Y?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    they are all WORD length
    Padawan-78

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    The RXM RSSI only outputs ~16mV/dB, so a big noise factor should really make this reading swing all over the page.

    Shouldn't this be I=H*2 to show battery voltage?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Code:
        ADCIN PORTA.0, sig1
        ADCIN PORTA.1, VALUE1
    Should be ...
    Code:
        ADCIN 0, sig1
        ADCIN 1, VALUE1
    DT

  6. #6
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    Bruce,
    to answer your question, yep the code should read
    Code:
     I=H*2
    However, the voltage level looked like half the amount (3~4.4VDC) floating all over the place instead of a consistent (~8.9VDC) or so. I included I=H*4 for better resolution.

    DT,
    I will try making the changes to channels,
    thanks,
    ~still stumped.
    Padawan-78

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Darrels' note on using the correct arguments with ADCIN should cure it. Using the port bit
    reference doesn't set it to the correct channel, so that's the major issue.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  8. #8
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    Thanks
    DT & Bruce,
    You were right about the channel numbers, Don't know were I got the idea to use "porta.?" instead of the # itself. Anyway all is well now. thanks again!
    Padawan-78

Similar Threads

  1. Solved: notes on annoying little issues
    By Probotics in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 26th May 2008, 20:02
  2. Circuit reliability issues
    By hkpatrice in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd November 2007, 14:55
  3. Migrating PIC16F876a to PIC18F252
    By cohenjdc in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st June 2007, 13:55
  4. Runing a PIc16F876A
    By lerameur in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 7th January 2007, 12:54
  5. how to get PCF8574 and PIC16F876A work together
    By nomada in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th December 2004, 02:07

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