Ever wanted to control several stepper motors precisely with just one microcontroller? Use PWM! Instead of bit-banging and writing your own delay functions to create square waves, you can use the builtin timers and pin-change interrupts available on most hobbyist microcontrollers.

In this case we'll use a Teensy LC, a Pololu DRV8825 driver and a NEMA 17 stepper motor.

Step 1: Wiring and Connections

First solder headers to your DRV8825 board and Teensy, then put them on a breadboard. (It's actually easiest to solder these headers while the boards are alreadyon a breadboard, but work in whatever order you'd like!)

We will connect the stepper driver much like the diagram from Pololu's product page (also included in the image below).

  • VMOT and GND will have a 100uF capacitor between them and be connected to a 12V benchtop supply capable of supplying at least 2A.
  • The ~RESET and ~SLEEP pins will be held high by connecting them to the teensy's 5V rail.
  • The stepper itself will connect to A1, A2, B1 and B2.
  • Set the stepper into 1/16 step mode by pulling M2 high and allowing M0 and M1 to float.
  • The driver's GND pin will connect to the teensy GND.
  • The teensy's pin 2 will connect to the driver's DIR pin.
  • And the teensy's pin 3 will connect to the driver's STEP pin.

The teensy will have one additional connection: pin 9 will be tied to pin 3. This will allow the teensy to count pulses via a pin-change interrupt.

Also make sure to set the DRV8825's current limiting resistor to an appropriate value, as described on their product page.

About This Instructable



More by StepsoftheSun:Control a Stepper Motor with PWM Soldering Station Trebuchet of the large variety (a work in progress), 4.28.07 update 
Add instructable to: