SD Card Corruption due to power loss during teensy3.6 operation

HeisenBerg

New member
In my project I will be logging data on the SD card which will be mounted on Teensy3.6. I wanted to know
1. would the SD Card be corrupted if there is sudden power loss in Vin to the teensy board while a read and write operation is going on
2. If Yes, is there any solid measure that I can implement like an additional battery backup that will ensure that the read-write operations on the SD card is completed before teensy turns OFF?
 
1) - yes, as with every system. This happens on your PC, too.
2) - You need to figure out how much time your program needs to detect power loss and to flush and close the file.
 
The farther upstream on power delivery you can detect power loss, the more time you'll have to respond. The very best (but often impractical) way is to directly detect the AC waveform arriving at your power supply. If either a positive or negative peak doesn't occur within the expected half-cycle time, you would close or flush files in prep of the power to be lost.

If you use a 5V regulator, sensing the voltage at its input will give you earlier warning than sensing the 5V output. Likewise, sensing 5V power is better than detecting a drop on the 3.3V power, which also run the SD card.
 
Short-term backup

Another approach that I've used in the past is to add a short-term backup capability to allow ample time to stop logging and close your files. I used a 5V supercapacitor of 0.47F which kept the Teensy input power above 4.0V for at least 2 seconds with a nominal power consumption of 30ma. Of course, the current drain spikes to nearly 150mA during SD card writes---but those are usually short-term events.

Backup.png

The VSense output connects to an input pin where your software can detect (via an interrupt or frequent monitoring in loop()) when the input power, V5V, drops out. The super cap is the expensive part--about $4 qty one. It's up to you to determine whether the integrity of your data is worth the component cost and board area.
 
Last edited:
Back
Top