SDcard Logger with FIFO
and FIR Filter (FreeRtos) for Maple Mini or Blue Pill
As it has been discussed in this forum, writing a continuous stream of data to an SDcard is difficult.
Not because of the SDcard's writing speeds, but because of Write Latencies
(up to 250ms).
During an WL an SDcard does not respond to the incoming data, it means when the data are not buffered, the data are lost.
You have to overcome the WL outages (random occurence, frequent, random duration) somehow, here is an example with a "FIFO
More on this WL issue you may find here:viewtopic.php?f=15&t=288#p18207
Below you may find a complete Demo I wrote for MapleMini and an SDcard connected to SPI1:
1. we sample 8ADCs, 200x per second,
2. we apply 30Hz low pass filter on each ADC channel measurement,
3. we write the data into the FIFO
4. in parallel
we read the data from the FIFO
and write the data onto an SDcard as fast as we can,
5. the format we write the data on the Sdcard is CSV, so you may analyze what is going on in Excel,
6. we also log information on FIFO
statuses (the values of counting semaphores).
1. In this demo we read 8ADC channels as an example, but some ADC channels read SPI1 signals,
as you may see on the results in the CSV file,
2. You may play with FIFO
size in Records (here default 150), the actual content of a Sample Record, and with
Sample period/rate (default 5ms =200Hz) such it all fits into MapleMini memory (we assume you got 20kB ram)
and you do not get FIFO
overruns when an WL hits,
3. I've tried to comment the code as the time permitted,
4. Provided As-Is, no warranties of any kind,
5. Use at your own risk.