MATLAB Answers

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

2 views (last 30 days)
Joncikas
Joncikas on 24 Sep 2020
Commented: Joncikas on 28 Sep 2020
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

  0 Comments

Sign in to comment.

Answers (1)

Nagasai Bharat
Nagasai Bharat on 28 Sep 2020
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 Comment

Joncikas
Joncikas on 28 Sep 2020
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...

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!