PIC ADC floating I think

Discussion in 'General Electronics Chat' started by gdallas, May 10, 2014.

  1. gdallas

    Thread Starter Member

    Apr 25, 2012
    74
    0
    Please see image attached. Whenever i remove my position sensor from my device, my displayed input which was previously 0% begins slowly floating up, and stops about 12% the sensor is just a variable resistor. so when disconnected the ADC input has nothing on its input other than a cap and a fixed resitor but the other end of he fixed resistor has no potential now obvioulsy. any ideas on what i can do either software or hardware to keep the reading at 0% when the sensor is disconnected?

    thanks
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,421
    3,357
    Put a 1MΩ resistor from the ADC input to ground.
     
  3. gdallas

    Thread Starter Member

    Apr 25, 2012
    74
    0
    thought about that. thanks. does that not affect the max input imp to the pic though of 10k?
     
  4. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Sure, but having nothing connected is also over 10K.
    If you really want to check if the sensor is connected, you could switch the pin to output high, switch back to ADC and measure how the voltage on the capacitor is changing, then repeat with output low. Driving an output straight into a capacitor would probably exceed the current recommendation of the pin, so an additional resistor at the pin might be a good idea.
     
  5. gdallas

    Thread Starter Member

    Apr 25, 2012
    74
    0
    i meant when the sensor is conncted. will that pull down not affect it?
     
  6. MrChips

    Moderator

    Oct 2, 2009
    12,421
    3,357
    Why not try it and see what happens?
     
  7. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Of course it will, but a better question is how much will the effect be.

    You have a source resistance (the pot) and the fixed R from the RC in series feeding a large value resistor.

    Construct the voltage divider this forms and see how much the effect is.

    Keep in mind that any voltage change less them 1/2 of a LSB * is basically undetectable.


    * LSB or least significant bit. The width of each input voltage step for a single count change. Equal to the A2D reference voltage divided by the number of states (1024 for a typical 10 bit converter).
     
    Last edited: May 10, 2014
  8. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    I suppose I should also add the maximum equivalent series resistance of a potentiometer divider is just R/2, or 2.5K for your 5K pot.

    (I can prove that if anyone wants to "see the work.")
     
Loading...