Introduction

A stepper motor is a component which transform an electric pulse to an angular movement.

We can find 3 types of motor:

variable reluctance motor
permanent magnet motor
hybrid motor, which is a combination of the two previous technologies

For this course, we will use a permanent magnet motor -> 28BYJ-48

The Stepper motors is not used for accurate angular position such as printer, scanner and hard drive…

Nevertheless, the stepper motor has many advantages. They are cheap and easy to use. It can stay in the position and turn without limit and change direction. This rotation can be controlled precisely.

What is the difference between the direct current motor, stepper motor and servo-motor?

There are different types of motors: direct current motors, stepper motor or servo-motor which have different qualities. We will see what is the used of each motors.

The servo-motor is a motor which turn at 180 degrees. That’s mean this motor can’t complete a tour on itself. It won’t be adapted for a project in which the motor has to complete a tour on itself such as a helicopter or a car for example. Nevertheless with a servo-motor, you can choose a precise angle like a stepper motor.

The direct current motor can complete a tour on itself. It will be useful to a helicopter project, or to move a car forward. Nevertheless you can’t control a direct current motor with an angular position. This motor is not useful for project that needs accuracy.

The stepper motor is the happy medium between the direct current motor and the servomotor. It has not the cons of the servo-motor, that mean it can complete a tour on itself. Furthermore it can be controlled with an accurate angle, not like a direct current motor. Nevertheless the stepper motor can’t run at high speed.

Which component to use?

In this course we will use the permanent magnet motor: 28BYJ-48.

This a 5V motor, that mean we don’t need an external power supply. Nevertheless some motors need a power supply of 12V.

The h bridge included with your stepper motor:

Use a stepper motor with a library

 

 

For the sketch, we can’t show it here but the two wires of power has be separate by two pins with the wire + close to the resistors and the wire – in the other side.

A library exists to control the movement of the stepper motor: Stepper.h. But it’s also possible to control it without a library.

Use a stepper motor without a library

We will see now a program to use a stepper motor without a library. You have some commentaries in the program to see what you have to change.

In the program without library you have more line to add to your program to make it work.

For the sketch of the circuit, its the same circuit as the program with library.

Use a stepper motor with a motorshield card

We will see now how to control a stepper motor with a motorshield card.

This is the program to use the stepper motor without a library. In fact, the motorshield card doesn’t need the library to control the stepper motor.

 

 

 

This is the sketch of the circuit.

As you can see, you don’t need to use the red pin.

Control the speed of the stepper motor

1. Problem with voltage threshold

With the direct current motor, you can use a potentiometer to control its speed. Nevertheless it won’t be possible with the stepper motor because there is a h bridge that need a minimum of power to be turn on.


2. Control the speed in the program

One solution of the problem previously mentioned is to control the speed of the stepper motor in the program.

By resuming the first program, you have to modify one line:

You can change this number from 0 to 17.

0 is lowest speed and 17 is the quickest.