Vous êtes sur la page 1sur 6

2010 Conference on Control and Fault Tolerant Systems FrB3.

4
Nice, France, October 6-8, 2010

Remote Control of Stepper Motor via Web Server


Jasmin Velagic, Nedim Osmic, Semir Silajdzic, Tarik Terzimehic and Vedran Vajnberger

Abstract—This paper explains the whole process of a the gear's teeth to magnetically be attracted to
system design for the remote control of a stepper motor electromagnet's teeth. When the gear's teeth are thus aligned
via web server. For this purpose a hardware structure is to the first electromagnet, they are slightly offset from the
fully designed and implemented. Two types of next electromagnet. So when the next electromagnet is
communications were used to operate with the stepper turned on and the first is turned off, the gear rotates slightly
motor. The first is realized by serial RS-232 protocol and to align with the next one, and from there the process is
the second one uses TCP/IP protocol for remote control. repeated. Each of those slight rotations is called a "step"
The TCP/IP protocol provides communication between with an integer number of steps making a full rotation. In
server and client computers. The proposed control that way, the motor can be turned by a precise angle [13].
system is connected to the server. The main objective of This paper describes implementation of the proposed
this paper was to obtain a precise control of velocity or remote control of the stepper motor via web server (one
number of steps of the stepper motor. Validity and client). The realized system exhibits the following:
effectiveness of the used algorithm were verified through • implementation based on PIC16F877a microcontroller,
both simulations and experiments.
• adjustment of the velocity, number of steps and rotation
direction of the stepper motor,
I. INTRODUCTION
• precise control over RS-232 serial communication,

R EMOTE CONTROL is one of the best solutions for


managing inaccessible systems (telemanipulation in
medicine). Many researches have been made in the field of
• extension to remote control the whole system,
• data acquisition and transmission to confirm the proper
operation of the stepper motor using a GUI.
the remote control [1]-[4]. These researches have improved This paper is structured as follows. In section II whole
certain aspects of industry, medicine, military, etc. The data analysis of the system realization in accordance to the
benefits of remote control are numerous, such as operating previously specified requirements is described. Section III
in hazard environment, telemedicine, missile guidance etc. provides hardware description that was realized manually.
The most important characteristic is operating in real-time Section IV explains hardware programming. Section V
[5]-[7]. presents the experimental results.
Many applications in the field of medicine and industry
use different kinds of motor-based systems, especially II. PROBLEM ANALYSIS
stepper motors because of their wide-range of sufficient
The problem of realizing a system that remotely controls
characteristics. The stepper motor can be used as constant the stepper can be divided into several interconnected units
power devices with accurate positioning and fast response as shown in Fig. 1.
[8]-[12]. Stepper motors consists of multiple "toothed"
electromagnets ranged around a coil of iron. Those
electromagnets need to be stimulated by some kind of
external control unit, in our case a microcontroller. The
microcontroller provides electrical impulses which stimulate

Manuscript received May 14, 2010.


J. Velagic is with the Faculty of Electrical Engineering, Department of
Fig.1. Interconnected units.
Automatic Control and Electronics, Sarajevo, Bosnia and Herzegovina (phone:
+387 33 25 07 65; fax: +387 33 25 07 25; e-mail: jasmin.velagic@etf.unsa.ba).
N. Osmic is with the Faculty of Electrical Engineering, Department of To understand the problem and its solution a brief
Automatic Control and Electronics, Sarajevo, Bosnia and Herzegovina (phone: description of each part will be provided in the rest of this
+387 61 24 87 05; email: nosmic2000@yahoo.com). section.
S. Silajdzic is with the Faculty of Electrical Engineering, Department of
Automatic Control and Electronics, Sarajevo, Bosnia and Herzegovina A. Control via Microcontroller
(phone: +387 61 22 51 49; e-mail: semir987@gmail.com).
T. Terzimehic is with the Faculty of Electrical Engineering, Department of The Microchip microcontroller PIC16F877a © generates
Automatic Control and Electronics, Sarajevo, Bosnia and Herzegovina impulses on four pins that are used to stimulate the
(phone: +387 61 36 79 87; e-mail: tarik.terzimehic@gmail.com).
V. Vajnberger is with the Faculty of Electrical Engineering, Department of movement of the stepper motor gear as shown in Fig 2.
Automatic Control and Electronics, Sarajevo, Bosnia and Herzegovina The impulses (U1÷U4) and a response in Fig. 2 show the
(phone: +387 61 81 23 93; e-mail: vvajnberger@gmail.com).
movement of the stepper in one direction by four steps. Each
step corresponds with one triggering impulse.

