I'm designing a minimalist hardware project, with one sensor, a few buttons for input, and an Uno or mini.
Considering power on options....
Currently I have programmed around the switches built into an LCD/switch shield by SainSmart, switches being physically connected to an analog pin for detecting which switch. Final project likely though will entail just connecting switches to individual digital input pins....
Reason for the question, I don;t want to go to the added cost of a power switch unless necessary, and the Arduino draws too much power in sleep mode to be feasible to allow it to go narcoleptic or otherwise sleep, the batteries would die too soon.
Maybe it's already discussed, I haven't found it in my google search, but here is what I propose....
Assign one of the menu select switches to a second purpose, being to momentarily apply power to a "hold" transistor or pfet, whose base or gate would then be maintained via startup software in the Arduino connected to a digital pin, whose collector or drain would provide and maintain the voltage until the software programatically wants to shutdown. It would just drop the digital pin, losing the transistor's drive.
Auto shutoff would work well with my application.
Has anybody else done this, and is there a proven example circuit here somewhere? Though I think I have it in my head already, just want to compare notes in case somebody else has an easier implementation
I am thinking that would work, but those are a lot of parts, just to supplant a power switch
My thought was a hybrid of this, using what looks like 3 resistors and 2 transistors...the hold voltage comes from a dedicated uC pin, programmed to go high on startup and stay that way as needed. Drop the pin to shutdown...
No time for a schematic right now, but essentially in text...
Existing momentary switch (with pullup resistor) leg not grounded is tapped to the gate of a pmos transistor to act as momentary switch....Its source and drain attach to constant +5v and the Arduino's 5v supply input. Shorting the gate to ground conducts power to the Arduino momentarily....
A dedicated Arduino ditigal pin assigned as output would wire through a series resistor to the base or gate of another transistor, whose source and drain would parallel the other one, connecting +5v and Arduino 5v input.
Once powered up, the digital line would maintain power to the Arduino via programming. The existing switch would still do its job as a momentary grounding input switch as always, and would be unaffected by the pmos, as it is connected via the gate. No added switch, and just a couple discrete inexpensive parts....
I don't see any down side to this simplified solution. I could be wrong.
The problem with your simplified circuit is that when the Arduino is powered down, the pin driving the second P-channel mosfet will go low because of the pin protection diode, and this will turn the mosfet back on. To fix this, use an NPN transistor or N-channel mosfet to invert the signal, so that you need a high on the pin to keep the P-channel mosfet on.
You can leave out the first P-channel mosfet if you connect the push button across the source and drain of the second P-channel mosfet, so that power flows through the push button initially. Or you can use the pushbutton to turn the second P-channel mosfet on, bypassing the NPN transistor.
An alternative solution for a final build is to use a barebones Arduino without the FTDI chip so that it consumes very little power in sleep mode. A standard 16x2 text LCD can be powered from a digital output pin through a 100 ohm resistor, with the backlight controlled from another pin, via a transistor if necessary.
I would have thought that if you wanted, you could connect all the menu switches to your latching transistor (via a diode per switch, so they don't back-feed each other) as well as to a digital input - that way, you wouldn't need to use a dedicated switch.
Depending which Arduino you use, you may need to replace the bootloader (or do without a bootloader altogether) to get the boot time acceptably short.
Just as an alternative here is a manual power on, auto power off circuit I've build and used in a few projects. It's based on a small DIP packaged 5vdc single coil latching relay that I found on Ebay ( I think I paid $5 for 10 of them). It draws no current when it's powered off, just brief coil current consumed while switching. On power up the output pin is set low in the startup function which 'seals' the power on contacts on the switch. Once powered up the sketch can turn off the system by simply outputting a digital low on the relay coil pin.
Good thought Peter...similarly, couldn't we put a diode in series with the switch, and a pullup resistor on the above mentioned pmos transistor to avoid restarting when the uC shuts down...
cornwallav8r:
Retro, isn't C1 needing to be in parallel now series with the relay coil? Wouldn't stay latched once C1 charges up.
No, that's how latching relays work. C1 charging up allows current to flow through the coil causing it to go to the 'set' position. Once C1 is fully charged current stops flowing but the relay still stays in the set position because it's magnetically latched to the 'set' side. When the Pin goes low current flows in the opposite direction causing the relay to go to the 'reset' position where is remains magnetically latched even when the current stops flowing. When a latching relay is placed in either its set or reset position it remains in that position even if physically removed from the circuit.