You are on page 1of 3

International Journal of Computer Science & Communication Vol. 1, No. 1, January-June 2010, pp.

189-191

Microcontroller Based Clockwise/Anticlockwise Stepper Motor Controller Using


PC Keyboard Via Com Port
Mandeep Singh1, Rekha2 & Balwinder Singh3
Centre for Development of Advanced Computing (C-DAC), Mohali – 160071, India
1, 3

(A Scientific Society of Ministry of Communication and Information Technology, Govt. of India).


2
University Institute of Engg. & Technology (UIET), Panjab University, Chandigarh.
1
mandeep@cdacmohali.in, 2er.rekha@yahoo.co.in, 3balwinder@cdacmohali.in

ABSTRACT
Computer controlled stepper motors are one of the most versatile forms of positioning systems. Open loop control of
stepper motors suffers from a major disadvantage that the rotation of the rotor becomes oscillatory and unstable in
certain speed ranges. This paper presents the micro stepping technique which overcomes the problem of instability
and at the same time provides high accuracy for micro stepping applications. This technique improves electronically
resolution of the stepper motors and suppresses oscillations due to effects of mechanical resonance. This has greatly
enhanced its usefulness in modern control applications.
Keywords: Microcontroller, Step Sequence, Stepper Motor, Keil Compiler

1. INTRODUCTION 2. SYSTEM DESIGN


In most process applications the cost of the control The system is built around the Atmel’s (AT89c51) 8-bit
system is only a relatively small fraction of the total cost microcontroller. In this system a unipolar stepper motor
and the cost of the processor is only a fraction of the is used (which is used widely in all kinds of floppy drives
control system’s cost. Except in some isolated instances, and CD drives) as shown in Fig. 1 with following
there is not a large number of situations in which direct specifications: Maximum voltage: 5V DC, Step angle: 1.8
degree, Steps per revolution: 200. Unipolar stepping
replacement of control components with a single
motors with 5 or 6 wires are available and usually wired
microcontroller driven version will result in either
as shown in Fig. 2 with a center tap at terminal 1 and 2
substantial cost saving or significantly important on each of the two windings. In use, the center taps of
performance. the windings are typically wired to the positive supply
A large number of applications have been already and the two ends of each winding are alternately
done for a variety of unit applications, i.e. control of grounded to reverse the direction of the field provided
by that winding.
processes that do not interact strongly with other
processes. There are typically special purpose
applications for which single microcontroller system has
unique hardware and software. This application
describes the use of single microcontroller to control the
speed, direction and rotation angle of a stepper motor
by sending pulse sequences to the motor winding in
response to the control commands [1]. Commands
executed by the code in this application include: single
step the motor rotates in a clockwise or counterclockwise
direction (i. e. rotate the rotor through a certain number
of degrees) when the corresponding key is pressed from
the computer keyboard [1]. This is a general purpose
application for which a degree of adjustment or
programmability is required to meet the needs of specific Fig 1: Unipolar Stepper Motor
processes and their performances.
190 International Journal of Computer Science & Communication (IJCSC)

the coil is turned off. As ULN 2003 has inbuilt driver


circuit so it is preferred [5]. The 89c51 has two pins that
are used specifically for transferring and receiving data
serially. These pins are called TxD and RxD and are part
of Port 3 (P3.0 and P3.1). These pins are TTL compatible
and therefore require a line driver to make them RS232
compatible. One such converter is MAX232 that converts
RS232 voltage levels [2].
The 89c51 has two pins that are used specifically for
transferring and receiving data serially. These pins are
Fig 2: Unipolar Stepper Motor Coil
called TxD and RxD and are part of Port 3 (P3.0 and P3.1).
Fig. 3 shows Microcontroller (AT89c51) based circuit These pins are TTL compatible and therefore require a
which can control all the functions of stepper motor. line driver to make them RS232 compatible. One such
Crystal oscillator of frequency 11.0592 MHz is used to converter is MAX232 that converts RS232 voltage levels
produce clock frequency for the microcontroller. Pins 21 [2].
through 28 of U2 are connected to pins 1 through 4 of U3
as shown in Fig. 4 (Schematic Diagram). However the
89c51 lacks sufficient current to drive the stepper motor
windings, so driver ULN2003 (U3) is used to energize
the stator. Instead of ULN 2003 transistors can also be
used. If transistors are used as drivers, diodes should be
used to take care of inductive current generated when Fig 3. Functional Block Diagram

