Writing to microSD card Teensy 3.6

Status
Not open for further replies.

gregolive

Member
Hello,

I am new to Teensy and Arduino in general, but am trying to use a Teensy 3.6 to collect data from analog sensors at around 10,000 samples per second per sensor, and write it to a microSD. Since I will have around 10 sensors I am concerned with being able to write the data to the SD quick enough with the 256kB of RAM. I have been browsing and found this data logger: https://github.com/MichaelStetner/TeensyDataLogger but I am unsure if that would be sufficient. For that data logger he was able to sample an analog pin at 25kHz, so I'm not sure if it could handle 10 pins at 10kHz. If anyone has any ideas or suggestions that would be greatly appreciated. Thanks in advance!

Greg
 
This project should be possible, but it will be pushing the hardware nearly as fast as it can go, which can be challenging.

You'll definitely need to buffer data while the SD card is busy.
 
why not split the buffer? write to one buffer in memory, when it reaches end, have it write to the SD, and start writing the 2nd buffer, when thats full, write that to SD and start rewriting the first buffer, no?
 
Thanks for the replies guys. My knowledge on memory buffering is very limited, so I was hoping to be able to use a data logging sketch that someone had posted to the forums. I have been looking a sketch by tni (https://forum.pjrc.com/threads/43834-Real-low-latency-logging-for-Teensy-3-5-3-6-SDIO-SD) that uses FIFO buffering and supposedly has worst case latency of 40ms, which seems like it should be sufficient.

As it stands right now I am looking at data acquisition at 220kB/s (11 sensors at 10kS/sec and 16 bit), so if I am interpreting everything correctly I should be able to use the sketch by tni and write everything to the microSD with no issues. However, a lot of the coding done in the sketch is over my head so I may be misunderstanding something. With your knowledge does this seem possible? I also bought two Teensy 3.6s so I am thinking of using both to split the sensors across the two, which should help limit the demand on each.
 
Note - post #5 links to Beta that is noted as out of date - suggest this is the current version: github.com/greiman/SdFat

It seems there was more than one fast logger thread - not sure if any page through buffers. There is one sample examples/AnalogBinLogger - but seemed to be __AVR__ ( not Teensy specific for ADC and RAM considerations ) but as far as I read it just filled the buffers - then wrote them all at once - not doing writes while sampling - and it was rather long and used delay() in places to perform that on UNO/MEGA type devices with smaller memory.
 
This sounds entirely possible to me if you haven't gotten it working already. I have a motor test controller/logger and I'm logging 3 channels at 25khz, 1 channel at 4khz and a handful of other signals at .1-1khz or so. Make use of both of your ADC channels to cut the number of sequential ADC reads in half, use ADC interrupts to allow the SD to be running catchup every spare cycle it can. I use a large ring buffer as my SD write buffer. Log raw ADC readings instead of trying to generate an ascii log on the logger. Should be no trouble at all to get that sort of thing off the ground as long as you are careful about not wasting cycles
 
Status
Not open for further replies.
Back
Top