0
\$\begingroup\$

This might be a straight forward question: An AVR gets its power from a regulator which can be turned off with a digital low level input. However on a spike (digital high followed by digital low) the regulator will re-enable itself.

If I use a GPIO of the AVR to control this regulator enable input, the regulator will be turned off, hence the AVR powers off too. Kind of a suicide thing, I know but I need it.

What can I expect from the AVR ports after cutting down the power from it?

What shall I do to kill the spikes on the ports? I must be sure that on the AVR's port remains on GND after the specific suicide instruction.

Is there any hardware requirements which applies to this situation?

\$\endgroup\$
  • 2
    \$\begingroup\$ To get better answers, please attach a schematic of your design, using either the Schematic editor button (best/preferred option) or Image button in your original question. \$\endgroup\$ – Huisman Jul 15 at 13:56
1
\$\begingroup\$

You can smooth out spikes with a capacitor. And a pull down resistor should keep the GND while powered off. Something like this:

schematic

simulate this circuit – Schematic created using CircuitLab

When the capacitor is empty and a spike hits it will start charging and hopefully the spike will be over before the voltage on the regulator leaves the low state. The pull down resistor R3will discharge the capacitor over time. R2 protects the AVR from drawing too much current from the GPIO pin when charging the capacitor while R1 protects the regulator from spikes (I assume you mean the AVR pin spikes).

You probably have to adjust the values of R1/2/3 and C1 to fit. You can connect an osciloscope and simulate spikes to check your math.

\$\endgroup\$
  • \$\begingroup\$ Check to see what the AVR's behavior is in reset. Some processors set up GPIO pins to have weak pull-ups coming out of reset, until they're disabled. If the AVR does that, then R3 in this circuit needs to be stout enough to overpower the weak pull-up -- or you need a 1-gate inverter here. \$\endgroup\$ – TimWescott Jul 15 at 14:50
  • 1
    \$\begingroup\$ Right. Forgot about that. Could even differ depending on which pin you choose. \$\endgroup\$ – Goswin von Brederlow Jul 15 at 15:16
  • \$\begingroup\$ Won't work because you have no means to turn it on. \$\endgroup\$ – Jack Creasey Jul 15 at 16:13
  • \$\begingroup\$ @JackCreasey or the OP just didn't tell us how it's turned on. You can make a pretty robust on/off switch for a \$\mu\$P-driven system by having a push button that forces the power to the \$\mu\$P on, and then set the \$\mu\$P up to hold power on when it comes out of reset. Make that button readable by the \$\mu\$P, and you can make the behavior as simple or complicated as your heart desires. \$\endgroup\$ – TimWescott Jul 15 at 16:24
  • \$\begingroup\$ @TimWescott No, the person answering the OPs question did not show any way to turn it on. It has to be part of the solution, no? \$\endgroup\$ – Jack Creasey Jul 15 at 19:41
0
\$\begingroup\$

In general this type of 'suicide' turn off will not work. As the power is disconnected the AVR will power fail and eventually all the I/O ports reset to inputs ...so your signal goes away.

Not amount of RC delays or clever tricks will help you. You need to be able to either store the state of power (on/off) or provide a relay (which itself is the logical state storage).

schematic

simulate this circuit – Schematic created using CircuitLab

Here you have a manual pushbutton to turn ON.
The MCU then takes over and holds the relay ON.
If the MCU code turn OFF the relay the supply to the MCU drops. Though you need to consider the timing for this since there is lots of capacitance on the supply.

You certainly could make this work, but timing is the detail.

\$\endgroup\$
  • \$\begingroup\$ Or a simple pull down resistor so once the pin goed off on suicide and turns to input it remains low and off. So your answer is wrong. There is a trivial solution to this and that was exactly the Ops question. \$\endgroup\$ – Goswin von Brederlow Jul 18 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.