Thursday, February 20, 2014

Stepper Motors

Stepper motors are unlike ordinary motors.  A simple motor will spin when current is applied to the coils.  Reverse the polarity of the current, and the motor spins in the opposite direction.  Stepper motors, however, contain multiple coils which can be energized individually to provide precise "stepping" of the motor.

This precise control makes them perfect for a variety of applications.  They are commonly used in floppy drives, hard drives and CD/DVD drives to precisely control the speed that the disc turns as well as where the read/write heads are positioned.  They are also used in scanners to position the scanning optics and in ink jet printers to move the paper and position the print head.  Any application that requires precise positioning is likely to use stepper motors.

For more details on the many varieties of stepper motors, see the following pages:

Quick Start for Beginners -

Stepper Motor Basics -

There are two basic methods for controlling a stepper motor.  One is to use an IC specifically designed as a stepper motor controller.  The other option is to use a microprocessor (the Raspberry Pi, in this case) to directly control the individual coils of the stepper motor.  This is the method that I demonstrate in the following video.

The code for the program used in this demo follows.


  1. Hello,
    Just wondering, how much cpu utilization do you get while driving 1 stepper motor via software PWM of wiring pi? Is it possible to run other processes/threads in parallel without major slowdowns?

    Have you tried 2+ stepper motors?

    Ty in advance

    1. I did not check the CPU utilization while running the stepper motor, but I expect that it would be pretty low. The CPU is just sleeping the vast majority of the time while doing the pulses. You should also be able to run several steppers with this method.