How to add arudino libraries to matlab
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
文宏
am 8 Okt. 2022
Kommentiert: Image Analyst
am 9 Okt. 2022
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 Kommentare
Akzeptierte Antwort
Image Analyst
am 8 Okt. 2022
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 Kommentare
Image Analyst
am 9 Okt. 2022
Yeah sorry but my only experience with arduino and MATLAB was a very limited amount many years ago. Call tech support.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Support Package for Arduino Hardware finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!