Arduino Suicide Power Switch: First Light

This may not look like much, but it’s the first test of the p-MOSFET power switch that completely kills power to the Arduino Pro Mini board and the Hall Effect LED Blinky Light:

Power off - 30 mA load
Power off – 30 mA load

The top trace is the base drive to the NPN transistor that holds the p-MOSFET on while the Arduino is running. When it’s time to shut off, the Arduino drops the base drive output, the MOSFET turns off, and the switched battery voltage in the bottom trace drops like a rock. The current is about 30 mA when the Arduino is running and immeasurably low when it’s off; the MOSFET spec says it’s less than 1 μA, which is fine with me.

I love it when reality matches the simulation.

That part of the schematic:

Hall Effect LED Blinky - Battery Switching
Hall Effect LED Blinky – Battery Switching

The PCB has those components clustered in the upper left corner, with the Arduino Pro Mini perched on header pins to the right:

Hall LED PCB - power switch test
Hall LED PCB – power switch test

The test code is a crudely hacked version of the canonical Blink sketch that waits 5 s after it starts running, then pulls the plug:

// Modified from Arduino Blink example
// Drives external p-MOSFET power switch
// Ed Nisley - KE4ZNU - Sep 2013

int led = 13;

// HIGH to enable power supply
int PowerOn = 4;

// HIGH to light Status LED
int Status = 10;

unsigned long MillisThen;

void setup() {

  pinMode(led, OUTPUT);

  pinMode(PowerOn,OUTPUT);
  digitalWrite(PowerOn,HIGH);
  pinMode(Status,OUTPUT);
  digitalWrite(Status,HIGH);

MillisThen = millis();
}

void loop() {
  digitalWrite(led, HIGH);
  delay(100);
  digitalWrite(led, LOW);
  delay(500);

  if (((millis() - MillisThen) > 5000ul)) {
      digitalWrite(Status,LOW);
      delay(50);
      digitalWrite(PowerOn,LOW);
      digitalWrite(Status,HIGH);
  }
}

It turns out that the Arduino runtime has a several-second delay after power comes up before the setup() routine starts running, so brief pulses from a vibration switch won’t last long enough to turn the thing on. That’s not a fatal flaw for now and, in fact, having to hold the power button in for a few seconds isn’t entirely a Bad Thing.

However, once the power turns on, a vibration switch could trigger an Arduino interrupt pin to reset a power-off timer. I’d be tempted to put the vibration switch in parallel with the button, with a pair of steering diodes that isolate the raw battery from the input pin.

This is, of course, a pure electronic implementation of a Useless Machine…

3 thoughts on “Arduino Suicide Power Switch: First Light

  1. for ‘instant on’ – ditch the bootloader – the ‘delay’ is the bootloader waiting for a sketch upload via the serial ports before loading the in-system sketch… If you use an ICSP programmer (or another arduino running the ICSP sketch) then you can burn sketches via the ‘upload using programmer’ function (after setting the serial port to the appropriate port for the programmer and selecting the programmer via ‘programmer’ in tools) and those sketches will run ‘instantly’ due to the lack of bootloader.

    1. ditch the bootloader

      That’s pretty much the nuclear option after getting everything else running: all the ICSP signals are connectorized on a Pro Mini, just not in a convenient layout.

      Somewhere in the pile, there’s a Bus Pirate waiting to become an ICSP widget, so I must gimmick up an adapter that connects to the Pro Mini’s pins. Something less risky than half a dozen flying leads seems in order.

      I thought the delay was maybe half a second, but it’s much longer than that…

Comments are closed.