Namaste!

Welcome to a blog about things in my life, observations about the world, and just silly stuff. Enjoy!

Monday, April 29, 2013

Driving Stepper Motors

This post discusses the integration of a quad stepper motor controller and 3 stepper motors, which are controlled by an Arduino Mega 2560.

Stepper Motors
The stepper motors I purchased have four wires (red, yellow, green, blue) used to control the motor.  In order to confirm the color combinations provided in the motor's drawing and thus find the wire pair that controls each coil, I used a multimeter to measure the amount of resistance between each motor pairing.  The wires with less than 10 Ohms of resistance belong to the same coil.  Before wiring your motor to a controller, I'd suggest double checking the wiring for any stepper motor using this method.  For this particular motor and driver board the wiring is (from left to right): red, green, yellow, blue.

Quad Stepper Motor Controller
I selected this particular stepper motor because it can control up to 4 stepper motors simultaneously and interfaces with an Arduino (Mega).

Quadstepper Motor Controller
I used 3 (pelvis, hip, knee joints) stepper motors for the compound pendulum.  In order to power the controller and motors, I had to determine how much power the controller needs for all the motors.  Since this robot won't be mobile, I wanted to have a wall outlet supply power to the motors and controller (instead of batteries).  These particular stepper motors are rated at 12V and 0.33A.  The controller has an operating voltage range of 8-35V and a max current of 2A.  The total current needed by the controller for the board is I = 3*0.33A ~ 1A.  To be safe and have the option to give the motors a little extra current if needed, I ended buying a wall adapter that has a 2.1mm barrel connector and can supply 12V and 2A to the controller.  Also by using a wall adapter that can supply 2A, I won't need to purchase a new adapter if I add a fourth motor (ankle joint) to the system.

Arduino Interface
The Arduino Mega connects to the driver board using 6 wires per motor (Enable, MS1, MS2, MS3, Direction, and Step).  Sparkfun has an Arduino library and initial code for using the Quadstepper motor controller with and Arduino.  The code for the quad-stepper driver requires the following pin connections:

Motor1 STP pin: mega pin 11
Motor2 STP pin: meag pin 5
Motor3 STP pin: meag pin 6
Motor4 STP pin: mega pin 46

And then you can set the remaining pin assignments for the direction, enable, and MS1-3 wires to whatever pins you want on your Arduino.

After confirming the connections and code for one motor, I added the other two motors and modified the code accordingly.  Here's a video of testing one stepper motor.






No comments:

Post a Comment