hi all, i'm trying to log 1hr worth of sensors data (each reading is 100 bytes, sampling rate is 100Hz, so 10KB/Sec).
I have a "data-ready" interrupt (fires at 100Hz sampling rate) that sets a "data-ready-flag". In the main loop, whenever the flag is up, I acquire the data from the sensors (100 Bytes). The sensors acquisition takes 1-2ms, and therefore is done outside of the ISR. The main loop runs much faster the 100Hz, and so no data is being loss.
Using the SdFat library (by Greiman) I tried to write these 100 Bytes, after each data acquisition (that is 100 times a second). It works generally well, but every now and then there are some (well known and well reported) 150-200msec latencies at the SdFile write method.
I've been digging a lot in the forum, and came across two main solutions:
(1) implementing a ring (/FIFO) buffer, and writing to the SD only whenever it is not busy.
(2) using contiguous file, and writing multiple blocks (as in the LowLatencyLogger examples provided with the SdFat library.
My problem with option (1), is that the `sdEx.card()->isBusy()` method seems to block my process for about 1sec, and returns alway True.. (works ok with SdFatSdio but not with SdFatSdioEx). From the forums it seems like accessing the card class directly is not advisable. So how this should be done?
My problem with option (2), is that writing blocks with `sdEx.card()->writeData()` doesn't work for me. But then again, the TeensySdioDemo example suggests that using the SdFatSdioEx one can write multiple blocks natively very fast. In that case, do I still need a ring buffer? how do I time the writing process if I can't access the isBusy() method? Or maybe I can override the `yield()` method and do the sensor acquisition there? I'm a bit lost here..
So, what would be the best practice way to implement this kind of data logger?
Many many thanks in advance,
Rubin
I have a "data-ready" interrupt (fires at 100Hz sampling rate) that sets a "data-ready-flag". In the main loop, whenever the flag is up, I acquire the data from the sensors (100 Bytes). The sensors acquisition takes 1-2ms, and therefore is done outside of the ISR. The main loop runs much faster the 100Hz, and so no data is being loss.
Using the SdFat library (by Greiman) I tried to write these 100 Bytes, after each data acquisition (that is 100 times a second). It works generally well, but every now and then there are some (well known and well reported) 150-200msec latencies at the SdFile write method.
I've been digging a lot in the forum, and came across two main solutions:
(1) implementing a ring (/FIFO) buffer, and writing to the SD only whenever it is not busy.
(2) using contiguous file, and writing multiple blocks (as in the LowLatencyLogger examples provided with the SdFat library.
My problem with option (1), is that the `sdEx.card()->isBusy()` method seems to block my process for about 1sec, and returns alway True.. (works ok with SdFatSdio but not with SdFatSdioEx). From the forums it seems like accessing the card class directly is not advisable. So how this should be done?
My problem with option (2), is that writing blocks with `sdEx.card()->writeData()` doesn't work for me. But then again, the TeensySdioDemo example suggests that using the SdFatSdioEx one can write multiple blocks natively very fast. In that case, do I still need a ring buffer? how do I time the writing process if I can't access the isBusy() method? Or maybe I can override the `yield()` method and do the sensor acquisition there? I'm a bit lost here..
So, what would be the best practice way to implement this kind of data logger?
Many many thanks in advance,
Rubin
Last edited: