"Honey, my PIC ADC pin sagged my peak detector voltage!"


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Mar 2009
    Posts
    653

    Default "Honey, my PIC ADC pin sagged my peak detector voltage!"

    Ok, to appraise you all, my signal path is....


    audio signal in->Half wave rectifier (opamp type)-> 500R resistor-> Diode-> 4.7uf Cap (to ground)-> PIC ADC pin

    (in other words a peak detect type circuit)

    With the signal path above unconnected to the PIC ADC Pin, I see a nice low ripple DC level moving between 0V & 5V on my scope (ie reflecting the size of the incoming audio) ...but when I connect the PIC ADC pin up - much more ripple & the DC level only gets up to about 2.8V.

    The PIC ADC pin is loading the peak detector capacitor :-(

    Now I know the traditional solution would be to put a voltage follower in between the output of the cap & the input of the ADC pin, but I really don't have room for an extra opamp (yes I know they're small, but every square millimetre of my board is chocka!)


    I'd have imagined that a PIC would have an ADC that's high impedance - & not loaded the cap significantly?

    Any top tips/workarounds gratefully recieved as I'm presently pouring light fluid on the circuit - and if it's not sorted by midnight, it's gonna resemble a car in the main square in Cairo.
    Last edited by HankMcSpank; - 9th February 2011 at 10:01.

  2. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: "Honey, my PIC ADC pin sagged my peak detector voltage!"

    Anyone know what to expect (voltage wise) on an analogue input pin configured for ADC with nothing connected? - I'm seeing 5V on mine (as seen on a DVM - but also I'm getting an ADC value of 255 with nothing connected to the pin - I was expecting 0?)

    When I connect up say a pot wiper - it reads the incoming coltage properly....I'I'm curious to know what's going on internally at a low level electronics inside?

    Edit: It seems this PIC (16f1828), doesn't disable PORTC weak pullups at initialisation, it should, this from the datasheet...

    "All pull-ups are disabled on a Power-on Reset"

    however I've just added the explicit line WPUC = 0 & now everything is reading 0 as expected on my Analogue/ ADC pins
    Last edited by HankMcSpank; - 12th February 2011 at 14:11.

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


    Did you find this post helpful? Yes | No

    Default Re: "Honey, my PIC ADC pin sagged my peak detector voltage!"

    5 volts if the the chip is running on 5 volts and not changing the reference and using 8 bit resolution will equal 255...
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: "Honey, my PIC ADC pin sagged my peak detector voltage!"

    Quote Originally Posted by mackrackit View Post
    5 volts if the the chip is running on 5 volts and not changing the reference and using 8 bit resolution will equal 255...
    Yes I know 5V = 255, but what I was getting at...until I set all the portC pullups disabled (which they should have been at power up anyway), in the absence of an incoming analogue signal, I was geting an ADC reading of 255 (because there was 5V residual on the unconnected pin)...soon as I disable pullups, I got the reading I was expecting ...ie an ADC reading of 0.

  5. #5
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default Re: "Honey, my PIC ADC pin sagged my peak detector voltage!"

    Yes I know 5V = 255, but what I was getting at...until I set all the portC pullups disabled (which they should have been at power up anyway), in the absence of an incoming analogue signal, I was geting an ADC reading of 255 (because there was 5V residual on the unconnected pin)...soon as I disable pullups, I got the reading I was expecting ...ie an ADC reading of 0.
    This is expected behaviour. Pullups will put 5V on the ADC input. Unless you meant to ask something else.....

  6. #6
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: "Honey, my PIC ADC pin sagged my peak detector voltage!"

    Quote Originally Posted by Jerson View Post
    This is expected behaviour. Pullups will put 5V on the ADC input. Unless you meant to ask something else.....
    That's just it - I never asked for or wanted pullups on the ADC pin, so was puzzled when 5V appeared there in the absence of a signal. The datasheet say WPUs are disabled at power up (& my code didn't enable them), so there shouldn't have been 5V on the ADC pin.....what I had to do in the end was disable them myself in my code - even though they should be disabled by default.

    In my opinion there's a problem with the PIC16f1828's startup settings vs what Microchip say in their associated datasheet.

  7. #7
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default Re: "Honey, my PIC ADC pin sagged my peak detector voltage!"

    Quote Originally Posted by HankMcSpank View Post
    In my opinion there's a problem with the PIC16f1828's startup settings vs what Microchip say in their associated datasheet.
    Why don't you contact MCHP, inform them of your findings and have them confirm that the datasheet is in error (or perhaps the datasheet is correct and that you may have discovered a silicon error)?
    Why pay for overpriced toys when you can have
    professional grade tools for FREE!!!

  8. #8
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: "Honey, my PIC ADC pin sagged my peak detector voltage!"

    Quote Originally Posted by rmteo View Post
    Why don't you contact MCHP, inform them of your findings and have them confirm that the datasheet is in error (or perhaps the datasheet is correct and that you may have discovered a silicon error)?
    For a few minutes I was overwhelmed by the onset of "global community spirit" to do the right thing ...so visited Microchip's website ...they've even produced a video about how to report back silicon errors.....I grew a beard to rival the guitarists in ZZ Top watching it, & then threw my wife's purse at the screen when it got to the bit about "& having followed the 11 steps we've just outlined, unless you attach scope traces we won't believe you & just assume you're a pleb"

    I'm now hoping anyone similar 16f1828 problems will find this thread via Google.
    Last edited by HankMcSpank; - 16th February 2011 at 14:50.

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


    Did you find this post helpful? Yes | No

    Default Re: "Honey, my PIC ADC pin sagged my peak detector voltage!"

    Quote Originally Posted by HankMcSpank View Post
    Edit: It seems this PIC (16f1828), doesn't disable PORTC weak pullups at initialisation, it should, this from the datasheet...

    "All pull-ups are disabled on a Power-on Reset"

    however I've just added the explicit line WPUC = 0 & now everything is reading 0 as expected on my Analogue/ ADC pins
    Hank,

    Weak Pull-ups are disabled at power-up / Reset.
    They are turned on by clearing WPUEN (OPTION_REG.7).
    All of the WPUx registers are enabled at power-up, so when you clear the WPUEN bit, they all come on unless you specifically disable individual pins WPUC.x.

    Does your code change OPTION_REG?
    DT

  10. #10
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: "Honey, my PIC ADC pin sagged my peak detector voltage!"

    Quote Originally Posted by Darrel Taylor View Post
    Hank,

    Weak Pull-ups are disabled at power-up / Reset.
    They are turned on by clearing WPUEN (OPTION_REG.7).
    All of the WPUx registers are enabled at power-up, so when you clear the WPUEN bit, they all come on unless you specifically disable individual pins WPUC.x.

    Does your code change OPTION_REG?
    Hey Darrel,

    this is the point in the proceeedings where I should lie profusely, but nope....

    "It's a fair cop guv"

    Yes, I do use WUPs on PORT B, so yes I have...

    Code:
    OPTION_REG.7 = 0
    ....which of course, then means all ports are enabled & I need to disable by port.

    My excuse is that my code is a heavy cut/paste from a former program, so I didn't enter every single line manually......but, that's lame so I offically declare myself a pleb.

    Great spot....... & thanks for chiming in to correct.
    Last edited by HankMcSpank; - 16th February 2011 at 19:44.

Members who have read this thread : 1

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