Reading MPU6050 data from Raspberry Pi in Simulink
6 次查看(过去 30 天)
显示 更早的评论
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/806514/image.png)
Inside the Enable Subsystem i have two Master Write block, with this settings:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/806519/image.png)
When I try to "Monitor & Tune" this model, I can't visualize the correct data:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/806524/image.png)
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.
0 个评论
回答(1 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Raspberry Pi Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!