Products for USB Sensing and Control Canada flag
Products for USB Sensing and Control

sales inquiries

quotes, distributor information, purchase orders

technical inquiries

support, advice, warranty, returns, misshipment

website inquiries

corrections or suggestions


Unit 1 - 6115 4 St SE
Calgary AB  T2H 2H9

Steppers with Encoders: When Open-loop Control Is Not Enough

by Mike


With the increasing popularity of DIY projects such as quadcopters, CNC tables and 3D printers, many people are faced with the decision of which type of motor to use in their project. For applications that require precise control of the position of the motor, the common choices are DC motors with encoders, servo motors, and stepper motors.

DC Motor

A DC motor is the standard electric motor; it will spin as fast as it can with the DC power you provide it with. On its own, a DC motor has no position control. Most DC motor controllers allow you to change the duty cycle, a value from 0 to 100% that describes how much of your power supply is being made available to the motor. However, controlling the duty cycle does not give you control over the position or even the velocity of the motor. This is where encoders come in: an encoder typically attaches to the rear shaft of your motor, and it measures the actual position of the motor and sends this information to your system. Now you can have real position control, because your system can easily calculate how far it needs to turn the motor in order to make the current position equal to the desired position.

Servo Motor

A servo motor is just a DC motor with some upgrades: they typically have a gearbox to increase output torque, and they have a control system built right inside the motor's casing. Since all of the control is built in, you can simply tell a servo to rotate to a specific angle, and it'll try its best to move to that position. The downside to an integrated control system is that you usually can't customize it in any way.

Stepper Motor

A stepper motor uses alternating current through two separate coils to turn the rotor. I won't go into the details, but the end result is that the motor moves in distinct “steps”, and the angle of these steps can be calculated from the step angle listed on the motor's datasheet and the gearbox reduction ratio, if it has a gearbox. Since the motor turns a known amount each time a step is made, the position and velocity can be calculated.

Now, in some situations, customers have used stepper motors with attached encoders. You may wonder, why on earth would you add position control to a motor that already has position control? As the title of this blog implies, this is the question I'll answer today.

Open-loop Position Control with a Stepper Motor

First, let's take a look at what the control system looks like on a stepper motor without an encoder. Suppose you want the stepper to make one complete rotation. Your program knows your motor's step angle is (for example) 1.8°, so it tells your controller to move 200 steps clockwise. The controller tells this to the driver chip, and the driver chip outputs the power signals that turn the motor. Next, suppose you want the motor to turn half a rotation counter-clockwise from it's original starting location. Your program remembers the motor is 200 steps away from the starting position, so it tells the controller to move 300 steps counter-clockwise, and so on.

This is known as open-loop control. You have precise control over the position of the motor, but only under the assumption that the motor has physically done exactly what it's been told to do. If the motor takes an extra step due to excessive inertia, if the motor stalls, or if you're using a gearbox that has significant backlash, your program's assumption of the motor's current state will be wrong.

Closed-loop Position Control with a DC Motor and Encoder

Now we'll look at the control system that results from using a DC motor and encoder. Suppose you want the motor to make one complete rotation. Your program tells the controller to move at 100% duty cycle. The motor starts moving, and as it does, the encoder updates your program with the motor's current position. The program then re-evaluates the situation and tells the controller a new duty cycle.

If your program is clever, it can adjust the duty cycle to gradually decrease as you get closer to your target position (this sort of control could be achieved with a PID control loop). If an external force were to stop the motor, your encoder would indicate to your program that the motor has stopped moving, and it could increase the duty cycle or activate another system designed to take care of the problem. This type of control is called a closed-loop controller, because the actual output of the system constantly loops back into the calculation that determines the future output. By installing an encoder onto your stepper motor, you can create a similar closed-loop system with all of the same benefits of a stepper motor. If the motor stalls and desynchronizes with the controller, you can restart it. If you miss steps or take too many, they can be accounted for instead of accumulating over time. If your gearbox backlash introduces a few degrees of error after a number of rotations, that error can be eliminated with an encoder.

Why Use a Stepper Then?

Now that we've determined that both DC motors and stepper motors have closed-loop control when used with an encoder, why would we want to use a stepper at all? While they both have the same level of control once you install an encoder, they are still very different in terms of operation. Stepper motors are better for applications where the motor needs to hold position while still providing full torque; a DC motor could do this, but it would be very bad for the motor's lifespan. Even with an encoder, pulling off that kind of precision with a DC motor would be extremely difficult, because a DC motor can't lock itself into position like a stepper can. Stepper motors are also preferred in applications that require precision, like CNC tables. For some applications, open-loop control with steppers is enough, but if error recovery is important, switching to closed-loop control is worth consideration. On the other hand, applications that require velocity feedback control at high speeds, such as a remote controlled vehicle, would favour DC motors.

Motor selection also depends on many other factors specific to your project. If you need any advice on what sort of motor and what degree of control you need for your project, feel free to contact us or make a post on our forums.