フィルターのクリア

how can i communicate matlab-arduino serial??

1 回表示 (過去 30 日間)
kwstis xoustoulakis
kwstis xoustoulakis 2015 年 9 月 12 日
コメント済み: Walter Roberson 2015 年 9 月 13 日
i hv made a robotic arm drawing ,with 3 servos and i want to communicate with servos serial and send specidic angles.
my code is
function [] = ServoAngle(Theta1,Theta2)
L1=0.065;%m
L2=0.125;%m
a=arduino('COM3');
a.servoAttach(9);
a.servoAttach(10);
px=L2*cos(Theta1+Theta2) + L1*cos(Theta1)
py=L2*sin(Theta1+Theta2) + L1*sin(Theta1)
a.servoWrite(9,Theta1);
a.servoWrite(10,Theta2);
plot(px,py,'r.');
xlabel('Px','fontsize',10);
ylabel('Py','fontsize',10);
pause(1);
end
without matlab only with the arduino i could send the microseconds (with writemicroseconds command) that i want, and servos does exactly the degrees that i want. but my project desires to use matlab and arduino to make the robotic arm ,so i want to communicate serial with arduino but i dont know how ?? i want to tell me the procedure to do this and some code... im interested to understand matlab-arduino serial communication and start change my code
thanks!!

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 9 月 12 日
The code you show looks plausible for the old arduino support package from the File Exchange. For the current arduino package, you should create two servo objects and readPosition() or writePosition() to the objects.
  2 件のコメント
kwstis xoustoulakis
kwstis xoustoulakis 2015 年 9 月 13 日
編集済み: kwstis xoustoulakis 2015 年 9 月 13 日
i have r2014b matlab edition is okay?? i try to create a servo connection but in s=servo(a,'D9') command says undefined function servo.... in arduino ide what code must load??? where can i find the current arduino package???
Walter Roberson
Walter Roberson 2015 年 9 月 13 日
The support package for R2014b onward needs to be installed; see http://www.mathworks.com/help/supportpkg/arduinoio/setup-and-configuration.html

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

カテゴリ

Help Center および File ExchangeMATLAB Support Package for Arduino Hardware についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by