Reading MPU6050 data from Raspberry Pi in Simulink

조회 수: 7 (최근 30일)
Luca Lorusso
Luca Lorusso 2021년 11월 19일
답변: Nirmalkumar Doreraju 2022년 3월 3일
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.

답변 (1개)

Nirmalkumar Doreraju
Nirmalkumar Doreraju 2022년 3월 3일
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

카테고리

Help CenterFile Exchange에서 Raspberry Pi Hardware에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by