cancel
Showing results for 
Search instead for 
Did you mean: 

What is MMC_Input_t data_in.TimeStamp used for in MotionMC?

Rstua.1
Senior

I have been using MotionMC and I think it has been working. My compass appears to reach calibration as it starts working as expected and the calibration value reaches 3 (the highest level?).

However, I've noticed while looking over my code that I am not providing MotionMC with an updated time stamp when I pass it MMC_Input_t data_in.TimeStamp in the library call MotionMC_Update(&data_in). Just what am I missing out on? Is this value even used in the MotionMC library?

-thanks

3 REPLIES 3
Eleon BORLINI
ST Employee

Hi @Rstua.1​ , by default the MMC_Input_t data_in.TimeStamp should no be necessary if ODRs of all the sensors involved are all the same and data are synchronized. I found on Github this example code that manually updates the Timestamp.

void print_sensor_values (void *pvParameters)
{
    while (true) {
        if (calEnabled) {
            MMC_Input_t data_in;
            MMC_Output_t data_out;
 
            if (magAvailable()) {
                readMag();
 
                data_in.TimeStamp = local_timestamp;
                data_in.Mag[0] = calcMag(mx) * 1000 * FROM_MGAUSS_TO_UT50;
                data_in.Mag[1] = calcMag(my) * 1000 * FROM_MGAUSS_TO_UT50;
                data_in.Mag[2] = calcMag(mz) * 1000 * FROM_MGAUSS_TO_UT50;
 
                MotionMC_Update(&data_in);
 
                MotionMC_GetCalParams(&data_out);
 
                if (maxQuality < data_out.CalQuality) {
                    maxQuality = data_out.CalQuality;
                    calEnabled = false;
                }
            }
        } else {
            // At least poor quality
        }
 
        local_timestamp += 50;
        vTaskDelay(50); // 20 Hz
    }
}

Regards

Rstua.1
Senior

Hi Eleon BORLINI,

Thank you for your response. It does sound like I do not need to set the data_in.TimeStamp. As I sample and use all my accelerometer and magnetometer data as it becomes available from the STMicro sensors. This is to say, I poll the data every 100ms and read it when the STMicro sensors are ready with a new sample. At which point I immediately process it. Do you see any problems w/this approach?

But To clarify, what does "ODR" mean.

Also when you say "data are synchronized" just how close do the magnetometer and accelerometer samples need to be? Or is this time used to mark the delta time between magnetometer and accelerometer readings?

-thanks

Hi @Rstua.1​ , the ODR is the output data rate that you can select for a sensor acting on its dedicated registers. The ODR selection depends on the signal you want to detect: assuming the case of a vibration as example, High ODRs will be suitable for high frequency signals, while low ODR for low frequency signals. The MotionMC library should automatically set the sensors ODR (should be same of the update frequency up and equal to 100 Hz) in order to make all the sensors synchronized. Regards