Connect with us

Controlling reset of PIC using transistor switch

Discussion in 'Microcontrollers, Programming and IoT' started by Rajinder, Mar 8, 2019.

  1. Rajinder

    Rajinder

    379
    7
    Jan 30, 2016
    Hi all,
    I am using a PIC18F4520. I need to be able to control the reset/MCLR line (which at the moment is pulled up via a 10K resistor to VDD 3.3V).
    I need the control to be software driven rather than have a switch from the pull up to 0V.
    What would be the best way to do this?
    Could a Logic level N channel MOSFET be adequate? This would be connected between the MCLR line and 0V, cintrolled by a spare I/O line of the PIC.
    I am not sure on calculations involved for driving the FET. Also i think i would need to keep the gate of the FET low on switch on to prevent any false resets.

    Any help would be aporeciated.
    Thanks in advance.
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    9,075
    1,825
    Nov 17, 2011
    There aren't any complicated calculations involved for this simple circuit.
    Any logic level MOSFET can be used as long as the gate threshold voltage (Vgsth) is less than the high output voltage of the mcu.
    You hold the gate of the MOSFET to GND using a pull down resistor to have the MOSFET off when the mcu is initially turned on - other wise it would keep the mcu in permanent reset.
    You'll have to make sure the mcu does not turn on the MOSFET during e.g. startup. Also some kind of filtering to prevent noise from involuntarily resetting the mcu is advised.
    upload_2019-3-8_9-36-26.png

    R1 C1 make the filter with ~100us time constant to improve noise immunity. increase or decrease the value of C1 for other time constants.
    R2 ensures the MOSFET is off without active high level from the mcu output.
    I improvised this circuit without any detailed calculations. The values are mostly arbitrary and can be adjusted by you to fit your specific needs.
     
    Rajinder likes this.
  3. Rajinder

    Rajinder

    379
    7
    Jan 30, 2016
    Hi Harald
    Many thanks for your help.
    I was going to use something similar but without the RC filter. So a pull down from the gate and a resistor from gate to MCU I/O line i.e. like the 1K you have used in your circuit.
    I still really want to understand how we calculate these resistor values, for a better understanding. I get that you must have logic high greater than the threshold voltage of the FET. What i dont quite understand is the resistor calculation taking into effect FET input impedance and capacitance etc.
    For example why use a 10K pull down instead of a 100K. Why we need a 1K instead of say a 220R.
    I look forward to hearing from you.
    Thanks in advance
    Raj
     
  4. Harald Kapp

    Harald Kapp Moderator Moderator

    9,075
    1,825
    Nov 17, 2011
    Take the values for these parameters from the datasheet and see if they make any difference to the circuit in this veeeeeerrrryyyy low frequency application. Take into consideration that even with very good components resistors have a tolerance of 1 % and capacitors of 10 % or worse (you don't want to use expensive precision components here ;)).
    Use 100 k if you feel like it. As I said, all these values are really not critical in this application, I chose them more or less at random judging from experience. That goes equally for the other component values and for the filter time. In an electrically quiet environment you may not even need any of R1, R2 or C1, although I consider it good practice to have them in place just in case.
    The thing you'll have to make sureis that the voltage divider R2/(R1+R2) leaves enough gate-source voltage to turn the MOSFET on. How much that voltage is you'll find in the datasheet of the MOSFET of your choice.
     
  5. Harald Kapp

    Harald Kapp Moderator Moderator

    9,075
    1,825
    Nov 17, 2011
    Why do you want to reset the mcu this way at all? Most mcus have a software reset function, so you don't need additional hardware.
     
  6. Rajinder

    Rajinder

    379
    7
    Jan 30, 2016
    The application requires us to be able to reset the micro, before initiating data transfer via UART. It is for a ZigBee application.
    What would be a software reset function on a PIC mucro 18F series?
    Thanks in advance.
     
  7. BobK

    BobK

    7,592
    1,636
    Jan 5, 2010
    Why?

    Bob
     
  8. Harald Kapp

    Harald Kapp Moderator Moderator

    9,075
    1,825
    Nov 17, 2011
    See e.g. here.
     
  9. Rajinder

    Rajinder

    379
    7
    Jan 30, 2016
    Hi Bob
    We need the UART TX and RX but also need to reset before programming the Z wave module.
    Best regards
    Raj
     
  10. Harald Kapp

    Harald Kapp Moderator Moderator

    9,075
    1,825
    Nov 17, 2011
    btw: Why use an additional transistor at all? You could simply connect an mcu output pin to the reset input - depending on what other circuitry drives reset besides the mcu output.
     
  11. BobK

    BobK

    7,592
    1,636
    Jan 5, 2010
    How does the Z wave module know whether you have just reset or not?

    Bob
     
  12. Rajinder

    Rajinder

    379
    7
    Jan 30, 2016
    Hi all,
    The TX and RX coupled with a reset allows communication to the z wave module.
    There is a set time after a reset that the module will look for a sequence of transmit pulses, from this it can recognise that it requires programming.
    If the RESET line is pulled high with a pull up resistor. Then can i simply connect this line to another mcu I/O pin? A logic 0 will reset the z wave module? Is that correct?
    I do not understand this, especially internally from the pull up side of the z wave module.
    Can you explain?
    Thanks.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-