12F1840 ADCIN troubles, help needed :(


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 ADCIN troubles, help needed :(

    Quote Originally Posted by CuriousOne View Post
    Well, troubles continue.

    Also I found a strange thing - if I set TRISA=%00110010, which means to set LATA.2 as input, the code does not works at all, but it also stops consuming current on that pin. What can be the reason?
    I think you have set porta.1 to input and not porta.2

    This sets PORTA.2 as input
    Code:
    %00110100
    Not sure about your other problems

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,626


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 ADCIN troubles, help needed :(

    Hi,
    The input (basically) only sinks current when it's configured as an output and set low. When being used as an input for the ADC it obviously needs to be set to input - just as Mark has pointed out. Then it "sinks" current only when the input is connected to the S/H circuit which leads us to the next issue: Your 100k pot viloates the maximum recommended input impedance by an order of magnitude.

    /Henrik.

  3. #3
    Join Date
    Feb 2013
    Posts
    1,159


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 ADCIN troubles, help needed :(

    I have created a voltage divider, 100k and 10k resistors, ADC input connected in their middle point. The problem is that PIC shorts the input to GND, but still works as ADC. This has no relation to input impedance, it feels like same pin is both digital out and analog in at same time. Is this possible?

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,626


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 ADCIN troubles, help needed :(

    Hi,
    In your original code ( TRISA=%00110000 ) leaves PortA.2 as an output which is wrong.
    In your post you contiune to say TRISA=%00110010, to set LATA.2 as input which again, as mark_s points out, is wrong, the above will STILL leave PortA.2 as an OUTPUT.

    Your setting of ANSELA in the code is commented out which doesn't really have any effect on the ADC input since it defaults to analog but it WILL have an effect on the pins you want to use as digital.

    The ADC DOES put a load on the node when it samples the input that's where the max input impedance comes from. Too high impedance and too short sampling time makes the voltage at the node droop when it's sampled.

    /Henrik.

  5. #5
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 ADCIN troubles, help needed :(

    HenrikOlsson,
    If you use 10K and 100K for divider, impedance that PIC input see is 9,09K.

  6. #6
    Join Date
    Feb 2013
    Posts
    1,159


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 ADCIN troubles, help needed :(

    Yes I have commented ANSELA because it had no effect anyways.

  7. #7
    Join Date
    Feb 2013
    Posts
    1,159


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 ADCIN troubles, help needed :(

    And I know that ADC needs some current, but not 25mA! On the RA3 or LATA.3 how you call it, which is input only, ADC works just fine and does not hog current.

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    2,719


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 ADCIN troubles, help needed :(

    RA3 or LATA.3 how you call it, which is input only, ADC works just fine and does not hog current.
    ? really
    RA3 is not an analogue input

    the only way a pic I/O pin will sink 25ma is :- if its an output, damaged or fed more volts than vdd

Similar Threads

  1. 12F1840 config issues
    By enigma in forum PBP3
    Replies: 13
    Last Post: - 15th February 2015, 08:49
  2. Problem converting 12F683 code to 12F1840
    By RossWaddell in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 14th March 2013, 02:55
  3. Help needed with ADCIN Averaging Routine
    By Aussie Barry in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 24th December 2012, 17:05
  4. PBP Support for 12F1840 8-Pin Device?
    By springtank in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 10th November 2012, 09:32
  5. troubles using more than one PCF8574
    By maus in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 28th July 2007, 20:37

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