SDcard Logger with FIFO and FIR Filter (FreeRtos)

What are you developing?
Post Reply
User avatar
Pito
Posts: 94
Joined: Tue Dec 24, 2019 1:53 pm

SDcard Logger with FIFO and FIR Filter (FreeRtos)

Post by Pito »

Hi folks,
this is an example I shared in past (old stm32duino forum).

///////////
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 occurrence, frequent, random duration) somehow, here is an example with a "FIFO buffering".
More on this WL issue you may find here:

http://www.stm32duino.com/viewtopic.php ... 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 buffer,
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).

Note:
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.

Enjoy logging,
Pito
////
Attachments
STM32_SDCARD_LOGGER_FreeRtos_FIFO__FIR_FILTER.zip
(4.84 KiB) Downloaded 428 times
Last edited by Pito on Wed Sep 09, 2020 1:20 pm, edited 1 time in total.
Pukao Hats Cleaning Services Ltd.
Post Reply

Return to “Projects”