Stepper Motors control though Mtalab

8 views (last 30 days)
Rajani Budha
Rajani Budha on 12 Nov 2019
Answered: Walter Roberson on 12 Nov 2019
Hello!
I am trying to control multiple stepper motors through arduino and adafruit shields. Is it possible to rotate stepper motors on both ports simultaneously? I can't make them rotate simultaneously so far. Below is the code I am using:
a = arduino('COM5','Uno','Libraries','Adafruit/MotorShieldV2');
shield = addon(a,'Adafruit/MotorShieldV2');
sm = stepper(shield,1,200,'RPM',1080);
sm1 = stepper(shield,2,200,'RPM',1080);
move(sm,1080);
release(sm);
move(sm1,-1080);
release(sm1);
clear a sm sm1 shield

Answers (1)

Walter Roberson
Walter Roberson on 12 Nov 2019
You would need to use the parallel computing toolbox and connect the devices to different workers. Then you would need to synchronize the workers, which you could do with labBarrier(). It is unlikely that you would be able to precisely synchronize the two. If, for example, you are using these to control turning drive wheels on a vehicle then this might not be satisfactory, and using the robots toolbox might be a better choice for such a situation.

Categories

Find more on Arduino Hardware in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!