I'm using the adafruit motorshield board with an arduino board togerther to control 3 steppers, NEMA-17. 2 of the steppers are wired together to one motor port on the shield board (as I need them to walk at the same time), and another one is wired to the other port on the board. An external power supply is also wired with the board, and the working current is usually set to 1A. Also, Matlab serves as the commander.
Now everything is good except the preciseness of the motor steps. When I use commands like move(sx,10) (command in matlab to tell the motor to move 10 steps.) to control the motor continuously, the motor can't move the exactly same distance every time for the commands of 10 steps. And also, they can't follow the order of steps correctly each time. Sometimes, the motros don't move when it's told to move. What is the problem here? I'm very confused. I don't think the codes are wrong. Is there something unconsidered about the adafriut motor shield?
Here are the codes.
Code: Select all
delete(instrfind({'Port'},{'COM3'}));
a = arduino('COM3', 'uno', 'Libraries', 'Adafruit\MotorShieldV2');
shield = addon(a, 'Adafruit\MotorShieldV2');
addrs = scanI2CBus(a,0);
% Move cameras to the 1st imaging position
sx = stepper(shield, 1, 200); % 2 x-axis motors
sy= stepper(shield, 2, 200); % y-axis motor
sx.RPM = 10;
sy.RPM = 10;
move(sy,585);
move(sx,500);
x = [70 70 0 -70 -70 0 70 70 0 -70 -70 -500];
y = [0 0 70 0 0 70 0 0 70 0 0 -795];
for i = 1:12
% move motors
move(sx,x(i));
move(sy,y(i));
pause(5)
end
Olivia