Home ARDUINO Getting started with Arduino Uno Stepper motor 28BYj-48 and ULN2003 Driver Module

Getting started with Arduino Uno Stepper motor 28BYj-48 and ULN2003 Driver Module

0

Arduino stepper motorthe basis of precision robotics. Unlike engines of constant rotation, one turn of the “Stepper motor” consists of a set of micro-displacements, which are called steps.

In other words, we can turn the motor shaft exactly 90 degrees and lock it in this position. A coarse analog of an Arduino stepper motor is a servomotor.

Stepper motor apply where you need to very accurately dispense the movement of the actuator. The most obvious example is a robot manipulator.

In order for the mechanical arm to touch the desired point with the working tool, it is necessary that each of the nodes turn to a strictly specified angle. The error in a fraction of a degree at the base of the arm will result in a huge error on the effector.

Another well-known example is the CNC machine. Take the same 3D printer. For precise displacement of the print head, stepper motors are used.

In old drives, Stepper Motor was used to move the magnetic head. And in modern cameras, micro-miniature stepper motors move lenses in the lens.

arduino stepper motor arduino stepper motor arduino stepper motor

In this tutorial, we will use the Arduino Uno controller to launch the stepping motor 28BYj-48, which is popular among beginners in robotics. This miniature stepper has a built-in gearbox, which allows you to make very precise movements of the output shaft.

Unipolar stepper motor 28BYj-48

Wave mode

Stepper motors are unipolar and bipolar. In the first case, the electromagnetic coils of the engine are connected in such a way that we can generate a field of only one direction on them. The scheme of the unipolar engine is as follows.

The diagram shows the so-called wave mode of operation. At each step of the engine, we apply the voltage only to one coil in which a magnetic field arises. The part of the core closest to the rotor begins to act like the south pole of the magnet, as a result of which the rotor turns toward it with its north pole!

Related Post Beginners guide for Arduino UNO

Full step mode

Obviously, if we connect two adjacent coils at the same time, the magnetic field acting on the rotor will be stronger, thereby increasing the torque of the engine. This mode of operation of the unipolar engine is called full-step.

arduino stepper motor

Half step mode

Finally, we can combine the wave and full-step mode, getting a half-step mode of operation. In this mode, for one revolution of the rotor, the engine takes twice as many steps, thereby increasing the positioning accuracy. However, in this mode, the engine every second step has a reduced torque, which should not be forgotten!

It should be noted that in a real stepper motor, the rotor usually has more than 2 poles, and the coils can have a different configuration. For example, in our 28byj-48 motor, electromagnets are located not perpendicular to the rotor axis, but along it.

Depending on the design features, different stepper motors may have a different number of steps. So, our 28byj-48 motor takes 32 steps per rotor rotation. In addition, this motor has a built-in gear reducer with a very strange ratio of 63.68395: 1. With this gear motor in full-step mode gives about 2048 steps!

ULN2003 Unipolar Stepper Motor Driver

We cannot connect this motor directly to the controller since the current on its windings can reach 160 mA, which is very much for the Arduino conclusions. To control the 28byj-48, we use a specialized chip ULN2003.

The driver board with ULN2003 might look like this:

arduino stepper motor

There are 7 pins for the microcontroller on the board: IN1..IN7, of which we will need only the first four. Five contacts for the engine, and two power contacts. There is also a jumper that breaks the motor supply circuit.

So Let’s Get started

Collect the Hardware

arduino stepper motor

 Make the wiring

Wire up the everything as I mention below, As a rule, the motor cable 28BYj-48 already has a connector with a key that is inserted into the board only in the correct position. Otherwise, when connecting, you must follow the color scheme (see figure). Contacts IN1..IN4 can be connected to any digital output of Arduino Uno.

arduino stepper motor

 

arduino stepper motor

Upload the source code

After wiring up the everything as I mention below in the diagram let’s upload the source code to the Arduino.

FULL-STEP MODE (FULL-STEP MODE)
STEP BLUE (A) PINK (B) YELLOW (A ‘) ORANGE (B ‘)
one one one 0 0
2 0 one one 0
3 0 0 one one
four one 0 0 one

 

Source Code

int in1 = 8;

int in2 = 9;

int in3 = 10;

int in4 = 11

const int dl = 11;

 

void setup () {

pinMode (in1, OUTPUT);

pinMode (in2, OUTPUT);

pinMode (in3, OUTPUT);

pinMode (in4, OUTPUT);

}

 

void loop () {

digitalWrite (in1, HIGH);

digitalWrite (in2, HIGH);

digitalWrite (in3, LOW);

digitalWrite (in4, LOW);

delay (dl);

 

digitalWrite (in1, LOW);

digitalWrite (in2, HIGH);

digitalWrite (in3, HIGH);

digitalWrite (in4, LOW);

delay (dl);

 

digitalWrite (in1, LOW);

digitalWrite (in2, LOW);

digitalWrite (in3, HIGH);

digitalWrite (in4, HIGH);

delay (dl);

 

digitalWrite (in1, HIGH);

digitalWrite (in2, LOW);

digitalWrite (in3, LOW);

digitalWrite (in4, HIGH);

delay (dl);

}

To make the engine move faster or slower, it will be necessary to change the variable dl. We can even increase the pause between commutations – the engine rotates more slowly. Reduce the pause – spinning faster.

Conclusion:

So, we got acquainted with the principle of operation of a unipolar stepper motor on the example of the popular model 28byj-48. Such motors are often used in amateur robotics, primarily because of its low price.

In tandem with the ULN2003 driver, the motor gives a small torque, which is enough except to create a small video camera’s guidance system or to create a pointer. However, there are methods that allow you to increase the characteristics of this motor, which will allow it to be used as a drive on wheeled robots and for creating various kinds of grippers. We will talk about the following articles in future content which is discussed in this paragraph.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

ten + 9 =