Stepper Motor Control: Single Coil, Double Coil, Interleaved Coil & Microstep Modes

Controlling stepper motors is a fundamental aspect of robotics, automation, and industrial applications. Stepper motors are widely used for their precision and ability to rotate in small, precise steps. In this stepper motor control using Arduino tutorial, we will discuss how to control a stepper motor with Arduino using different step modes, including single coil steps, double coil steps, interleaved coil steps, and microsteps.

Stepper Motor Different Stepping Modes

Single Coil Steps 

Single coil steps, also known as Wave Drive, use only one coil at a time to drive the motor. This mode provides the lowest torque and is less smooth than other modes. It requires less power and is suitable for low-torque applications such as moving small objects.

Double Coil Steps 

Double coil steps, also known as Full Step, use both coils of the motor at once. It provides higher torque than the single coil step but is less smooth. It is suitable for medium-torque applications such as moving a camera or a small robot.

Interleave Coil Steps 

Interleaved Coil Steps, also known as Half Step, alternate between one and two coils, providing higher resolution than the full step. It provides a higher resolution and smoother motion than the previous two modes, making it suitable for high-torque applications such as CNC machines.

Microsteps 

Microsteps divide each full step into smaller steps, providing even smoother motion than the previous modes. It can be used in applications that require high precision and smooth motion, such as 3D printers, robotics, and medical devices.

Here we will be using AFmotor.h library which has the different types of stepping function and use L293D Arduino motor shield. If you don't know how to install AFmotor.h library see the tutorial how to add AFmotor library in Arduino.

Interfacing Stepper motor with Arduino and L293D motor shield

The interfacing is simple. The stepper motor has four wires which are connected to the motor M3 and M4 of the Arduino motor shield. This is shown below.

arduino motor shield stepper motor circuit

AFmotor Stepper motor Control Program

The following is the Arduino program code for controlling stepper motor with different stepping methods using the AFmotor library.

    
 #include <AFMotor.h>

    // Specify Steps Per Revolution, depends on Stepmotor specification
    const int spp = 200;

    // connect stepmotor to stepper motor port #2 (M3 and M4)
    AF_Stepper stepmotor(spp, 2);

    void setup() {
    Serial.begin(9600);   //configure serial interface
    stepmotor.setSpeed(20);  // 20 rpm  
    }

    void loop() {
    unsigned char cmd;
    if(Serial.available()){
        cmd = Serial.read();
        switch(cmd){
            case 's':
            Serial.println("Single coil steps");
            stepmotor.step(100, FORWARD, SINGLE);
            stepmotor.step(100, BACKWARD, SINGLE);
            break;

            case 'd':
            Serial.println("Double coil steps");
            stepmotor.step(100, FORWARD, DOUBLE);
            stepmotor.step(100, BACKWARD, DOUBLE);
            break;

            case 'i':
            Serial.println("Interleave coil steps");
            stepmotor.step(100, FORWARD, INTERLEAVE);
            stepmotor.step(100, BACKWARD, INTERLEAVE);
            break;

            case'm':
            Serial.println("Micrsostep steps");
            stepmotor.step(100, FORWARD, MICROSTEP);
            stepmotor.step(100, BACKWARD, MICROSTEP);
            break;

            case 'r':
            Serial.println("Release Torque");
            stepmotor.release();
            break;

            default:
            break;
        }
    }
    }
 

Now, let's take a look at the code snippet provided. 

First, we include the AFMotor library that provides functions to control stepper motors. We also specify the number of steps per revolution of the motor (spp), which depends on the motor specifications.

In the setup() function, we configure the serial interface to communicate with the computer and set the speed of the motor to 20 RPM.

In the loop() function, we wait for a command from the computer through the serial interface. If a command is available, we read it and execute the corresponding case statement.

For example, if the 's' command is received, we print "Single coil steps" to the serial monitor, then move the motor forward and backward 100 steps in single coil steps using the step() function from the AFMotor library. We pass three arguments to the step() function: the number of steps to move, the direction to move (FORWARD or BACKWARD), and the step mode (SINGLE, DOUBLE, INTERLEAVE, or MICROSTEP).

We repeat this process for each command: 'd' for double coil steps, 'i' for interleaved coil steps, 'm' for microsteps, and 'r' to release the motor torque.

Finally, if no command is received, the program does nothing and loops back to wait for the next command.

Overall, this code allows us to easily control a stepper motor using different step modes through a simple serial interface. We can send commands from a computer or any device that can communicate through the serial interface to control the motor's movement.

Video demonstration

Following video demonstrates how the stepper motor can be controlled in single, double, interleaved and microstep modes using Arduino and Arduino motor shield.

 

 

In conclusion, stepper motors are versatile and useful for many applications. With the help of an Arduino and the AFMotor library, controlling stepper motors becomes a straightforward task. We can choose from different step modes, each with its advantages and disadvantages, to achieve the desired motion for our specific application.

Post a Comment

Previous Post Next Post