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?