2025-07-28 4:43 PM
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
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, ®_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]);
}
2025-07-29 12:39 AM
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.
2025-07-29 7:31 AM
Thanks Federica. Bench testing always looks good. I get about 1G magnitude between the 3 axes. Even motion FX shows good rotation data on the bench.
Field data is always where we see the weird values. Our logging is only at 4Hz due to space constrictions.
I'll compare your github examples against what we have, and go from there.
Is there any reason a sampling rate of 104 hz is risky? The examples have lower sample rates.
Is there any documentation of sampling rate minimums to use with Motion FX?
2025-07-30 7:44 AM
@Federica Bossi I am noticing some small and large differences from your example code.
I'm going to add batch rates, stream mode, disable I3C and pull out sensor hub and the extra registers and do some field testing.
The code I've inherited does not
The code I have inherited does
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
2025-07-31 1:48 PM
I changed my code to reflect the settings in the example product. Still seeing 2.5g peaks on 2 axes.
I ordered an IMU data logger to provide another source of measurements. I will report back next week after a field test.