Clear Filters
Clear Filters

Reading MPU6050 data from Raspberry Pi in Simulink

22 views (last 30 days)
Hello everyone, I'm having trouble in reading data from my MPU6050 linked with my Raspberry Pi 4 in Simulink (2021b).
My model is the following:
Inside the Enable Subsystem i have two Master Write block, with this settings:
When I try to "Monitor & Tune" this model, I can't visualize the correct data:
As you can see, the output value for the Z acceleration in something like -2e4, while I'm expecting a value of about -12 (measured with both my Arduino and the MATLAB function "mpu6050()").
How can I fix my model in order to read the correct values?
Thank you in advance.

Answers (1)

Nirmalkumar Doreraju
Nirmalkumar Doreraju on 3 Mar 2022
Hi Luca,
It seems that the setup sequence done by the enable subsystem might be having some problems.
There is a 'Initialization function' block you can use that to setup the MPU6050. Also you need to make sure that Initialization follows the order of registers as mentioned in the data sheet.
For this you can use the Block priority, right click on a block -> Properties and mention a priority number. For more information on priority check this help page
I would also push the reading to an enabled subsytem and read one sample time later.
Please let us know if this solution works for you.


Find more on Raspberry Pi Hardware in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!