Pages: [1] 2 3   Go Down
Author Topic: Low power shutdown/failure/t'is quittin' time ...  (Read 2498 times)
0 Members and 1 Guest are viewing this topic.
Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I suppose this could apply to a bunch of stuff, but this is specific to what I'm doing here.  It might help someone else out though.  I have a 328p that's running a sketch that's using two pins acting as DATA and CLK, driving a bunch of WS2801 LED drivers.  The 328p as well as the LED strings are both powered via Vin.  Now, when the battery voltage drops too low, the Atmel quits, or shuts off.  However, because the LED string is powered separately, that will stay on (till the batteries go completely dead), and stuck on whatever the last command was.

Now, programmatically, I can send 0x0's down the string and the LEDs will shut off - the string is still powered, but nothing is lit.  Is there a way to do that when the Atmel shuts off? (In other words, does the Atmel, at any time, know when it's about to die?)

Or should I be looking at an external solution (to the Atmel) that can detect when the Atmel goes 'kerplunk' and it kills power to the LED strings?  Then there's the issue of the batteries possibly regenerating just enough juice to restart the Atmel again ... I wouldn't want that to happen ... once dead, it needs to stay dead till I replace the batteries.
Logged

Seattle, WA
Offline Offline
God Member
*****
Karma: 11
Posts: 673
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

To solve this, I run a voltage divider circuit from my battery to an analog input pin.  It needs to be divided down so that the max voltage on Vbatt equals the voltage on your board (presumably 5V).

In this particular circuit, I'm using a 1M/470 combo, which gets 15V down to 5V.

Logged


Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

HOLD THE PHONE!

I just realized something ... it's not the Atmel that's quitting, it's the 5V regulator.  So forget everything I said earlier about the Atmel.  The regulator is quitting when Vbat gets too low for it to function properly, however since the string is powered directly from Vbat, it kills the Atmel, but the string remains lit.  So I need to rethink this.  Need to figure out a way to also kill Vbat going to the string when the regulator cuts power to the Atmel and related electronics.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The processor has brown-out detection in it, but maniacbug's suggestion of monitoring the Vbat line might be the way to go for you.
Logged

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah, BOD won't work in this case because it's the regulator that quits, not the Atmel itself.  So I'm thinking maybe a small relay of sorts that's connected to one of the pins on the Atmel.  Bring the pin high and the relay provides Vbat to the string.  If the Atmel dies, that pin will go low, relay will shut off Vbat to the string.

Other suggestions besides a voltage divider or my idea above?
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Edison Member
*
Karma: 19
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: November 02, 2011, 12:56:46 am by KirAsh4 » Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8471
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3942
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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".
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ...
Logged

Pages: [1] 2 3   Go Up
Jump to: