Interface LSM303AGR Acceleration sensor STM32F4xx Board

26 visualizaciones (últimos 30 días)
Sanath
Sanath el 29 de Ag. de 2023
Comentada: Sebastian Gross el 1 de Sept. de 2023
Hello,
As part of my master thesis, I am working on the STM32F411E Discovery board. This board has an LSM303AGR Accelerometer+Gyroscope via I2C communication, which I am trying to interface in Simulink to further develop a model in Simulink.
I have installed the STM Embedded coder support package however this doesnt have a block to get acceleration sensor data. I tried to look up how to interface an IMU sensor in Simulink however I could not find a tutorial that would fit my case. Has anyone worked on accel sesnsor fusion for STM board who could help me in the same. I have found various posts on the community regarding this but seems to be unsolved, posts dating back to 2016 even. It would be very useful if anyone could finally solve this sensor interface.
Thank you so much in advance for all the help.

Respuestas (2)

Sebastian Gross
Sebastian Gross el 30 de Ag. de 2023
Hi Sanath,
it is almost impossible to provide a block for every sensor for every target hardware.
There is an example for I2C communication with LSM303AGR on Arduino: https://www.mathworks.com/help/fusion/ug/estimate-oientation-using-ahrs-filter-and-imu-data-in-simulink.html. You might have seen this one. Do you have the corresponding I2C read block for your hardware plattform?
There are also ways to develop your own device driver block: https://www.mathworks.com/help/supportpkg/arduino/device-driver-blocks.html. This would result in a block like the LSM6DSL block in the example I listed above.
Did you try those approaches?
Best
Sebastian
  3 comentarios
Sebastian Gross
Sebastian Gross el 31 de Ag. de 2023
Editada: Sebastian Gross el 31 de Ag. de 2023
Hi,
the link did not work as the dot at the end of the sentence became part of the URL. It should work now.
"The model provided is pre-configured for STMicroelectronics Nucleo F401RE board. You can configure this model for other supported Nucleo boards by browsing to Configuration Parameters > Hardware Implementation > Hardware board and selecting the required board."
With the support package I can open stmnucleo_AccelGyro_extmode and select STM32F411RE and STM32F4-Discovery as hardware boards. I think you should give this a try. Let me know how it goes.
Sanath
Sanath el 31 de Ag. de 2023
Hello, thank you for the response, seems like you suggested the two examples I am already using to tune, firstly, I tried to run this example with my target hardware and only the magnetometer part because it uses the same sensor that i have onboard,
I am able to deploy the code without errors but when I choose monitor and tune to see the data in display block of simulink, I get the following error
"Error:External Mode Open Protocol Connect command failed
Caused by:
Could not connect to target application: XCP serial port error: open: The system cannot find the file specified [system:2]"
a quick search suggested I might have the COM port wrong but thats not the case sincemy blink program worked fine. How could i debug this? there is no COM port listed for my ST board under device manager as well. I am assuming port#1.hub#1 in properties means it is COM port 1 and blink program worked fine hence it confirmed for me.

Iniciar sesión para comentar.


Sebastian Gross
Sebastian Gross el 1 de Sept. de 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by