How can I program my step motor to complete 1 revolution in 1 minute?

Hi,
I'm building a Drawing Machine that completes the drawing in one minute but this is my first arduino project and I`m having a lot os problems trying to understand how to write the code for my step motor to complete one revolution in one minute. Does anyone know how can I do it??

Thank you

How many degrees per step?

A full circle is 360 degrees: 360/degrees per step is how many steps you need.

1000/NumSteps gives milliseconds per step.

e.g.

  • number of degrees / step = 1.8
  • number of steps = 360/1.8 = 200
  • milliseconds per step is 1000/200 = 5

In theory, you could do:

#define DEG_PER_STEP    (float)1.8
.
.
.
numSteps = (int)(360.0/DEG_PER_STEP);
for( int i=0; i<numSteps; i++ )
{
    stepMotor();    //use whatever you need to step the motor
    //if numSteps > 1000 consider using micros timing
    delay( 1000/numSteps );
}//for

Not great in practice as the processor is essentially blocking here until the rotation is done but hopefully you get the idea...

If, for example, your motor needs 400 steps to do a revolution, you do a step every 60s / 400 = 150ms.

You can time this with delay() but this will block any other functionality in the mean time. Better to use millis(). For that, have a look at Blink without delay.

The speed of a stepper motor is determined by the interval between steps.

These links may help

Stepper Motor Basics
Simple Stepper Code

...R