cancel
Showing results for 
Search instead for 
Did you mean: 

Check configuration on lsm6dso32

ms360
Associate II

Hi! 

I inherited a project and we're seeing strange accelerometer values and I'd like to get a sanity check on my configuration. when Idle and flat, I see 1g on Z, 0g on X and Y. When my device is moving I see peaks on many axes beyond 1g, eg 2.5 on X or Z, and it does not seem real. Here is downsampled data from a log file. X (brown) goes from +1.5g to -1.5g, Z (gray) is over 2.3g. I am not expecting such numbers during a short banked turn at ~15 mph 

ms360_0-1753746022179.png

This is my init. I'm expecting 104Hz data rate, 4g acc scale, 1000dps gyrp scale

	m_dev_ctx.write_reg = (stmdev_write_ptr) STWriteRegister;
	m_dev_ctx.read_reg = (stmdev_read_ptr) STReadRegister;

	lsm6dso32_reset_set(&m_dev_ctx, PROPERTY_ENABLE);

	do
	{
		lsm6dso32_reset_get(&m_dev_ctx, &rst);
	}
	while (rst);

	/* Enable Block Data Update */
	lsm6dso32_block_data_update_set(&m_dev_ctx, PROPERTY_ENABLE);

	/* Set Output Data Rate */
	lsm6dso32_xl_data_rate_set(&m_dev_ctx, LSM6DSO32_XL_ODR_104Hz_HIGH_PERF);
	lsm6dso32_gy_data_rate_set(&m_dev_ctx, LSM6DSO32_GY_ODR_104Hz_HIGH_PERF);
	// lsm6dso32_fifo_data_rate_set(&m_dev_ctx, lsm6dso32_GY_ODR_104Hz);

	/* Set full scale */
	lsm6dso32_xl_full_scale_set(&m_dev_ctx, LSM6DSO32_4g);
	lsm6dso32_gy_full_scale_set(&m_dev_ctx, LSM6DSO32_1000dps);

	lsm6dso32_timestamp_set(&m_dev_ctx, 1);

	//set watermark level to 2 samples
	lsm6dso32_fifo_watermark_set(&m_dev_ctx, 2);

	lsm6dso32_pin_int1_route_t int1_set = {};
	int1_set.int1_ctrl.int1_fifo_th = 1;
	results = lsm6dso32_pin_int1_route_set(&m_dev_ctx, &int1_set);

	uint8_t value = 0x44;//accell and gyro
	int ret = lsm6dso32_write_reg(&m_dev_ctx, LSM6DSO32_FIFO_CTRL3, &value, 1);

	uint8_t value = 0x06;
	int ret = lsm6dso32_write_reg(&m_dev_ctx, LSM6DSO32_FIFO_CTRL4, &value, 1); //ne

... skipping motion FX init b/c the raw accel data looks bad. 

 Data acquisition after INT1 -> process in app scheduler. Apologies for sloppy indenting. I didn't fix it yet. 

lsm6dso32_fifo_tag_t reg_tag;
    /* Read number of samples in FIFO */
    lsm6dso32_fifo_data_level_get(&m_dev_ctx, &num);
    int i=0;
    int t=0;
    // NRF_LOG_ERROR("IMU SAMPLES: %d",num);
    while (num--) {
        
        /* Read FIFO tag */
        lsm6dso32_fifo_sensor_tag_get(&m_dev_ctx, &reg_tag);
        uint8_t buffer[6];
        
        switch (reg_tag) {
            case LSM6DSO32_XL_NC_TAG:
            memset(&m_imu_raw_sample_buffer[i].m_raw_imu_values[3], 0x00, 3 * sizeof(int16_t));
            lsm6dso32_fifo_out_raw_get(&m_dev_ctx, (uint8_t *)&m_imu_raw_sample_buffer[i].m_raw_imu_values[3]);
            i++;
            break;
            
            case LSM6DSO32_GYRO_NC_TAG:
            memset(&m_imu_raw_sample_buffer[t].m_raw_imu_values[0], 0x00, 3 * sizeof(int16_t));
            lsm6dso32_fifo_out_raw_get(&m_dev_ctx, (uint8_t *)&m_imu_raw_sample_buffer[t].m_raw_imu_values[0]);
            t++;
            break;
            
            default:
            /* Flush unused samples */
            }
        }
        for (int y=0;y<i; y++)
        {
        IMU_Process_Data(&m_imu_raw_sample_buffer[y].m_raw_imu_values[3], &m_imu_raw_sample_buffer[y].m_raw_imu_values[0]);
        }
                

 

1 REPLY 1
Federica Bossi
ST Employee

Hi @ms360 ,

We don't expect such values. Could you try repeating the test by implementing our examples available on GitHub? Just to exclude any issues related to your code.

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.