My main problem/goal is to log 7 int to a persistent storage within 1 millisecond. It will be repeated for 200hz. It needs to be done in 1 ms as I have other stuff to run. (Maybe a bit more time ~20% is fine)
After some research, I found sdfat which provides low latency sd card logging. However, I am unsure if my goal is really possible. I read from one of the forum post by fat16lib that the library can log with a latency of ~800 microseconds, I'm guessing that it can only be achieved with certain sd cards. What type of sd card works well with this library for low latency logging?
If there are any other alternatives to my goal / If you think its impossible please let me know too!
Thanks!
If it is not possible, at the bare minimum can I achive my goal if I only want to log 2 int.
Ian2024:
I'm quite low on budget tho. Is it possible for sd card to log that fast?
Do look up prices! At about 1,000 times the cost of SD storage it is still just a few USD or even less per chip.... Expensive does not necessarily mean "a huge amount of money".
2 int values = 4 bytes
200 Hz = 800 bytes per second or 24,000 bytes in 30 seconds.
That fits in the RAM of an ESP8266, meaning you can just store your 30 seconds of data in RAM and then leisurely write it out to SD card.
One second of data fits in the memory of an Arduino, which you can then write to the external SD card in one go. A single 32 kB I2C FRAM chip costs USD 2.15 on Digikey; the faster SPI version USD 2.29. If you're going to write to SD card afterwards you can go for SRAM for temporary storage, a 32 kB SPI chip is just USD 1.02 a piece.
7 int values = 14 bytes; 84,000 bytes in 30 seconds. A 128 kB SPI FRAM chip goes for USD 3.50 each.
It seems an SD card needs at least some 10 ms to do a write operation (a quick Google search doesn't give much info there). That library you mention is probably caching data in memory, it still has to be written out now and then, I guess on a per-block basis. It seems SD cards also have internal caching, but again that now and then needs to be flushed and written out.
wvmarle:
It seems an SD card needs at least some 10 ms to do a write operation (a quick Google search doesn't give much info there). That library you mention is probably caching data in memory, it still has to be written out now and then, I guess on a per-block basis. It seems SD cards also have internal caching, but again that now and then needs to be flushed and written out.
Agreed, the bottleneck is when writing the data to the sd card. Even though the bytes/sec write speed might be fast, it is no use if the write latency is too slow.
Thanks for the information. I will do some research on FRAM first. Will keep you posted.