Design of Intelligent Stepping Motor Control System

: According to the applications of stepping motor in industrial controlling fields, an intelligent control system is designed based on personal computer and single chip machine in this paper. The working principle and control mode of stepping motor are introduced firstly. Then, the hardware of single chip machine system is introduced; especially the crystal oscillator circuit, driving circuit, power circuit, LED display circuit, watchdog circuit and serial communication circuit are analyzed in details. Finally the software including motor controlling program, communication program and human-machine interface program are designed. The practice showed that the system has the characters of good performance and low cost, so it can be widely used in stepping motor controlling.


INTRODUCTION
Stepping motor is a kind of mechanical and electrical control device which convert electric pulse signal into a corresponding angular displacement or linear displacement.Stepper motors provide a means for precise positioning and speed control without the use of feedback sensors.It is widely used in many fields such as automatic control systems, electro-mechanics system, precision machinery and other fields (Benetta et al., 2012).The difference between stepper motor and the ordinary motor is the form of pulse driving, just for this characteristic, the stepper motor can combine with modern digital control technology easily (Xiang, 2008).Although the low-speed performance of stepping motor is worse than the closed-loop DC servo motor, it is simple and low cost (Meng and Li, 2006).Thus, with the development of digital technology and improvement of control technology, the stepper motor will be more widely used in many fields (Thulasiraman et al., 2010).
Because the traditionally made driver of stepping motor is complex and has poor portability, so, it is difficult to adapt to a number of occasions where requires higher intelligence.According to this problem, a design method of stepping motor control system is proposed based on SCM.It is realize through serial communication technology between PC and SCM to drive the motor.

CONTROL PRINCIPLE OF STEPPING MOTOR
Stepping motor is a pure digital control motor.When the stepping motor driver receives a pulse signal, it will finish a fixed angle rotation according to settings (Xu and Du, 2008).In order to achieve the purpose of precise positioning, a number of pulses can be controlled by setting the angular displacement.Meanwhile, by controlling the pulse frequency, the motor rotation speed and acceleration also can be regulated.The Stepping motor driver works according to the signal which is produce from single chip machine (Sousa et al., 2009).Take the three-phase reactive stepping motor as an example, its typical structure is shown in Fig. 1.The basic functions are as follows: • Control the commutation sequence: The stepper motor commutation order is in accordance with its working mode strictly.Commonly, we often called the course as impulse distribution (Zhang and Qian, 2006).For example, three-phase stepping motor works in Three-phase & six beats mode, the galvanization order is A-AB-B-BC-C-CA-A (Forward) or A-CA-C-CB-B-BA-A (Backward).The control pulses were strictly controlled in accordance with the order of A, B, C phase power.• Control the direction: If it is given positive sequence power commutation, the stepping motor turns forward.Otherwise, it rotates backward.• Control the speed: The stepping motor is turning according to the control of pulse.Less the interval of two impulses, faster the motor speed.So, the speed is determined by the pulse frequency.The speed regulation is realized by adjusting the impulse frequency deriving from the controller (Liu et al., 2007;Liu and Bi, 2007).

THE HARDWARE OF SYSTEM
The overall structure of system is mainly composed of PC, controller, the crystal oscillator circuit, driving circuit, power circuit, LED display circuit, watchdog circuit and serial communication circuit and stepping motor.Its structure diagram is shown in Fig. 2.
In the control processing, the commands are send from PC and transmit to SCM through communication circuit.Then, the SCM receives the commands to produce pulses for driving the stepping motor (Yang and Zhu, 2010).According to different commands, the stepping motor can realize the operation such as forward, backward, stopping, et al.

Microcontroller:
This system uses AT89C51 as MCU, it is an 8-bit CMOS microcontroller with the characters of 4 KB Flash/EEPROM, low-power and high performance.The on-chip Flash allows the program memory to be reprogrammed in-system or by an ordinary nonvolatile memory programmer.Atmel AT89C51 is a powerful microcomputer/microcontroller (as they are used inter-changeably) which provides a highly-flexible and cost-effective solution to many embedded control applications.When MCU receives a command from the PC, it will be calculated into the control pulse signal by the algorithm and outputted through I/O port to driving the stepper motor.

Crystal oscillator and resetting circuit:
In order to keep running, the minimum system of microcontroller at least contains a crystal oscillator and resetting circuit.The single-chip crystal oscillator signal is used to provide base-time of single-chip operation and the resetting operation is for initializing the microcontroller chip, making the device starts running from a defined initial state.In the microcontroller, there is a high-gain inverting amplifier.When connecting an external crystal between pins XTAL1 and XTAL2, it will constitute a self-excited oscillator and generate oscillation clock pulse.As shown in Fig. 3, the capacitors C1 and C2 is selecting 30 pF.The resetting circuit uses switch mode, when pushing and releasing the K1 button; the resetting operation will be done.

