How to Control 28BYJ-48 Stepper Motor With ULN2003 Driver and Arduino

by Rachana Jain in Circuits > Arduino

640 Views, 3 Favorites, 0 Comments

How to Control 28BYJ-48 Stepper Motor With ULN2003 Driver and Arduino

Controlling 28BYJ-48 stepper motor with ULN2003 and Arduino | Arduino Project

In this tutorial, we will learn how to control a 28BYJ-48 stepper motor using an Arduino and a ULN2003 driver module. The 28BYJ-48 stepper motor is a popular choice for projects because it is inexpensive and easy to control with the ULN2003 driver. The tutorial will cover the basics of stepper motors, the specific characteristics of the 28BYJ-48 motor, and how to interface it with an Arduino.

Supplies

  1. Arduino Uno
  2. 28BYJ-48 Stepper Motor
  3. ULN2003 Driver Module
  4. Jumper wires
  5. Breadboard (optional)

How Does a Stepper Motor Work?

Stepper motor working all steps.png

Stepper motors are a type of brushless DC electric motor that divides a full rotation into a number of equal steps. They are known for their ability to position precisely and repeatedly without the need for feedback systems. Each step moves the motor a fixed increment, allowing for precise control of angular position. Stepper motors are widely used in applications requiring precise motion control, such as 3D printers, CNC machines, and robotics.

A stepper motor operates by energizing a sequence of coils in a specific order, which creates a rotating magnetic field. The rotor, which is a permanent magnet or contains a magnetic material, follows this rotating magnetic field, resulting in a stepwise movement.

Modes of Operation in Stepper Motor

Full Step Mode (Single Phase ON) or Wave Stepping

In Full Step Mode (Single Phase ON), only one coil is energized at a time. This mode offers less torque but consumes less power and generates less heat. It’s suitable for applications where precision and smoothness of motion are not critical.

Full Step Mode (Two Phase ON)

In this mode, two coils are energized simultaneously, producing higher torque compared to the Single Phase ON mode. This mode is preferred in applications where torque is more critical than power consumption.

Half Step Mode

Half Step Mode alternates between energizing one coil and two coils. This effectively doubles the number of steps per revolution, resulting in smoother motion and higher resolution. However, the torque in half step mode is slightly lower than in the Full Step (Two Phase ON) mode.

Microstepping Mode

Microstepping divides each step into smaller steps by controlling the current through the coils with high precision. This mode provides the smoothest motion and highest resolution, but it requires more sophisticated control and generates more heat.

Introduction to 28BYJ-48 Stepper Motor

Stepper motor.jpg
28BYJ-48 Stepper Motor Pinout Configuration.jpg

The 28BYJ-48 stepper motor is a popular and versatile stepper motor widely used in various electronics and hobbyist projects. It is known for its compact size, low cost, and easy control, making it an ideal choice for applications that require precise positioning and controlled movements.


28BYJ-48 Stepper Motor Specifications

  • Rated Voltage: 5V DC
  • Number of Phases: 4
  • Stride Angle: 5.625°/64
  • Gear Reduction Ratio: 1/64
  • Insulated Resistance: 20MΩ (500V)


28BYJ-48 Stepper Motor Pinout

The 28BYJ-48 has five pins: four for the coil connections and one for the common connection. These pins are typically labeled as follows:

  1. Coil 1 (Blue wire)
  2. Coil 2 (Pink wire)
  3. Coil 3 (Yellow wire)
  4. Coil 4 (Orange wire)
  5. Common (Red wire)


What is the Gear Reduction Ratio?

The 28BYJ-48 stepper motor has a gear reduction ratio of 1/64, meaning that the motor’s shaft turns 1/64th of a revolution for each full revolution of the motor’s internal rotor. This high reduction ratio provides the motor with increased torque and finer control over the shaft position, making it ideal for applications requiring precise movements.

Understanding ULN2003 Stepper Motor Driver Module

Stepper Motor Driver ULN2003 Module Pinout.jpg

The ULN2003 stepper motor driver module is an essential component for controlling the 28BYJ-48 stepper motor. This module simplifies the process of interfacing the stepper motor with a microcontroller like the Arduino. 

ULN2003 Module Pinout

The ULN2003 module has a series of input pins, output pins, and power connections:

  1. IN1, IN2, IN3, IN4: Control inputs for the coils of the stepper motor.
  2. OUT1, OUT2, OUT3, OUT4: Outputs connected to the stepper motor coils.
  3. GND: Ground connection.
  4. VCC: Power supply connection (usually 5V).

Interfacing 28BYJ-48 Stepper Motor With Arduino Uno

Wiring-Diagram-for-Interfacing-28BYJ-48-stepper-motor-with-Arduino-UNO.png

Now, let’s interface the 28BYJ-48 stepper motor with an Arduino Uno using the ULN2003 driver module. To begin, connect the 28BYJ-48 stepper motor to the ULN2003 driver module. The motor comes with a 5-wire connector that plugs directly into the ULN2003 module.

Pin Connections between ULN2003 Driver and Arduino Uno

Next, connect the ULN2003 module to the Arduino Uno:

ULN2003 IN1 to Arduino Digital Pin 7

ULN2003 IN2 to Arduino Digital Pin 6

ULN2003 IN3 to Arduino Digital Pin 5

ULN2003 IN4 to Arduino Digital Pin 4

ULN2003 GND to Arduino GND

ULN2003 VCC to Arduino 5V

Arduino Code

In the following code, we will rotatethe stepper motor in the clockwise and anti-clockwise direction. 

#include <Stepper.h>

//define Input pins of the Motor
#define OUTPUT1 7 // Connected to the Blue coloured wire
#define OUTPUT2 6 // Connected to the Pink coloured wire
#define OUTPUT3 5 // Connected to the Yellow coloured wire
#define OUTPUT4 4 // Connected to the Orange coloured wire

// Define the number of steps per rotation
const int stepsPerRotation = 2048; // 28BYJ-48 has 2048 steps per rotation in full step mode as given in data sheet

// Initialize the stepper motor with the sequence of control pins OUTPUT1, OUTPUT3, OUTPUT2, IN4
// OUTPUT1 and OUTPUT3 are connected to one coil and OUTPUT2 and OUTPUT4 are connected to one Coil
Stepper myStepper(stepsPerRotation, OUTPUT1, OUTPUT3, OUTPUT2, OUTPUT4);
void setup() {
// Set the speed of the motor in RPM (adjust as needed)
myStepper.setSpeed(15); // 15 RPM
}

void loop() {
// Rotate in One Direction and complete one complete rotation i.e 2048 steps
myStepper.step(stepsPerRotation);
delay(1000); // Delay between rotations
// For Rotation in opposite direction provide the variable to the parameter with negative Sign
myStepper.step(-stepsPerRotation);
delay(1000); // Delay between rotations
}

Conclusion

In this tutorial, we covered the basics of stepper motors, the specific characteristics and pinout of the 28BYJ-48 stepper motor, and how to interface it with an Arduino using the ULN2003 driver module. We also explored different modes of operation for stepper motors and provided a step-by-step guide to control the 28BYJ-48 stepper motor using an Arduino.

By following this tutorial, you should now be able to integrate the 28BYJ-48 stepper motor into your projects, allowing for precise control of angular position and motion. Whether you're working on a simple hobby project or a more complex application, the 28BYJ-48 stepper motor and ULN2003 driver module provide a reliable and cost-effective solution for your stepper motor control needs.

Credits