• AVR Freaks

Hot!PIC Input

Author
Designer
Super Member
  • Total Posts : 454
  • Reward points : 0
  • Joined: 2007/11/20 20:28:41
  • Location: 0
  • Status: offline
2019/10/22 04:16:05 (permalink)
0

PIC Input

This is the hardware I'm using to connect a Door Contact (Reed Switch) to PORTB. I have enabled Weak Pull-ups.
The wires I'm using just "Twin Flex" type & the length is around 10 meters.Is it ok the hardware interface?Will it work reliably in site condition?
 

Attached Image(s)

#1

7 Replies Related Threads

    ric
    Super Member
    • Total Posts : 24593
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: PIC Input 2019/10/22 04:20:25 (permalink)
    +1 (1)
    No, it almost certainly will NOT work.
    You need a much stronger pullup than the PIC's "weak pullup" for a connection that long.
    I would use the 4.7k as your pullup, and replace R1 with another 100R resistor.
     
    If I was designing this, I wouldn't directly connect anything coming from "off the board" directly to the PIC input, even just via a resistor. There's too much chance of ESD damaging the PIC.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    Ian.M
    Super Member
    • Total Posts : 13268
    • Reward points : 0
    • Joined: 2009/07/23 07:02:40
    • Location: UK
    • Status: offline
    Re: PIC Input 2019/10/22 04:35:52 (permalink)
    +2 (2)
    Put the external pullup on the sensor side of the series resistor.   Then the series resistor can be much larger to better protect the PIC input, e.g 10K.  I'd also add 10nF to Vss to reduce susceptibility to RFI and ESD, and Schottky diode clamping to Vdd and Vss, both right at the PIC input.   As long as your circuit has >1.2mA minimum load on Vdd, the protection is sufficient as long as the input is never shorted to any voltage above 12V, and the sensor pullup doesn't go to Vdd.   If the sensor pullup *MUST* be fed from Vdd, and you need significant over-voltage withstand capability, add a >100V rated Schottky diode in series with the pullup resistor, and use the clamping circuit I proposed in reply#4 here: https://www.microchip.com/forums/FindPost/634506 with R1 replaced with the 10K series resistor I mentioned earlier.
     
    Also you probably need significant wetting current for reliability unless the door sensor switch has precious metal contacts for 'dry' switching applications.  Try a 1K pullup and no resistor on the ground side for 5mA through the switch.  If you need to 'idiot-proof' the input against sensor ground getting connected to 12V or similar, consider a polyfuse in the ground side.
    post edited by Ian.M - 2019/10/22 06:13:11

    --
    NEW USERS: Posting images, links and code - workaround for restrictions.
    I also support http://picforum.ric323.com because this forum is sometimes too broken to use!
    #3
    Jim Nickerson
    User 452
    • Total Posts : 6365
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: PIC Input 2019/10/22 06:26:13 (permalink)
    +2 (2)
    Ian.M
    consider a polyfuse in the ground side.

    I agree with Ian
    From personal experience do pay attention to the max ambient temperature derating of the PTC Smile: Smile
    #4
    Designer
    Super Member
    • Total Posts : 454
    • Reward points : 0
    • Joined: 2007/11/20 20:28:41
    • Location: 0
    • Status: offline
    Re: PIC Input 2019/10/24 02:37:49 (permalink)
    0
    Hi Ian Thanks for the detailed explanation.I redraw the circuit, Is it better than earlier? I have only one +5V rail.That is VDD.

    Attached Image(s)

    #5
    ric
    Super Member
    • Total Posts : 24593
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: PIC Input 2019/10/24 02:51:04 (permalink)
    +1 (1)
    R2 is on the wrong side of R1.
    Ian.M
    Put the external pullup on the sensor side of the series resistor.
    ...



     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    nigelwright7557
    Super Member
    • Total Posts : 310
    • Reward points : 0
    • Joined: 2006/11/06 08:15:51
    • Location: 0
    • Status: offline
    Re: PIC Input 2019/10/24 05:00:47 (permalink)
    0
    For a long wire you need something like 1k pull up.
    To stop ESD you need something like 10k in series with input.
    Forget weak pull ups as they are prone to noise.
     
    #7
    t1d
    Senior Member
    • Total Posts : 138
    • Reward points : 0
    • Joined: 2015/01/26 15:49:24
    • Location: 0
    • Status: offline
    Re: PIC Input 2019/10/24 05:21:54 (permalink)
    0
    Don't forget to debounce the switch, either by code or hardware.
     
    For reverse polarity protection, I am learning about using P-Channel MOSFETs on the high side to do the job.
     
    I am aware of polyfuses, but I have never employed one. I buy my components at Mouser and they do have polyfuses. Here's a broad site search with 455 hits: https://www.mouser.com/Se...efine?Keyword=polyfuse
    #8
    Jump to:
    © 2019 APG vNext Commercial Version 4.5