Basics of Design CC Blog Research & Design Hub

Stepper Motors

Written by Stuart Ball

A Primer for When You Need Precise Positioning

Stepper motors are used for all kinds of mechanical positioning applications. This article will look at how they work, how to implement them, and what to watch out for so you don’t trip over something.

  • What are stepper motors used for?
  • How can I use a stepper motor?
  • What are the advantages to stepper motors?
  • Stepper
  • STMicroelectronics
  • Texas Instruments 
  • Toshiba

Stepper motors are used in printers, CNC machines, 3D printers, and many kinds of robotics. Understanding steppers, how they work, and how to use them is an important part of implementing a stepper-based solution.


Figure 1 shows a simplified diagram of a DC motor and a stepper motor. The DC motor has a rotor on a shaft and the rotor is wound with wire. When it is energized, it makes an electromagnet. The DC voltage passes to the rotor windings through a commutator, which is a conductor, insulated from the rotor shaft, with a tiny gap on both sides. When the rotor is energized, it rotates to align with the stator permanent magnets, shown on the top and bottom of the diagram. Just as the rotor aligns with the magnets, the commutator reverses the current into the rotor, so the rotor magnetic field is now reversed. It continues rotating to align with the magnets again, and the commutator reverses the voltage again and the cycle continues.

Simplified diagrams of a DC motor and a stepper motor
Simplified diagrams of a DC motor and a stepper motor

In a small DC motor, the magnets will be permanent magnets, while in a larger motor they may be electromagnets. This diagram is simple—a real motor will have more poles. If you built a DC motor in a high school shop or science class, you will recognize the basic configuration shown in the diagram.

For the purposes of this article, the key concept is that the rotor is an electromagnet and the commutator keeps reversing the rotor polarity to keep the motor spinning. A DC motor only needs two wires to run. A real DC motor might have a position or speed sensor connected to the rotor shaft, but the motor itself needs only two wires because the commutation happens in the motor. Because there is an arc every time the commutator breaks the connection, a DC motor tends to generate electromagnetic interference (EMI).

Figure 1 also shows a simplified diagram of a stepper motor. In the stepper motor, the rotor is a permanent magnet and the electromagnets are in the stator. There is no commutator. Instead, commutation of the motor is performed by external circuitry. This means there are no brushes to wear out and there is no EMI from commutator arcing. But the drive circuitry for a stepper is more complex. The primary benefit of a stepper motor is that the controlling electronics can precisely position the rotor at any point in rotation.

Again, the diagram in the figure is simplified; I’ve shown the rotor poles aligning with the stator electromagnets, and there are four of each. A real stepper motor might have eight windings and the rotor will have multiple teeth.

The key thing to take away from the stepper motor diagram is that the rotor is the permanent magnet, the electromagnets are on the stator, and commutation must be performed externally.

Figure 2 is a photo of a disassembled stepper motor. This one has four coils and is a unipolar stepper (more about that later). You can see the rotor consists of two sections with multiple teeth; one section is the north pole and the other is the south pole. This motor has 25 teeth on each section, for a total of 50. It takes 200 steps for a full rotation (1.8 degrees per step). This is a common configuration, although others are available.

Disassembled unipolar stepper showing coils and rotor
Disassembled unipolar stepper showing coils and rotor

There are basically two types of stepper motors: unipolar and bipolar. There are different stepper constructions (hybrid, permanent magnet, and variable reluctance), but hybrid is the most common. A brushless DC motor is functionally similar to a stepper in that the rotor is a permanent magnet and the stator has coils that are driven to spin the rotor. But like a DC motor, brushless DC motors are used in continuous rotation, not positioning applications.

Figure 3 shows a schematic representation of the windings in unipolar and bipolar steppers. A unipolar stepper will typically have four drive coils with a common connection, although steppers with more coils are available. Unipolar steppers can be driven by connecting the common point to the supply voltage and grounding the other side through a transistor. Motor direction is controlled by the sequence of the coil activation. A bipolar stepper has two separate coils that are not connected together. If the unipolar motor has the connection made inside the motor, with five wires to the outside, then it can only be used as a unipolar motor. However, if the center point of the coils is brought out of the motor (total of six wires), then it can be driven as either unipolar, by connecting the center taps, or bipolar, by leaving the center taps unconnected and driving the two coils separately. Because only one half of each coil is driven at a time, the torque of a unipolar motor will be less than that of an otherwise identical bipolar motor.

