cancel
Showing results for 
Search instead for 
Did you mean: 

LSM6DSV16X QVar data with XL/G/SFLP FIFO

NicolasGoualard
Associate II

Hi, in my application I intend to use the LSM6DSV16X in order to store accelerometer, gyroscope, SFLP and QVar data, all at the same time.
I am able to get XL, G and SFLP data from the FIFO on INT1 correctly, and now I want to also record QVar data.
Based off of the example provided here: https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blob/master/lsm6dsv16x_STdC/examples/lsm6dsv16x_qvar_read_data_polling.c , I was able to get QVar data alone by routing it to the INT2 pin, however when I also enable the FIFO, I don't receive the data ready interrupts anymore.
Is there an incompatibility between these functions that I missed by reading the datasheet ?

 

Here is the code that I am using to set up the sensor (the commented out section are the commands that prevent QVar data from getting output):

int lsm6dsv16x_start_acquisition(bool enable_gbias)
{
	lsm6dsv16x_pin_int_route_t pin1_int;
	lsm6dsv16x_pin_int_route_t pin2_int;
	lsm6dsv16x_fifo_sflp_raw_t fifo_sflp;
	lsm6dsv16x_filt_settling_mask_t filt_settling_mask;
	int ret;

	/* Enable Block Data Update */
	ret = lsm6dsv16x_block_data_update_set(&sensor.dev_ctx, PROPERTY_ENABLE);
	if (ret) {
		LOG_ERR("lsm6dsv16x_block_data_update_set (%i)", ret);
	}
	/* Set full scale */
	ret = lsm6dsv16x_xl_full_scale_set(&sensor.dev_ctx, LSM6DSV16X_2g);
	if (ret) {
		LOG_ERR("lsm6dsv16x_xl_full_scale_set (%i)", ret);
	}
	ret = lsm6dsv16x_gy_full_scale_set(&sensor.dev_ctx, LSM6DSV16X_2000dps);
	if (ret) {
		LOG_ERR("lsm6dsv16x_gy_full_scale_set (%i)", ret);
	}

	/*
	* Set FIFO watermark (number of unread sensor data TAG + 6 bytes
	* stored in FIFO) to FIFO_WATERMARK samples
	*/
	ret = lsm6dsv16x_fifo_watermark_set(&sensor.dev_ctx, FIFO_WATERMARK);
	if (ret) {
		LOG_ERR("lsm6dsv16x_fifo_watermark_set (%i)", ret);
	}

	/* Set FIFO batch XL/Gyro ODR to 60Hz */
	ret = lsm6dsv16x_fifo_xl_batch_set(&sensor.dev_ctx, LSM6DSV16X_XL_BATCHED_AT_60Hz);
	if (ret) {
		LOG_ERR("lsm6dsv16x_fifo_xl_batch_set (%i)", ret);
	}
	ret = lsm6dsv16x_fifo_gy_batch_set(&sensor.dev_ctx, LSM6DSV16X_GY_BATCHED_AT_60Hz);
	if (ret) {
		LOG_ERR("lsm6dsv16x_fifo_gy_batch_set (%i)", ret);
	}

	/* Set FIFO mode to Stream mode (aka Continuous Mode) */
/*
	ret = lsm6dsv16x_fifo_mode_set(&sensor.dev_ctx, LSM6DSV16X_STREAM_MODE);
	if (ret) {
		LOG_ERR("lsm6dsv16x_fifo_mode_set (%i)", ret);
	}

	pin1_int.fifo_th = PROPERTY_ENABLE;
	ret = lsm6dsv16x_pin_int1_route_set(&sensor.dev_ctx, &pin1_int);
	if (ret) {
		LOG_ERR("lsm6dsv16x_pin_int1_route_set (%i)", ret);
	}
*/
	/* Set Output Data Rate */
	ret = lsm6dsv16x_xl_data_rate_set(&sensor.dev_ctx, LSM6DSV16X_ODR_AT_960Hz);
	if (ret) {
		LOG_ERR("lsm6dsv16x_xl_data_rate_set (%i)", ret);
	}
	ret = lsm6dsv16x_gy_data_rate_set(&sensor.dev_ctx, LSM6DSV16X_ODR_AT_960Hz);
	if (ret) {
		LOG_ERR("lsm6dsv16x_gy_data_rate_set (%i)", ret);
	}

	/* Mask accelerometer and gyroscope data until the settling of the sensors filter is completed */
  	filt_settling_mask.drdy = PROPERTY_ENABLE;
  	filt_settling_mask.irq_xl = PROPERTY_ENABLE;
  	filt_settling_mask.irq_g = PROPERTY_ENABLE;
  	ret = lsm6dsv16x_filt_settling_mask_set(&sensor.dev_ctx, filt_settling_mask);
	if (ret) {
		LOG_ERR("lsm6dsv16x_filt_settling_mask_set (%i)", ret);
	}
	lsm6dsv16x_filt_xl_lp2_set(&sensor.dev_ctx, PROPERTY_ENABLE);
	lsm6dsv16x_filt_xl_lp2_bandwidth_set(&sensor.dev_ctx, LSM6DSV16X_XL_STRONG);

	qvar_mode.ah_qvar_en = 1;
	ret = lsm6dsv16x_ah_qvar_mode_set(&sensor.dev_ctx, qvar_mode);
	if (ret) {
		LOG_ERR("lsm6dsv16x_ah_qvar_mode_set (%i)", ret);
	}

	pin2_int.drdy_ah_qvar = PROPERTY_ENABLE;
	ret = lsm6dsv16x_pin_int2_route_set(&sensor.dev_ctx, &pin2_int);
	if (ret) {
		LOG_ERR("lsm6dsv16x_pin_int2_route_set (%i)", ret);
	}
	return 0;
}

 

 

As a side question, I saw that the LSM6DSV16BX sensor is capable of outputting the QVar data in FIFO. What are the differences between the two versions LSM6DSV16X/LSM6DSV16BX ? I will look into that component's datasheet to see if I can find some, but it would be a nice help

Thanks in advance for your help

Nicolas Goualard

1 ACCEPTED SOLUTION

Accepted Solutions
NicolasGoualard
Associate II

The structures related to int1, int2, sflp and settling mask were not initialized, so random values could be present. When I initialized these structures to 0, it worked fine.

View solution in original post

1 REPLY 1
NicolasGoualard
Associate II

The structures related to int1, int2, sflp and settling mask were not initialized, so random values could be present. When I initialized these structures to 0, it worked fine.