ADCIN Problem


Closed Thread
Results 1 to 34 of 34

Thread: ADCIN Problem

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ardhuru View Post
    Just to rule out the basics, if you ground the input, do you get a consistent '0'? and connect it to +5, do you get a consistent '255'?
    Or a consistent 1023...

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi,

    I didn't see the " CMCON = 7 " ... Default value ... yes, but, just to be sure of .

    Also, did you try to tie RA.0 to ground or to RA1 ... it makes a superb noise input, as left floating !
    Note unused portA pins should be tied to ground through 10 k resistors ...

    - or use RA.0 as input !!! and other RA pins as outputs, if unused.

    Alain
    Last edited by Acetronics2; - 21st December 2008 at 10:19.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by skimask View Post
    Or a consistent 1023...
    ADC set to 8 bits, remember?

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ardhuru View Post
    ADC set to 8 bits, remember?
    Which way are those 8 bits justified? Left? Right? Inverted?

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Try this setting . . .
    Code:
    ADCON1 = %00001101 ' VREF off A.0 & A.1 as analog
    ADCON2.7 = 1    ' Right justified
    ADCON0.2 = 1    ' Channel 1 enabled 
    ADCON0.1 = 1    ' A/D conversion in process
    ADCON0.0 = 1    ' A/D Module Enabled
    . . . If I read it right . . .
    Edit: you posted while I was working on mine . . .
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    Dec 2008
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    I tried:

    ADCON0 = %00000011

    as I am using AN0 pin for input now, no change.

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by JavPar View Post
    I am using AN0 pin for input now, no change.
    Somehow I missed the change from AN1to AN0.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  8. #8
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Hi, JavPar

    Could you Post your HEX code ???

    Purpose is to verify the config real settings ....

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  9. #9
    Join Date
    Dec 2008
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    Test results:

    1.) Didn't see any change when changed to 8 bits, so I'm back to using 10 bits.

    2.) I edited my code so only RA0 is being used for input analog.

    3.) When connect ADCIN pin to any GND on the project, I get steady 0V readings. When connect pin to 5V I get erratic 5V readings BUT, noticed that when connect pin to 5V before my on/off switch, then I get 5V steady. Noticed also that when connected to 5V before on/off switch, this makes the PIC kind of work because my green LED connected to PORTD.2 starts to blinks like if my project is running but LCD stays off. Nothing happends when connect ADCIN pin to 5V after on/off switch. Removed the on/off switch, 5V voltage readings are erratic anywhere in the project.

    4.) Erratic readings are less npticeable when in 5V ranging from 1020 to 1023. When connect an angular sensor for example I get ranges from 480s to 540s aproximately. Other things I have connect ot ADCIN pin are a 1.5V battery and a 3V wall ac/dc adapter. I get erratic readings from both also.

    DEFINE LOADER_USED 1 'Bootloader Used
    @ __CONFIG _CONFIG1H, _OSC_HS_1H
    DEFINE OSC 8
    Define ADC_BITS 10
    Define ADC_CLOCK 3
    Define ADC_SAMPLEUS 50
    adval var word
    TRISA = %00000001
    ADCON0 = %00000001
    ADCON1 = %00001110
    'ADCON2.7 = 1
    ADCON2 = %10001011
    CVRCON.4 = 0
    'CMCON = 7
    Pause 1000
    Serout2 PORTD.0,16468,[$1b, $2a, $ff]
    loop:
    HIGH PORTD.2
    ADCIN 0, adval
    pause 50
    Serout2 PORTB.7,16468,[dec adval] ' to PC
    Serout2 PORTD.0,16468,[$fe, 1]
    Serout2 PORTD.0,16468,[dec adval] ' to LCD
    LOW PORTD.2
    pause 50
    Goto loop
    End

Similar Threads

  1. ADC or ADCIN "bias" problem?
    By RussMartin in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th February 2010, 19:39
  2. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  3. electrical problem adcin
    By jcleaver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 28th March 2007, 22:52
  4. adcin problem
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 13th February 2005, 17:47
  5. weird 12F629/675 problem
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 7th October 2004, 01:08

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