Skip to main content
Visitor II
May 1, 2020
Question

Saving values from different sources into an SD CARD

  • May 1, 2020
  • 2 replies
  • 1128 views

Hello,

I'm getting values from an ADC an ACC, and a microphone. The ACC and ADC are in continuous acquiring mode but with different sampling rates. The microphone is turned on after a random trigger in time, basically the microphone record data for 1 second (at 48kHz) and then stops.

I need to save all the values into an SD Card without losing the time perception of when the signals were acquired.

What are the best practices to save values in SD CARD without losing the synchronization between them? Maybe I need to write values in structure data?

I hope someone can guide me with this topic!

Thank you in advance!

    This topic has been closed for replies.

    2 replies

    Super User
    May 2, 2020

    You'll need to add some sort of structure to be able to know how to interpret the data, especially if it's not uniform data since the microphone burst is random.

    You could add a header before each data.

    uint8_t identifier;

    uint16_t length;

    then a bunch of uint8_t data.

    then identifier 0 is ACC, 1 is ADC, 2 is microphone. Might also want to include a timestamp or time since reset. Something like that. Could also do different files for each type of data.

    Graduate II
    May 2, 2020

    Have a single thread manage the stream to the card.

    Have some way to interleave or mux the data.

    Look at RIFF, encapsulate with timestamp so data can be reconstructed.

    Try using a packet format that spills data in some multiple of the sector or cluster, ie 512 bytes, 8KB, 32KB, etc.

    Large aligned writes will be the most efficient.