Skip to main content
Visitor II
June 4, 2024
Solved

AIS2IH Read Data Registers

  • June 4, 2024
  • 8 replies
  • 2744 views

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));

 

 

 

    This topic has been closed for replies.
    Best answer by Federica Bossi

    Hi @scboris ,

    Can you share a photo of your setup?

    8 replies

    scborisAuthor
    Visitor II
    June 4, 2024

    Whats wrong with my accelerometer?

    Thank You

    scborisAuthor
    Visitor II
    June 4, 2024

    The  result is:

    A[r]:0,0,0; T[C]:0; R:4,DUP=0

     

    There R:4 is the AIS2IH_CTRL2 register value

    scborisAuthor
    Visitor II
    June 4, 2024

    What changes I  can made to get  the real values of the acceleration  or  temperature.

    Thank You

    Technical Moderator
    June 4, 2024

    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.

    scborisAuthor
    Visitor II
    June 4, 2024

    OK!

    scborisAuthor
    Visitor II
    June 4, 2024

    Thank You!

    I changed the code of the program as it is in the link above. I take the

    ais2ih_read_data_polling.c

    example.

      I take another AIS2Ih accelerometer. 

    But still, It is  no changes at   the result.

     

    Technical Moderator
    June 5, 2024

    Hi @scboris ,

    Can you share a photo of your setup?

    scborisAuthor
    Visitor II
    June 5, 2024

    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);

    }

    scborisAuthor
    Visitor II
    June 6, 2024

    So, the problem is with setup of the sensor.

    Technical Moderator
    June 6, 2024

    Can I see your hardware?

    scborisAuthor
    Visitor II
    June 6, 2024

    OK?