MATLAB Answers

Simulink S-Function MPU6050

75 ビュー (過去 30 日間)
Philip Harris
Philip Harris 2019 年 1 月 20 日
編集済み: Adib Ahmadi 2019 年 8 月 8 日
I've managed to follow the above guide to integrate the MPU6050 into a system for my Arduino Mega but I can't seem to port it to work with my Uno and I'm a bit lost on why.
I have amended the target hardware and upon compiling for the Uno it throws the following error.
mpu6050_sfcn_wrapper.o ../mpu6050_sfcn_wrapper.cpp
../mpu6050_sfcn_wrapper.cpp: In function 'void mpu6050_sfcn_Outputs_wrapper(real_T*, real_T*, real_T*, const real_T*)':
../mpu6050_sfcn_wrapper.cpp:191:9: error: 'Serial2' was not declared in this scope
Serial2.print("ypr\t");
No problem, revert any mention of Serial2 to Serial and it will now compile for the Uno but I can't view the data in a Scope like I can with the Mega.

  0 件のコメント

Sign in to comment.

回答 (3 件)

Adib Ahmadi
Adib Ahmadi 2019 年 8 月 8 日
編集済み: Adib Ahmadi 2019 年 8 月 8 日
i have put all the code and whole files folder here : multiple mpu6050 with s function

  0 件のコメント

Sign in to comment.


mouad boumediene
mouad boumediene 2019 年 6 月 18 日
external mode does not work with arduino uno

  0 件のコメント

Sign in to comment.


Arun Kumar
Arun Kumar 2019 年 6 月 27 日
編集済み: Arun Kumar 2019 年 6 月 27 日
Hi Philip Harris,
Simulink external mode uses arduino Serial port 0 to communicate with the target.
In the example, the target is Arduino Mega which has more than one serial port. Serial port 0 is used to communicate with simulink while Serial Port 1 is used to print the logs. But in case of Arduino Uno, there is only one serial port. Changing the Serial Port 2 to Serial Port has no issues on Arduino side, the code will compile and run properly. But, on simulink side, Simulink will receive your debug logs along with external mode communication which might result in some unexpected behaviour.
My recommendation is to comment all lines that use Serial Port 2.
-Arun

  0 件のコメント

Sign in to comment.

製品


リリース

R2018b

Translated by