The Smell of Molten Projects in the Morning

Ed Nisley's Blog: Shop notes, electronics, firmware, machinery, 3D printing, laser cuttery, and curiosities. Contents: 100% human thinking, 0% AI slop.

Day: October 3, 2013

  • 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…