You are on page 1of 13

CSE-311B: Peripheral & Interfacing Lab

Lab Report: 05
Title of the experiment: Design & Implement
a circuit to control stepper motor using parallel port.
Submitted by
Nahida Sultana
Roll No:36
Jyoti Islam
Roll No:48
Kaniz Fatema Chowdhury
Roll No:66
Group:B
11th Batch

Submitted to
Ahsan Raja Chowdhury
Lecturer
Rumana Nazmul
Lecturer
Department of CSE
University of Dhaka
Prepared by
Jyoti Islam
Roll: 48
Title of the experiment: Design & implement a circuit to
control stepper motor using parallel port.

Objective: The objective of the experiment is to design and


implement a circuit which controls stepper motor using parallel port.
Stepper motors converts electrical pulses into discrete mechanical rotational
movements or steps. The motive of this experiment is to get familiar with
the stepper motor as well as controlling it. Actually for this experiment we
will use the 4-arrow key of the keyboard. By using the upper arrow key, we
can increase the speed of the motor. The down key motor will do the
reverse. Whenever we are pressing the left arrow key it will move
clockwise. If right-key is pressed then it will move anti-clockwise.

Introduction: Digital computers are often used to control different


devices for various purposes. In this experiment we are going to implement
a circuit to do such a thing. We have the purpose to design & implement a
circuit to control stepper motor using parallel port. For this, we design a
circuit using computer, stepper motor and 25 pin parallel cable; write
necessary code for driving the circuit and implement it. In the following
sections of this report we’ll describe the related theory, design strategies,
code, circuit and sample input/output of the experiment.

Theory: Stepper motor provides a means for precise positioning and


speed control without the use of feedback sensors. It was developed in the
early 1960's as a low cost alternative to position servo systems in the
emerging computer peripheral industry. The main advantage of stepper
motors is that they can achieve accurate position control without the
requirement for position feedback. In other words, they can run "open-loop",
which significantly reduces the cost of a position control system.

The basic operation of a stepper motor allows the shaft to move a precise
number of degrees each time a pulse of electricity is sent to the motor. Since
the shaft of the motor moves only the number of degrees that it was
designed for when each pulse is delivered, you can control the pulses that
are sent and control the positioning and speed. The rotor of the motor
produces torque from the interaction between the magnetic field in the stator

2
and rotor. The strength of the magnetic fields is proportional to the amount
of current sent to the stator and the number of turns in the windings. The
stepper motor uses the theory of operation for magnets to make the motor
shaft turn a precise distance when a pulse of electricity is provided. A
stepper motor is shown in
Fig.1.1.

Fig.1.1. A stepper motor.

You learned previously that like poles of a magnet repel and unlike poles
attract. Fig.1.2 shows a typical cross-sectional view of the rotor and stator of
a stepper motor. From this diagram you can see that the stator (stationary
winding) has four poles, and the rotor has six poles (three complete
magnets). The rotor will require 12 pulses of electricity to move the 12 steps
to make one complete revolution. Another way to say this is that the rotor
will move precisely 30° for each pulse of electricity that the motor receives.
The number of degrees the rotor will turn when a pulse of electricity is
delivered to the motor can be calculated by dividing the number of degrees
in one revolution of the shaft (360°) by the number of poles (north and
south) in the rotor. In this stepper motor 360° is divided by 12 to get 30°.

When no power is applied to the motor, the residual magnetism in the rotor
magnets will cause the rotor to detent or align one set of its magnetic poles
with the magnetic poles of one of the stator magnets. This means that the

3
rotor will have 12 possible detent positions. When the rotor is in a detent
position, it will have enough magnetic force to keep the shaft from moving
to the next position. This is what makes the rotor feel like it is clicking from
one position to the next as you rotate the rotor by hand with no power
applied.

When power is applied, it is directed to only one of the stator pairs of


windings, which will cause that winding pair to become a magnet. One of
the coils for the pair will become the north pole, and the other will become
the south pole. When this occurs, the stator coil that is the north pole will
attract the closest rotor tooth that has the opposite polarity, and the stator
coil that is the south pole will attract the closest rotor tooth that has the
opposite polarity. When current is flowing through these poles, the rotor will
now have a much stronger attraction to the stator winding, and the increased
torque is called holding torque.

Fig.1.2. The position of the six-pole rotor and four-pole


stator of a typical stepper motor.

By changing the current flow to the next stator winding, the magnetic field
will be changed 90°. The rotor will only move 30° before its magnetic fields
will again align with the change in the stator field. The magnetic field in the
stator is continually changed as the rotor moves through the 12 steps to
move a total of 360°. Figure 03 shows the position of the rotor changing as
the current supplied to the stator changes.

In Fig.1.3(a) you can see that when current is applied to the top and bottom
stator windings, they will become a magnet with the top part of the winding

4
being the north pole, and the bottom part of the winding being the south
pole.

