Hot!PIC18F getting power from UART lines

Page: 12 > Showing page 1 of 2 - Powered by APG vNext Trial
Author
naeem1234
Super Member
  • Total Posts : 358
  • Reward points : 0
  • Joined: 2015/02/19 06:39:28
  • Location: 0
  • Status: offline
2018/04/27 13:31:29 (permalink)
0

PIC18F getting power from UART lines

Hello everyone
 
I am using PIC18F46K22 DIP40 Pins. Ext Crystal 20 MHz, Vdd=5.0 V.
It is connected to another external device via UART Rx, Tx, GND lines directly without any level shifter in between. This device has independent power supply.
The circuit works OK.
If I turn off the power of my PIC controller, while the other device is power ON, then the PIC somehow keeps running. Is it its normal behavior or there is someway to stop the PIC from getting power from the RX, TX lines?
 
Your help is highly appreciated.
#1

39 Replies Related Threads

    Trevor Smith
    Senior Member
    • Total Posts : 140
    • Reward points : 0
    • Joined: 2013/07/22 11:42:07
    • Location: Peterborough UK
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/27 13:58:48 (permalink)
    0
    I have had this before on external inputs.
    Inputs can feed the PIC's 5V internal rail, through the input pin's clamping zener diodes.
     
    Can you try in-line resistors on UART Rx, Tx lines ? ...... say 4K7 ???
    Obviously, RX needs a pull-up to your 5V, on your PCB.
    If you put a 470R resistor across your PIC's 5V / 0V supply, the it may drag down the external inputs, when your PIC's 5V goes off.
    When your 5V is on, the 470R is "invisible".
     
    Trevor
    #2
    PStechPaul
    Super Member
    • Total Posts : 1834
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/27 14:00:15 (permalink)
    +1 (1)
    The TXD line from the external device into the RXD line of the PIC will forward bias the upper protection diode to Vdd, which will allow the PIC to run. You could add a MOSFET switch that would block this voltage when the PIC is turned off. If you are using an interface IC like the MAX232, powered by the same supply as the PIC, it should shut down the output when power is removed. It can remain safely connected to an active RS-232 device.

     
    #3
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 2578
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/27 14:01:36 (permalink)
    0
    How do you mean, keeps running?
    Does sleep work?

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #4
    Trevor Smith
    Senior Member
    • Total Posts : 140
    • Reward points : 0
    • Joined: 2013/07/22 11:42:07
    • Location: Peterborough UK
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/27 14:07:17 (permalink)
    0
    Does sleep work?

    OP wants to switch OFF, but finds the PIC is spuriously doing stuff, when he switches BACK ON.
    Can he use Brown-out to go to sleep ?
    Trevor
    #5
    Trevor Smith
    Senior Member
    • Total Posts : 140
    • Reward points : 0
    • Joined: 2013/07/22 11:42:07
    • Location: Peterborough UK
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/27 14:10:08 (permalink)
    0
    Paul's MAX232 idea would work, if not too late to develop this.
    Trevor
    #6
    NKurzman
    A Guy on the Net
    • Total Posts : 15932
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/27 14:17:24 (permalink)
    +1 (1)
    That is Very Normal behavior.  The voltage flows though the PICs ESD diodes and powers the PIC.
    #7
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 2578
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/27 14:30:54 (permalink)
    0
    I've seen Dave on EEVBlog do that.
     
    +2 for Paul's solution.

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #8
    Trevor Smith
    Senior Member
    • Total Posts : 140
    • Reward points : 0
    • Joined: 2013/07/22 11:42:07
    • Location: Peterborough UK
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/27 14:37:44 (permalink)
    0
    @Gort2015, but ...... 
    Can he use Brown-out to go to sleep ?

    Trevor
    #9
    naeem1234
    Super Member
    • Total Posts : 358
    • Reward points : 0
    • Joined: 2015/02/19 06:39:28
    • Location: 0
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/27 21:57:43 (permalink)
    0
    Trevor Smith
    @Gort2015, but ...... 
    Can he use Brown-out to go to sleep ?

    Trevor




    Brown-out looks like good option. Can you tell what is safe value to set for the brown-out condition?
    #10
    PStechPaul
    Super Member
    • Total Posts : 1834
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/27 23:57:04 (permalink)
    +1 (1)
    If the device connected to the serial port has 5 VDC high levels, the protection diodes will drive Vdd to about 4.3 volts, and maybe as much as 4.5 volts at higher temperature. The highest brownout reset voltage (BORV) is 2.85 volts, so that will not work, unless you load the Vdd-Vss pins with a low enough resistance to draw down the TXD from the serial port.
     
    You could use the ADC to monitor the voltage on Vdd by using it as reference and connect one ADC to the 4.096V internal reference, or maybe the 2.048V reference. When Vdd drops below 4.6 volts, you can enter SLEEP and run at very low power. However you may need to keep the ADC running to detect when full 5V is again applied so you can resume operation or perform a self-reset. That may require an IDLE mode where ADC still runs. The POR only works if Vdd drops below its threshold.
     
    Another simple method would be to use the MCLR with a pull-up to the 5V supply, and isolate the Vdd using a diode. When the power supply voltage is removed, it will pull MCLR low and the device will be in reset, even though its Vdd will still be high enough for it to run.
     
    Thinking on those lines, you might be able to use a pull-up on the RXD line to Vdd, and use a diode from the external TXD source. Thus the source can only pull RXD low, and cannot power the PIC through its diodes.

     
    #11
    naeem1234
    Super Member
    • Total Posts : 358
    • Reward points : 0
    • Joined: 2015/02/19 06:39:28
    • Location: 0
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/28 04:02:52 (permalink)
    0
    PStechPaul
    Another simple method would be to use the MCLR with a pull-up to the 5V supply, and isolate the Vdd using a diode. When the power supply voltage is removed, it will pull MCLR low and the device will be in reset, even though its Vdd will still be high enough for it to run.
     

     
    Can you suggest a circuit for this method?
    #12
    Trevor Smith
    Senior Member
    • Total Posts : 140
    • Reward points : 0
    • Joined: 2013/07/22 11:42:07
    • Location: Peterborough UK
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/28 10:31:35 (permalink)
    0
    I think what Paul suggests maybe looks like the attached picture  .....
     
    Figure 1
    So, the PIC inputs cannot supply power OUT through the Vdd pins (blocked by diode).
    The MCLR is normally pulled-up, but will be grounded to 0V, when the 5V supply is off.
    Then the PIC is held in reset and cannot function, until 5V is restored.
     
    Figure 2
    Only down side of Figure 1 is that the PIC now has a 4.3 - 4.5V supply on Vdd.
    In Figure 2, if you used a 1Amp diode, to adequately supply all of your part of the system, then you could add a diode in the 0V leg of the 5V regulator, to make the 5V = 5.5V.
     
    Please ensure you fully test all this.
    And .....be careful not to supply 5.5V directly to any PIC pins !!!!
     
     
    See edit ...... better make the MCLR pull-up = 10K !
    Trevor
    post edited by Trevor Smith - 2018/04/28 10:51:05

    Attached Image(s)

    #13
    PStechPaul
    Super Member
    • Total Posts : 1834
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/28 12:38:15 (permalink)
    +1 (1)
    You need to take in consideration that MCLR has a weak pull-up that draws as much as 300 uA at 5 volts, or 17 k equivalent. MCLR must be pulled down to a maximum of 0.2*Vdd, or 1 volt. Thus the external pull-down resistor must be no larger than about 3k. A better solution might be a Schottky diode with cathode on the external 5V supply. This will pull MCLR to about 0.3 volts or less. A Schottky diode would also be a good choice for isolating Vdd from the external supply. Something else to consider is that the external supply seems to have a high impedance when turned off, so it would need to be shunted with an appropriate load. A "power-on" LED and resistor might work, but would only pull Vdd down to the forward bias voltage of about 1.5 volts. That is not low enough to assert RESET, but it is low enough to enable brown-out and POR.

     
    #14
    Ian.M
    Super Member
    • Total Posts : 13114
    • Reward points : 0
    • Joined: 2009/07/23 07:02:40
    • Location: UK
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/28 13:43:28 (permalink)
    +2 (2)
    Alternatively, if you can get 5V power from the external device, simply add a  74LVC1T45 buffer in the offending line
    http://www.ti.com/lit/ds/symlink/sn74lvc1t45.pdf
    Its a level translating single gate buffer in SOT23-6 (or even smaller packages) that has two separate Vcc pins that support operation over the full range from 1.65V to 5.5V on either side, and is guaranteed Hi-Z when one side is powered down.   Tie its DIR pin low to fix the direction B=>A. You'll probably want one in both RX and TX so the PIC is also protected against its output being overloaded  if its powered while the external device is powered down.
     
     

    --
    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!
    #15
    naeem1234
    Super Member
    • Total Posts : 358
    • Reward points : 0
    • Joined: 2015/02/19 06:39:28
    • Location: 0
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/28 21:57:25 (permalink)
    0
    Trevor Smith
    I think what Paul suggests maybe looks like the attached picture  .....
     
    Figure 1
    So, the PIC inputs cannot supply power OUT through the Vdd pins (blocked by diode).
    The MCLR is normally pulled-up, but will be grounded to 0V, when the 5V supply is off.
    Then the PIC is held in reset and cannot function, until 5V is restored.
     
    Figure 2
    Only down side of Figure 1 is that the PIC now has a 4.3 - 4.5V supply on Vdd.
    In Figure 2, if you used a 1Amp diode, to adequately supply all of your part of the system, then you could add a diode in the 0V leg of the 5V regulator, to make the 5V = 5.5V.
     
    Please ensure you fully test all this.
    And .....be careful not to supply 5.5V directly to any PIC pins !!!!
     
     
    See edit ...... better make the MCLR pull-up = 10K !
    Trevor




     
    Thanks for the details and the circuit.
     
    If I don't want to change my +5V supply to lower or higher value by using a diode on its GND line etc.. but want to use a transistor on MCLR' Pin such that if the +5V supply is turned off then MCLR' is pulled down to force the PIC18 in reset state.. then how would that circuit look like? Would this approach be advisable?
    #16
    Trevor Smith
    Senior Member
    • Total Posts : 140
    • Reward points : 0
    • Joined: 2013/07/22 11:42:07
    • Location: Peterborough UK
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/29 03:30:44 (permalink)
    +1 (1)
    use a transistor on MCLR' Pin such that if the +5V supply is turned off then MCLR' is pulled down to force the PIC18 in reset state

    OK, but you're missing the whole point ..... if the PIC Vdd 5V is being held up through external inputs being HIGH, then your 5V supply going OFF doesn't change anything.
     
    I have "blown up" inputs before, which seemed a mystery at first, until I realised that external inputs were supplying the whole circuit with 5V.  I had a back-lit LCD display and other bits, using about 50mA which destroyed the input pin's ESD diodes.
     
    Paul has suggested some great ideas,  as always ........ please try some of them, if you don't want to block the 5V getting to Vdd.
     
    Trevor
    #17
    timijk
    Super Member
    • Total Posts : 1216
    • Reward points : 0
    • Joined: 2007/11/26 00:30:07
    • Location: Taiwan
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/29 03:46:40 (permalink)
    +1 (1)
    This might work: put schottky diodes (-->) between TX/RX.
    PIC.TX ------>--- (-)RX
    PIC.RX(+) -->------ TX
     
    (+) means pull-up, (-) means pull-down.
    #18
    naeem1234
    Super Member
    • Total Posts : 358
    • Reward points : 0
    • Joined: 2015/02/19 06:39:28
    • Location: 0
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/29 13:18:16 (permalink)
    0
    timijk
    This might work: put schottky diodes (-->) between TX/RX.
    PIC.TX ------>--- (-)RX
    PIC.RX(+) -->------ TX
     
    (+) means pull-up, (-) means pull-down.




    Can you suggest a few appropriate schottky diodes and also the value of pull-up and pull-down resistors?
    #19
    PStechPaul
    Super Member
    • Total Posts : 1834
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: PIC18F getting power from UART lines 2018/04/29 15:01:54 (permalink)
    +1 (1)
    Seeking such advice makes me question your ability to analyze and design the rest of the circuit. Only you know the parameters of the design and factors such as cost, size, and power. There has been more than enough information supplied here to make a selection and determine if it meets your requirements.

     
    #20
    Page: 12 > Showing page 1 of 2 - Powered by APG vNext Trial
    Jump to:
    © 2018 APG vNext Trial Version 4.5