How can I run 2 stepper motors simultaneously connected to an arduino Uno using Matlab?
27 views (last 30 days)
I am using a motor shield with the arduino Uno.
I want to be able to run 2 stepper motors simultaneously.
This is a code that runs the 2 motors, but not simultaneously, as in, for motor 2 to start, it has to wait for motor 1 to stop.
I have tried to use 'parfor' loops instead of 'for' loops, that didn't do the trick.
I have tried uploading an edited version of the srv.pde to integrate the I2C and AccelStepper libraries, but I'm not getting a simultaneous movement either...
I added to the srv.pde:
and to the void loop (), I added:
and uploaded that as to the master arduino.
and uploaded to the slave arduino:
void receiveEvent( int howMany)
I need help modifying the srv.pde so that when I upload it, I would be able to run the stepper motors simultaneously. Or another way, without having to modify the srv.pde file, to be able to run the motors simultaneously...
[Merged information from duplicate Question]
Hi, I have 2 arduinos, 2 motor shields, and 2 stepper motors. I want the 2 motors to run simultaneously, when I connect the 2 steppers to one arduino, the motors do not run at the same time. For example, in a for loop like this, motor 1 will run, stop, then moto 2 will run, stop.
The same issue occurs if I have 2 arduinos connected. For example, the for loop would be like this:
with "b." representing a different arduino than the "a."
Is there a way to make the 2 motors run at the same time?
Rolfe Dlugy-Hegwer on 12 Feb 2013
If you install the Simulink Support Package for Arduino Hardware, check out the "Drive with PID Control" tutorial example with its arduinomega2560_drive_openloop.mdl model.
To add this capability, enter "targetinstaller" in the MATLAB Command Window. Then follow the instructions in Support Package Installer.