The inside of the simplified stepper motor pictured below is a metal rotor surrounded by several multi-toothed electromagnets. When one of the electromagnets is turned on, it pulls the rotor towards it, making the magnet and rotor’s teeth align as shown in the animations. Each fractional turn of the rotor induced by different electromagnets being turned on is a step. In the animation, it takes 4 steps for the wheel to turn by one tooth. Since there are a total of 25 teeth, one full rotation will be completed in 100 steps. Not every stepper motor is designed exactly like this, but they all work in fundamentally the same way: turning electromagnets on and off in order to make a central rotor spin.
A simplified model of a 4-phase, unipolar stepper motor.
(Source: wikipedia.com)
Each electromagnet, referred to as an electromagnetic coil or just a coil, is grouped with other coils in something called a phase. All coils within a phase will turn on at the same time, meaning that they all serve an identical and parallel function in making the rotor move by a single step when that phase is sent a HIGH signal. In the above animation, there is only one coil per phase – typically you’ll find at least two. In the real world, coil count doesn’t necessarily mean much to us on its own, and phase count is generally only relevant when figuring out how we need to control a motor. When deciding which stepper motor to use for a certain application, we should be more concerned with things like step count, power draw, max RPM, and holding torque, as they will all directly affect a stepper motor’s function more significantly than phase count.
By leaving a phase energized, stepper motors have the unique ability to hold a single position and resist any external rotational forces that try to change that position. This resistance is quantified by the holding torque, and it’s measured using force units (Nm). Holding torque is very important in many industrial applications, and larger stepper motors with bigger coils or gear reductions tend to have higher holding torque ratings. A stepper motor’s holding torque rating is often very similar to its low-speed torque rating.
To understand what unipolar and bipolar motors are, I’m going to briefly go into a bit more detail on how the coils are magnetized when the motor takes a step. There are two things to keep in mind: stepper motors can turn on 2 or more phases at once, and each phase can switch polarity.
In many stepper motors, the central rotor will be magnetized, meaning it will have a north and south pole relative to the coils. If a positive current flow through a coil attracts the teeth on one side of a magnetized rotor, then a negative current flow on the coil opposite will also attract the rotor. Alternating polarity phases is fundamental to the function of many stepper motors, and two or more phases may need to be energized in certain steps to make the rotor turn as intended.
The way in which the polarity is switched in each phase is what defines the difference between unipolar and bipolar stepper motors. Unipolar motors have 3 wires per phase – 2 positives on either end of the coil and a common ground in the middle. By changing which positive wire we send the signal to, the current will move through the coil in a different direction, reversing its polarity each time. On the other hand, bipolar motors have only two wires per phase and instead reverse polarity by using H-bridge circuitry.
Unipolar stepper motors tend to be simpler to control and can spin more quickly because they don’t have to wait for the coils to de-energize before starting the next step. However, they have less torque than bipolar stepper motors of equal size. This is because they can only energize half of each coil during each step (from the positive wire to the center lead, as pictured below), whereas bipolar stepper motors can energize the entire length of their coils.
Depending on which kind of motor we’re looking to use (unipolar or bipolar), our options for controlling them will vary. Driving unipolar motors is comparatively easy, as dedicated drivers like the ULN2003 are easy to configure. It’s also possible to drive them using a series of transistors or simple switches. Bipolar stepper motors are a bit more difficult to control due to their need for H-bridge circuits, but H-bridge motor drivers like the L293D and dedicated bipolar drivers, like the A4988, TMC2209, and DRV8825, are generally easy to come by and find documentation for.
Depending on the arrangement of phases within a stepper motor, each model will have a unique sequence of signals that need to be sent to the stepper motor to make it turn properly. In the case of the 28BYJ, the sequence for turning clockwise when using the ULN2003 driver board in your kit is as follows:
If using your 28BYJ stepper motor with the supplied ULN2003 driver board (pictured below), setup is fairly straightforward. Board features of note are listed below:
Sending a HIGH signal to any of the control pins will turn on the phase that the pin connects to within the stepper motor. Sending the wrong signals won’t damage anything – the motor just won’t turn.
The 4 LEDs will blink when a signal is sent to their respective control pins. However, in the sample Python program, each signal is switched from HIGH to LOW in a matter of milliseconds, making it appear as though the LEDs are constantly lit. Slowing down the step speed to 100ms or slower will allow the LED pattern to be visible, though the stepper motor will turn very slowly.
The 28BYJ stepper motor only actually moves 16 steps per revolution, but is geared in such a way (pictured below) to make it act as though it has 512 steps. This gives it impressively high accuracy and decent torque (.0805 Nm), but the drawback is that it moves very slowly, capping out at about 17 RPM.
The motor requires a 5V power input, which is supplied to the highlighted pins in the above diagram of the ULN2003 board. According to the specifications it should not exceed a 300 mA current draw, and a 9V battery has enough capacity to run it for an extended period of time. Due to the 5V power supply requirement, the 9V battery must be stepped down using something like a breadboard power supply. The steps for doing this can be found online or in the stepper motor circuit build guide.