How to add arudino libraries to matlab
3 ビュー (過去 30 日間)
古いコメントを表示
a = arduino();
s = servo(a,'D6');
lib = listArduinoLibraries()
Hello!
Now I have [Matlab support package for arduino hardware 21.2.1]
It is installed and there are 11 libraries as shown in the picture above.
I want to use MATLAB to control the angle of the servo motor. Therefore, I want to put "VarSpeedServo.h" into Matlab, but I don't know how to include it.
What I was able to do
1.Angular speed control using "VarSpeedServo.h" with arduino software only (without using MATLAB)
2. Checked simple operation using [Servo] in MATLAB.
Operation confirmed
clear a s
a = arduino('com5', 'Uno', 'Libraries', 'Servo');
s = servo(a, 'D6');
Base_angle = 90;
Min_angle = -30;
Max_angle = 30;
for angle = Min_angle:10:Max_angle
Wangle = (angle+Base_angle)/180;
writePosition(s, Wangle);
current_pos = readPosition(s);
current_pos = current_pos*180;
fprintf('Current motor position is %d degrees\n', current_pos);
pause(1);
end
Wangle = (Base_angle)/180;
writePosition(s, Wangle);
If anyone can help me understand, I'd appreciate it if you could let me know.
I'm glad it's simple grammar!
0 件のコメント
採用された回答
Image Analyst
2022 年 10 月 8 日
It's hard without us having your servo hardware, but why can't you make the arduino code "VarSpeedServo.h" into a MATLAB function and then call it from your main script (which is something like in your step 2)?
2 件のコメント
Image Analyst
2022 年 10 月 9 日
Yeah sorry but my only experience with arduino and MATLAB was a very limited amount many years ago. Call tech support.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Arduino Hardware についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!