You are on page 1of 12

EXPERIMENT TITLE: To control the Speed of a Stepper Motor Using

Arduino IDE

OBJECTIVE: To examine the Speed Control of the Stepper Motor with


Arduino IDE

COMPONENTS:

 Arduino UNO
 28BYJ-48 stepper motor
 ULN2003 stepper controller
 Jumper wires
CIRCUIT DIAGRAM
PRINCIPLE OF OPERATION

Stepper motor is a particular types of dc motor that used every day in both
industrial and commercial application because of their low cost high reliability
high torque at low speed and simple, rugged construction that operate in almost
any environment.
Stepper Motors are brushless DC motors with the shaft attached to a series of
permanent magnets that control the shaft rotation to 32 equal steps. The shaft is
connected to a series of gears to reduce its speed and increases the torque of the
motor. In a 28BJY-48, these gears reduce the speed by a factor of 64. So the
motor shaft must rotate 32 times to get 1 full rotation of the shaft, which then
rotates 64 times to get 1 full revolution of the stepper motor.
Utilizing a ULN2003 driver and an Arduino UNO, or Arduino Pro-Mini,
provides precise timing, directional control, and power management for the
stepper.
There are two types of stepper motor configurations: the uni-polar and the bi-
polar. Each has specific attributes to consider when designing a device using
stepper motors.
In order for the stepper motor to move to the next step, reverse the current
through the electromagnets.
UNIPOLAR AND BIPOLAR STEPPER MOTORS
Each of the two basic configurations of the stepper motor, unipolar and bi-polar,
have specific differences that in the past were important due to the high cost of
switching transistors. Today, with low-cost Darlington pair transistors readily
available, the cost-benefit of a unipolar stepper motor has lost some of its early
appeals.
Each of the configurations above utilizes a rotating shaft made up of numerous
powerful permanent magnets.
Connect two transistors to each coil to control the current through the coil
windings.
By controlling the direction of current flow through the driving transistors, the
rotation of the stepper motor can be easily controlled.
“Half-step” and “full-step” are methods by which stepper motors control their
output. It configures the driving transistors slightly differently using two motors
simultaneously, as discussed in the bi-polar example. Half-step moves the
stepper half the distance but uses more power since you are using two motors,
or in the case of unipolar, you’re using the full capacity of both coils. The
benefit of half-step is that smaller steps give you more control, more accuracy,
and more torque. The disadvantage is that you are consuming more power than
you would in full-step.
A 28BYJ-48 Stepper Motor is configured to create a total of 32 full steps in one
revolution (32:1 ratio). It is then connected to a series of gears that further
reduces the speed and increases the torque (64:1 ratio). The motor must step 32
times for its shaft to rotate once and the shaft must then rotate 64 times for the
gear reduction to cause the stepper motor to rotate once.
ULN2003 STEPPER MOTOR DRIVER
The 28BYJ-48 Stepper Motor can draw up to 240 mA, considerably more than
what an Arduino can deliver through any of its ports. So, you will need some
sort of a driver to safely control the stepper motor. There are numerous ways to
create a driver starting with a simple transistor for each of the coils. This
solution would also require clamping diodes to protect the Arduino from the
inductive voltage induced from the coil.

There are prefabricated circuits that incorporate the ULN2003 integrated circuit.
You could also use just the ULN2003 integrated circuit rated at 500 mA at 50V
which is a little cheaper than the prefabricated PCB. Since the prefabricated
circuit board and the ULN2003 connections are nearly identical, for this tutorial
we will just use the integrated circuit.
PROCEDURES

Step 1: The circuit was build.

Step 2: Program was written.

Step 3: Then the program was compiled and uploaded to Arduino UNO board.

Step 4: The <Stepper.h> was the library that was used facilitates controlled of
the stepper motor followed by the creation of two variables:
stepsPerRevolution, and rpm.

Step 5: The stepper motor object was created using the library to reference the
specific stepper motor. In our example, we used “stepper1”, that’s why it has to
be Stepper stepper1 = Stepper (stepsPerRevolution, 4, 6, 5, 7); The function
uses 5 variables, the number of steps per revolution, as well as the 4 ports used
to connect the Arduino to the driver.

Step 6: For the setup () function, the Speed () was set, stepper1.setSpeed(rpm);
was used to indicate the speed of the motor’s shaft with the variable rpm set up
earlier.

For the loop () function, we used the step () function to indicate the total number
of steps in a revolution. Since the stepsPerRevolution variable was already set
up earlier, we used stepper1.step(stepsPerRevolution); followed by a delay (),
then reversed the direction of the stepper with the step() function again.
ARDUINO CODE

#include <Stepper.h>

const int stepsPerRevolution = 2040;

const int rpm = 6;

Stepper stepper1 = Stepper(stepsPerRevolution, 4, 6, 5, 7);

void setup() {

stepper1.setSpeed(rpm);

void loop() {

stepper1.step(stepsPerRevolution);

delay(100);

}
Program and Working Explanation:

I. The stepsPerRevolution will be set to 100, and the rpm to 1.


II. Then run the modified code while touching the stepper motor (it will
probably be warm to the touch). See if you can feel the steps as the
stepper turns. 100 steps at 1 rpm will cause the motor to move almost
imperceptibly, but you will feel the motor stepping.
III. Change the rpm to 20 and steps set to 2040 and try it again. You can
think of stepsPerRevolution as distance and rpm as speed.
IV. Try different variations of rpm and steps. RPM ranges from (1-16), Steps
range from (20 – 2040).

There are some issues with stepper motors like users have no options where to
set the stepper to begin without elaborate hardware additions. It will start at the
same spot where it has completed the last revolution. If you need to specify the
starting position, you should consider using a Servo Motor.
CONCLUSION

When precise control over the rotating shaft is needed, stepper motors are
employed. A good example would be a robotic arm that reaches out for a
component, picks it up, and places it exactly where it’s needed.

Stepper Motors are brushless DC motors with the shaft attached to a series of
permanent magnets that control the shaft rotation to 32 equal steps. The shaft is
connected to a series of gears to reduce its speed and increases the torque of the
motor. In a 28BJY-48, these gears reduce the speed by a factor of 64. So the
motor shaft must rotate 32 times to get 1 full rotation of the shaft, which then
rotates 64 times to get 1 full revolution of the stepper motor.

You might also like