Electronic – Powering micro controller using n-channel mosfet and tpl5111

#nodemcumicrocontrollertimer

I am trying to create home made battery saver circuit to powering on my microcontroller (nodemcu v2),

I am following http://www.ti.com/product/TPL5111/datasheet/detailed_description, and created the connection on breadboard,

TPL is connected as follows

  1. Pin -1 V+ – to power rail (5v or normal Li-Ion battery 4.2v)
  2. Pin -2 GND – common GND
  3. Pin -3 DELAY – 20Kohm to Ground (~20 sec of up time)
  4. Pin -4 EN – GND (Since i want this to be one shot and not as timer)via push button and other leg of push button to V+.
  5. Pin -5 DRV – Gate to my MOSFET (FQP30N06 N-Channel enhancement)
  6. Pin -6 DONE – Done pin to MicroController D2/2 (depends on esp8266 type)

On MOSFET side

  1. GATE is connected to Pin 5 above, so every time i push the button TPL asserts DRV pin high which should enable the mosfet
  2. MC USB pin connected to V+
  3. MC Ground is connected Drain of Mosfet
  4. Source of Mosfet is connected to Common GND
  5. GATE and DRAIN are connected using 5K ohm resistor

Following are my doubts

  1. Even when TPL DRV is low my external LED to MC on pin 13 is lit and voltage is < 0.5 volts, should microcontroller be OFF completely?
  2. My intention is to attach Reed Switch instead of push button to TPL so every time i open the door it should turn on mosfet via tpl and microcontroller should do the job and send the DONE to turn off
  3. Sending DONE via microcontroller doesnt turn off the TPL, but thats not something bothering me at this stage but still would like to know

I will upload my circuit from breadboard but i need to put labels on it.

Below is simple code which turn on LED on Pin 13/D7

    #include "AdafruitIO_WiFi.h"
    #define HUZZAH
    #ifdef HUZZAH
      #define DONEPIN   2 // TPL5100 Done signal
      #define LEDPIN    13
    #else
      #define DONEPIN   D2 // TPL5100 Done signal
      #define LEDPIN    D7
    #endif
    #define DEBUG true
    #define BAUD_RATE    115200

    const char* ssid = "wifi";
    const char* password = "password";
    #define AIO_KEY  "mykey"

    AdafruitIO_WiFi io("userId", AIO_KEY, ssid, password);

    void logMessage(String message, boolean noCRLF=false){
      #ifdef DEBUG
      if (Serial){
        if (noCRLF){
          Serial.print(message);
        }else{
          Serial.println(message);
        }
      }
      #endif
    }

    void connectAdaIo(){
      bool sendData = false;
      logMessage("Connecting to Adafruit.io");
      // connect to io.adafruit.com
      io.connect();
      int retry = 0;
      // wait for a connection
      while(io.status() < AIO_CONNECTED || retry < 10) {
        logMessage(".");
        retry++;
        delay(500);
      }
      if (io.status() < AIO_CONNECTED){
        sendData = false;
      }
      // we are connected
      logMessage("Adafruit connected:" + sendData ? "true" : "false");
      logMessage(io.statusText());
    }


    /*
     * send DONE signla to TPL5100 to shut the power off
     */
    void sendDone(){
      digitalWrite(DONEPIN, HIGH);
      delay(1);
      digitalWrite(DONEPIN, LOW);
      delay(1);  
    }

    void setup() {
      delay(10);
      Serial.begin(BAUD_RATE);
      Serial.println("Measuring Temp on DS18B20 \n");
      delay(10);
      pinMode(DONEPIN, OUTPUT);
      pinMode(LEDPIN, OUTPUT);
      digitalWrite(DONEPIN, LOW);
      connectAdaIo();
    }

    void loop() {
      io.run();
      digitalWrite(LEDPIN, HIGH);
      logMessage("I was here", true);
      delay(3000);
      digitalWrite(LEDPIN, LOW);
      while(true){
        sendDone();
      }
    }

schematic

simulate this circuit – Schematic created using CircuitLab

Best Answer

In addition to the helpful suggestion from Jim Fischer, I see another possible cause of your problem.

High-side vs. Low-side switching

Even when TPL DRV is low my external LED to MC on pin 13 is lit and voltage is < 0.5 volts, should microcontroller be OFF completely?

Notice from the TPL5111 datasheet that the "Typical Application" example is not controlling a low-side switch - it is controlling a high-side switch. You might wonder why that matters...

Look at this diagram from its HTML datasheet:

TPL5111 typical application

Figure1: Example TPL5111 schematic from its datasheet

In that example, there is no chance of leakage from the MCU GPIO pin, nor via the I2C pull-up resistors shown in that example, when the power is switched off using the high-side power switch.

However, looking at your schematic, since you are switching on the low-side, there are "hidden" current paths from the power rail via the MCU D2 pin and the 1MΩ resistor to ground, and via the MCU D3 pin and the LED to ground:

Current schematic version

Figure 2: Present version of schematic from the question

These types of "hidden" current paths, via GPIO pins, can be enough to (partially) power-on an MCU. This is quite a common problem when using low-side switching, as you need to consider every possible path to ground from each device, when its main ground connection (e.g. Vss) is disconnected.

You can test this hypothesis on your design:

  • Disconnect the MCU D2 GPIO pin, so that it is not connected to the 1MΩ pull-down resistor or the TPL5111 DONE pin..
  • Change the LED connection, so that it is between the MCU D3 pin and Vdd (i.e. the positive power rail) instead of between the D3 pin and ground. You then need to change your code, since driving that MCU pin High will switch the LED off, and driving the pin Low will switch the LED on.
  • Disconnect any other GPIO pins which are used, but which are not shown on the schematic.
  • Also, shouldn't you use a resistor for that LED, no matter how you connect it?

Then check again whether your MCU still lights the LED, when its GND pin is disconnected by the TPL5111 & MOSFET.


A few more points:

  • I have already mentioned in a comment that SW1 in your schematic seems wrong, as it would directly short the power supply when the switch is pressed. However I assume that is a mistake in the schematic and does not show the real connections which you have to SW1.

  • Your chosen FQP30N06 MOSFET may not do a good job of switching-on your load. Notice that its \$\small R_{DS(on)}\$ is specified at \$\small V_{GS} = 10\;\textrm{V}\$ but you are switching it using a much lower voltage, so its \$\small R_{DS(on)}\$ will be higher than its "headline" specification of 40 mΩ.

  • The TPL5111 is designed for switching a logic-level power signal, not a MOSFET gate. It is specified at 1 mA of drive and 50 pF load (absolute maximum 5 mA). Although I doubt this will be a problem with small MOSFETs (small values of gate capacitance), personally I would suggest to review the MOSFET specification and its suitability more closely (I have run out of time). Also use a 'scope to view that gate drive signal, to ensure it has sensible rise/fall times.

  • Depending on your design constraints, component availability etc., you could consider inverting the TPL5111 DRVn signal using a small signal NPN BJT or N-channel MOSFET, and using that (now inverted i.e. active-low signal) to drive the gate of a suitable P-channel MOSFET, acting as a high-side driver. It all depends on the reason(s) why you decided to use a low-side switch in the first place.