2024-06-04 01:21 AM
Hi,
I am using AIS2IH.
I can see in terminal window of my computer
that registers of data and temperature are zero's. 0 0 0 ...
My program use the setup:
ais2ih_cs_mode_set(&dev_ctx, AIS2IH_PULL_UP_DISCONNECT);
ais2ih_i2c_interface_set(&dev_ctx, AIS2IH_I2C_DISABLE);
ais2ih_spi_mode_set(&dev_ctx, AIS2IH_SPI_4_WIRE);
ais2ih_reset_set(&dev_ctx, PROPERTY_ENABLE);
platform_delay(0x00333333);
ais2ih_reset_get(&dev_ctx, &rst);
platform_delay(0x00333333);
ais2ih_reset_get(&dev_ctx, &rst);
platform_delay(0x00333333);
ais2ih_cs_mode_set(&dev_ctx, AIS2IH_PULL_UP_DISCONNECT);
ais2ih_i2c_interface_set(&dev_ctx, AIS2IH_I2C_DISABLE);
ais2ih_spi_mode_set(&dev_ctx, AIS2IH_SPI_4_WIRE);
/* Set full scale */
ais2ih_full_scale_set(&dev_ctx, AIS2IH_2g);
/* Set Output Data Rate */
ais2ih_data_rate_set(&dev_ctx, AIS2IH_XL_ODR_400Hz);
ais2ih_filter_path_set(&dev_ctx, AIS2IH_LPF_ON_OUT);
ais2ih_filter_bandwidth_set(&dev_ctx, AIS2IH_ODR_DIV_4);
ais2ih_self_test_set(&dev_ctx, AIS2IH_XL_ST_DISABLE );
/* Configure power mode */
ais2ih_power_mode_set(&dev_ctx, AIS2IH_HIGH_PERFORMANCE_LOW_NOISE);
memset(data_raw_acceleration, 0x00, 3 * sizeof(int16_t));
ais2ih_acceleration_raw_get(&dev_ctx, &data_raw_acceleration);
ais2ih_temperature_raw_get(&dev_ctx, &data_raw_temperature);
ais2ih_status_dup_get(&dev_ctx,& reg3);
sprintf((char *)tx_bufferL,"\n\t\r A[r]:%d,%d,%d; T[C]:%d; R:%u,DUP=%u",data_raw_acceleration[0],data_raw_acceleration[1],data_raw_acceleration[2],data_raw_temperature,tempraw,reg3);
strcat(tx_buffer, tx_bufferL);
strcat(tx_buffer,"\r\n\0");
tx_com(tx_buffer, strlen((char const *)tx_buffer));
Solved! Go to Solution.
2024-06-05 01:34 AM
Hi @scboris ,
Can you share a photo of your setup?
2024-06-04 01:24 AM
Whats wrong with my accelerometer?
Thank You
2024-06-04 01:43 AM
The result is:
A[r]:0,0,0; T[C]:0; R:4,DUP=0
There R:4 is the AIS2IH_CTRL2 register value
2024-06-04 01:49 AM
What changes I can made to get the real values of the acceleration or temperature.
Thank You
2024-06-04 01:53 AM
Hi @scboris ,
Welcome to ST Community!
Can you try to implement our official example on github and let me know if you still have the problem?
Thanks.
2024-06-04 04:10 AM
OK!
2024-06-04 05:16 AM
Thank You!
I changed the code of the program as it is in the link above. I take the
I take another AIS2Ih accelerometer.
But still, It is no changes at the result.
2024-06-05 01:34 AM
Hi @scboris ,
Can you share a photo of your setup?
2024-06-05 07:11 AM
Hi Federica!
What is the setup?
Hardware(schematic diagram?) or software() or timing diagram of the setup?
void ais2ih_init(void)
{
/* Initialize mems driver interface. */
stmdev_ctx_t dev_ctx;
ais2ih_reg_t int_route;
dev_ctx.write_reg = platform_write;
dev_ctx.read_reg = platform_read;
dev_ctx.handle = &SENSOR_BUS;
/* Initialize platform specific hardware */
platform_init();
/* Wait sensor boot time */
platform_delay(BOOT_TIME);
ais2ih_reset_set(&dev_ctx, PROPERTY_ENABLE);
platform_delay(0x08333333);
ais2ih_reset_get(&dev_ctx, &rst);
platform_delay(0x08333333);
platform_delay(0x08333333);
ais2ih_reset_get(&dev_ctx, &rst);
platform_delay(0x08333333);
ais2ih_cs_mode_set(&dev_ctx, AIS2IH_PULL_UP_DISCONNECT);
platform_delay(0x08333333);
ais2ih_i2c_interface_set(&dev_ctx, AIS2IH_I2C_DISABLE);
platform_delay(0x08333333);
ais2ih_spi_mode_set(&dev_ctx, AIS2IH_SPI_4_WIRE);
platform_delay(0x08333333);
}
2024-06-05 07:27 AM
And the setup program is here:
ais2ih_device_id_get(&dev_ctx, &whoamI);
platform_delay(0x06333333);
ais2ih_device_id_get(&dev_ctx, &whoamI);
platform_delay(0x06333333);
ais2ih_device_id_get(&dev_ctx, &whoamI);
platform_delay(0x06333333);
/* Restore default configuration */
ais2ih_reset_set(&dev_ctx, PROPERTY_ENABLE);
platform_delay(0x06333333);
ais2ih_reset_get(&dev_ctx, &rst);
platform_delay(0x06333333);
platform_delay(0x00333333);
ais2ih_reset_get(&dev_ctx, &rst);
platform_delay(0x06333333);
ais2ih_cs_mode_set(&dev_ctx, AIS2IH_PULL_UP_DISCONNECT);
platform_delay(0x00333333);
platform_delay(0x06333333);
ais2ih_i2c_interface_set(&dev_ctx, AIS2IH_I2C_DISABLE);
platform_delay(0x00333333);
platform_delay(0x06333333);
ais2ih_spi_mode_set(&dev_ctx, AIS2IH_SPI_4_WIRE);
platform_delay(0x00333333);
platform_delay(0x06333333);
/* Enable Block Data Update */
ais2ih_block_data_update_set(&dev_ctx, PROPERTY_ENABLE);
platform_delay(0x06333333);
/* Set full scale */
ais2ih_full_scale_set(&dev_ctx, AIS2IH_2g);
platform_delay(0x00333333);
platform_delay(0x06333333);
ais2ih_filter_path_set(&dev_ctx, AIS2IH_LPF_ON_OUT);
platform_delay(0x00333333);
platform_delay(0x06333333);
ais2ih_filter_bandwidth_set(&dev_ctx, AIS2IH_ODR_DIV_4);
platform_delay(0x00333333);
platform_delay(0x06333333);
/* Configure power mode */
ais2ih_power_mode_set(&dev_ctx, AIS2IH_HIGH_PERFORMANCE);//AIS2IH_HIGH_PERFORMANCE_LOW_NOISE
platform_delay(0x08333333);
/* Set Output Data Rate */
ais2ih_data_rate_set(&dev_ctx, AIS2IH_XL_ODR_25Hz);//AIS2IH_XL_ODR_400Hz
platform_delay(0x08333333);