Why does my stepper motor run that slowly?
Show older comments
Hi everyone,
I have a problem when I try to control my stepper motor with Matlab.
I use an Arduino Uno to control my motor and I try to communicate with my Arduino through Matlab : the fact is that my stepper motor runs but very slowly. However, it is not the case when I use the Arduino interface to communicate with my Arduino Uno : in this case, the motor isn't slow.
Here is my little program on Matlab :
clear all;
a = arduino('COM3','Uno','BaudRate',115200);
configurePin(a,'D2','DigitalOutput');
configurePin(a,'D5','DigitalOutput');
writeDigitalPin(a,'D5',1);
for i=1:500
writeDigitalPin(a,'D2', 1);
pause(0.0005);
writeDigitalPin(a,'D2',0);
pause(0.0005);
end;
writeDigitalPin(a,'D5',0);
for i=1:500
writeDigitalPin(a,'D2',1);
pause(0.0005);
writeDigitalPin(a,'D2',0);
pause(0.0005);
end;
I have tried to increase the BaudRate, however it wasn't conclusive.
If anyone has some device, I would be pleased!
1 Comment
Have you tried to setup the servo motor like this ?
s = servo(a, 'D9'); % D9 is the pin where servo motor is connected
writePosition(s, 0.5); % The position can be from 0 to 1
Answers (0)
Categories
Find more on Arduino Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!