Fig 4: Schematic of Final Hardware

2.1. Clockwise/Anticlockwise Rotation coils are energized in clockwise and anticlockwise


Here, Unipolar stepper motor having 5 leads is used: 4 direction is given in table1.
leads representing the four stator windings and one for Table 1
centered-tapped leads. As the sequence of power is Full Step Sequence
applied to each stator winding the rotor will rotate. There Clockwise Rotation Anticlockwise Rotation
are several widely used sequences where each has a Wind Wind Wind Wind Wind Wind Wind Windi
different degree of precision. ing A ing B ing C ing D ing A ing B ing C ng D
1 0 0 1 0 0 1 1
2.2. Step Sequence 1 1 0 0 0 1 1 0
Stepper motors can be driven in two different patterns 0 1 1 0 1 1 0 0
or sequences [3]: 0 0 1 1 1 0 0 1

• Full Step Sequence; 2.2.2. Half Step Sequence


• Half Step Sequence. In Half Step Sequence motor, step angle reduces to half
the angle in full mode. So the angular resolution is also
2.2.1. Full Step Sequence increased i.e. it becomes double the angular resolution
In the full step sequence, two coils are energized at the in full mode. Also in half mode sequence the number of
same time and motor shaft rotates. The order in which steps gets doubled as that of full mode. Half mode is
Microcontroller Based Clockwise/Anticlockwise Stepper Motor Controller Using PC Keyboard Via Com Port 191

usually preferred over full mode. The sequence given in


table 2 is called 8 step switching sequence.
Table 2
Half Step Sequence
Clockwise rotation Anticlockwise rotation
Winding Winding Winding Winding Winding Winding Winding Winding
A B C D A B C D
1 0 0 1 0 0 0 1
1 0 0 0 0 0 1 1
1 1 0 0 0 0 1 0
0 1 0 0 0 1 1 0
0 1 1 0 0 1 0 0
0 0 1 0 1 1 0 0
0 0 1 1 1 0 0 0
0 0 0 1 1 0 0 1

3. SOFTWARE
The software program is written in assembly language
for AT89c51 and then compiled to hex file using Keil
compiler software. The compiled HEX program is then
burnt on AT89c51 chip. It works as per flow chart shown
in Fig. 5. Another program in ‘C’ language is used for
transmission of ASCII code of the key pressed from the
keyboard as shown in Fig. 6. ASCII code of the key Fig 6: Flow Chart for ‘C’ Program
pressed is then transmitted serially through serial port
(Com1) of computer and is received by the SBuffer 4. CONCLUSION
(SBuff) of microcontroller. The microcontroller checks the The implementation of microstepping for a standard
ASCII code of the key pressed from the computer. If the stepper motor is presented in this paper. The key feature
pressed key is ‘F’ then the microcontroller load step of this controller lies in its flexibility to provide for high
sequence to rotate stepper motor in clockwise direction position resolution operation of a given stepper motor
and if key pressed is ‘R’ then the microcontroller load control system. In the case of retrofitting an existing
step sequence to rotate the motor in anticlockwise standard stepper motor controller to a high position
direction. The RPM of the motor can also be increased or resolution controller, the technique presented here
decreased by changing the time delay. appears to be an excellent consideration. The controller
is capable of controlling multiple stepper motors
simultaneously with very precise resolution.

REFERENCES
[1] Baluta, G, “Microstepping Mode for Stepper Motor
Control”, IEEE International Symposium on Signals Circuits
and Systems, 2, pp.1-4, July 2007.
[2] Baluta, G. Coteata, M., “Precision Microstepping System
for Bipolar Stepper Motor Control”, IEEE International
Conference on Electrical Machines and Power Electronics,
pp. 291 – 296, Sept. 2007.
[3] Rusu, C. Szoke, E, “Embedded System Design for Field-
Oriented Stepper Motor Control”, IEEE International
Conference on Optimization of Electrical and Electronic
Equipment, pp. 63 – 68, May 2008.
[4] Rusu, C. Birou, I. Szoke, E, “Model Based Design
Controller for the Stepper Motor”, IEEE International
Conference on Automation, Quality and Testing, Robotics,
2, pp.175 – 179, May 2008.
[5] Mazidi Muhammad Ali, “The 8051 Microcontroller and
Embedded Systems”, Prentice Hall of India, New Delhi,
Fig 5: Flow Chart for Assembly Program India, pp. 492-507, Chap 17, 2007.