2 Wire Unipolar Stepper Driver using ULN2003 + Arduino Code

Controlling stepper motors is a critical skill set for many physical computing, robitics and CNC projects as well as most electronics projects that include an element of motion. 

While there are many off the shelf solutions for controlling stepper motors that range from Arduino shields to hardened industrial controls, my preference is to learn from the ground up so that I can grasp the concepts rather than just plug and play.

Even though the controller I have put together today does not go to the extent of discrete transistors to control the stepper, it is "ground-up" enough for me. The controller circuit that I have put together below uses a ULN2003 Darlington Array IC wired up in a unique way that allows for only 2 wires from the microcontroller. 

 

More details on the schematics and stepper basics can be found Here

Unipolar stepping or stepper motors are very common in printers, scanners and other electronics so building a simple controller that can be interfaced with an arduino was very desirable to me.  

 

 

My next step is to solder a few of these circuits up on some proto-board and perhaps add some higher power mosfets on the outputs to allow control of bigger steppers.

 

Reference:  The code used on the arduino to drive this circuit comes from Tom Igoe's website is shown below if you would like to try this out for yourself.

/*

 

 Stepper Motor Controller
 language: Wiring/Arduino

 This program drives a unipolar or bipolar stepper motor.
 The motor is attached to digital pins 8 and 9 of the Arduino.

 The motor moves 100 steps in one direction, then 100 in the other.

 Created 11 Mar. 2007
 Modified 7 Apr. 2007
 by Tom Igoe

 */

// define the pins that the motor is attached to. You can use
// any digital I/O pins.

#include <Stepper.h>

#define motorSteps 200     // change this depending on the number of steps
                           // per revolution of your motor
#define motorPin1 8
#define motorPin2 9
#define ledPin 13

// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1,motorPin2); 

void setup() {
  // set the motor speed at 60 RPMS:
  myStepper.setSpeed(60);

  // Initialize the Serial port:
  Serial.begin(9600);

  // set up the LED pin:
  pinMode(ledPin, OUTPUT);
  // blink the LED:
  blink(3);
}

void loop() {
  // Step forward 100 steps:
  Serial.println("Forward");
  myStepper.step(100);
  delay(500);

  // Step backward 100 steps:
  Serial.println("Backward");
  myStepper.step(-100);
  delay(500); 

}

// Blink the reset LED:
void blink(int howManyTimes) {
  int i;
  for (i=0; i< howManyTimes; i++) {
    digitalWrite(ledPin, HIGH);
    delay(200);
    digitalWrite(ledPin, LOW);
    delay(200);
  }
}

 

Access: 

6 comments

<p>Images Re-sized at request of anonymous user.</p>

<p>Will it take a step and direction input?&nbsp; Slimming it down to just a atmega 168/328 (just the arduino microcontroller) and the current handling ULN2003 would make it interchangeable with the reprap stepper motor driver wouldn't it?&nbsp; Except for the current handling.</p>

<p>Unfortunately this set-up does not accept Step &amp;&nbsp;Direction. That could be achieved by adding a small Microprocessor to the circuit but at that point it would probably make more sense to use a stepper control IC&nbsp;that could provide other functionality such as half/micro-stepping.&nbsp; I have been looking at quite a few of these types of chips and hope to build up just such a driver soon. I&nbsp;think my next stepper project will be the L297/298 Stepper controller and Dual H-Bridge chip controller that will be intended to run Bipolar/Bifilar steppers.&nbsp; This unit should have the abiltiy to do step/direction. I&nbsp;think it will also handle higher current.</p>

<p>&nbsp;Hey Jeff,</p><p>I have the same stepper as you do, and some other 5 wire unipolar NMB steppers. Could you give me a hand identifying the wires of the stepper? If so, do you think this might be similar to other unipolar 5 wire NMB steppers? I also noticed you did not use a diode to connect common to the stepper ? why ?</p><p>Thanks your help would be much appreciated.&nbsp;</p><p>Kind regards , christo</p>

<p>&nbsp;Hey Jeff,&nbsp;</p><p>Maybe you will get this twice. I have the same stepper you used. Could you give me a hand identifying the wires for the stepper motor?, I am having some trouble with the datasheets. I wish to know which wire is what. &nbsp;Do you think this topology will be similar to other 5 wire unipolar NMB steppers? &nbsp;Thanks, I also noticed you didnt use a diode. Why?</p><p>Thanks a lot, kind regards christo</p>

<P>Hi Jeff,</P> <P>I have the same stepper but cant find a wire diagram in the datasheet. Can you give me some help with this? Would be great if you could.</P> <P>Kind regards.christo</P>