Low power shutdown/failure/t'is quittin' time ...

What is the range for Vbat?

A transistor that the processor has to drive high for the LEDs to work (a MOSFET or something)?

Can you get rid of the voltage regulator?

Vbat is 4x AA batteries. A fresh set measures about 6.4V.

The Atmel isn't driving the LEDs directly. It's driving a bunch of WS2801 via a DATA and CLK pin. Those will in turn drive the LEDs. This is why the LED string is powered directly from Vbat, while the Atmel is powered from the regulator.

Come to think of it, it doesn't matter what I end up doing with the different components in the circuit, ultimately I still need to drop that 6Vbat down to at the very minimum, 5Vreg. I can also drop it to 3.3Vreg (I thought the RF module needed 5V, turns out I can power it between 3.3V to 7V) Still, I need a regulator to handle that.

The initial problem is still there though, how to cut Vbat from the string once the Atmel dies, since the string is powered from Vbat, not Vreg.

What would be ideal is something like a LiPo protection circuit that completely cuts off power when the voltage is lower than a certain point, right? Then you just have to set it for above whatever the BOD is set at (+~1.5 for the regulator) and they should shut off at the same time.

That would work, though the cut off would have to be somewhere around 3.0V - any lower and the RF module dies.

Another thought as I keep pondering this ... the regulator I'm using has an ENable pin. As long as that pin is high, it's working. Bring the pin low and the regulator shuts off. What if I wire that pin to one of the Atmel pins and use that to cut the power? I know, it's a chicken and egg problem ... Atmel can't bring it high because there's no power and there's no power because the pin isn't high. But, couldn't I wire a momentary switch in parallel from Vbat to the ENable pin, and push it to kick-start the regulator which in turn starts the Atmel which then brings (and keeps) the pin high till it quits?

And once it quits, it stays down regardless of what the batteries are doing, at least till someone hits the switch again?

What's wrong with that theory?

[ an hour later ]
Now that I think about it some more ... that would put the full Vbat voltage onto the Atmel's pin when I push the button, and then to bring the Atmel's pin also high ... I smell disaster.

You can do that if you isolate the AVR pin from the high V, say with a high-side FET in parallel with the switch.


Rob

I'd say the best bet is for the AVR to monitor the input voltage to the regulator through an appropriate voltage divider or whatever. Some experimentation may be needed to determine at what level the regulator gives up, and then program the AVR to react at a slightly higher level, perhaps by going to sleep after it shuts down the LEDs. With a nominal 6V input to a 5V regulator, there may not be a lot of headroom to play with, even with LDO regulators. If this project is not a one-off, then individual calibration may be needed to avoid unreasonably early shut-down decisions. If it's not an LDO regulator, the input voltage could be borderline-insufficient even with fresh batteries.

The BOD is probably not a solution, because it just basically holds the AVR in a reset state once Vcc falls below a certain trigger point, and does not supply an "early warning".

I've done some minor modifications now. Originally it was 6Vbat going to a 5V regulator and that still got me plenty of usage, upwards of 10 hours. For what this project is for, that's about 4x more than what's really needed. However, I too realized that's a small margin to work with, so I've since then replaced the regulator for a 3.3V one. Everything in the circuit can function as low as 3.3V so I'm okay there. That will give me a bit more breathing room as well ...

And I think you are correct, I may just have to do a quick and dirty voltage divider and have the Atmel read that in and go from there.

Another thought: what about using a diode on the Atmel's pin, so that when the switch is pushed, power doesn't feed into the Atmel. I suspect I would need one on the pin at the switch, or just after as well, so the voltage coming from the Atmel doesn't feed back into Vbat and cause all kinds of nastiness ...

Without knowing the exact regulator, would something like this work? No switch. The pullup resistor keeps the regulator enabled until the MCU drives the pin connected to the transistor high. GPIO pins are inputs at reset time, so until the pin is configured as an output and driven high, the regulator stays enabled. When the MCU decides it's quittin' time, it drives its control pin high and goes to sleep.

sch1.jpg

It's the MIC5205 regulator. Its ENable pin needs to be driven HIGH to enable it, or LOW to shut it off.

KirAsh4:
It's the MIC5205 regulator. Its ENable pin needs to be driven HIGH to enable it, or LOW to shut it off.

Yep, I might try that circuit then. I also see the dropout voltage is 165mV at the max current output of 150mA, so not bad.

Where I'm uncertain is when you say the MCU drives its pin high when it quits. When the MCU quits, it shuts down, doesn't drive anything high ... they just go bye-bye.

Oh wait, maybe I'm going in circles here. Hmmm...

Maaaybe, though I prefer ellipses. Anyway, the MIC5205 needs its ENable pin high to function, which is why if it's not used, it's always tied to Vin. So, if I'm to use the controller to keep it high, I need to wait for the controller to come up, for the sketch to kick in, configure a pin as OUTPUT and then drive it HIGH. When the controller reaches its brownout, or if for some reason there's an ant sitting cross legged on an exposed trace, sucking the juice, it will simply die and everything on the controller goes byebye, taking the pin low and thus shutting off the regulator - this is what I want to happen. And it needs to stay off and not turn itself back on after the batteries have regenerated just enough juice to turn things on again, even for a brief second.

That's why I thought up the idea of using a momentary push button to kick start things ... once running and I let go of the button, the only thing keeping the regulator alive is the controller itself.

By the way, I have one shot at this. I received my first set of test boards today, which I know already have issues, but, being that they're test boards, I can muck with them. But since it takes so long to push things through BatchPCB, I have one shot at getting these done by the end of the month. That includes building about 300 tiny little PCBs. :confused:

So yeah, I'd like to get this right, or as good as can be. Not expecting perfection here ...

The transistor basically inverts the signal from the MCU. In the absence of any input from the MCU, the pullup resistor pulls the ENable pin high on the regulator to keep it on. When the MCU drives the base on the transistor high, it pulls the regulator ENable pin down to near ground, turning the regulator off. BUT, if there is not time (and I wouldn't bet there is) for the MCU to then get into power-down mode, then it'll just reset, the pin driving the transistor will be an input after reset, allowing the pullup resistor to once again enable the regulator. Catch-22. Have to drive the pin to the transistor high, then go into sleep mode, but driving the transistor high cuts the juice.

But it's too late and I'm brain dead... :~

Nick suggested earlier a MOSFET which controls the power to the LEDs. Probably a better approach than fiddling with the regulator enable. G'nite.

Yep, I think the options offered here were a voltage divider and measure it with a pin. (ManiacBug)
MOSFET driving the LED string (Nick Gammon)
The equivalent of a LiPo protection circuit (WizenedEE)
If I do a switch, I could possibly isolate the pin from Vbat with a high-side FET (Graynomad)

And I don't know if having a switch with diodes on the two lines would work ... can't wrap my feeble brain around it.

Alright, decision time. I'm going to sleep on it and come back to it tomorrow. Thanks for all the suggestions.