PC/CP320 Physical Computing

Raspberry Pi Stepper Motors


Stepper motors are common.


  1. To introduce control of stepper motors with the Raspberry Pi





  1. Datasheet Examination

    Look at the driver chip datasheet and the motor datasheet and the controller board datasheet to answer the following questions:
    Is there diode protection in the chip or will optoisolators be needed on the inputs?
    What input voltage is required for a high? Can this be provided by the Pi?
    Note: The Pi power pin may not provide enough power for the motor. If that is the case then use the bench supply, but make sure your bench ground and the Pi ground are connected.
    How many pairs of coils are inside this stepper motor?

  2. Identify which pins have which function:
    • power
    • ground
    • control signals

  3. Motor Calibration

    Write a program to control the stepper using a set of GPIO pins and incorporating half-stepping.
    See my example which shows output to several pins at once.

    Many stepper motors, such as this one, have internal gearing so that the external shaft takes many motor revolutions to make one complete shaft revolution.
    Modify your program to find the number of steps for a complete shaft rotation.
    Hint: The number of motor coils must divide evenly into the number of steps. Also, somewhere in the documentation the number of steps in a revolution should be specified.

  4. Program Refinement

    Modify your program so that you input the desired angle of rotation in degrees.
    Modify your program so that, when you quit, the motor will be returned to the neutral position.

  5. Demonstrate your circuit and program to the lab supervisor.


To view pdf documents, you can download Adobe Acrobat Reader .
get Acrobat Reader
If you need to update a browser, you might try Firefox which is Get Firefox!
Since this page uses cascading style sheets for its layout, it will look best with a browser which supports the specifications as fully as possible.

If you are looking for an office package, with a word processor, spreadsheet, etc., you might try LibreOffice which is Get LibreOffice!

Go to the main page for the Department of Physics and Computer Science.

Valid XHTML 1.1

Valid CSS!

(Level AA)

Wilfrid Laurier University