MATLAB Answers

Arduino i2c and pwm failure

2 ビュー (過去 30 日間)
Torbjørn Heimvik Lied
Torbjørn Heimvik Lied 2019 年 4 月 11 日
Hi! I am trying to control two dc motors regulated by the feedback from a MPU6050 gyro accelerometer with an Arduino Mega 2560.
I am using the the Matlab and Simulink Arduino support packages and Rensselaer Arduino Support Package Library for the gyro.
However, once a current starts flowing through the motors, the model stops and I get the following error message, wich is equal to unplugging the USB cable:
Error occurred while executing External Mode MEX-file 'ext_comm': ExtTargetPktPending() call failed while checking for target pkt
Component:Simulink | Category:Block diagram error
Error occurred while executing External Mode MEX-file 'ext_comm': ExtSetTargetPkt() call failed on CLOSE. Ensure target is still running
I have tried different motor drivers, different gyros and different Arduino Mega boards, all with no success. It is worth mentioning that this is part of a University bachelor thesis where I have discussed the problem with my supervisors as well, but we can still not figure out why it is not possible to read i2c values and control motors at the same time. Separately each task works well, but the problem is when one or both motors are actuated while reading i2c values at the same time.
Does anyone have an idea what the problem might be?

  0 件のコメント

サインインしてコメントする。

回答 (2 件)

Madhu Govindarajan
Madhu Govindarajan 2019 年 4 月 11 日
Which release of MATLAB are you using?

  2 件のコメント

Torbjørn Heimvik Lied
Torbjørn Heimvik Lied 2019 年 4 月 15 日
We are using r2017b.
Torbjørn Heimvik Lied
Torbjørn Heimvik Lied 2019 年 4 月 15 日
By the way, further experimentation have resulted in the same error message without any current going through the motors. This indicates we have a software problem only, and not hardware related.

サインインしてコメントする。


Madhu Govindarajan
Madhu Govindarajan 2019 年 4 月 16 日
Is it possible that you are not using an external battery to power these devices? I have had this happen to me sometimes when there is enough current/juice to go around for a few devices/sensors but not all of them.
If you are not using external power supply, then I would recommend doing so especially for the motors as they are the ones that have varying current demands.

  3 件のコメント

Torbjørn Heimvik Lied
Torbjørn Heimvik Lied 2019 年 4 月 23 日
All the devices are powered by external power source. As said above, we have figured out that the porblem is with the software, as the error message appears even if no of the motors are connected.
Do you have any idea what the problem might be?
Madhu Govindarajan
Madhu Govindarajan 2019 年 4 月 23 日
Unfortunately no. I would recommend you to reach out to support@mathworks.com or call our Technical Support line to get more assistance.
Regards,
Madhu
Torbjørn Heimvik Lied
Torbjørn Heimvik Lied 2019 年 5 月 5 日
Okay, thanks for your help. Have a good day.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by