UniPolar and Bipolar Stepper Motors Speed and Position Control programming

Stepper Motor


Stepper Motors are used for precise positioning and that’s why they are used in Printers, CNC machines, CD ROMs, Robotics, Telescopes, toys and so on. There are mainly two types of Stepper motors

  1. UniPolar stepper Motors
  2. Bipolar stepper motors.

Unipolar  motors are further divided into two groups

  1. 5 wires UniPolar stepper motors
  2. 6 wires UniPolar stepper motors.

Bipolar motors come with 4 wires.

Regardless of the stepper motors type and size, the basic working concept of all stepper motors is exactly the same. In this guide, will teach you how to use the same programs to power all three stepper motors.

This post covers

  1. Constant speed and constant limits
  2. Variable speed and constant limits
  3. Precise manual positioning

The Amazon Purchase links are given below:

L298N motor driver: https://amzn.to/2Qprz68
12v UniPolar stepper motor: https://amzn.to/35aA8qB
CD ROM bipolar stepper motor: https://amzn.to/2Qa6lKN
24BYJ48 5V DC unipolar stepper motor: https://amzn.to/2Ffoel7
Arduino Uno: https://amzn.to/39aq6ZT
Mega 2560: https://amzn.to/2SszMsI
lm7805 Voltage Regulator: https://amzn.to/2ERYoTJ
330-ohm resistors pack: https://amzn.to/2Qj1Igg
female DC power jack socket: https://amzn.to/377Pg9M
470uf capacitors: https://amzn.to/2MrN3xR
5×7 cm Vero board: https://amzn.to/37b7KWO
female headers: https://amzn.to/350w6RE
connection wires: https://amzn.to/2MvOJXd
Super Starter kit for Beginners: https://amzn.to/398dliF
Jumper Wires: https://amzn.to/2SrnBwo
Bread Board: https://amzn.to/2MxV5FM
12v Adaptor: https://amzn.to/2MuOlZk
PCB plate: https://amzn.to/2MuwNMB
Variable Supply: https://amzn.to/39d0KdP
Digital Multimeter: https://amzn.to/34WbVoa
Vero Board / stripboard: https://amzn.to/39nL9Zg
Soldering iron kit: “best” You guys should definitely purchase this: https://amzn.to/2PVwexF
Solder wire: https://amzn.to/2QlOvTS
Wire Stripper: https://amzn.to/353tYJa
wirecutter: https://amzn.to/2tV2lFj
PCB small portable drill machine: https://amzn.to/2MvQqnx


Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Circuit Diagram:

Stepper Motor

This is the full circuit diagram, built in the 9.1.0 edition of cadsoft eagle. As I said earlier, the basic working concept of all stepper motors is exactly the same regardless of the type and size of the  motors. As you can see on the screen, the circuit diagram will remain the same for all 3 stepper motors. Like the stepper motor,

use less than 4amps, so that’s why chose to use the L298N motor engine. The L298N motor driver is essentially designed to control simple dc motors; used this motor driver to power the robot in my previous tutorials  Since the L298N motor driver has the ability to control dc motors at the same time, and since you know that stepper motor has wires, this means that the l298N motor diver can control the unipolar and bipolar stepper motor. Okay, there’s no connection between the through wires. The unipolar connection is the same as the l298 engine as the bipolar connection As you can see in the circuit diagram, the stepper motor’s four wires are connected to the out1, out2, out3 and out4. While the motor driver’s input pins are attached to Arduino’s Pin number 8, 9, 10, and 11.

By definition, the l298n motor driver pins come with the jumper caps, so make sure you remove the jumper caps and attach the allow pins to pin number 6 and pin number 7 of the Arduino.

J1 is the DC female power jack, where we attach the 12v or 5v external power supply and eventually link the L298N motor driver’s VCC to the Arduino’s 5volts.

Let me tell you again if you use stepper motors with current ratings in excess of 4amps then never use the motor driver l298N. Now let’s look at the L298N motor driver’s pinout.

L2989N Motor Driver Pinout:

Stepper Motor

This is the dual H bridge operator of the L298N. With a peak current of up to 2amps, it motor driver can be used to  power Dc motors with voltages between 5 and 35volts. Since this is a dual HBridge motor driver, the speed and direction of two DC motors can be controlled simultaneously.

Since you have wires in stepper motor, this means that we can use the L298N motor driver to power one stepper motor. The motor coil wires of UniPolar and BiPolar Stepper are attached to the OUT1, OUT2, OUT3, and OUT4.

Let’s look at the L298N module pinout now, this module has three terminal blocks, two-terminal blocks are marked with OUT1, OUT2, OUT3, and OUT4. 

This is where the Stepper Motor wires are connected.

Stepper Motor

It block is labelled with + 12v, GND, and + 5v. The external power supply is connected to the contacts of + 12v and GND. This doesn’t matter if we always connect 12 volts, it depends on the Stepper motor’s voltage level.

You can attach a 5 volt power supply to the + 12v and GND contacts if you are using a 5v Stepper motor. I will be using a 12-volt power supply and a 5-volt power supply in this article. The touch of + 5 volts is connected to the 5 volts of the Arduino.

Stepper Motor

As you can see, this motor driver also has some male headers and ENA, IN1, IN2, IN3, IN4, and ENB are clearly labeled. To allow both the engines, the ENA and the ENB are used. Jumper caps ensures all engines are permitted by default and the engines spin at full speed.

If the jumper caps are removed and the ENA and ENB pins connected to the Arduino PWM pins, the frequency of the motors can be controlled by modulation of the pulse width.

But we don’t use Pulse Width Modulation in this tutorial. We will only use the appropriate pins to turn the stepper motors on and off. In the circuit diagram, the relations are already clarified.

Stepper Motor Programming:

Stepper Motors Program 1:

Stepper Motors Program number 2:

Stepper Motors Program 3:

Watch Video Tutorial

Recommended For You

Leave a Reply

%d bloggers like this: