How to update values from I2C in Simulink using Arduino hardware for the MMA8541 Accelerometer

4 次查看(过去 30 天)
I have followed the tutorial listed on to connect my MMA8541 Accelerometer to an Arduino Uno using Simulink. Iunderstand that the board in the tutorial is different, but I doubt that is the problem, as it should work in a similar fashion: https://ww2.mathworks.cn/help/supportpkg/freedomboard/examples/read-acceleration-data-from-the-onboard-mma8451q-3-axis-digital-accelerometer-via-i2c.html
Unfortunately, no matter how much i research and try various things, I cannot manage to get it to work. This is what my "main" simulink block looks like:
The board I am using is the Arduino Uno. I am trying to connect it using I2C. When I do so, no error shows, I this is what i see when I execute the .slx file:
My read configuration:
The output I get stays the same, it doesn't change one bit... Could someone please help me? Ii attached the file below just in case

回答(1 个)

Nagasai Bharat
Nagasai Bharat 2020-9-28
Hi,
As the tutorial is given for the onboard accelerometer and the hardware architecture for FRDM Board would be different from Arduino Uno and hence leading to the issue.
Try going through the datasheet for the accelerometer you are using and get the registers right.
Try the model in the above model as it could be of some help.
  1 个评论
Joncikas
Joncikas 2020-9-28
Thank you for your reply :)
Unfortunately I have attempted that code with no success... I tried it on the 2020a version, as well as the 2019b version. It should work, but it doesn't. I get values, buty they stay the same hroughout, even though I tilt the MMA8451 board back and forth...

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Modeling 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by