Fig.1.3. Movement of the stepper motor rotor as current is pulsed to


the stator. (a) Current is applied to the top and bottom windings, so
the top winding is north, (b) Current is applied to left and right
windings, so the left winding is north, (c) Current is applied to the top
and bottom windings, so the bottom winding is north, (d) Current is
applied to the left and right windings so the right winding is north.

You should notice that this will cause the rotor to move a small amount so
that one of its south poles is aligned with the north stator pole (at the top),
and the opposite end of the rotor pole, which is the north pole, will align
with the south pole of the stator (at the bottom). A line is placed on the
south-pole piece that is located at the 12 o'clock position in Fig.1.3(a) so that
you can follow its movement as current is moved from one stator winding to
the next.

In Fig.1.3(b) current has been turned off to the top and bottom windings, and
current is now applied to the stator windings shown at the right and left sides
of the motor. When this occurs, the stator winding at the 3 o'clock position
will have the polarity for the south pole of the stator magnet, and the
winding at the 9 o'clock position will have the north-pole polarity. In this
condition, the next rotor pole that will be able to align with the stator
magnets is the next pole in the clockwise position to the previous pole. This

5
means that the rotor will only need to rotate 30° in the clockwise position
for this set of poles to align itself so that it attracts the stator poles.

In Fig.1.3(c) you can see that the top and bottom stator windings are again
energized, but this time the top winding is the south pole of the magnetic
field and the bottom winding is the north pole. This change in magnetic field
will cause the rotor to again move 30° in the clockwise position until its
poles will align with the top and bottom stator poles. You should notice that
the original rotor pole that was at the 12 o'clock position when the motor
first started has now moved three steps in the clockwise position.

In Fig.1.3(d) you can see that the two side stator windings are again
energized, but this time the winding at the 3 o'clock position is the north
pole. This change in polarity will cause the rotor to move another 30° in the
clockwise direction. You should notice that the rotor has moved four steps of
30° each, which means the rotor has moved a total of 120° from its original
position. This can be verified by the position of the rotor pole that has the
line on it, which is now pointing at the stator winding that is located in the 3
o'clock position.

Some characteristics of stepper motor are:

(01.) Low cost solution for position control.


(02.) Inherent "zero-following" error in servo systems.
(03.) Easy to interface to digital controllers.
(04.) Inherently high torque/position gain resulting in excellent holding
torque.
(05.) Limited holding torque available even when the motor is unpowered.
(06.) Heat is generated in the stator and is easy to remove.
(07.) Synchronous operation permits tight open-loop speed control.

Some applications of stepper motor:

We can use stepper motor in different sectors. We can use it in a floppy disk,
printer, tape reader, card reader, copy machine, plotters, and typewriters
(automatic). Credit card positioning is also an important example of stepper
motors application. We can use it in industrial purpose also. Silicon
processing, IC bonding are some common examples in industrial sector.
Stepper motor is also used in some machine like sewing machine, drilling
machine, grinding machine etc.

6
PNP

NPN

Fig.2.1 Symbols of n-p-n & p-n-p transistors.

When a third doped element is added to a crystal diode in such a way that
two p-n junctions are formed, the resulting device is known as a transistor. A
transistor consists of two p-n junctions formed by sandwiching either p-type
or n-type semiconductor between a pair of opposite types. Accordingly there
are two types of transistors, namely; n-p-n transistor & p-n-p transistor.
Fig.2.1 shows the symbol of n-p-n & p-n-p transistor. There are three
terminals for a transistor. These are emitter, connector & base. Transistors
are mechanically strong, have practically unlimited life, need no heating
power and can do some jobs better than vacuum tubes.

Another important thing for this experiment is a parallel port cable(Fig 2.1).

Fig. 2.1: DB-25 parallel port cable.


To control stepper motor we need to give control information to it. This is
passed to the motor by parallel port cable which is known as DB-25 male to
male parallel port cable . This cable has 25 pins in both sides. Pin 2 to 9 are
used as data pin, pin 18 to 25 are used as ground, pin 10 to 15 are used as
status port and pin 1,14,16 and 17 are used as control port.

7
As we know that there are two connectors but we should consider that the
both side should be male. We will have 13 pins on one side & 12 pins on
another side. This wire is mainly used for interfacing. Each of the pin has its
own function. We have described those in a table below:

Table 01 25-pin parallel port pin out details


Pin No. Function Pin No. Function
01 Strobe 14 Auto feed
02 Data 0 15 Error
03 Data 1 16 Init
04 Data 2 17 Select In
05 Data 3 18 Signal Ground
06 Data 4 19 Signal Ground
07 Data 5 20 Signal Ground
08 Data 6 21 Signal Ground
09 Data 7 22 Signal Ground
10 Acknowledge 23 Signal Ground
11 Busy 24 Signal Ground
12 Paper Empty 25 Signal Ground
13 Select

