Go Down

Topic: Questions about fast SD logging (using the SdFat LowLatencyLogger example) (Read 1 time) previous topic - next topic

user111


I am hoping experts (perhaps fat16lib) can help me with these questions.

I am using a Mega and trying to log sensor data (imu and gps). Goal is to log imu @100Hz.

I'm using code from the LowLatencyLogger example, and am making progress but have a few questions:
 
As I understand this example creates a contiguous file for logging. Currently, the max latency reported over a few runs is ~720us.

First question --- when using the contiguous file method, will the latency always be ~720us for this same card? (or will there still be occasional longer latencies)

As I understand, the AnalogBinLogger uses the similar technique with the addition of reading the sensor in an ISR, while SD writing continues in main loop.

Second question --- considering that I need to log readings every 10ms, and if the SD write latency for contiguous file is constantly ~720us, I can absorb the SD write latency. So, I think I can read the sensor in the main loop as well. Is this a reasonable understanding?

The thing with this 'contiguous file' technique is that at the end of data logging, the program needs an input and some additional steps/time so that the contiguous temp file can be truncated and renamed to final/usable one. The issue is that when I complete my device, I plan to have just a 2 way switch with 'OFF' and 'LOG' options. So when the user is done logging data he will just switch to OFF --- but we need to save the contiguous temp file.
So I think I need to find a way to keep the power on for a few seconds even after switched to OFF to perform the truncation/rename.
Question --- I'd appreciate pointers on how this can be achieved -- use capacitor? other methods?
Is there any other way to solve this problem, may be such that the extra time is not needed at all?


Thank you.

fat16lib

The low latency logger depends on the fact that you can determine if the SD card is busy for a block write in contiguous mode.

There are at least two block buffers so after reading the sensors, you check for a full buffer and write it if the SD card is not busy.  This insures the write latency will be about 720 μs.  The card may be busy for several ms but you just skip writing and save data in another buffer during the busy period.

Quote
So, I think I can read the sensor in the main loop as well. Is this a reasonable understanding?
At 100 Hz you should have no problem.

Quote
The thing with this 'contiguous file' technique is that at the end of data logging, the program needs an input and some additional steps/time so that the contiguous temp file can be truncated and renamed to final/usable one.
You need to do this kind of step with any high speed logger.  If you use file writes, you can't open and close the file for each point.  You can't even flush the data to the SD since this will force much SD activity so you must close the file when you are done.

Truncating a file is fairly fast.

user111

Thanks a lot fat16lib.


OK, so looks like I will need a way to keep power applied to my device for 1-2 seconds after switched to OFF.

People -- any pointers on established and/or graceful ways of doing this?

Thank you.


CrossRoads

Supercap and a boost regulator to hold the power line up until the cap is gone.
Isolate the parts that need power from others that don't. Take any control lines low to those parts so the IO lines don't inadvertantly power them.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

user111


Go Up