How to quickly drain a power supply to reset MCU

I have a circuit that uses an ATTiny MCU as a timer to control a relay.

When the AC power is turned on, the MCU immediately turns on, counts three seconds, then turns on a relay. Simple.

The circuit is powered by a tiny 5VDC, 2.5W power supply. If the AC is switched off and on too quickly, the power supply capacitor hasn't drained yet and the processor keeps running. It doesn't reset and count the three seconds.

I've added a 1K bleeder resistor across the PSU rails, and it does drain the cap in about 4-5 seconds, but that's still too long.

I'm wondering if it's safe to lower the bleeder resistance to something like 820R or 680R to have the PSU drain within 2-3 seconds for a faster MCU reset.

If the resistance is too low, at what point does it start to strain the PSU with its continual load while the circuit is on? I'm concerned that the PSU would eventually fail because it's stressed by the load of the MCU + bleeder resistor.

Any suggestions from the forum would be greatly appreciated.

psu.jpg

Unless you want to use the Arduino for the exercise, it is a sledgehammer to crack a nut. All you need is a couple of transistors and a few resistors / capacitor.

Yes, I know all that. That's not what I'm asking.

I'm wondering if it's safe to lower the bleeder resistance to something like 820R or 680R to have the PSU drain within 2-3 seconds for a faster MCU reset.

You can set it at what ever value you want, providing is is not too low to exceed the rating of the power supply.

2.5W at 5V is 0.5A, so perhaps drain it at 0.25A, ie 20 ohm, 2W resistor?

2W resistor?

Well not really as that would be for continuous operation, this is only going to be a short pulse for a very limited number of times per second.

Is your BOD detector disabled? In case try to enable it and set it to 4.3 V, you'll have a faster reset.

Ciao, Ale.

Thank you all kindly for the suggestions.

I'm not sure of the math. So a PSU with 5 VDC @ 500 mA would be 2.5W. Ohm's law says R = V / I. So 5/0.5 = 10 ohms. So a resistor of 10 ohms would dissipate the entire 2.5W of the PSU?

MarkT suggests a 20R resistor that would dissipate 1/2 of the PSU current. I think that's reasonable. As long as I leave ample headroom that I'm not constantly running the PSU at or near full current.

Attached is a picture of my circuit board. It's an ATTiny 13A driving an Omron solid-state MOSFET relay. Currently I have a 1K bleeder across the rails.

Very simple design, alleviating a lot of analog components and the ability to quickly change the timing period through firmware with a programming clip.

Don't know what and why you are doing this,
but the only fast way to detect if the power is off is with a sensor to detect that the power is off.

I would use an opto coupler.
Opto transistor between an I/O pin and ground, with internal pull up enabled in pinMode.
Opto LED powered directly from the mains. 1mA LED current should be more than enough.
Make sure there is a diode with reverse polarity across that LED, or use an opto made for AC.
Leo..

Wawa:
Opto LED powered directly from the mains. 1mA LED current should be more than enough.
Make sure there is a diode with reverse polarity across that LED, or use an opto made for AC.

Of course, this will shut off for half of the mains cycle, or for short periods at each zero crossing if using an AC optocoupler, so you need to incorporate frequent polling and a delay algorithm to determine when the power actually ceases. :grinning:

Sure, the pin gets LOW once each cycle for a short time with a common one-LED opto coupler.
But that can be detected/stretched to a full cycle with code.
Leo..

Today I tried a 390R 1/2W bleeder resistor and it drains the PSU cap in about 1.5 secs. The processor resets every time now. And the resistor doesn't even get warm.

Thanks for all the help.

Ohms law
5 volts with a 390R resistor draws 5 / 390 = 12.8 mA
So it will be dissipating I2 * R = 0.063 W
So a 0.5W resistor is a bit of an overkill by ten times. Even disregarding the face that this is not a continuations dissipation.

The power supply is actually on the whole time, even after the 3 sec. timing pulse. The resistor comes in a standard SMD 1206 package, so not a problem. As I said, it doesn't even get warm. Thanks for your suggestions and help with the math Grumpy_Mike.