978-1-4244-8154-5/10/$26.00 ©2010 IEEE 910


communication between the server PC and the
microcontroller is realized using second m-function called
“send”. It has five input arguments: send(s1, message1,
message2, message3, message4). The first input argument is
the name of a created serial port object. Other arguments are
one-byte values that are sent to the microcontroller. Those
values represent desired mode of operation (velocity or
positional mode), direction of rotation, velocity and number
of steps (available only in positional mode). The first bit of
message1 is start bit (1 for start of rotation and 0 for stop).
The second bit represents desired mode of operation (1 for
velocity and 0 for positional mode). The third bit determines
Fig. 2. Triggering impulses and gear response. direction of rotation. The last five bits of message1, together
with message2, represent desired velocity (13 bits for
If they are reversed (U4-U1), the movement of the motor velocity). Message3 and message4 are low and high bytes of
is in the opposite direction. The length of the triggering desired number of steps. The last m-file ends the serial port
impulses depends on desired velocity. The width between session.
those impulses is infinitesimal. The shorter length of the
C. Remote Control via Web Server
triggering impulses is the higher velocity becomes; i.e. to
reach 60 RPM (revolutions per minute), the length of each Because MATLAB was used to send control commands to
triggering impulse needs to be 5 ms, to reach 120 RPM the microcontroller an additional toolbox called
length should be 2.5 ms. As earlier mentioned, besides TCP/UDP/IP was installed. This toolbox establishes a
connection between two computers (server and client) using
velocity control, there was the urge for exact positioning.
the TCP/IP protocol as shown in Fig. 4.
This task was realized by sending a certain amount of
triggering impulses in the correct order.
Even though stepper motors are used in open-looped
systems, because of their characteristics, in this case an
additional encoder was installed on the system. Its purpose is
to check does the stepper responses accurately to the given
commands, i.e. combination of impulses.
B. Control via RS-232
In this work the advantages of a microcontroller were
used to establish a communication with the server PC. The
used communication is the serial communication RS-232.
Serial communication is the most common low-level
protocol for communicating between two or more devices
[14], [15]. Texas Instruments MAX232 is used to make
adjustment between microcontroller’s TTL logic level (5V,
0V) and logic level for RS232 standard (-12V, +12V). An
example of the conversion is shown in Fig 3.

Fig 4. Established connection between server and client computers.

One of the computers is used as the server, while the other


one is used as client. The web server is established on the
server computer. All commands that control the stepper are
sent from the client computer. In the case of communication
breakdown, microcontroller stops stepper motor. On the
other hand, all feedback needed for acknowledgment of the
proper remote control i.e. did the stepper reached the desired
Fig. 3. Conversion TTL logic level into RS232 logic level. velocity or position, is send from the server to the client via
the established connection. All that was needed to establish a
The communication was established through MATLAB connection was provided in the additional toolbox using the
using three m-files. One m-file was written to create serial created m-files such as pnet, pnet_putvar and pnet_getvar
port object and to configure its properties. The [15]. Using the pnet m-file a handler called ‘con’ was

911
created. This handler was used in combination with m-files Microcontroller interprets those commands and generates
pnet_putvar and pnet_getvar to send the necessary data to trigger impulses on PORT D. These impulses are sent to
the connection and to collect that data from connection unipolar transistors which are combined to form a power
respectively. Two m-files were created (for host and client) amplifier. This power amplifier is directly connected to the
using these previously mentioned m-files. The required stepper motor. The stepper motor has an encoder disc
toolbox can be found in the references along with all mounted on its shaft. The encoder recognizes alterations
explanations for each m-file [15]. from encoder disc and sends them as impulses to the analog
For the establishment of correct remote control input on PIC. These impulses are used to determine proper
connection, first of all the connection between the work of the stepper motor. Fig. 7 represents the realized
system.
microcontroller and server need to be provided (RS232). The
next step is to setup the connection between server and client
(TCP/IP). If there is no connection between server and
client, stop command is active. After successful connection
between server and client, only correct messages are send
through the server, and there via RS232 to the
microcontroller and executed.

