1

member

Easy Basics: Project 004a 28 BYJ - 48 Stepper Motor, ULN2003 No library used

of Acoptex.com in UNO

Basics: Project 004a

Project name: 28 BYJ - 48 Stepper Motor, ULN2003 No library used

Attachments: sketch1  and sketch2

In this project, you needed these parts :

1.Aruduino Uno R3 (you can also use the other version of Arduino)

2.BYJ 48 Stepper Motor

3.Arduino IDE ( you can download it from here  )

4.Jumper cables

5.ULN2003 stepper motor driver board

General

Stepper motors, due to their unique design, can be controlled to a high degree of accuracy without any feedback mechanisms. The shaft of a stepper, mounted with a series of magnets, is controlled by a series of electromagnetic coils that are charged positively and negatively in a specific sequence, precisely moving it forward or backward in small "steps".

 
There are two types of steppers, unipolars and bipolars, and it is very important to know which type you are working with. In this experiment, we will use a unipolar stepper.
Arduino board or other MCUs cannot directly drive stepper motors. A driver circuit is necessary, so we use a stepper motor driver board to drive the stepper motor.

Stepper motors, due to their unique design, can be controlled to a high degree of accuracy without any feedback mechanisms. The shaft of a stepper, mounted with a series of magnets, is controlled by a series of electromagnetic coils that are charged positively and negatively in a specific sequence, precisely moving it forward or backward in small "steps". There are two types of steppers, unipolars and bipolars, and it is very important to know which type you are working with. In this experiment, we will use a unipolar stepper.Arduino board or other MCUs cannot directly drive stepper motors. A driver circuit is necessary, so we use a stepper motor driver board to drive the stepper motor.

In this project we will learn how to connect the stepper motor to Arduino board.

Understanding the stepper motors

A stepper motor is a motor controlled by a series of electromagnetic coils. The center shaft has a series of magnets mounted on it, and the coils surrounding the shaft are alternately given current or not, creating magnetic fields which repulse or attract the magnets on the shaft, causing the motor to rotate.

This design allows for very precise control of the motor: by proper pulsing, it can be turned in very accurate steps of set degree increments (for example, two-degree increments, half-degree increments, etc.). They are used in printers, disk drives, and other devices where precise positioning of the motor is necessary.

There are two basic types of stepper motors, unipolar steppers and bipolar steppers.

Unipolar Stepper Motors

The unipolar stepper motor has five or six wires and four coils (actually two coils divided by center connections on each coil). The center connections of the coils are tied together and used as the power connection. They are called unipolar steppers because power always comes in on this one pole.

The stepper motor is a four-phase one, which uses a unipolarity DC power supply. As long as you electrify all phase windings of the stepper motor by an appropriate timing sequence, you can make the motor rotate step by step. The schematic diagram of a four-phase reactive stepper motor is as shown below:

In the figure, in the middle of the motor is a rotor – a gear-shaped permanent magnet. Around the rotor, 0 to 5 are teeth. Then more outside, there are 8 magnetic poles, with each two opposite ones connected by coil winding. So they form four pairs from A to D, which is called a phase. It has four lead wires to be connected with switches SA, SB,SC, and SD. Therefore, the four phases are in parallel in the circuit, and the two magnetic poles in one phase are in series.

Here's how a 4-phase stepper motor works:

At the beginning, switch SB is power on, switch SA, SC, and SD is power off, andB-phase magnetic poles align with tooth 0 and 3 of the rotor. At the same time, tooth 1 and 4 generate staggered teeth with C- and D-phase poles. Tooth 2 and 5 generate staggered teeth with D- and A-phase poles. When switch SC is power on, switch SB, SA, and SD is power off, the rotor rotates under magnetic field of C-phase winding and that between tooth 1 and 4. Then tooth 1 and 4 align with the magnetic poles of C-phase winding. While tooth 0 and 3 generate staggered teeth with A- and B-phase poles, and tooth 2 and 5 generate staggered teeth with the magnetic poles of A- and D-phase poles. The similar situation goes on and on. Energize the A, B, C and D phases  in turn, and the rotor will rotate in the order of A, B, C and D. The four-phase stepper motor has three operating modes: single four-step, double four-step, and eight-step. The step angle for the single four-step and double four-step are the same, but the driving torque for the single four-step is smaller. The step angle of the eight-step is half that of the single four-step and double four-step. Thus, the eight-step operating mode can keep high driving torque and improve control accuracy. 

Bipolar stepper motors

The bipolar stepper motor usually has four wires coming out of it. Unlike unipolar steppers, bipolar steppers have no common center connection. They have two independent sets of coils instead. You can distinguish them from unipolar steppers by measuring the resistance between the wires. You should find two pairs of wires with equal resistance. If you’ve got the leads of your meter connected to two wires that are not connected (i.e. not attached to the same coil), you should see infinite resistance (or no continuity).

