Arduino simulink MATLAB function error

15 ビュー (過去 30 日間)
Krzysztof Kaczmarek
Krzysztof Kaczmarek 2018 年 5 月 11 日
回答済み: Madhu Govindarajan 2018 年 5 月 15 日
Hi,
I would like to use MATLAB function in my Simulink project. Unfourently I get error that my device isn't connected. It might be caused by line 5 "a = arduino('COM3', 'Mega2560', 'Libraries', 'JRodrigoTech/HCSR04');" in my MATLAB function. Without MATLAB function block everything work correctly. Below I inserted code and block function. I would by grateful for Your help.
function H1 = Out_H1 ()
coder.extrinsic('arduino');
coder.extrinsic('addon');
coder.extrinsic('readTravelTime');
a = arduino('COM3', 'Mega2560', 'Libraries', 'JRodrigoTech/HCSR04');
sensor = addon(a, 'JRodrigoTech/HCSR04', 'D52', 'D53');
t = readTravelTime(sensor);
temp1 = 0;
temp1 = 340*t*1000/2;
H1 = temp1;
Best regards, KK

回答 (1 件)

Madhu Govindarajan
Madhu Govindarajan 2018 年 5 月 15 日
Try using the Ultrasonic sensor block in this submission - https://www.mathworks.com/matlabcentral/fileexchange/66568-arduino-engineering-kit-hardware-support

カテゴリ

Help Center および File ExchangeArduino Hardware についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by