III. HARDWARE STRUCTURE


Fig. 5. shows the detailed hardware structure of the
proposed distributed system.

PROGRAMMER

SUPPLY
P COMMUNICATION Fig. 7. The realized stepper motor control system.

IV. HARDWARE PROGRAMMING


ANALOG
I
INPUTS
After making the hardware, the next step was to program
C TRIGGERING the circuit itself. The code is written in CCSC Compiler,
IMPULSES version 4, from manufacturer Custom Computer Services
TACT Inc. [16]. The structure of the software is shown in Fig. 8.
16F877A The user chooses mode of operation, desired direction of
rotation, velocity and number of steps using GUI (see Fig.
9). That information is collected into four 8-bits values and
Fig. 5. Block structure of the system. sends to server PC via ETHERNET. Server PC forwards
those messages to microcontroller using RS-232.
The device is a product of fully independent work. Microcontroller analyses received messages and sets/resets
Production implied the implementation of the entire appropriate bits according to select a mode, direction,
hardware circuit, and construction of work algorithm. Fig. 6 velocity and number of steps. In the main program, if
shows the most important components used in this hardware START bit is set, microcontroller generates appropriate
realization. sequence of triggering impulses based on chosen direction
and velocity. The width of one impulse is given by:

60000
Twidth = [ms ] (1)
RPM ⋅ 200
(b)
(a) Timer1 is set to appropriate value so it overflows every
100 ms and an interrupt is generated. In Timer1 Interrupt
(d) Service Routine microcontroller sends number of steps made
(c)
in last 100 ms to server PC via RS-232. Timer0 is used as
Fig. 6. Main components used for construction of the system (a) counter. Because the timer0 requires analog signals, output
PIC16F877a; (b) IRF639; (c) MAX 232; (d) Encoder.
from encoder is led to analog pin RA4/T0CKI. Timer0
The system is operated from the client’s computer GUI. The increments on every step. Client PC uses received
commands from host are sent through serial connection. information about number of steps made, calculate the

912
velocity and shows it on GUI. The similar GUI can be set at
the server and used in directly control of the stepper motor.

CLIENT PC

ETHERNET

SERVER PC

RS232

RECEIVE DATA
AVAILABLE
MICRCONTROLLER
INTERRUPT PIC16F877A
SERVICE ROUTINE

TIMER0
Fig. 9. Graphical user interface.
No INTERRUPT
Detect start
SERVICE
message '#' ?
ROUTINE The experimental verification of the proposed stepper
Yes
motor control will be demonstrated in the next section.
Read Timer0 value

Read other messages.


V. TESTING RESULTS
Reset Timer0
The effectiveness of the stepper motor control is rated by
Analyse messages and set/
the step velocity response to provide a trigger impulse from
reset appropriate bits
according to chosen mode,
microcontroller. The experimental results obtained by
Send number of
direction, velocity and
steps made in last aplying the step velocity exitation are shown in Figs. 10, 12
number of steps
100ms
and 14. The responses to a certain set velocity are shown in
Set/reset START bit Figs. 11, 13 and 15.

TIMER 1
COUNTER

MAIN PROGRAM
No
Is START
bit=1?

Yes D0
D1
Reset Timer0, Timer1
D2
D3
t

Generate appropriate
Different direction of rotation
sequence of 4 impluses.

D0 Fig. 10. Time response of the motor voltage (desired velocity = 30 RPM).
Yes D1
Is START bit=1 AND D2
total number of steps
< required D3

t
No

Send number of steps


In velocity mode of operation
only START bit is examined

ENCODER

Fig. 8. Schematic display of the software organization.


Fig. 11. Desired and actual velocities (desired velocity = 30 RPM).

913
As shown in Figs. 10, 12 and 14, the responses are almost
instant. The small deviation is the result of mechanical
characteristics of stepper motor. The noise in those figures is
caused by imperfection of the encoder and its disc. The
response signal collected from encoder is raised from logical
“0” (0.5 [V]) to logical “one” (4.75 [V]) within a short
period of time (see Figs. 10, 12 and 14).
Figures 11, 13 and 15 show various measurements of
desired and actual velocities. It can be seen that the actual
velocity follows the desired one. At certain moments there
are deviations of actual velocity. These deviations are caused
by restrictions of the used encoder. The shape of those
Fig. 12. Time response of the motor voltage (desired velocity = 60 RPM).
deviations is the result of linear approximation of the
characteristic.

