フィルターのクリア

Reading MPU6050 data from Raspberry Pi in Simulink

22 ビュー (過去 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 Center および File ExchangeRaspberry Pi Hardware についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by