cancel
Showing results for 
Search instead for 
Did you mean: 

LSM303AGR initialization in simulink

sanathhere
Associate III

Hello,

I am working on sensor fusion of LSM303AGR MEMS accelerometer, As a simple program to read acceleration values, I used the I2C read and write blocks, here is my step by step: 

Initialize sensor: I2C write (0x32), write 0x57 on CTRL_REG1_A(0x20)

sanathhere_1-1694771482210.png

 

Read XYZ values: I2C read (0x33), read from 28, 29, 2A, 2B, 2C, 2D

sanathhere_0-1694771156390.png

however, on all displays I get only 00. and nothing else is happening when i move the board. I suspect, I might have an old version of the sensor where the address might be 0x19 for the acceleration sensor.

Is my methodology correct to work the sensor, or are there extra steps involved in initialization or does my returned data need to be multiplied with sensitivty?

I have another project in keil mdk where i added the ACC_I2C_ADDRESS to the watch window in debug mode to check if i am using the correct I2C address, but it does not display any value rather throws an error 'cannot evaluate'

Could anyone help?

 

2 REPLIES 2
Issamos
Lead II

Hello @sanathhere 

I suggest you to use this drive to communicate with your LSM303AGR. If not, you can use the same configuration (adress, commands ,....)as in this drive .

Best regards.

II

@Issamos In Keil MDK, I am infact using the STM provided example which uses these files for the sensor, what i am trying to do is use this example and get the I2C address to verify if I am infact using the correct addresses in my simulink code. Do you know how I can check that? I have read posts about who am i addresses to confirm which version you have is one of the methodologies, but my WHO_AM_I variable cannot be read in watch window, is there another way? 

Thank you for replying