View Single Post
Old 10-01-2009, 06:34 PM   #2 (permalink)
jonoxer
EcoModding Lurker
 
Join Date: Sep 2009
Location: Melbourne, Australia
Posts: 15
Thanks: 1
Thanked 10 Times in 8 Posts
I can't speak for the effect of unexpected loss of power on the original MPGuino but it's a big problem for my version (OBDuino running on a Mega) because I have it writing to a USB memory stick so I took specific steps to alleviate the problem. Maybe the same technique could be applied to other versions.

I'm feeding raw power to a really big capacitor with the positive side feeding through a diode to an LM2940CT-5 (the automotive-rated version of the 7805) which feeds the Arduino. Across the capacitor I have a voltage divider with the lower half protected by a 5.6V zener diode set up so that in normal operation the divider is between about 3.8V and 4.5V. That's then fed to an interrupt on the Arduino, and the code has an ISR to perform an "emergency shutdown" if the interrupt is triggered. That includes setting a flag to force closure of any files open on the USB memory stick so they're not corrupt or lost.

The capacitor stores enough energy to keep the Arduino and all its peripherals running for a few milliseconds after power loss, which is barely enough. It's also powering a 20x4 display and backlight, a GPS module, and the USB memory subsystem though. My plan is to have the ISR cut power instantly to the GPS and the display to try to buy a few more milliseconds for the cleanup to finish.

Cheers :-)

Jonathan Oxer
Practical Arduino: www.practicalarduino.com
Geek My Ride: www.geekmyride.org
  Reply With Quote