2021-03-16 02:01 AM
Hi,
I'm trying to read step counts. I'm executing all pedometer related functions, but I get no any output.
Sincerely,
TalhaAnd While Loop
Solved! Go to Solution.
2021-03-24 01:19 AM
Hi @Eleon BORLINI ,
I applied the configurations in the application note as mentioned. But the result is the same, negative.
static void pedoConf(void)
{
/* Holds reset variable. */
uint8_t rst = 0;
lsm6ds3_reset_set(&g_dev_ctx, PROPERTY_ENABLE);
do
{
lsm6ds3_reset_get(&g_dev_ctx, &rst);
}while(rst);
/* Enable Block Data Update */
lsm6ds3_block_data_update_set(&g_dev_ctx, PROPERTY_ENABLE);
lsm6ds3_int1_route_t int1_route_t;
/* Set Output Data Rate for Acc and Gyro */
lsm6ds3_xl_data_rate_set(&g_dev_ctx, LSM6DS3_XL_ODR_26Hz);
lsm6ds3_gy_data_rate_set(&g_dev_ctx, LSM6DS3_GY_ODR_26Hz);
lsm6ds3_xl_full_scale_set(&g_dev_ctx, LSM6DS3_2g);
lsm6ds3_gy_full_scale_set(&g_dev_ctx, LSM6DS3_2000dps);
/* Enable pedometer */
lsm6ds3_****_sens_set(&g_dev_ctx, 1);
lsm6ds3_pin_int1_route_get(&g_dev_ctx, &int1_route_t);
int1_route_t.int1_step_detector = PROPERTY_ENABLE;
lsm6ds3_pin_int1_route_set(&g_dev_ctx, &int1_route_t);
lsm6ds3_int_notification_set(&g_dev_ctx,LSM6DS3_INT_LATCHED);
/* Reset steps of pedometer */
lsm6ds3_****_step_reset_set(&g_dev_ctx, PROPERTY_ENABLE);
}
I checked the lsm6d3_****_sens_set(), whether it is setting or not the related registers. All the registers we want, as mentioned in the application note, are setting with this function.
/**
* @brief Enable pedometer algorithm.[set]
*
* @param ctx read / write interface definitions(ptr)
* @param val change the values of ****_en in reg TAP_CFG
* @retval interface status (MANDATORY: return 0 -> no Error)
*
*/
int32_t lsm6ds3_****_sens_set(stmdev_ctx_t *ctx, uint8_t val)
{
lsm6ds3_ctrl10_c_t ctrl10_c;
lsm6ds3_tap_cfg_t tap_cfg;
int32_t ret;
ret = 0;
if (val == PROPERTY_ENABLE){
ret = lsm6ds3_read_reg(ctx, LSM6DS3_CTRL10_C, (uint8_t*)&ctrl10_c, 1);
if(ret == 0){
ctrl10_c.func_en = PROPERTY_ENABLE;
ret = lsm6ds3_write_reg(ctx, LSM6DS3_CTRL10_C, (uint8_t*)&ctrl10_c, 1);
}
}
if(ret == 0){
ret = lsm6ds3_read_reg(ctx, LSM6DS3_TAP_CFG, (uint8_t*)&tap_cfg, 1);
}
if(ret == 0){
ret = lsm6ds3_read_reg(ctx, LSM6DS3_TAP_CFG, (uint8_t*)&tap_cfg, 1);
}
if(ret == 0){
tap_cfg.****_en = (uint8_t)val;
ret = lsm6ds3_write_reg(ctx, LSM6DS3_TAP_CFG, (uint8_t*)&tap_cfg, 1);
}
return ret;
}
I checked that and matched the other IMU's pedometer examples but it didn't work again.
if(all_source.func_src.step_detected)
{
/* Read steps */
lsm6ds3_number_of_steps_get(&g_dev_ctx, &steps);
UART_PRINT("Step: ");
UART_PRINT("%d\n", steps);
showError(ICON_HEART, NULL, steps, "Steps");
}
In while loop, the way that I check if there is a detection or not. What can it possible error and how can I solve it?
Best regards,
Talha
2021-03-16 07:44 AM
Hi @TKCK.1 ,
I'm not sure if I well interpreted your code, but I suggest you to try to implement the in the way it is described in the LSM6DS3 application note AN4650, p.62:
1 Write 20h into CTRL1_XL // Turn on the accelerometer
// ODR_XL = 26 Hz, FS_XL = ±2 g
2 Write 3Ch into CTRL10_C // Enable embedded functions
3 Write 40h into TAP_CFG // Enable pedometer algorithm
4 Write 80h into INT1_CTRL // Step Detector interrupt driven to INT1 pin
This deploys the embedded pedometer feature, without the need of additional configuration of parameters such as debouncing and threshold.
-Eleon
2021-03-24 01:03 AM
2021-03-24 01:16 AM
2021-03-24 01:19 AM
Hi @Eleon BORLINI ,
I applied the configurations in the application note as mentioned. But the result is the same, negative.
static void pedoConf(void)
{
/* Holds reset variable. */
uint8_t rst = 0;
lsm6ds3_reset_set(&g_dev_ctx, PROPERTY_ENABLE);
do
{
lsm6ds3_reset_get(&g_dev_ctx, &rst);
}while(rst);
/* Enable Block Data Update */
lsm6ds3_block_data_update_set(&g_dev_ctx, PROPERTY_ENABLE);
lsm6ds3_int1_route_t int1_route_t;
/* Set Output Data Rate for Acc and Gyro */
lsm6ds3_xl_data_rate_set(&g_dev_ctx, LSM6DS3_XL_ODR_26Hz);
lsm6ds3_gy_data_rate_set(&g_dev_ctx, LSM6DS3_GY_ODR_26Hz);
lsm6ds3_xl_full_scale_set(&g_dev_ctx, LSM6DS3_2g);
lsm6ds3_gy_full_scale_set(&g_dev_ctx, LSM6DS3_2000dps);
/* Enable pedometer */
lsm6ds3_****_sens_set(&g_dev_ctx, 1);
lsm6ds3_pin_int1_route_get(&g_dev_ctx, &int1_route_t);
int1_route_t.int1_step_detector = PROPERTY_ENABLE;
lsm6ds3_pin_int1_route_set(&g_dev_ctx, &int1_route_t);
lsm6ds3_int_notification_set(&g_dev_ctx,LSM6DS3_INT_LATCHED);
/* Reset steps of pedometer */
lsm6ds3_****_step_reset_set(&g_dev_ctx, PROPERTY_ENABLE);
}
I checked the lsm6d3_****_sens_set(), whether it is setting or not the related registers. All the registers we want, as mentioned in the application note, are setting with this function.
/**
* @brief Enable pedometer algorithm.[set]
*
* @param ctx read / write interface definitions(ptr)
* @param val change the values of ****_en in reg TAP_CFG
* @retval interface status (MANDATORY: return 0 -> no Error)
*
*/
int32_t lsm6ds3_****_sens_set(stmdev_ctx_t *ctx, uint8_t val)
{
lsm6ds3_ctrl10_c_t ctrl10_c;
lsm6ds3_tap_cfg_t tap_cfg;
int32_t ret;
ret = 0;
if (val == PROPERTY_ENABLE){
ret = lsm6ds3_read_reg(ctx, LSM6DS3_CTRL10_C, (uint8_t*)&ctrl10_c, 1);
if(ret == 0){
ctrl10_c.func_en = PROPERTY_ENABLE;
ret = lsm6ds3_write_reg(ctx, LSM6DS3_CTRL10_C, (uint8_t*)&ctrl10_c, 1);
}
}
if(ret == 0){
ret = lsm6ds3_read_reg(ctx, LSM6DS3_TAP_CFG, (uint8_t*)&tap_cfg, 1);
}
if(ret == 0){
ret = lsm6ds3_read_reg(ctx, LSM6DS3_TAP_CFG, (uint8_t*)&tap_cfg, 1);
}
if(ret == 0){
tap_cfg.****_en = (uint8_t)val;
ret = lsm6ds3_write_reg(ctx, LSM6DS3_TAP_CFG, (uint8_t*)&tap_cfg, 1);
}
return ret;
}
I checked that and matched the other IMU's pedometer examples but it didn't work again.
if(all_source.func_src.step_detected)
{
/* Read steps */
lsm6ds3_number_of_steps_get(&g_dev_ctx, &steps);
UART_PRINT("Step: ");
UART_PRINT("%d\n", steps);
showError(ICON_HEART, NULL, steps, "Steps");
}
In while loop, the way that I check if there is a detection or not. What can it possible error and how can I solve it?
Best regards,
Talha
2021-03-24 02:35 AM
Is this related to an issue with your sourcecode, or to this forum ?
> I'm executing all pedometer related functions, but I get no any output.
Do you see ANY output from the accelerometer ?
Do a real-world evaluation, i.e. carry the board around while walking, and record the sensor output.
Let several different people do it.
Then you can evaluate possible "step thresholds".
2021-03-24 02:47 AM
Hi @Ozone ,
Yes, I can read acc&gyro values in all axis(x, y, z). Also I'm able to read Free Fall interrupts, tapping interrupts..
I have already real-world sensor ouputs, I recorded them. But in our project, firstly we need to read the steps simply. So I need to execute via registers.
2021-03-24 03:28 AM
So, as I understand it, the threshold setting via sensor config does not work, or not work properly.
Instead, consider evaluating the raw data directly.