Stepper motors are a special type of electric motor that can be used for precision maneuvering. Even a small stepper motor can produce a lot of torque, which makes it a valuable addition to the Grove Starter Kit used at the Intel IoT Hack-a-thon. We used ours to turn a valve which released water when needed by our Save the Pipes! project. But stepper motors aren't really intuitive -- they aren't like a regular DC motor, which you just plug in and watch it turn (or plug in with reversed polarity and watch it turn backwards).
A stepper motor is sort of a challenge to control, and hooking up the stepper motor included with the Grove kit to use the sample code was not intuitive to us. We managed to get it working well enough for our project to win the Hack-a-Thon, though, so we figured we'd share what we learned.
This Instructable may seem a little pedantic; we created it with people who may not be very experienced with "hardware electronics" in mind. We hope it's useful to you!
Step 1: What You'll Need
- The Intel Edison board. Follow the quickstart guide to get it up and running.
-The stepper motor that comes with the Grove starter kit. This is a 5V stepper motor.
- The stepper motor controller that comes with the Grove starter kit; ours is version 1.4.
- Male-to-male jumper wires. You can muddle through without these, but they sure do make things a lot easier.
- Female-to-male jumper wires. The Grove starter kit comes with a few of these.
- 1 Female-to-female jumper. You can use any of the four-wire cables that come with the Grove kit.
- A breadboard. Again, not strictly necessary, but it makes things a lot easier!
- A 5V power supply. The one used in this Instructable is really a 5.5V power supply, which makes the stepper motor turn with authority! You can also use a regular USB cable.
- Wire cutters, to modify the power supply for use with the stepper motor.
- Wire strippers, also to modify the power supply
- Some solid-core wire so you can plug the power supply into the motor (we used 18AWG wire, but any small-ish wire will do)
- Solder (not strictly necessary, if you have enough tape!)
- A soldering iron (again, this is just to make things neater)
- Electrical tape
Step 2: Plug in the Motor
The stepper motor is controlled by the controller board, which is driven by the Edison. Plug the motor into the controller board.
Step 3: Ground the Controller
The controller needs to share a ground connection with the Edison. I find it easier to use a breadboard for this, since this ground will need to be shared with the motor's power supply. Connect the ground output from the Edison to the breadboard.
Step 4: Power the Controller
As with the ground, connect 5V from the Edison board to the breadboard for use with the controller.
Step 5: Wire Up the Controller
Here is where the male-female jumper wires are used. Take six of them and plug them into the controller board. Plug the ground pin on the controller board into ground on the breadboard, and plug the Vcc pin on the controller board into 5V on the breadboard.
Don't connect the Vm pin on the controller board yet -- we'll get to that later.
Next, connect the four input pins -- IN1, IN2, IN3, and IN4 -- into output pins 8, 9, 10, and 11 (respectively) on the Edison. The sample code uses these four pins, though I suppose you can use whichever pins you want! Just make sure they are plugged in in the correct order (i.e., do not plug IN1 into pin 9 on the Edison, or the motor will not turn).
Step 6: The Secret Sauce
While both the stepper motor controller and the motor itself run off 5V, the Edison board can only supply enough current to power the controller: it (probably) cannot also power the motor (this is why the controller board has a Vcc pin to power the electronics on the controller, and a Vm pin to power the motor). So, you will need to locate a suitable power supply that can deliver 5V and enough current to the motor.
This Instructable uses an old flip-phone charger. You can also use a standard USB cable, which carries 5V also.
Start by cutting one end off the charger, or USB cable, and stripping the wires.
Step 7: Prepare the Motor Power
Cut two lengths of solid-core wire and strip both ends. These will be the leads for the motor's power supply.
Connect the leads to the power supply leads which you stripped in the previous step. I used solder, but you may be dextrous enough to just twist them together.
Finally, wrap the connections in electrical tape, or some other covering.
Step 8: Power the Motor
The motor power supply and the controller board must share a common ground. Plug the power supply's ground wire into the same ground as the controller. This is where the breadboard comes in handy; otherwise you can twist the three connections together.
Don't plug the motor's 5V into the controller's 5V! They may not be at exactly the same 5V, and you wouldn't want a short. Instead, plug the motor's 5V directly into Vm on the controller board.
Step 9: Add the Code
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */ // Leave the above lines for propper jshinting //Type Node.js Here :)
var Uln200xa_lib = require('jsupm_uln200xa');
// Instantiate a Stepper motor on a ULN200XA Darlington Motor Driver
// This was tested with the Grove Geared Step Motor with Driver
// Instantiate a ULN2003XA stepper object
var myUln200xa_obj = new Uln200xa_lib.ULN200XA(4096, 8, 9, 10, 11);
// go clockwise to open
myUln200xa_obj.goForward = function()
myUln200xa_obj.setSpeed(5); // 5 RPMs
console.log("Rotating 1 revolution clockwise.");
// go counterclockwise to close
myUln200xa_obj.reverseDirection = function()
console.log("Rotating 1 revolution counter clockwise");
// Run ULN200xa driven stepper
// Turn clockwise 1 rotation, pause for 2 seconds, and then go counterclockwise for 1 rotation.
PhilipO27 made it!