AnsweredAssumed Answered

[stm32f3discovery]jumpy sensor reading (megne and gyro)

Question asked by fante.lesto on May 16, 2013
Latest reply on Aug 27, 2013 by baird.hal.001
Hi,
i'm reading the sensors on my STM32F3-discovery, and i've found out the reading arequite "jumpy". That means gyro and magnetometer value have consistent change (>1024) aven when the board is static. notice that accelerometer reading are fine.
gyro and accelerometer are in sigle reading, and i chek the data ready bit (ZYXDA for gyro and acc, DRDY for magne) is set. BTW it still give me strange update frequency for sensor, like this bit is almost always set...
I'm writing the reading over USB as audio USB card. here the output:
[code]
MagZ    diff: 1024.0    a:-16896.0    b:-17920.0
GyroY    diff: 17495.0    a:17491.0    b:-4.0
GyroZ    diff: 16621.0    a:16640.0    b:19.0
GyroY    diff: -17477.0    a:14.0    b:17491.0
GyroZ    diff: -16627.0    a:13.0    b:16640.0
MagZ    diff: 1024.0    a:-16896.0    b:-17920.0
GyroY    diff: 17495.0    a:17491.0    b:-4.0
GyroZ    diff: 16621.0    a:16640.0    b:19.0
GyroY    diff: -17477.0    a:14.0    b:17491.0
GyroZ    diff: -16627.0    a:13.0    b:16640.0
MagZ    diff: 1024.0    a:-16896.0    b:-17920.0
GyroY    diff: 17495.0    a:17491.0    b:-4.0
GyroZ    diff: 16621.0    a:16640.0    b:19.0
GyroY    diff: -17477.0    a:14.0    b:17491.0
GyroZ    diff: -16627.0    a:13.0    b:16640.0
MagZ    diff: 1024.0    a:-16896.0    b:-17920.0
GyroY    diff: 17495.0    a:17491.0    b:-4.0
GyroZ    diff: 16621.0    a:16640.0    b:19.0
GyroY    diff: -17477.0    a:14.0    b:17491.0
GyroZ    diff: -16627.0    a:13.0    b:16640.0
MagZ    diff: 1024.0    a:-16896.0    b:-17920.0
GyroY    diff: 17495.0    a:17491.0    b:-4.0
GyroZ    diff: 16621.0    a:16640.0    b:19.0
GyroY    diff: -17477.0    a:14.0    b:17491.0
GyroZ    diff: -16627.0    a:13.0    b:16640.0
MagZ    diff: 1024.0    a:-16896.0    b:-17920.0
GyroY    diff: 17495.0    a:17491.0    b:-4.0
GyroZ    diff: 16621.0    a:16640.0    b:19.0
GyroY    diff: -17477.0    a:14.0    b:17491.0
GyroZ    diff: -16627.0    a:13.0    b:16640.0
read/sec:20963.831867057674 byte/sec: 179863.147605083
sensor read/s: giro 2783 acc 5110 magne 5206
different sensor read/s: giro 2783 acc 2783 magne 2476
[/code]

and a peace of code, the part for gyro reding:
[code]
uint8_t Gyro_ReadAngRate (uint16_t* pfData)
{
    uint8_t tmpreg;

    L3GD20_Read(&tmpreg,L3GD20_STATUS_REG_ADDR,1);

    if (!(tmpreg & 0x08)){ //no data ready!
        return 0;
    }

    int i =0;

    L3GD20_Read(buffer,L3GD20_OUT_X_L_ADDR,6);


    for(i=0; i<3; i++)
    {
        pfData[i]=(int16_t)(((uint16_t)buffer[2*i+1] << 8) + buffer[2*i]);
    }

    return 1;
}
[/code]

Outcomes