Hot!PIC18f4550 - Detection if a potentiometer is connected or not

Author
JulioGM
New Member
  • Total Posts : 2
  • Reward points : 0
  • Joined: 2018/05/28 11:40:14
  • Location: 0
  • Status: offline
2018/08/11 20:50:14 (permalink)
0

PIC18f4550 - Detection if a potentiometer is connected or not

Hello guys!

This is my first thread, so please sorry for any kind of mistake, such in bad explication of my situation as for my bad english.

So here is my question, is there a way I can detect if a person did connected a potentiometer or not by software? I'm developing a board that have 8 potentiometer connections, and not always will they all be connected, and if one of them is not connected I don't wanna floating values displaying, for this situation I wanna lock the value to 0. And I wanna some kind of plug and play, if someone connect a potentiometer without reset the board, it would start read and displaying the values.

Can someone help me?

I tried to put the pin high and do a ADC read, and then put it low and read again, I know if ther is not a potentiometer connected I will read something like 1020 and 3, and if is there one connected I will read diferent values, but I have a fear to burn my chip if the person let the potentiometer in the low or high position, or this won't happen?

Unfortunately, I can do only software change, hardware changes is no longer avaliable because my boards is already manufactured.

Thanks all you guys!
#1

5 Replies Related Threads

    NorthGuy
    Super Member
    • Total Posts : 5308
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: PIC18f4550 - Detection if a potentiometer is connected or not 2018/08/11 21:21:46 (permalink)
    +1 (1)
    Connect external 1M pull-down. Then do two tests:
     
    1. Disable internal pull-up. PORT will read as zero if unconnected.
     
    2. Enable internal pull-up. PORT will read as one if unconnected.
     
    If something is connected, both will read the same. Potentially a bad case when the pot is connected, but set right to the middle.
     
    Or, you can measure with ADC.
     
    #2
    JulioGM
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2018/05/28 11:40:14
    • Location: 0
    • Status: offline
    Re: PIC18f4550 - Detection if a potentiometer is connected or not 2018/08/12 08:19:29 (permalink)
    0
    Hi NorthGuy! Thank you for your answer!

    But as I told, hardware modifications are no longer avaliable, so the external pull-down is not a possible soluction. And the PORTA, responsible for the ADC reads, don't have internal pull-up resistor on this PIC.
    #3
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    Re: PIC18f4550 - Detection if a potentiometer is connected or not 2018/08/12 08:26:49 (permalink)
    0
    Done quickly, that thing about going out/high and out/low will work without issues...

    GENOVA :D :D ! GODO
    #4
    NorthGuy
    Super Member
    • Total Posts : 5308
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: PIC18f4550 - Detection if a potentiometer is connected or not 2018/08/12 08:32:10 (permalink)
    +1 (1)
    JulioGM
    But as I told, hardware modifications are no longer avaliable, so the external pull-down is not a possible soluction. And the PORTA, responsible for the ADC reads, don't have internal pull-up resistor on this PIC.



     
    Driving the high/low for very short time might be Ok - you only need two cycles to get a digital read.
     
    If you only measure the signal. it's hard to predict what you see. You may get some fluctuations, or you may see it as dead 0, or 1. Cannot detect reliably.
     
    Would be better to have a more modern PIC with pull-ups and pull-downs on every pin.
     
    #5
    PStechPaul
    Super Member
    • Total Posts : 2159
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: PIC18f4550 - Detection if a potentiometer is connected or not 2018/08/12 14:10:17 (permalink)
    0
    Ideally the analog inputs from the pots will have a capacitor to GND, so if you enable the weak pull-up, the voltage will gradually rise to Vdd. If a potentiometer is connected, the voltage will change only a little with the pull-up (unless the pot is at maximum). You can also safely set the pin as digital output and pull it to GND briefly to discharge the capacitor. If no capacitor is present, the internal sampling capacitor may be enough to hold the high or low voltage level long enough to see a variation between successive readings.

     
    #6
    Jump to:
    © 2019 APG vNext Commercial Version 4.5