Drive configuration for unipolar and bipolar stepper motors
Drive configuration for unipolar and bipolar stepper motors

As shown in Figure 3, the bipolar motor has two independent coils. The bipolar motor has more complex drive requirements than the unipolar. To step a unipolar motor, only one coil has to be driven at a time, and just one transistor is needed per coil. But a bipolar motor requires that each coil be driven in both directions. This requires the use of an H-bridge, which has four transistors per coil. So, the two-coil configuration in Figure 3 would require eight transistors. As shown in the figure, turning on transistors Q7 and Q9 causes current to flow through coil A from top to bottom. Turning on Q8 and Q10 causes current to flow through coil A in the other direction. To rotate a bipolar stepper motor, you alternately drive current through each coil, alternating directions.

What happens if you turn on transistors Q6 and Q9 at the same time? This is called shoot-through, and it causes a direct short between the supply voltage (V+) and ground. Bad things happen when you do this, usually involving failure of the transistors. The point is that an H-bridge has some considerations that the individual drive transistors of a unipolar motor don’t have.


Figure 4 and Figure 5 are a schematic of a stepper controller that I used as an example for this article. Figure 4 is the MCU schematic, and if you’ve read my previous articles, you may recognize the circuit—the MCU is a TI TM4C1233H6PM. The actual MCU circuit has more on it than is shown here, because I deleted everything not relevant to this example from the schematic. Connector J6 is the serial port programming connector; the schematic of the programming adapter is available on the Circuit Cellar Article Materials and Resources webpage. The firmware was developed in TI Code Composer Studio.

Schematic of MCU for example circuit
Schematic of MCU for example circuit
Schematic of unipolar and bipolar stepper drivers for example circuit.
Schematic of unipolar and bipolar stepper drivers for example circuit.

Figure 5 is the stepper control circuitry. The schematic in Figure 5 will control a unipolar and a bipolar stepper. The firmware is simple—it just ramps the stepper speed up from about 1 step per second to 500 steps per second, then ramps it back down. It doesn’t do anything sophisticated, but it could be used as the basis for a more complete control system. IC U2 is an open-drain part to interface between the 3V levels of the MCU and the 5V levels of the bipolar motor controller.

Although the schematic is shown as a single circuit, the stepper control circuit is on a separate PCB that plugs into the MCU board. I had to do this because the L9935 device is in a unique SMT package that was impractical to put on a hand-wired board.

Unipolar Motor: The unipolar motor is driven by U3, a Toshiba TB67S111 [1]. This is a transistor driver; driving an input high drives the corresponding output low. The part has a connection at pin 15 for a flyback protection diode (more about that later). To step the unipolar motor, the MCU alternately turns on one transistor at a time. The MCU firmware uses a 1KHz timer tick, so I used that for the motor timing. You could also use one of the internal general-purpose timers to generate a timing interrupt independent of the timer tick.

Bipolar Motor: The bipolar motor is driven by U1, an ST L9935 device specifically designed for driving bipolar stepper motors [2]. The L9935 is significantly more complex than the TB67S111. It uses an SPI interface for connection to the MCU. Resistors R2 and R3 sense the current through the motor windings. Excessive current turns off the motor drive, and it’s turned back on regularly. Since the motor windings are inductive, the current does not reach the limit value immediately—it rises until the limit is reached and current is turned off. This is called chopper drive and is used to control the motor current. The device has limited turn-on time to reduce EMI, senses open windings and overcurrent, and prevents shoot-through.

When I built the prototype (it was on a 4-layer PCB) I managed to drop some solder into connector J2, shorting out one of the windings. The motor wouldn’t turn, and the current waveforms didn’t look right. I finally figured out what was wrong and fixed it. But the L9935 did its job, shutting down the motor drive when excessive current was detected—in this case shoot-through because of the shorted winding.

