cancel
Showing results for 
Search instead for 
Did you mean: 

LSM6DSM- Incorrect Accel Data on high ODR using FIFO

douglasEDM
Associate II

Good day, 

I'm currently reading data on the FIFO using Continuous-to-FIFO mode. I'm also using the lsm6dsm_STdC provided on Github. I'm doing the tests using the STEVAL-MKI189V1

I've set up the FIFO to only read Accelerometer data for now. 

While testing, I place the device in three positions, X, Y, Z down respectively.

In the test data: Data0 = X, Data1 = Y and Data2 =Z.

I've set the ODR of the FIFO and Accel to 1k66Hz.

While testing I get the following Results:

X Pointing Down: X reads -1000mG which is expected. But Y and Z jumps between 0 and -1000. Shouldn't they both be 0?

x-down.png

Y Pointing Down: X reads 0 as expected. But Y and Z jumps between 0 and -1000. Shouldn't Z be 0 and Y = -1000?

y-down.png

Z Down: Both X and Y reads 0, but Z jumps between 0 and -1000.

z-down.png

When I set Fifo ODR to 52Hz, everything looks as it should. Why am I getting these results if the ODR is at 1k66Hz?

Regards

Douglas

3 REPLIES 3
Federica Bossi
ST Employee

Hi @douglasEDM ,

Can you share a reg dump so that I can replicate the test in your same conditions?

Thanks

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.
douglasEDM
Associate II

Hi, 

This is my setup:

 

/* Restore default configuration */
	   lsm6dsm_reset_set(&dev_ctx, PROPERTY_ENABLE);

	   do {
	     lsm6dsm_reset_get(&dev_ctx, &rst);
	   } while (rst);

		/* Set XL full scale and Gyro full scale */
		lsm6dsm_xl_full_scale_set(&dev_ctx, LSM6DSM_16g);
		lsm6dsm_gy_full_scale_set(&dev_ctx, LSM6DSM_125dps);
		/* Enable Block Data Update (BDU) when FIFO support selected */
		lsm6dsm_block_data_update_set(&dev_ctx, PROPERTY_ENABLE);
		/* Set FIFO watermark to a multiple of a pattern
		* in this example we set watermark to 260 pattern
		* which means ten sequence of:
		* (GYRO + XL) = 12 bytes
		*/
		lsm6dsm_fifo_watermark_set(&dev_ctx, 10 * pattern_len);
		lsm6dsm_fifo_stop_on_wtm_set(&dev_ctx, PROPERTY_ENABLE);
		/* Set FIFO mode to Stream to FIFO */
		lsm6dsm_fifo_mode_set(&dev_ctx, LSM6DSM_STREAM_TO_FIFO_MODE);

		/* Enable FIFO watermark interrupt generation on INT1 pin */
		lsm6dsm_pin_int1_route_get(&dev_ctx, &int_1_reg);
		int_1_reg.int1_fth = PROPERTY_ENABLE;
		lsm6dsm_pin_int1_route_set(&dev_ctx, int_1_reg);
		/* FIFO watermark interrupt on INT2 pin */
		//lsm6dsm_pin_int2_route_get(&dev_ctx, &int_2_reg);
		//int_2_reg.int2_fth = PROPERTY_ENABLE;
		//lsm6dsm_pin_int2_route_set(&dev_ctx, int_2_reg);
		/* Set FIFO sensor decimator */
		lsm6dsm_fifo_xl_batch_set(&dev_ctx, LSM6DSM_FIFO_XL_NO_DEC);
		lsm6dsm_fifo_gy_batch_set(&dev_ctx, LSM6DSM_FIFO_GY_NO_DEC);
		/* Set ODR FIFO */
		lsm6dsm_fifo_data_rate_set(&dev_ctx, LSM6DSM_FIFO_1k66Hz);
		/* Set XL and Gyro Output Data Rate:
		* in this example we set 52 Hz for Accelerometer and
		* 52 Hz for Gyroscope
		*/
		lsm6dsm_xl_data_rate_set(&dev_ctx, LSM6DSM_XL_ODR_1k66Hz);
		lsm6dsm_gy_data_rate_set(&dev_ctx, LSM6DSM_GY_ODR_1k66Hz);

 

And this is how I read the values:

if (waterm)
		  {

			HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
			/* Read number of word in FIFO */
			lsm6dsm_fifo_data_level_get(&dev_ctx, &num);
			num_pattern = num / pattern_len;

			while (num_pattern-- > 0)
			{
			  /* Following the sensors ODR configuration, FIFO pattern is composed
			   * by this sequence of samples: GYRO, XL
			   */
			  lsm6dsm_fifo_pattern_get(&dev_ctx, &pattern);
			  lsm6dsm_fifo_raw_data_get(&dev_ctx, data_raw_angular_rate.u8bit, 3 * sizeof(int16_t));
			  angular_rate_dps[0] = lsm6dsm_from_fs125dps_to_mdps(data_raw_angular_rate.i16bit[0])/100;
			  angular_rate_dps[1] = lsm6dsm_from_fs125dps_to_mdps(data_raw_angular_rate.i16bit[1])/100;
			  angular_rate_dps[2] = lsm6dsm_from_fs125dps_to_mdps(data_raw_angular_rate.i16bit[2]/100);
//			  sprintf((char *)tx_buffer, "Angular rate [mdps]:%4.2f\t%4.2f\t%4.2f\r\n",	angular_rate_mdps[0], angular_rate_mdps[1], angular_rate_mdps[2]);
//			  sprintf((char *)tx_buffer, "%4.2f\t%4.2f\t%4.2f\r\n", angular_rate_mdps[0], angular_rate_mdps[1], angular_rate_mdps[2]);

//			  tx_com(tx_buffer, strlen((char const *)tx_buffer));
			  lsm6dsm_fifo_pattern_get(&dev_ctx, &pattern);
			  lsm6dsm_fifo_raw_data_get(&dev_ctx, data_raw_acceleration.u8bit, 3 * sizeof(int16_t));
			  acceleration_mg[0] = lsm6dsm_from_fs16g_to_mg(data_raw_acceleration.i16bit[0]);
			  acceleration_mg[1] = lsm6dsm_from_fs16g_to_mg(data_raw_acceleration.i16bit[1]);
			  acceleration_mg[2] = lsm6dsm_from_fs16g_to_mg(data_raw_acceleration.i16bit[2]);
//			  sprintf((char *)tx_buffer, "Acc [mg]:%4.2f\t%4.2f\t%4.2f\r\n", acceleration_mg[0], acceleration_mg[1], acceleration_mg[2]);
			  sprintf((char *)tx_buffer, "%4.2f\t%4.2f\t%4.2f\t%4.2f\t%4.2f\t%4.2f\r\n", acceleration_mg[0], acceleration_mg[1], acceleration_mg[2], angular_rate_dps[0], angular_rate_dps[1], angular_rate_dps[2]);

			  tx_com(tx_buffer, strlen((char const *)tx_buffer));
			}
			/* Reset FIFO */
			lsm6dsm_fifo_mode_set(&dev_ctx, LSM6DSM_BYPASS_MODE);
			waterm = 0;
			lsm6dsm_fifo_mode_set(&dev_ctx, LSM6DSM_STREAM_TO_FIFO_MODE);
		  }

This code is however for both gyro and accel. I experience the same issue. In this case, at a higher ODR it seems that the Accel follows the same pattern as the Gyro.

Reading the FIFO pattern shows that the correct data pattern is read. 

Hi, 

Do you have any feedback yet?