Stepper motor Control with Potentiometer and Arduino

Stepper motor Control with Potentiometer and Arduino (Last Updated On: February 25, 2019)

Introduction:

In this post we will learn about Stepper motor Control with Potentiometer and Arduino. Commercially, stepper motors are used in floppy disk drives, flatbed scanners, computer printers, plotters, slot machines, image scanners, compact disc drives, intelligent lighting, camera lenses, CNC machines and, more recently, in 3D printers.

Thus we will learn the basics about stepper motor and its applications. We will also be interfacing stepper motor with Arduino. The movement and rotating direction of stepper motor will be controlled using potentiometer.




What is Stepper Motor:

Stepper motor Control with Potentiometer & Arduino

A stepper motor or step motor or stepping motor is a brushless DC electric motor that divides a full rotation into a number of equal steps. The motor’s position can then be commanded to move and hold at one of these steps without any position sensor for feedback (an open-loop controller), as long as the motor is carefully sized to the application in respect to torque and speed.


Construction & Working of Stepper Motor:

The stepper motor is known by its property to convert a train of input pulses (typically square wave pulses) into a precisely defined increment in the shaft position. Each pulse moves the shaft through a fixed angle.

Stepper motor Control with Potentiometer & Arduino

Stepper motors effectively have multiple “toothed” electromagnets arranged around a central gear-shaped piece of iron. The electromagnets are energized by an external driver circuit or a micro controller. To make the motor shaft turn, first, one electromagnet is given power, which magnetically attracts the gear’s teeth. When the gear’s teeth are aligned to the first electromagnet, they are slightly offset from the next electromagnet. This means that when the next electromagnet is turned on and the first is turned off, the gear rotates slightly to align with the next one. From there the process is repeated. Each of those rotations is called a “step”, with an integer number of steps making a full rotation. In that way, the motor can be turned by a precise angle.


The circular arrangement of electromagnets is divided into groups, each group called a phase, and there is an equal number of electromagnets per group. The number of groups is chosen by the designer of the stepper motor. The electromagnets of each group are interleaved with the electromagnets of other groups to form a uniform pattern of arrangement. For example, if the stepper motor has two groups identified as A or B, and ten electromagnets in total, then the grouping pattern would be ABABABABAB.

Electromagnets within the same group are all energized together. Because of this, stepper motors with more phases typically have more wires (or leads) to control the motor.


Stepper motor Control with Potentiometer and Arduino:

Components Required:

For learning about Stepper motor Control with Potentiometer & Arduino we need following components:

1. Arduino UNO Board
2. ULN2003 Darlington Pair IC
3. 10K Potentiometer
4. Stepper Motor 28-BYJ48
5. Bread Board & Connecting wires

Circuit Diagram:

Stepper motor Control with Potentiometer & Arduino

Stepper Motor 28-BYJ48 Connection:

Stepper Motor 28-BYJ48 is a Unipolar motor with 5-lead coil arrangement. There are four coils which have to be energized in a particular sequence. The Red wires will be supplied with +5V and the remaining four wires will be pulled to ground for triggering the respective coil. We used Arduino board to energize these coils in a particular sequence and make the motor perform the required number of steps.

Stepper motor Control with Potentiometer & Arduino

Need of ULN2003 as Driver:

Stepper Motors operates with the help of driver IC. The reason is the controller requires high current for operation but the stepper motor alone will not be able to provide enough current from its I/O pins for the motor to operate. So with the application of ULN2003 as a driver module current is amplified.

Stepper motor Control with Potentiometer & Arduino


Steps Calculations:

There is need of calculations of steps before uploading code to Arduino board for Stepper motor Control with Potentiometer and Arduino

In Arduino we will be operating the motor in 4-step sequence so the stride angle calculation is necessary.

Stride Angle = 5.625°
Arduino Step Sequence = 4
Required Step Sequence = 8
Steps per Revolution = 5.625*2 = 11.25

Steps per revolution = 360/step angle= 360/11.25 = 32 steps per revolution.




Source Code/Program:

#include <Stepper.h> // Include the header file
#define STEPS 64

Stepper stepper(STEPS, 8, 10, 9, 11);

int Pv = 0;
int potV = 0;

void setup() {
Serial.begin(9600);
stepper.setSpeed(200);
}
void loop() {

potV = map(analogRead(A0),0,1024,0,360);
if (potV>Pv)
stepper.step(5);
if (potV<Pv)
stepper.step(-5);

Pv = potV;
Serial.println(Pv);
}

Video tutorial & Explanation:

Recommended For You

About the Author: Alex Newton

Ask A Question .......

Close