Like other motors, stepper motors require more power than a microcontroller can give them, so you’ll need a separate power supply for it. Ideally you’ll know the voltage from the manufacturer, but if not, get a variable DC power supply, apply the minimum voltage (hopefully 3V or so), apply voltage across two wires of a coil (e.g. 1 to 2 or 3 to 4) and slowly raise the voltage until the motor is difficult to turn. It is possible to damage a motor this way, so don’t go too far. Typical voltages for a stepper might be 5V, 9V, 12V, 24V. Higher than 24V is less common for small steppers, and frankly, above that level it’s best not to guess.

To control the stepper, apply voltage to each of the coils in a specific sequence. The sequence would go like this:

Step wire 1 wire 2 wire 3 wire 4
1 High low high low
2 low high high low
3 low high low high
4 high low low high

To control a unipolar stepper, you use a Darlington Transistor Array. The stepping sequence is as shown above. Wires 5 and 6 are wired to the supply voltage.

To control a bipolar stepper motor, you give the coils current using to the same steps as for a unipolar stepper motor. However, instead of using four coils, you use the both poles of the two coils, and reverse the polarity of the current.

The easiest way to reverse the polarity in the coils is to use a pair of H-bridges. The L293D dual H-bridge has two H-bridges in the chip, so it will work nicely for this purpose.

Once you have the motor stepping in one direction, stepping in the other direction is simply a matter of doing the steps in reverse order.

Knowing the position is a matter of knowing how many degrees per step, and counting the steps and multiplying by that many degrees. So for examples, if you have a 1.8-degree stepper, and it’s turned 200 steps, then it’s turned 1.8 x 200 degrees, or 360 degrees, or one full revolution.

Two-Wire Control

In every step of the sequence, two wires are always set to opposite polarities. Because of this, it’s possible to control steppers with only two wires instead of four, with a slightly more complex circuit. The stepping sequence is the same as it is for the two middle wires of the sequence above:

Step wire 1 wire 2
1 low high
2 high high
3 high low
4 low low

The circuits for two-wire stepping are as follows:

Unipolar stepper two-wire circuit:

Biolar stepper two-wire circuit:


Because both unipolar and bipolar stepper motors are controlled by the same stepping sequence, we can use the same microcontroller code to control either one. In the code examples below, connect either the Darlington transistor array (for unipolar steppers) or the dual H-bridge (for bipolar steppers) to the pins of your microcontroller as described in each example. There is a switch attached to the microcontroller as well. When the switch is high, the motor turns one direction. When it’s low, it turns the other direction.

We will use unipolar stepper motor 28 BYJ - 48 for this project and let it work in the eight-step mode.

There are many types of drivers - L293, ULN2003, A3967SLB and more. 

The 28BYJ-48 even comes with breakout using ULN2003 as a motor driver chip.

Datasheet can be found here.

Understanding the ULN2003 

To apply the motor in the circuit, a driver board needs to be used. Stepper Motor Driver-ULN2003 is a 7-channel inverter circuit. That is, when the input end is at high level, the output end of ULN2003 is at low level, and vice versa. If we supply high level to IN1, and low level to IN2, IN3 and IN4, then the output end OUT1 is at low level, and all the other output ends are at high level. So D1 lights up, switch SA  is power on, and the stepper motor rotates one step. The similar case repeats on and on. Therefore, just give the stepper motor a specific timing sequence, it will rotate step by step. The ULN2003 here is used to provide particular timing sequences for the stepper motor.

Signals and contacts stepper motor and ULN2003

Note: if you want to use L293 instead of ULN2003 you will need to leave Red wire No connection.

Wiring

The following table and picture shows the needed connections with the Arduino Uno.

Step by Step instruction

  1. Plug your Adruino Uno board into your PC and select the correct board and com port
  2. Verify and upload the the sketch to your Adruino Uno.
  3. You should see the rocker arm of the stepper motor spin clockwise and counterclockwise alternately. 
  4. See converion table below.

Summary

You have learnt how to connect to the Arduino baoard and use the stepper motor without library code just using logic based program.

Library:

  • No library required for this project

Sketch:

  • See attachment on the begining of this project description.


Other projects of Acoptex.com
Easy Raspberry basics: Project 26a Raspberry PI Zero W board - Enable SSH of Acoptex.com in Raspberry Pi Zero W 07-01-2019
Easy Raspberry basics: Project 24a Raspberry PI Zero W board - Apache web server of Acoptex.com in Raspberry Pi Zero W 05-01-2019

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 21-08-2017
Viewed: 1512 times