I decided to create another analog datalogger for my RC aircraft but I need some help and tips for design.
Since I started learning FreeRTOS for Arduino, I realized soon, that the best way is to use an real time application for savings data on a SD card.
So here the general specifies:
- Task 1 (“T1”, high priority) reads the 6 analog pins every 4 millisecs and save them in a struct. Then move the struct into a queue;
- Task 2 (“T2”, lower priority) reads the struct from the queue and save it into a SD Card. This Task runs everytime T1 is blocked;
The biggest problem is that I don t know how to efficiently copy data from the queue to the SD card. Since it could last milliseconds, I thought 2 strategies:
- to append during T2 the whole queue into the file and then close it => super Problem: it lasts more than 4 - 0.6 = 3.4 milliseconds;
- to append during T2 just few values from the queue to a static buffer (which can store about 2000-3000 values) and only when the buffer is completely full then transfer all the buffer to the file and close it (during this operation I would stop T1, since I don’t need more values from the sensors).
I have no idea, how it is better to implement it. Since I don t have too much time between T1 und T2 I m afraid I can mess all data in the queue. Do you have a much better idea !??!?! Please…you are welcome!!!
PS: I know that there are more efficient RTOS out there, like NilRTOS for istance, but please, I m learning now FreeRTOS and I bought the application guide for microcontrollers, so I don t want to get crazy learning another RTOS.