# Arduino secondary power supply?

Alright in the mod I'm working on the Arduino will get it's 5v from the computer's power supply. However upon loss of voltage to the signal pin it will perform a function. for htis I need the Arduino to have power after teh computer is off. It only needs to be for a few seconds. Can I use some sort of capacitor setup for this? I'm thinking the cap will charge while the computer is on, but then leave 3 or 4 seconds worth of power to the Arduino when power is taken away from it.

How much power does the Arduino draw? What would be the best way to go about setting this up?

I'm estimating about 25mA of current draw. This circuit should keep the voltage above 4V for a few seconds (in theory...haven't tested it):

The Cooper-Bussmann PM-5R0V474-R capacitor should fit the bill.

That looks like a nice solution for a 'hold on awhile' voltage source. However an additional challenge is how is the program going to know that the Vcc has cut-out from the PC and to start the shutdown saving or whatever the OP needs performed?

Lefty

Well, he didn't say anything about actually wanting to KNOW the power was out!

I'm thinking a voltage divider (by 5) from +5V to an A/D input pin and 1.1V internal reference. There should be an instant 0.3V drop on +5V when power goes out which translates to ~60mV after voltage division, or about 55 A/D counts. Doing continuous conversions on the A/D input and watching for a drop of >30 or so should work.

Doing continuous conversions on the A/D input and watching for a drop of >30 or so should work.

Sounds a little clunky and would add significant overhead to the main sketch. A circuit to generate a interrupt on loss of PC Vcc is what would be really desirable.

Lefty

A circuit to generate a interrupt on loss of PC Vcc

That's what I did for the Vehicle Telemetry Project in Practical Arduino. There's a big cap on the input side of the voltage reg, being fed via a diode. A voltage divider on the input side of the diode is connected to an interrupt on the Arduino with a Zener diode as a voltage clamp. The Arduino therefore knows right away if the power supply goes away, and the diode prevents the cap from holding the voltage divider high. In that particular project the ISR triggers an emergency shutdown that closes a logfile being written to a USB memory stick so it's not corrupted when the Arduino loses power a few milliseconds later.

## Jon

Practical Arduino: www.practicalarduino.com
Freetronics: www.freetronics.com

as far as for the board knowing the computer is off, the PSU puts out 5v as well as 12v, and the code I have tells the arduino to check for voltage on pin 7, so when the computer is on there will be voltage to pin 7 and the loop will run. When the computer shuts off it will take voltage away form pin 7 and set the servo to a preset position. I want to run the arduin off an internal USB connection, so this is why I need it to stay on for 3 seconds or so after the computer shuts off. If it shuts off at the same time it won't set the servo to it's base position.

Thanks everyone for their help! I'll give this a shot hopefully this weekend.

This is what I'm doing with it:

When the computer shuts off it will take voltage away form pin 7 and set the servo to a preset position.

Ooooo....you didn't say that originally. Moving a servo takes way more than 25mA so my proposed solution won't work, unless you have the servos powered from an external power supply. Though I guess you could just increase the capacitance (as your wallet allows) until it does work.

A member of the forum I've got this worklog on pointed me to a pair of 10F caps that I can wire in series to get 5F and charge with 5V. Should that be enough?

That should get you ~250mA for 3 seconds instead of ~25mA. It might work....

if you watch the vid, all it needs to do is move the servo (standard r.c car servo) about 25 degrees. that's it. I'll breadboard it up when I get those caps in and let you know.

now as far as hooking teh caps to the arduin (like in your diagram) can I use the 5v and ground pins on the arduino itself? or would I have to hook it into one of the inputs? (like make a custom usb cable with the exra leads)

Yes, you should be able to just use the 5V and ground pins on the Arduino itself.

I've got this worklog on pointed me to a pair of 10F caps that I can wire in series to get 5F and charge with 5V.

Get the data sheet for those caps, I know some large caps can't provide large currents and in this context you have a large current.

Get the data sheet for those caps, I know some large caps can't provide large currents and in this context you have a large current.

datasheet:

I don't think those are going to work. The ESR is too high (40 ohms for the 10F caps). Put two in series for 80 ohms and you're not going to get your ~5V at 250mA.

The caps I originally suggested (0.47F) had an internal ESR of 0.3 ohms. You're looking for (I'd say) <1 ohm if you're going to be powering a servo.

but how many of those in series will I need to run the servo for ~1 second?

They're rated for 5V so you don't need to put them in series. I would put 10 of them in parallel to get 4.7F, though that'll set you back about \$40:

If you're going to put caps in parallel their ESR's combine in parallel so maybe you can find cheaper caps with higher ESR.

Well the two 10F 2.5V caps in series worked perfectly. I was able to cycle the servo 5 or 6 times before they were drained to the point that they'd no longer power the arduino, so that's more than enough.

This thread has all the info and the eventual setup:

alright I got it working perfectly!

if you go to Circuit Simulator Applet it will open up a java applet. go to file -> import then copy and paste this code:

``````\$ 1 0.0050 1.6308177459886661 40 10.0 62
g 128 96 80 96 0
R 128 32 80 32 0 0 40.0 12.0 0.0 0.0 0.5
w 288 176 288 208 0
w 288 208 384 208 2
r 368 288 368 336 0 15.0
s 112 64 192 64 0 0 false
z 336 336 336 288 1 0.805904783 5.6
w 336 288 368 288 0
w 368 288 432 288 0
c 336 336 336 384 0 10.0 1.2014201366351538
c 336 384 336 432 0 10.0 1.20142013663504
w 336 432 384 432 0
w 336 336 368 336 0
w 384 432 432 432 0
178 272 48 320 48 0 1 0.2 0.25 0.05 1000000.0 0.02 20.0
w 272 80 208 80 0
w 272 96 128 96 0
w 432 288 432 208 0
w 432 208 384 208 0
w 320 128 288 128 0
r 288 128 288 176 0 5.0
w 336 432 144 432 0
w 144 432 128 96 0
162 432 288 432 432 1 5.0 1.0 0.0 0.0
z 320 64 320 128 1 0.805904783 5.6
R 112 64 80 64 0 0 40.0 5.0 0.0 0.0 0.5
w 208 80 208 64 0
w 208 64 192 64 0
w 128 32 272 32 0
w 272 32 272 48 0
x 467 359 550 365 0 24 Arduino
x 320 152 572 155 0 10 diode and resistor will be replaced with a 5v regulator
x 259 66 296 69 0 10 5v relay
x 315 171 598 174 0 10 There is no 5v regulator in the program so I had to substitute
o 9 64 0 35 1.25 0.4 0 -1
o 10 64 0 35 1.25 0.4 1 -1
o 23 64 0 35 10.0 1.6 2 -1
o 4 64 0 35 5.0 0.4 3 -1
``````

There is no 5v regulator in this program so I subbed in a diode and resistor to give the same effect. It gives more than enough voltage to close the servo, and fully charges both caps in 3-4 minutes. you can view the full idea thread here: