cancel
Showing results for 
Search instead for 
Did you mean: 

Understanding Output Data from I3G4250D Gyro Sensor on STM32F411e-Discovery

Duc
Associate II

Hello STM32 community,

I'm relatively new to STM32 development and I'm currently working with the I3G4250D Gyro Sensor on the STM32F411e-Discovery board. I've been using the stm32f411e_discovery_gyroscope.c file provided by STM32Cube to interface with the sensor.

I've managed to retrieve data from the sensor using the provided code snippet:

BSP_GYRO_GetXYZ(Buffer2);

Xval = Buffer2[0];
Yval = Buffer2[1];
Zval = Buffer2[2];

 

However, the output I'm getting seems to be raw data, and I'm not quite sure how to interpret it correctly. My understanding is that these values represent the raw sensor readings, but I'm unsure how to convert them into meaningful X, Y, and Z values.

Could someone please provide guidance on how to properly interpret and convert these raw values into meaningful data? Additionally, if there are any specific calibration steps or formulas that need to be applied to obtain accurate results, I would greatly appreciate any insights on that as well.

Thank you in advance for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
Federica Bossi
ST Employee

Hi @Duc ,

To have data in mdps you need to multiply the raw data in LSB by the sensitivity reported in the datasheet according to your FS setting:

FedericaBossi_0-1714637772473.png

In addition, you could also look at our PID examples.

 

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

14 REPLIES 14
Federica Bossi
ST Employee

Hi @Duc ,

To have data in mdps you need to multiply the raw data in LSB by the sensitivity reported in the datasheet according to your FS setting:

FedericaBossi_0-1714637772473.png

In addition, you could also look at our PID examples.

 

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
Kushal_Es
Associate

I got the same problem. In addition, I found that the output values keep varying even if the system is at rest (not moving at all). The output values are not zero


@Kushal_Es wrote:

I got the same problem. 


So did you do as @Federica Bossi said to fix that?

 


@Kushal_Es wrote:

I found that the output values keep varying even if the system is at rest (not moving at all). The output values are not zero


So what values are you getting?

All measurements are subject to noise and offsets...

Do the values change when the system is moving?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Hi there,

I believe your setup may not be configured correctly, and the investigation might be incomplete. If you're using the same hardware as I am, you should be able to obtain the correct values with the proper settings.

Feel free to refer to my test code at: refer_code.

 




As I'm using BSP drivers available in the BSP folder of STM32Cube, In the I3G4250D.c file the function is already defined and the sensitivity is being multiplied in this function already (as @Federica Bossi said):

void I3G4250D_ReadXYZAngRate(float *pfData)
{
  uint8_t tmpbuffer[6] = {0};
  int16_t RawData[3] = {0};
  uint8_t tmpreg = 0;
  float sensitivity = 0;
  int i = 0;

  GYRO_IO_Read(&tmpreg, I3G4250D_CTRL_REG4_ADDR, 1);

  GYRO_IO_Read(tmpbuffer, I3G4250D_OUT_X_L_ADDR, 6);

  /* check in the control register 4 the data alignment (Big Endian or Little Endian)*/
  if (!(tmpreg & I3G4250D_BLE_MSB))
  {
    for (i = 0; i < 3; i++)
    {
      RawData[i] = (int16_t)(((uint16_t)tmpbuffer[2 * i + 1] << 8) + tmpbuffer[2 * i]);
    }
  }
  else
  {
    for (i = 0; i < 3; i++)
    {
      RawData[i] = (int16_t)(((uint16_t)tmpbuffer[2 * i] << 8) + tmpbuffer[2 * i + 1]);
    }
  }

  /* Switch the sensitivity value set in the CRTL4 */
  switch (tmpreg & I3G4250D_FULLSCALE_SELECTION)
  {
    case I3G4250D_FULLSCALE_245:
      sensitivity = I3G4250D_SENSITIVITY_245DPS;
      break;

    case I3G4250D_FULLSCALE_500:
      sensitivity = I3G4250D_SENSITIVITY_500DPS;
      break;

    case I3G4250D_FULLSCALE_2000:
      sensitivity = I3G4250D_SENSITIVITY_2000DPS;
      break;
  }
  /* Multiplied by sensitivity */
  for (i = 0; i < 3; i++)
  {
    pfData[i] = (float)(RawData[i] * sensitivity);
  }
}

 

I've attached a video of the values I'm getting when the system is stationery:

Here is the video of values I'm getting if I move the system around z axis

Which board or hardware are you using?

I'm using STM32F411E - DISCO board.

Thanks for providing the refer code!

I tried using it but using that code, its giving constant values at outputs even while moving.