Stepper Motor with ULN2003 Driver

 Stepper motors are great motors for position control. They are a special type of brushless motors that divides a full rotation into a number of equal “steps”. They are usually found in desktop printers, 3D printers, CNC milling machines, and anything else that requires precise positioning control.

One of the inexpensive way to learn about stepper motors is to use 28BYJ-48 stepper motors. They usually come with a ULN2003 based driver board which makes them super easy to use.


The 28BYJ-48 is a 5-wire unipolar stepper motor that runs on 5 volts.

The interesting thing about this motor is that people have been using it in countless applications over the last few decades. It is used in air-conditioner, vending machines and many other applications.One of the best things about these motors is that they can be positioned accurately, one ‘step’ at a time.

The other advantage is that they are relatively precise in their movement and they are quite reliable since the motor does not use contact brushes.

28BYJ-48 Gear Reduction Ratio


In addition, the motor has a 1/64 reduction gear set. (Actually its 1/63.68395 but for most purposes 1/64 is a good enough approximation)

What this means is that there are actually 32*63.68395 steps per revolution = 2037.8864 ~ 2038 steps!

The ULN2003 Driver Board

The motor usually comes with a ULN2003 based driver board.

The ULN2003 is one of the most common motor driver ICs, consisting of an array of 7 Darlington transistor pairs, each pair is capable of driving loads of up to 500mA and 50V. Four out of seven pairs are used on this board.


The board has a connector that mates the motor wires perfectly which makes it very easy to connect the motor to the board. There are also connections for four control inputs as well as power supply connections.

The board has four LEDs that show activity on the four control input lines (to indicate stepping state). They provide a nice visual when stepping.

Wiring 28BYJ-48 Stepper Motor and ULN2003 Driver to Arduino

Now that we know everything about the motor, we can begin hooking it up to our Arduino!

Start by connecting the power supply up to the ULN2003 driver.Note that it is possible to directly power the stepper motor from the Arduino. However, this is not recommended; as the motor may induce electrical noise onto its power supply lines and this could damage the Arduino.

So, use a separate 5V power supply to power your stepper motors.

Next connect the ground from that power supply to the arduino’s ground. This is very important so that we establish the same voltage reference between the two.

Now connect the driver board’s IN1, IN2, IN3, IN4 to the Arduino digital pins 8, 9, 10, and 11 respectively.

Finally, hook the motor cable from the stepper motor up to the driver board.

When you’re done you should have something that looks similar to the illustration shown below.


Arduino Code

For our first experiment we will make use of the Arduino Stepper Library which comes packaged with your Arduino IDE.

The stepper library takes care of the stepping sequence and makes it straight forward to control a wide variety of stepper motors, both unipolar and bipolar.

//Includes the Arduino Stepper Library
#include <Stepper.h>

// Defines the number of steps per rotation
const int stepsPerRevolution = 2038;

// Creates an instance of stepper class
// Pins entered in sequence IN1-IN3-IN2-IN4 for proper step sequence
Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);

void setup() {
	// Nothing to do (Stepper Library sets pins as outputs)
}

void loop() {
	// Rotate CW slowly
	myStepper.setSpeed(100);
	myStepper.step(stepsPerRevolution);
	delay(1000);
	
	// Rotate CCW quickly
	myStepper.setSpeed(700);
	myStepper.step(-stepsPerRevolution);
	delay(1000);
}


Comments

Popular posts from this blog

Voice Record & Playback Module

GSM Sim800L

GPS