If using a chopper drive, you can drive the motor with voltage that exceeds the motor rating. The motor voltage (if one is specified) tells you the voltage that will produce the maximum allowable current in the windings. But with chopper drive, the chopping circuit will limit the current. A higher drive voltage will let the motor winding reach the limit current more quickly. Needless to say, you can’t exceed the maximum supply voltage of the driver IC.

If you need to control a bipolar stepper, you can of course do it with discrete transistors and other components driven directly by the MCU. But to achieve the same level of functionality, you will need analog-to-digital converters (ADC) to sense the current, some way to shut down the drivers when overcurrent is detected, temperature sensing of the transistors, and other features. I don’t see a lot of advantage to doing it that way unless you just can’t find an IC that will meet your needs.


I mentioned flyback earlier. When a switching transistor is turned on, drawing current through an inductor, and then the transistor switches off, conservation of energy says that the energy stored in the inductor must go someplace. It will produce a voltage spike, and if the voltage is uncontrolled, it can get high enough to damage the transistors. It is common to clamp the coil to the power supply through a diode to prevent excess voltage; the flyback voltage is then limited to the power supply voltage plus the diode voltage. But if this is done with just a diode, it takes more time for the energy to bleed off. The TB67S111 makes provision for a Zener diode to be added for this purpose (D1 on the schematic). Inside the TB67S111 there is a blocking diode from each output to the COM pin, and then a Zener is connected between COM and the motor supply voltage. Figure 6 shows what happens when the output switches off; the voltage on the pin rises to about 32V, which is the Zener voltage (20V) plus the power supply voltage (12V). The higher the Zener voltage, the faster the energy in the coil is dissipated. The output pins on the TB67S111 are limited to 80V.

Captured flyback voltage pulse from unipolar stepper driver
Captured flyback voltage pulse from unipolar stepper driver

The flyback spike is real current being dumped into the positive supply, so you need enough supply capacitance to avoid causing a ripple on the supply voltage. The L9935 uses intrinsic diodes to handle flyback voltage. If you build an H-bridge or unipolar driver with discrete transistors, or you use a part without internal flyback protection, you will need to provide a way to clamp the flyback voltage.


The point of a stepper motor is to move a load of some kind. To do this, you will need to have enough energy, in the form of current in the motor windings, to provide adequate torque. Torque is force applied through a radius; when you tighten a bolt with a wrench, you are applying torque.

The bipolar stepper I used in the example circuit has a holding torque of 0.42 Newton-meters, or 3.72 inch-pounds. Holding torque is the amount of torque the motor will apply with current through the coils when not rotating. It is how much torque you would need with a wrench to move the stepper out of position. The motor I used has a maximum current of 1.5A, so the holding torque is measured at 1.5A.

Rotating torque will be lower because when a motor is rotating it functions as a generator. You can demonstrate this by shorting the leads on a stepper or DC motor and trying to turn the shaft. It will be more difficult to turn with the leads shorted because of the generated current. In a motor circuit, this is called back electromotive force (back EMF), and it opposes the rotation of the motor. Some stepper motor datasheets will have a graph showing the relationship between speed and torque. If the torque applied to your motor exceeds the torque the motor can generate, the motor will skip steps or stall. In designing with a stepper, you must translate the forces applied to the motor shaft into torque values and make sure that the available motor torque isn’t exceeded.

A motor will be driving a shaft. To calculate the torque needed to raise a weight, you need to know the weight and the radius of the drive shaft. If you are turning drive wheels through a belt or gear on the motor shaft, you will need to determine the force needed to turn the wheels on different surfaces and translate that into a torque applied to the motor shaft. Oriental Motor has a good paper on motor sizing and torque, the link for which is also available on Circuit Cellar’s Article Materials and Resources webpage [3].


A stepper motor can provide precise positioning. You apply steps to the motor, and, knowing the number of steps per full rotation, you know how many degrees the motor turns. But there are caveats. As mentioned above, excess torque will cause the motor to skip steps. But you will probably never know that, as there will be no feedback. Also, an open winding coil, a bad bearing, or anything else that keeps the motor from moving will result in an erroneous result. On powerup, you will probably have no idea what angle the motor shaft is at, which could be an issue if you are driving something that has to start each operation at a specific motor angle. Closed-loop operation may be required in some safety-related applications, such as medical electronics.

