Reading MPU6050 data from Raspberry Pi in Simulink

7 visualizaciones (últimos 30 días)
Luca Lorusso
Luca Lorusso el 19 de Nov. de 2021
Respondida: Nirmalkumar Doreraju el 3 de Mzo. de 2022
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.

Respuestas (1)

Nirmalkumar Doreraju
Nirmalkumar Doreraju el 3 de Mzo. de 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 https://in.mathworks.com/help/simulink/slref/block-priority.html
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.
Regards,
Nirmal

Categorías

Más información sobre Raspberry Pi Hardware en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by