steppers running simultaneously

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
100mph
 
Posts: 6
Joined: Sun Mar 30, 2008 12:46 pm

steppers running simultaneously

Post by 100mph »

I've got my steppers up and running but I can't get them to both run simultaneously. Is there code I can use to get this to happen or is the resulting "one motor fires then the other" pattern a result of the motor shield hardware circuit.

Thanks,
mg

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Post by adafruit »

this is a 'software' problem not a hardware one. check out the library code, what you want is to call onestep() and interleave the call to stepper #1 and #2

100mph
 
Posts: 6
Joined: Sun Mar 30, 2008 12:46 pm

interleave?

Post by 100mph »

I'm a code newbie. Do you think you could explain "interleave". Where do I put the interleave call in this code below. Or do I have to go alter the AFMotor.h or the AFMotor.cpp

#include <AFMotor.h>



AF_Stepper motor_freight(200, 1);
AF_Stepper motor_passenger(200, 2);

void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");

motor_freight.setSpeed(80); // 60 rpm
motor_passenger.setSpeed(100);

}

void loop() {
motor_freight.step(300, FORWARD, SINGLE);
delay(500);
motor_passenger.step(500, FORWARD, SINGLE);
delay(10);
motor_freight.step(100, BACKWARD, SINGLE);
delay(500);
motor_passenger.step(200, FORWARD, SINGLE);
delay(500);


}

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Post by adafruit »

you need to do something like

loop 300 times:
motor_freight.step(1, FORWARD, SINGLE);
motor_passenger.step(1, FORWARD, SINGLE);


that will step the two motors at the same time

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”