Developer Portal Community

    Showing results for 
    Search instead for 
    Did you mean: 

    Storing data with high sampling rate (e.g. acceleration data)

    Established Member

    Re: Storing data with high sampling rate (e.g. acceleration data)

    Hello JanGieseler,

    As per your requirements, the best option would be go for the double task and double buffer concept as explained by LlobetAtWork.

    That way data acquisition and SD card write operation both can be handled and yor desired sample frequency can also be met.

    With regards to your query on impact of MITA, it is only an alternate and simpler language to generate c code using simpler syntax.

    The auto-generated code will still have the same task execution time and the software  will not have much change w.r.t system timings.

    Some insights on your other queries

    1.  how do I check the actual loop execution time?

    Simplest way would be to do a diff of the tick counts before and afer execution within the loop.

    2.  is there an error if the actual loop execution time is longer than the specified 10ms ? If so, how do I catch it?

    You can add a timer in your sstem to have accurate measurements or use a semaphore to detect lags

    3. can I run 2 parallel threads, one that acquires the data into a buffer and one that writes the buffer to the SD card? I tested with two `every xx milliseconds {} ` loops but this didn't work

    Yes, you can create two tasks, one to get sensor data and other to write to Sd card.



    Shanmathi P



    Re: Storing data with high sampling rate (e.g. acceleration data)

    Thanks  for the reply. 

    Just to be clear, the solutions (` do a diff of the tick counts`, `add a timer in your sstem`, `create two tasks`) you propose are implemented in the C Code and can not be implemented directly in MITA, right?

    Established Member

    Re: Storing data with high sampling rate (e.g. acceleration data)

    Hi JanGieseler,

    Calulating tick count diff and timers can be done using mita. Already in the code which you have shared, on every 10 ms timer has been created.

    But currently creation of tasks is not supported in Mita.

    So you will have to implement the dual task logic in normal embedded c code.


    With Regards,

    Shanmathi P


    Re: Storing data with high sampling rate (e.g. acceleration data)

    I understand that one can easily implement a timer in MITA. My question is how do I make sure that the code in the timer gets executed at the specified interval in the case that the code within the loop takes longer than the loop interval.


    every 1 milliseconds {


    Would the above code throw and error or would the loop interval simply be 2ms?