Atlas Robotics
Motor ControlIntermediate

What is a stepper motor? Rotation in discrete steps without feedback

Atlasbot · 16/8/2026 · 11 min read

What is a stepper motor? Rotation in discrete steps without feedback
Power supply sequence for 4 coils to create each rotation step

The DC motor rotates continuously. If you want to know the exact position, you must add an encoder. The Stepper motor (stepper motor) goes in the opposite direction: the motor only rotates in fixed discrete steps each time it receives a control pulse — if the number of sent pulses is counted correctly, in theory it always knows the exact shaft position without needing any sensor feedback.

Key concepts

Inside the stepper there are many pairs of coils arranged around the axis. Each pair, when energized, creates a magnetic field that pulls the rotor to a stop at a fixed angular position. By sequentially energizing the pairs of coils in the correct order, the rotor is "pulled" to rotate in small steps — a common stepper motor can have 200 steps per revolution (that's each step = 1.8°).

Full step, half step, and microstepping

  • Full step — power supply in the correct basic sequence, each step change is a full step (eg: 1.8°)
  • Half step — alternately powering 1 coil and 2 coils at the same time, double the number of steps, smoother movement
  • Microstepping — adjusts the current through each coil in the form of a sine wave instead of turning it on/off completely, dividing each mechanical step into dozens of virtual "microsteps", extremely smooth and quiet movement, but requires a specialized driver to support (Example: TMC2209)

In short: Stepper allows precise positioning in an open-loop fashion (no need for sensor feedback) — as long as the torque requirement does not exceed the motor's capacity at running speed, otherwise the rotor will "slip" from the magnetic field pulling it, called step loss, and the position counted on the MCU will deviate from the ground truth which has no way to detect itself without an additional encoder.

How it works

Basic power supply sequence for 4-coil stepper (bipolar, full step):

Step 1: Coil A ON, Coil B OFF → rotor stops at 0°
Step 2: Coil A OFF, Coil B ON → rotor stops at 90°
Step 3: Coil A ON (reverse polarity), Coil B OFF → rotor stops at 180°
Step 4: Coil A OFF, Coil B ON (reverse polarity) → rotor stops at 270°

In reality, the MCU does not manually generate this sequence for each coil — always going through a dedicated driver (A4988, DRV8825, TMC2209...), the MCU only needs to send 2 simple signals: STEP (each pulse = 1 step) and DIR (direction of rotation):

HAL_GPIO_WritePin(DIR_Port, DIR_Pin, GPIO_PIN_SET); // Select rotation direction

for (int i = 0; i < 200; i++) {   // 200 pulses = 1 full revolution (full step)
    HAL_GPIO_WritePin(STEP_Port, STEP_Pin, GPIO_PIN_SET);
    delay_us(500);
    HAL_GPIO_WritePin(STEP_Port, STEP_Pin, GPIO_PIN_RESET);
    delay_us(500);
}

Technical details

Formulas

Rotation speed calculated directly from STEP pulse frequency and number of steps per revolution (multiplied with microstepping factor if used):

Effective number of steps/round = Basic number of steps × microstepping coefficient
RPM = (STEP pulse frequency × 60) / Effective number of steps/rev

For example: motor 200 steps/revolution (full step), microstepping 1/8, STEP pulse at 1000Hz
Effective number of steps/round = 200 × 8 = 1600
RPM = (1000 × 60) / 1600 = 37.5 rpm

Parameters

Typical parameters of common steppers in 3D printers/CNC/robots:

TypeFull stepHolding torque
NEMA17 (most common)200 (1.8°/step)~40-60 N·cm
NEMA23 (higher power)200 (1.8°/step)~100-300 N·cm

Driver A4988 can withstand a maximum current of ~1-2A/coil (in fact, it is recommended to use below this level); The TMC2209 supports the same current but operates much quieter thanks to a more sophisticated current control algorithm.

Register / Bit / Byte

On the A4988 driver, the microstepping resolution is selected by 3 logic pins MS1/MS2/MS3 — this combination of 3 bits (each HIGH/LOW pin) selects 1 of 5 levels from full step (1/1) to 1/16 microstep, according to the lookup table in the datasheet (eg: MS1=0, MS2=0, MS3=0 → full step; MS1=1, MS2=1, MS3=1 → 1/16 step). Some more modern drivers such as the TMC2209 can also be configured in more detail (current limit, resolution, quiet mode) via a separate 1-wire configuration UART interface with the main STEP/DIR signal, allowing fine-tuning without changing the physical bridge on the board.

Practical applications

Steppers are suitable for positioning axes that require high precision and predictable loads — for example, the lift mechanism on a conveyor belt AMR robot, where precise stopping at multiple fixed heights is required without the need for continuous position sensing, or a sensor/camera-mounted spindle needs to scan at a predetermined key angle. With the moving wheel of an AMR (the load changes continuously depending on the terrain, real speed feedback is needed), a DC motor combined with an encoder and PID is still the more suitable choice - this is the boundary that decides whether to choose a stepper or a DC motor for each specific joint on the robot.

Practical example

#include <stdio.h>

int main() {
    int base_steps = 200;
    int microstep[] = {1, 2, 4, 8, 16};
    float step_freq = 1000.0;   // Hz

    for (int i = 0; i < 5; i++) {
        int steps_per_rev = base_steps * microstep[i];
        float rpm = (step_freq * 60) / steps_per_rev;
        printf("1/%2d step: %d buoc/vong -> %.2f RPM (cung tan so xung)\n",
               microstep[i], steps_per_rev, rpm);
    }
    return 0;
}
Output:
1/ 1 step: 200 buoc/vong -> 300.00 RPM (cung tan so xung)
1/ 2 step: 400 buoc/vong -> 150.00 RPM (cung tan so xung)
1/ 4 step: 800 buoc/vong -> 75.00 RPM (cung tan so xung)
1/ 8 step: 1600 buoc/vong -> 37.50 RPM (cung tan so xung)
1/16 step: 3200 buoc/vong -> 18.75 RPM (cung tan so xung)

Given the same STEP pulse frequency (1000Hz), the RPM actually decreases as the microstepping factor increases — because more pulses are needed to complete 1 full rotation. Here's the trade-off to remember: microstepping gives smoother motion, but to achieve the same rotation speed, a correspondingly higher STEP pulse frequency is needed.

Common mistakes

  • Step loss due to acceleration too fast or load exceeding the motor's capacity — as mentioned in the Main Concepts section, when the rotor cannot keep up with the pulling magnetic field, the position counted on the MCU will be permanently different from the ground truth until it is "reset" (eg, homing to the limit switch) — it is necessary to gradually accelerate/decelerate (ramp up/down) instead of suddenly changing speed.
  • Not properly limiting driver current — most drivers have resistors/registers to limit the maximum current delivered to the coil; Setting too high causes the motor/driver to overheat, setting too low causes the motor to lack power and lose steps more easily.
  • Driver does not have a heatsink when running continuously at high current — driver ICs such as the A4988 automatically reduce current or completely shut down (thermal shutdown) when overheating, which manifests as the motor suddenly weakening or stopping completely in the middle.
  • Misconfigured pins MS1/MS2/MS3 — choosing the wrong combination of logic levels leads to a different microstepping coefficient than expected in the code, causing the actual speed/distance to deviate from the calculation even though the code is completely logical.

Conclusion

Stepper motors allow precise open-loop positioning without the need for sensor feedback — suitable for predictable load positioning axes, at the expense of risking step loss if the motor's capabilities are exceeded. Always calculate the correct RPM according to the pulse frequency and microstepping factor, and limit the driver current properly before long-term operation. The next article in this section is about PID — a feedback control algorithm used to keep the DC motor speed stable, something a stepper does not need but a DC motor must have.

Get new articles and lessons by email

When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.

Unsubscribe any time with the link in each email. See our Privacy policy.

What is a stepper motor? Rotation in discrete steps without feedback — Atlas Robotics