VI. CONCLUSION
This paper presented the design of a remotely controlled
stepper motor via web server. An operating algorithm and
GUI were created for this purpose. Through the GUI user
can operate the motor in two modes: velocity and positional.
The feedback received from the encoder is sent through the
established connection from server to the client.
Experimental results demonstrate the effectiveness of the
remotely controlled stepper motor system.

REFERENCES
Fig. 13. Desired and actual velocities (desired velocity = 60 RPM). [1] T. B. Sheridan, “Space teleoperation through time delay review and
prognosis,” IEEE Transaction on Robotics and Automation, vol. 9, pp.
592-606, October 1993.
[2] C. Sayers, Remote Control Robotics, New York: Springer Verlag,
1996.
[3] J. Velagic, M. Coralic and M. Hebibovic, “The remote control of
robot manipulator for precise time-limited complex path tracking,” in
Proc. the IEEE International Conference on Mechatronics and
Robotics (MechRob2004), Volume 2, September 13-15, Aachen,
Germany, pp. 841-846
[4] D. Lee, and M.W. Spong, “Passive bilateral teleoperation with
constant time delay,” IEEE Transactions on Robotics and Automation,
vol. 22, no.2, pp. 269-281, April 2006.
[5] Vladimir Lucan, Petr Simacek, Jari Seppälä, Hannu Koivisto,
“Bluetooth and wireless LAN applicability for real-time control”,
September 2002.
[6] Xin Liu , Yongtian Wang , Yue Liu , Dongdong Weng, Xiaoming
Hu, “A remote control system based on real-time image processing”,
in Proc. 2009 Fifth International Conference on Image and Graphics,
Fig. 14. Time response of the motor voltage (desired velocity = 120 RPM). September 2009.
[7] Chui Yew Leong and Abdul Rahman Ramli, “Development of a real-
time embedded remote triggering and monitoring system with SC12,”
Intelligent Systems and Robotics Laboratory (ISRL), Institute Of
Advanced Technology, Universiti Putra Malaysia. 43400 Serdang,
Selangor. 2004.
[8] G. Srinivasarao and S. Sao, “Security system based on stepper motor
control using microcontroller”, November 2009.
[9] A. Altintas, ”A graphical user interface for programming stepper
motors used at different kinds of applications,” Mathematical and
Computational Applications, vol. 14, no. 2, pp. 139-146, 2009.
[10] F. Betin, D. Pinchon, and G.A. Capolino, “Fuzzy logic applied to
speed control of a stepping motor drive,” IEEE Transactions on
Industrial Electronics, June 2000.
[11] Jan B.A. Habraken, K. de Bruin, M. Shehata, J. Booij, R. Bennink, B.
L.F. van Eck Smit, and E.B. Sokole, “Evaluation of high-resolution
pinhole SPECT using a small rotating animal,” Journal of Nuclear
Medicine, vol. 42, no. pp. 1863-186, 2001.
Fig. 15. Desired and actual velocities (desired velocity = 120 RPM).

914
[12] F. Liu, Z. Hu, L. Qiu, C. Hui, C. Li, P. Zhong, and J. [14] Y. Wang, K. Yan, G. Sun, and P. Lou, “Serial communication in
Zhang, “Boosting high-intensity focused ultrasound-induced anti- DNC information systems”, The CIMS Center of NUAA, Nanjing
tumor immunity using a sparse-scan strategy that can more effectively 210016, China, Published by Moxa Technologies, January 2003.
promote dendritic cell maturation,” Journal of Translational [15] P. Rydesaeter, TCP/UDP/IP toolbox 2.0.6. user guide, March 2001.
Medicine, 2010. Available:http://www.mathworks.com/matlabcentral/fileexchange/345
[13] G. Liptak Bela, Instrument Engineers' Handbook: Process Control [16] CCS User guidance. Available: http://www.ccsinfo.com/
and Optimization. CRC Press, 2005.

915

Vous aimerez peut-être aussi