4
$\begingroup$

I would like to know what software is available to control a timing belt with stepper motors for arduino board.Much like how its done in 3d printing. But in this case i wont be making a 3d printer.Just one simple setup.

$\endgroup$
2
$\begingroup$

Here you go. This will control 2 steppers on an Arduino.

#include <Stepper.h>

#define STEPS 200       // change this to the number of steps on your motor

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's attached to 
Stepper stepperX(STEPS, 2, 3, 4, 5);    // Arduino pins attached to the stepper driver
Stepper stepperY(STEPS, 8, 9, 10, 11);

int previous = 0;       // the previous reading from the analog input

void setup()
{
    // set the speed of the motor to # RPMs
    stepperX.setSpeed(60);
    stepperY.setSpeed(60);

    // Initialize the Serial port:
    Serial.begin(9600);
}

void loop()
{
    int sensorPosition = analogRead(0);

    // Step forward # steps:
    Serial.println("Moving Forward...");
    stepperX.step(500);
    stepperY.step(500);
    delay(1000);

    // Step backward # steps:
    Serial.println("Moving Backward...");
    stepperX.step(-100);
    stepperY.step(-100);
    delay(1000); 
}

As mentioned in @Chuck's post, the Arduino doesn't directly control stepper motors. What happens is that you plug in a stepper driver to the Arduino, and that driver is wired to & controls the motor. You'll see that my pins are 2, 3, 4, and 5 for one driver & motor, and 8, 9, 10, and 11 for the other driver & motor.

Stepper stepperX(STEPS, 2, 3, 4, 5);    // Arduino pins attached to the stepper driver
Stepper stepperY(STEPS, 8, 9, 10, 11);

This is because I'm using 4-phase unipolar motors. Your choice of stepper motors will determine your own setup.

Here's a great writeup on the topic of motor selection:

AdaFruit stepper motor knowledge

Good luck!

Ryan

$\endgroup$
  • $\begingroup$ Great answer! Only comment I would make is to point out that the step values could be parameterized. Currently your code has the values hard coded, and the values for forward and reverse are different. Way more detail than my post, though, as I have yet to actually do anything with the Arduinos I have laying around. $\endgroup$ – Chuck Jan 21 '16 at 0:10
  • $\begingroup$ Thanks for the code. I shall read the Stepper Motor Knowledge link. $\endgroup$ – sohaib shaikh Jan 21 '16 at 10:47
0
$\begingroup$

Typically stepper motor control isn't necessarily done in software but in hardware. See this stepper motor driver for an example.

The driver allows you to set bits to control how much you would like to step (full, half, quarter, etc.), and takes care of actually providing driving current to the motor. Some drivers may allow you to set a speed in steps/time, but typically after that point you send a pulse train to the motor driver; this can be done with an interrupt or other hardware timer.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.