For situations like these, you may need a way to know the exact location of the motor shaft. You can do something simple like have a sensor that detects a “home” position. For more complicated situations, you may need an encoder. This is a sensor that mounts on the motor shaft (usually on the back of the motor) and generates either a series of pulses representing motor rotation, or a digital value that represents the absolute shaft position. You would use the encoder to verify that a step command to the motor results in an actual rotation of the shaft. If steps are missed, you might slow the motor to improve torque, or generate an error indication.


Whatever the motor is driving has inertia and probably some friction as well; it won’t go from stopped to full speed in a few steps. So, when you change speed or go from stationary to some desired speed, you have to ramp the speed up. You also have to ramp speed down when slowing or stopping. The example system does nothing but ramp up and ramp down since it’s just for demonstration. But you have to take the ramp-up and ramp-down characteristics of the system into account or you will miss steps when trying to get to the speed or position you want. Oriental Motor has a useful whitepaper on motor sizing and inertia [4].


The example circuit generates a drive sequence for the bipolar motor that always applies current to both motor coils. The motor rotates by changing the current direction through the coils. A bipolar motor can be half-stepped by applying current to one coil and turning off the current to the other coil. By doing this in the correct sequence, the motor will move one half-step (0.9 degrees on a motor with a 1.8-degree full step). This provides smoother motion and less vibration.

A full-step sequence looks like that shown in Table 1 (+ and – indicate the current direction). You can see that the full-step sequence always energizes both coils.

A half-step sequence is shown in Table 2. There are some drawbacks to microstepping. The big one is that the torque is reduced in the half-step positions. Since only one coil is energized, only half the holding torque is available to hold the load. So, you have to allow for this; you might need a bigger motor than would be needed in a full-step application.

Table 1
Full-step drive for bipolar stepper
Table 1
Full-step drive for bipolar stepper
Table 2
Half-step drive for bipolar stepper
Table 2
Half-step drive for bipolar stepper

Another issue with microstepping is that you have to generate more step pulses; in the half-step example, you have to produce twice as many steps for the same amount of rotation.

A motor can be turned in even finer steps if you apply an approximately sinusoid signal to the windings. This is done by changing the current in the steps. The L9935 has current control; you can change the current for each step. But this will significantly increase the number of steps needed for a full revolution and increase the workload on the MCU.

The example code with this article (see Circuit Cellar’s Article Materials and Resources webpage) includes a table for half-stepping. See the code comments for instructions to enable it. You can try full steps and half steps to see how the motor vibration changes.


There are other stepper drivers, of course. The L9935 used here has an SPI interface. The TI DRV8846 uses a step/direction interface where a step signal causes the stepper to step one position and the direction signal determines which direction the motor goes. The DRV8846 allows microstepping up to 1/32 of a step. Pick a driver that works best with your application and has the features you need. You will need to select a driver that will supply the needed current and that will work over the required voltage range.


Stepper motors provide precise positioning, allowing you to control the direction and speed of a robot, the precise location of a cutting head on an XY table, or the precise position of a sampling probe in a medical diagnostic test device. This overview should make it easier to apply steppers while avoiding some of the pitfalls. 

[1] Toshiba TB67S111 datasheet:
[2] STMicroelectronics L9935 datasheet:
[3] Oriental Motor torque article:
[4] Oriental Motor inertia article:

STMicroelectronics |
Texas Instruments |
Toshiba |

Code and Supporting Files


Keep up-to-date with our FREE Weekly Newsletter!

Don't miss out on upcoming issues of Circuit Cellar.

Note: We’ve made the Dec 2022 issue of Circuit Cellar available as a free sample issue. In it, you’ll find a rich variety of the kinds of articles and information that exemplify a typical issue of the current magazine.

Would you like to write for Circuit Cellar? We are always accepting articles/posts from the technical community. Get in touch with us and let's discuss your ideas.


Advertise Here

Sponsor this Article

Stuart Ball recently retired from a 40+ year career as an electrical engineer and engineering manager.  His most recent position was as a Principal Engineer at Seagate Technologies.

Supporting Companies

Upcoming Events

Copyright © KCK Media Corp.
All Rights Reserved

Copyright © 2024 KCK Media Corp.

Stepper Motors

by Stuart Ball time to read: 14 min