A more versatile stepper motor

The stepper motors found in consumer appliances like printers and air conditioners generally have four coils instead of just one. One such motor is the 28YBJ-48. It has a motor that makes a full revolution in 64 steps, and a set of gears that further reduce the speed (and increase the turning force) by 64.

   

In this motor, the coils are set up in pairs, and the center of each pair is connected to the red wire, which is connected to the positive side of the power supply. The power supply can be anything from 5 to 12 volts.

By connecting any of the other wires to ground, we can energize any of the coils. The coils are electromagnets that pull on little gear-like teeth in the motor. By controlling which coils are pulling at any time, we can make the motor step 1/64th of a circle at a time, either clockwise or counterclockwise. Because of the gearing, we actually step 2048 times to make the shaft turn one complete turn. This gives us a lot of control over the position of something we are moving.

The diagram above shows how the colored wires connect to the coils.

Because the motor moves the same amount each time we step it, we can accurately move back and forth, and always land on the same spot.

We do pay a price for the gear reduction in this motor, however. The gears have some play in them, so the shaft of the motor can move back and forth a little bit, causing positioning accuracy to suffer. More expensive stepper motors have more teeth in their rotors, and have as many as 200 steps per revolution instead of just 64. These motors generally don't have gears, and can accurately step without any play in the rotor.

Energia has a stepper motor library that takes all of the complexity out of driving stepper motors.

We simply include the header file for the library in our program, and make an instance of the Stepper class (we'll call our instance 'motor'). Then we tell motor to step some number of steps, using a positive number to step clockwise, or a negative number to step counterclockwise.

That's all there is to it, as far as the software goes.

Our problem comes when we realize that the Launchpad can only put 3.3 volts on a pin, and can't drive the 92 milliamperes needed to make the motor move. We need to add a transistor on each pin. That will both allow us to send a higher voltage to the motor, and to provide plenty of current to drive the motor.

Instead of using 4 separate transistors, we can use a convenient package of 16 transistors on a chip called the ULN2003A. The transistors are arranged in pairs (called a Darlington pair) that gives them more amplification, and allows them to sink more current. We will only use half of the transistors in the chip, since we only have four coils to drive.

We connect the Launchpad pins to pins 1 through 4 on the ULN2003A chip. We connect the colored wires on the motor to pins 16, 15, 14, 13, and 9 according to the drawing above. Pin 9 is also connected to the positive side of a power supply that can provide 5 to 12 volts. The negative side of that power supply is connected to pin 8. The Launchpad's ground is also connected to pin 8, so the Launchpad and the other power supply can agree on what zero volts is.

Many suppliers sell the 28BYJ-48 stepper motor and a small circuit board containing the ULN2003A together as a package, making life even that much more convenient. One such circuit board, which also comes with LEDs to show which motor pins are being driven, is shown below.

However, it is easy enough to just plug the ULN2003A (or as in the case below, the very similar ULN2004A chip) into the solderless breadboard and connect it up. The photo below shows a six wire stepper motor (a Seiko Epson STP-35N148) being driven by the same demonstration program. It can handle 24 volts, (it turns just fine on 4.5 volts, but 24 volts would move heavier loads). The two brown wires are connected to the two center taps of the coil pairs, and we connect them to the positive power supply (pin 9 of the ULN2004A) just like we did with the red wire in the 5 wire motor.

Stepper Motor Demonstration