The connector side view of the cable is shown in Fig.2.2.

Fig.2.2 Connector side view of a 25-pin parallel port cable.

The pin configuration of the cable is shown in fig.2.3. To give input to the
circuit, we write a code where we call the function outportb( ) with 0x378
and the adjusted value.

8
Fig.2.3. Pin configuration of parallel port cable (DB 25 male).

The function outportb() has two parameters. One is the port number, another
is the value passed to the port. Here, we use 0x378 as port number. The
value changes according to the input. We use a delay loop to watch the
changes in motor rotation perfectly.

Design strategies: To design the circuit, first we draw the logic


diagram of the circuit, calculate the values to be passed to the stepper motor
to control it, write the code to drive the circuit and then implement it. The
circuit works as an interface between the computer and the motor. The
following sections describe the design strategies of the experiment.

Logic diagram: The logic diagram of the circuit is shown in fig.


3.1.

9
Fig.3.1.Logic diagram of the circuit.

Code: The code used for designing the circuit is as follows:


#include<stdio.h>
#include<conio.h>
#include<dos.h>

int main(void)
{
int i,d,s;
i=1;
d=1;
s=1000;
char ch;
while(!kbhit()){
if(kbhit( ))
{
ch=getche( );
if(ch= =’Q’)
break;
if(ch= =75)
d=0;
else if(ch= =77)
d=1;
else if(ch= =72)
s=s/10;
else if(ch= =80)
s=s*10;
}
else if(i= =16 && d= =1)
i=1;
else if(i= =16 && d= =0)
i=16;
outportb(888,i);
delay(s);
if(d= =1)
i=i*2;
if(d= =0)

10
i=i/2;
}
return 0;

Description of the experiment: In this section,


we’ll describe the necessary equipments for the experiment, the working
procedure of it and the sample input/output.

List of equipments: In this experiment, we use several


equipments. They are as follows:

1. Computer.
2. Trainer Board.
3. 25 pin Modem Cable (male to male).
4. One stepper motor.
5. Four resistors.
6. Four transistors.
7. Four diodes.
8. Wires.

Working procedure: Now we’ll describe the working procedure


of the experiment.

1. At first, we connect the 25 pin modem cable (male to male) with the
parallel port of the computer and the trainer board.

2. Then, we give power supply to the pc and trainer board. For this
experiment we use +12 volts as the working voltage. So, before starting
the experiment we have to adjust the trainer board to get the specific
voltage.

3. Then we connect the ground of the parallel port & the ground of the
trainer board & get a common ground to use in our experiment.

4. After that we connect one side of a resistor with the pin no. 2 of the
parallel port which is connected with the trainer board.

11
5. The other terminal of the resistor is being connected with the base
portion of the transistor. The emitter part is grounded.

6. The connector terminal of the n-p-n transistor is connected with the


positive terminal of the diode. Now there is an important question-How
will we recognize that which one terminal is the positive part & which
terminal is the negative part? Now if we observe the diode carefully- we
will see a thin white line surrounding the diode. So the terminal which is
near from the white line will be the negative portion & the other
terminal is the positive terminal.

7. The negative part of the diode is connected with the yellow wire of the
stepper motor. The emitter part is grounded.

8. Then we repeat the same procedure for the black, orange & brown wires
of the motor.

9. After that we use the upper arrow key (↑) to increase the speed of the
motor. The down arrow key (↓) is used for decreasing the speed of the
motor. The right arrow key (→) & the left arrow key (←) are used for
moving the motor clockwise & anti-clockwise respectively.

10. Since the stepper motor rotates in exact direction given from the arrows
and its speed is also changeable so the circuit is working perfectly.

Precautions: It was really very important for us to have a close


look at the following precautions for the successful implementation of our
designed circuit.

1. Faulty trainer board and breadboard should not be used.

2. All the pins of the parallel cable specially those of data port must
function properly.

3. The wires should be with sharp head. Loose wire connection should
be avoided. The connection should be given properly so that short
circuit can’t occur in the circuit.

12
4. The transistors, diodes and stepper motor should work properly.

5. The code should be error free and efficient to handle the circuit.

6. Overall, a careful visual inspection is needed when implementing the


circuit for avoiding all unexpected circumstances.

Discussion: Designing and implementing this circuit was really


very exciting for us. When designing the interface, we learn different
important things of controlling a device from a computer. We use parallel
port cable for this purpose and instantly controlled the rotation of the stepper
motor. Since, our designed circuit works properly, so it can be said that we
have completed our experiment successfully.

References: During designing and implementing this circuit, we


have taken help from some books and websites. They are listed below:

Related books:
1. Ronald J. Tocci, Neal S. Widmer; Digital Systems, Prentice Hall
International, Inc. Dave Garza; Eighth edition,2002

Related websites:
2. www. wikipedia.org

13

You might also like