How to use the A4988 stepper motor driver with 28BYJ-48 Stepper motor

How to use the A4988 stepper motor driver with 28BYJ-48 Stepper motor

Hello and welcome back. In this tutorial, we will learn how to use the A4988 stepper motor driver step by step. For that, I used a 28BYJ-48 stepper motor. But you can use any bipolar stepper motor up to 2A output current per coil. Ex. NEMA 17, NEMA 23, and NEMA 34.

What is an A4988 stepper motor driver?

It’s mainly based on the A4988N motor driver chip and It’s a bipolar stepper motor driver. We can control up to 2A output current per coil stepper motor. The driver has a built-in translator which means it can take pulse signals from a microcontroller and convert them into the correct sequence of motor windings energization. This means that stepper motors can be easily controlled with just a few input signals. The A4988 can be used in 3D printers, CNC machines, robotics, and many other applications. And to use this stepper motor driver we need a microcontroller. I used the Arduino UNO board for that. Also, we must use the heat sink or any other cooling system. Because it uses the hot during operation.

How to use the A4988 stepper motor driver with 28BYJ-48 Stepper motor

Specifications of A4988 stepper driver

  • Microstepping: Full, 1/2, 1/4, 1/8 and 1/16
  • Output current: Adjustable up to 2A per coil
  • Input voltage: 8V to 35V
  • Output voltage: 2.5V to 5.0V (default 3.0V)
  • Thermal shutdown circuitry
  • Over-current protection
  • Cross-current protection
  • Low-power sleep mode

Pin diagram of this driver

How to use the A4988 stepper motor driver with 28BYJ-48 Stepper motor

  • EN — Active low input, when pulled LOW the A4988 driver is enabled.
  • MS1 / MS2 / MS3 — Microstep Selection Pins.

The A4988 stepper driver supports various micro-stepping modes. We can control smoother and more precise motion with your stepper motor using these modes. Microstepping is achieved by controlling the current to each coil of the stepper motor in a more gradual and precise way than traditional full-step or half-step modes. For that, you can use the table information below.

How to use the A4988 stepper motor driver with 28BYJ-48 Stepper motor
  • RST — Lively low input.
  • SLP — Active low input.
  • STEP — Input controls the micro-steps of the motor.
  • DIR — Input controls the spinning direction of the motor.
  • VMOT/GND — Power supply pins for the stepper motor. (8v – 35v)
  • 2B, 2A, 1B, 1A — Out put pins.
  • VDD / GND — Stepper driver power supply. (3v – 5.5v)

Ok, let’s see how to use it with an Arduino UNO board. The required components are given below.

Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

Step 1

Firstly, identify these components.

Step 2

Secondly, place the stepper driver on the breadboard. And then, connect the capacitor to VMOT and GND pins.

Step 3

Thirdly, let’s set the current limit.

What is the current limit potentiometer?

We can use this current limit potentiometer to set the maximum current that the driver will deliver to the stepper motor. This is important because exceeding the maximum current rating of a stepper motor can cause it to overheat and potentially fail. For that, we need to adjust the current sense resistor (RCS) on the driver board. Follow the instructions below for that. I used the 28BYJ-48 stepper motor. (5v / 240mA)

  • First, assemble the circuit as follows.
  • And then, provide an external 12v power supply to this circuit.
  • Now, measure the VREF voltage and set it to 0.096v. Use a multimeter for that. You can change this value using a small screwdriver. Also, you must remember to set the current limit according to the motor datasheet.
  • Ok, it’s ready for you. Now remove the power supply.

Step 4

Now, connect the “STEP” and “DIR” pins to the Arduino board. For that, use the circuit diagram below.

How to use the A4988 stepper motor driver with 28BYJ-48 Stepper motor

Step 5

And then, connect the Arduino board to the computer.

How to use the A4988 stepper motor driver with 28BYJ-48 Stepper motor
  • Now copy and paste the test code into the Arduino IDE.
// Define pin connections & motor's steps per revolution
const int dirPin = 2;
const int stepPin = 3;
const int stepsPerRevolution = 200;

void setup() {
  // Declare pins as Outputs
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
}
void loop() {
  // Set motor direction clockwise
  digitalWrite(dirPin, HIGH);

  // Spin motor slowly
  for (int x = 0; x < stepsPerRevolution; x++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(2000);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(2000);
  }
  delay(1000); // Wait a second

  // Set motor direction counterclockwise
  digitalWrite(dirPin, LOW);

  // Spin motor quickly
  for (int x = 0; x < stepsPerRevolution; x++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(1000);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(1000);
  }
  delay(1000); // Wait a second
}
  • Next, select the board and port. After, click the upload button.

Step 6

Now, reconnect the 12v power supply to the stepper motor driver. For that, use the circuit diagram above.

OK, now you can see the movements of the motor.

Step 7

Now, let’s try the second example.

  • First, include the “AccelStepper” library to the Arduino IDE.
  • Code and Circuit diagram — Download
  • And then, copy and paste the program below.
// Include the AccelStepper Library
#include <AccelStepper.h>

// Define pin connections
const int dirPin = 2;
const int stepPin = 3;

// Define motor interface type
#define motorInterfaceType 1

// Creates an instance
AccelStepper stepper(motorInterfaceType, stepPin, dirPin);

void setup() {
  // set the maximum speed, acceleration factor,
  // initial speed and the target position
  stepper.setMaxSpeed(1000);
  stepper.setAcceleration(50);
  stepper.setSpeed(400);
  stepper.moveTo(500);
}

void loop() {
  // Change direction once the motor reaches target position
  if (stepper.distanceToGo() == 0) 
    stepper.moveTo(-stepper.currentPosition());

  // Move the motor one step
  stepper.run();
}
  • After, select the board and port. Finally, click the upload button.

Now, you can see the movements of the motor and change these values and enjoy this tutorial. The full video guide is below. We hope to see you in the next tutorial or project.

How to use the A4988 stepper motor driver with 28BYJ-48 Stepper motor

How to use the A4988 stepper motor driver with 28BYJ-48 Stepper motor

Similar Posts

3 Comments

  1. Hi , Great Detail, One Question…
    The 28BYJ motor is wired as a traditional 4 phase motor with a common ground.
    to be able to use the A4988 did you need to first modify the motor ? to convert it into a true bipolar Stepper? (cutting Track on the Motor PCB)
    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *