Let's Make Robots!

Self Shutting Down Arduino (or any other microcontroller, for that matter)

If a locking relay was attached to a micro-controller's power-supply, couldn't said micro-controller shut itself off? Does a locking relay require a pulse of a certain length? I am an absolute beginner in electronics and I would love improvements/suggestions. I would be sending a command from a computer (pi?) for my robot to shut itself off and save the map of its environment. This led me to thinking about remote turn on. Could some sort of unpowered rf receiver be used to trigger said relay? I would love suggestions/ideas/part numbers for CHEAP rf modules that would work for this.

thanks

-gabriel

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
OddBot's picture

This is a relatively simple circuit that should suit your needs. The On/Off switch behaves like normal except than when you turn it on the circuit only supplies power for about 100mS. The MCU must pull the control pin high to maintain power.

You can manually turn the robot off using the power switch or the MCU can turn the circuit off by pulling the control pin low. Once the MCU has turned off power the circuit must be reset. This can be done by switching the On/Off switch to the "Off" position long enough for the capacitor to discharge or by using an optional reset button. 

The IRF9540 is a low cost, commonly available Pch FET that can switch a few amps without a heatsink and up to 20A using a suitable heatsink. Other Pch FETs can be used as long as your input voltage does not exceed their Vgs rating which is usually between -12V and -25V depending on the FET being used.

The BC548 is just a general purpose NPN transistor and can be replaced with any other NPN transistor such as a PN100 or a 2N series transistor.

Depending on your controller and it's bootloader you may want to extend the the time needed for the MCU to power up and pullup the control pin. Increasing the capacitor value to 1uF may be necessary.

 

Maxhirez's picture
I'd think you'd want to avoid having a μ controller controlling its own power. Do it one way and it has to hold a pin high all the time-a brief drop-out (admit it-they happen) and night-night. Do it the other way, so that it turns off by interrupting, and you have to have (as bdk notes) a separate way of turning it back on. Best to keep it a separate circuit so you can do the standby thing.
bdk6's picture

By locking relay I assume you mean a latching relay.  That would work to turn it off, but it would use quite a bit of power (probably a lot more than an arduino) and need more circuits like transistors to turn it on.  You can control the power to an arduino (which isn't much) with just a transistor and a couple resistors.  Turning itself off is easy.  Turning it on is a lot harder.  In short, some circuit has to have power continuously for it to be able to turn on by itself.  Remote control TVs and other devices work that way.  They have a "standby" mode where only the remote control circuit is powered.  You could use RF or infrared, but it would have to have power.  An automatic turn off with manual turn on can be done like this:

edit:  removed the circuit.  After a moments thought realized it wouldn't work.

Try googling for automatic power off circuit for microcontroller.  This has been done lots of times.

 

bdk6's picture

Since my brain refuses to do this properly myself, I found a link for you. 

http://www.mosaic-industries.com/embedded-systems/microcontroller-projects/electronic-circuits/push-button-switch-turn-on/microcontroller-latching-on-off

The first circuit there is more complicated than what you really need, but should work.  I didn't look very closely at the second.

Ladvien's picture
With information given, I'd say take a hardware route. Some sort of device to trigger the relay long enough for your code to boot, then have one of your digital pins hold the relay open. When your done, set the pin to low. It would help to know the goal: e.g., to save battery life. If that is the case, it'd be better to simply shutdown the connected devices. Might also check out... http://playground.arduino.cc/Learning/arduinoSleepCode
Gabriel42's picture

Although my robot will be autonoumous, I wanted a controller to interface and debug with it. I was then thinking about adding a remote turn off feature. the robot will be active when it is on almost continously, so sleeping the arduino would not help much.