Clock circuit:
As shown in Fig. 4 the system has a special clock circuit by using a low power real time clock chip DS1302.

Display circuit:
The system uses 4-connected-LED to display data, which is driving with transistor S8550 and using dynamic scanning mode.The drive circuit is shown in Fig. 5.The data (BCD code) from higher 4 bits of P2 will be outputted to 7447, after decoding, it will drive the 7-segment LED digital module.The lower 4 bits of P2 will be sent to the common terminal of LED.

Watch-dog circuit:
System has a power-on reset circuit and a manual reset circuit to initialize the system power state when running from a status.Considering that the SCM will be interfered from the environment, the system microcontroller circuit added an external watchdog circuit.This watchdog circuit can reset SCM automatically following a system crash.In this system, we selected MAX813L as the key chip which is designed to supervise microprocessor activity and indicate when the system is not working properly.During normal operation, the microprocessor should repeatedly toggle the watchdog input before the selected watchdog timeout period elapses to indicate that the system is executing code properly.The circuit of watch dog is shown in Fig. 6.
Communication module: System using TI's MAX232 chip TTL level and RS-232 level converter circuit connections.The means of communication through the serial port will be measured from the message to the host computer.The system uses the RS-232 bus to achieve communications between the computer and ultrasonic rangefinder.As the SCM signal is TTL level, in order to realize level conversion, it is needed the conversion module MAX232.MAX232 is designed for RS-232 and V.28 communications in harsh environments.Each transmitter output and receiver input is protected against ±15 kV electrostatic discharge shocks, without latch up.Through serial communication, the measured distance information can be send to the host computer.The application circuit is shown in Fig. 7.

Driving circuit:
The control ports A, B and C of stepper motor are connected with P1.0, P1.1 and P1.2 of AT89C51, respectively, which are act on the base of transistor in order to driving the stepping motor directly.The function of power amplifier circuit is to realize the amplification of current and voltage so as to drive a stepping motor.In order to increase the working flexibility of the stepper motor, when a key is pressed, the external interrupt generation is set to achieve the purpose of flexible control.The drive circuit is shown in Fig. 8.
In the stepping motor system with single chip machine, the CP pulse frequency or commutation cycle is actually control the speed of the stepping motor (Masi et al., 2012).There are two ways can be used to control the speed of the stepper motor: one is delaying, another is timer.Delaying method is to call a time delay procedure after each reversing, when the time delay is executed, the reversing operation will be executed again.Then, this cycle can produce a certain frequency CP pulses, and delay time of delay subroutine and the reversing time of commutation process is CP pulse cycle.The method is simple, less resource, and can achieve only with software, so it can be used in this system.

SOFTWARE OF SYSTEM
The software of system is composed of three parts: stepping motor control program, communication program, and human-machine interface program.The details are as follows: Stepping motor control program: If the SCM sends a control pulse, stepper motor will turn a step correspondingly.If it is given positive sequence power commutation, the stepping motor turns forward.Otherwise, it rotates backward.
Turning forward: Turning backward: According to the wiring diagram in Fig. 3, then, the corresponding mathematical models of control are shown in Table 1.

Communication program:
In order to ensure the smooth flow of communication and improve data transmission reliability, the handshake protocol mechanism is needed before data transmission.The handshake protocol is as follows:  Before sending the data, the host machine sends characters P firstly, after waiting for the returning character Y, it determine whether the characters is Y.If it is so, that will proved that the communication circuit smoothing and it is a successful handshake.Otherwise the handshake is unsuccessful.After a successful handshake, host can send data to the slave machine.In the control system, because of the real-time ability, so the general way is using the serial interrupt communication.The communication flow chart is shown in Fig. 9.
Human-machine interface: In this system, the host computer interface is designed by using VB6.0, it makes the program simple, clear, and provides users with intuitive and friendly management platform.Users can realize real-time control of stepping motor through the management interface.There are two methods to realize the serial communication between the PC and SCM.One is Windows-API-based method, another is Active X-based method.In this system, we used MS Comm for the management and control.The interface is shown in Fig. 10.

CONCLUSION
In this paper, the SCM-based stepping motor control system has the advantages such as simple structure, low cost and easy to control.It is easily to realize the speed regulation and position control, reliably to achieve a variety of complete complex work.The practice proved that the stepping motor control system is reliable and flexible to control.To different types of stepper motor control, it is need not changing the hardware circuit, but only modifying the software to achieve a variety of control functions.So, it will be have broad application prospects.

Table 1 :
Control words