01183670

9
IEEE TRANSACTIONS ON EDUCATION, VOL. 46,NO. 1, FEBRUARY 2003 79 Development of a Real-Time Digital Control System With a Hardware-in-the-Loop Magnetic Levitation Device for Reinforcement of Controls Education Panayiotis S. Shiakolas, Member, IEEE, and Damrongrit Piyabongkarn Abstract—This paper discusses the development of a real-time digital control system with hardware in the loop (HIL) for mod- eling and controls education. This environment requires software tools by MathWorks, Inc. and a C++ compiler. The hardware tools include an off-the-shelf data acquisition card and the desired hard- ware to be controlled. The use of a single environment for dynamic system analysis, control law development, simulation evaluation, and final implementation on an HIL system has many educational advantages as compared to multienvironment settings. This host- target real-time environment is implemented and demonstrated by controlling a nonlinear, open-loop unstable, and time varying custom-built magnetic levitation device. The values of any param- eter (control law, reference trajectory) in the Simulink model can be changed dynamically on the host computer without recompiling the control code, and their effects are observed in real-time on the HIL system. This environment allows for extensive experimen- tation, development of linear and nonlinear controllers, and per- formance comparison with HIL as shown in the presented exam- ples. The educational features of this environment are presented throughout the paper and were verified in a class setting. Index Terms—Control education, magnetic levitation, MATLAB, real-time, simulink, xPC target. I. INTRODUCTION T HE use of a single environment for dynamic system anal- ysis, control law development, and simulation evaluation has many advantages as compared to multienvironment settings, especially in an educational setting where students are not re- quired to learn or familiarize themselves with a number of soft- ware tools, thus freeing up time for activities that reinforce the learning of the fundamental concepts presented. In addition, the use of hardware-in-the-loop (HIL) devices where one could ob- serve in real time the system response as a result of changes of reference trajectories or controller parameters would reinforce concepts presented in class. The combination of these two set- tings in an easy to setup environment and the use of the simu- lation software for control of the HIL device adds another level of understanding of the fundamental concepts. MATLAB by MathWorks, Inc. [1] is widely used in the dynamic system and controls analysis and simulation areas. MATLAB is the basic “engine” with add-on components called toolboxes. Simulink is a MATLAB add-on that provides a graphical user interface for model development and system simulation [2]. The Real Time Workshop, RTW, toolbox is Manuscript received December 4, 2001; revised April 16, 2002. The authors are with the Mechanical and Aerospace Engineering Department, University of Texas, Arlington, TX 76019 USA (e-mail [email protected]). Digital Object Identifier 10.1109/TE.2002.808268 capable of generating real time code for Simulink models [3]. The xPC Target toolbox allows access to input/output data directly from a compatible data acquisition card and generates, compiles, and creates real-time executable code for Simulink models without the user having to write low-level code [4]. These toolboxes enhance the capabilities of MATLAB not only in the digital prototyping arena but also in the HIL arena. MATLAB provides a unique environment where students could perform dynamic analysis, study and evaluate the simulated response of a system, implement, evaluate, and improve the performance of control laws in a simulated mode, and then easily port the developed controllers to hardware all within the same familiar interface. Being able to capture generated real-time data allows for analysis at a later time such as system identification or plotting. The result is an integrated environ- ment in which a student can perform rapid prototyping, system analysis, and implementation and verification of traditional and advanced control laws in a simulation environment. Finally with minor changes the student can easily generate real-time code. The real-time code is used to control a system in a HIL environment. The data generated by any component of the model, digital or hardware, can be displayed in real-time and/or saved for later use. A valuable teaching tool that enhances and reinforces learning and understanding of fundamental concepts presented in class is the ability to observe the HIL response in real-time because of changes in the reference input or control parameters and to explain the system behavior because of these changes. An environment similar to the one described above was im- plemented and demonstrated through the digital control of a magnetic levitation device. The host-target real-time environ- ment is implemented using MathWorks tools, a data acquisition board from National Instruments, and a Visual C++ compiler from Microsoft. The selected HIL is a custom-built magnetic levitation (maglev) system. The maglev system is chosen be- cause it is nonlinear, open-loop unstable, and time varying. The main components of the maglev system are an electromagnet, an infrared emitter/receiver (IR) pair for detecting the position of the ferromagnetic object, and a power transistor for powering the electromagnet. A literature survey on the use of experimental digital controllers focused on magnetic levitation devices will be presented. Then, the required tools will be introduced along with a discussion on the development and implementation of the digital controller and the available tools. Features and high- lights of this rapid prototyping environment will be presented 0018-9359/03$17.00 © 2003 IEEE

Upload: jacobo-javier-caceres-rodriguez

Post on 21-Jan-2016

14 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 01183670

IEEE TRANSACTIONS ON EDUCATION, VOL. 46, NO. 1, FEBRUARY 2003 79

Development of a Real-Time Digital Control SystemWith a Hardware-in-the-Loop Magnetic LevitationDevice for Reinforcement of Controls Education

Panayiotis S. Shiakolas, Member, IEEE,and Damrongrit Piyabongkarn

Abstract—This paper discusses the development of a real-timedigital control system with hardware in the loop (HIL) for mod-eling and controls education. This environment requires softwaretools by MathWorks, Inc. and a C++ compiler. The hardware toolsinclude an off-the-shelf data acquisition card and the desired hard-ware to be controlled. The use of a single environment for dynamicsystem analysis, control law development, simulation evaluation,and final implementation on an HIL system has many educationaladvantages as compared to multienvironment settings. This host-target real-time environment is implemented and demonstratedby controlling a nonlinear, open-loop unstable, and time varyingcustom-built magnetic levitation device. The values of any param-eter (control law, reference trajectory) in the Simulink model canbe changed dynamically on the host computer without recompilingthe control code, and their effects are observed in real-time onthe HIL system. This environment allows for extensive experimen-tation, development of linear and nonlinear controllers, and per-formance comparison with HIL as shown in the presented exam-ples. The educational features of this environment are presentedthroughout the paper and were verified in a class setting.

Index Terms—Control education, magnetic levitation,MATLAB, real-time, simulink, xPC target.

I. INTRODUCTION

T HE use of a single environment for dynamic system anal-ysis, control law development, and simulation evaluation

has many advantages as compared to multienvironment settings,especially in an educational setting where students are not re-quired to learn or familiarize themselves with a number of soft-ware tools, thus freeing up time for activities that reinforce thelearning of the fundamental concepts presented. In addition, theuse of hardware-in-the-loop (HIL) devices where one could ob-serve in real time the system response as a result of changes ofreference trajectories or controller parameters would reinforceconcepts presented in class. The combination of these two set-tings in an easy to setup environment and the use of the simu-lation software for control of the HIL device adds another levelof understanding of the fundamental concepts.

MATLAB by MathWorks, Inc. [1] is widely used in thedynamic system and controls analysis and simulation areas.MATLAB is the basic “engine” with add-on components calledtoolboxes. Simulink is a MATLAB add-on that provides agraphical user interface for model development and systemsimulation [2]. The Real Time Workshop, RTW, toolbox is

Manuscript received December 4, 2001; revised April 16, 2002.The authors are with the Mechanical and Aerospace Engineering Department,

University of Texas, Arlington, TX 76019 USA (e-mail [email protected]).Digital Object Identifier 10.1109/TE.2002.808268

capable of generating real time code for Simulink models [3].The xPC Target toolbox allows access to input/output datadirectly from a compatible data acquisition card and generates,compiles, and creates real-time executable code for Simulinkmodels without the user having to write low-level code [4].These toolboxes enhance the capabilities of MATLAB notonly in the digital prototyping arena but also in the HIL arena.MATLAB provides a unique environment where students couldperform dynamic analysis, study and evaluate the simulatedresponse of a system, implement, evaluate, and improve theperformance of control laws in a simulated mode, and theneasily port the developed controllers to hardware all withinthe same familiar interface. Being able to capture generatedreal-time data allows for analysis at a later time such as systemidentification or plotting. The result is an integrated environ-ment in which a student can perform rapid prototyping, systemanalysis, and implementation and verification of traditional andadvanced control laws in a simulation environment. Finallywith minor changes the student can easily generate real-timecode. The real-time code is used to control a system in a HILenvironment. The data generated by any component of themodel, digital or hardware, can be displayed in real-time and/orsaved for later use. A valuable teaching tool that enhances andreinforces learning and understanding of fundamental conceptspresented in class is the ability to observe the HIL response inreal-time because of changes in the reference input or controlparameters and to explain the system behavior because of thesechanges.

An environment similar to the one described above was im-plemented and demonstrated through the digital control of amagnetic levitation device. The host-target real-time environ-ment is implemented using MathWorks tools, a data acquisitionboard from National Instruments, and a Visual C++ compilerfrom Microsoft. The selected HIL is a custom-built magneticlevitation (maglev) system. The maglev system is chosen be-cause it is nonlinear, open-loop unstable, and time varying. Themain components of the maglev system are an electromagnet,an infrared emitter/receiver (IR) pair for detecting the positionof the ferromagnetic object, and a power transistor for poweringthe electromagnet.

A literature survey on the use of experimental digitalcontrollers focused on magnetic levitation devices will bepresented. Then, the required tools will be introduced alongwith a discussion on the development and implementation ofthe digital controller and the available tools. Features and high-lights of this rapid prototyping environment will be presented

0018-9359/03$17.00 © 2003 IEEE

Page 2: 01183670

80 IEEE TRANSACTIONS ON EDUCATION, VOL. 46, NO. 1, FEBRUARY 2003

Fig. 1. Host-target real-time control system architecture.

through experimental results. Finally, the educational aspectsand issues of the experiments to be performed, along with theuse of the hardware and software setups, will be presentedbased upon student assessment.

A. Literature Survey

The software suite by MathWorks Inc. is a well-establishedand proven platform for modeling and simulation. Mostengineering and science students get introduced to MATLABand the various toolboxes at an early stage of their collegecareer. It would be advantageous if MATLAB could providethe backbone for a rapid prototyping system according to[5]. Several researchers used the TMS320C31 digital signalprocessor (DSP) from Texas Instruments Inc., and RTWgenerated real-time code. DSPs are highly optimized for fastarithmetic, and can be used in developing very demandingand sophisticated control strategies, such as controllers[6]–[9]. However, the interface between the RTW generatedcode and the TMS320C31 must be manually performed usingcustom low-level programs in C or some other language. Ifthis custom interface is not performed, then custom softwaremust be written to provide a real-time shell for executing thecomplete controller on the hardware platform, and to maintainthe communication link between the host PC and the real-timeDSP controller. The HARTS software partially addresses thisneed by providing a custom link between the Simulink/RTWpackage and a specific DSP platform from Innovative Integra-tion Inc. [5].

The RTW environment provides for real-time operation usingpersonal computers and multifuction I/O boards. Advanced con-trol algorithms, such as sliding mode, , and neural general-ized predictive control for a maglev system, were implemented[8], [10]. The use of the RTW environment still required thedevelopment of custom interface programs for correct commu-nication with the multifunction I/O boards.

The Real-Time Windows Target (RTWT) could be used alongwith RTW, and provides for I/O interfacing, without requiringthe development of low-level interfacing programs. RTWT runsunder Microsoft Windows using only one computer. The gen-erated target application is executed at a higher priority (ring

0) where other windows applications are executed in the back-ground [4]. The RTWT environment was used for a maglevsystem [11].

Commercially available environments similar to the oneimplemented in this work are available from companies suchas Quanser, Educational Control Products (ECP), and dSpace.These systems still require MATLAB, Simulink, and RTWfrom MathWorks, and they are restricted to their own propri-etary interface boards. The Quanser system called WinCon is agraphical interface between the user, software, and hardwaremodules. WinCon requires the MathWorks products and VisualC++ in order to generate the real-time code from a Simulinkblock diagram. The software is a custom interface designedto interface with the Quanser MultiQ DAQ board [12]. ECPrequires the use of tools from MathWorks as well and interfaceswith its own proprietary hardware modules [13]. dSpace usesits own real-time interface implementation software to generateand then download the real-time code to specific dSpace boards[14].

II. SYSTEM DESCRIPTION

The software and hardware tools used in the development andimplementation of this educational environment for digital con-trol algorithm development and testing are discussed in this sec-tion. The overall host-target real-time control system architec-ture is shown in Fig. 1.

The main advantage of the combination of RTW and xPCTarget is that there is no need for the student to program acontroller or other components, such as DAQ board I/O, in alow-level programming language. This combination provides aunique and complete environment for prototyping, testing, anddeploying real-time digital controllers using standard hardwarecomponents. A desktop PC is used as a host computer run-ning the ubiquitous Windows operating system and other re-quired software tools. The model is developed in Simulink usingSimulink blocks, and then it is “built,” i.e., generates C code,compiles and generates a real-time executable to be downloadedto the host computer. A second desktop type PC system calledthe target is booted using an xPC boot floppy that loads the

Page 3: 01183670

SHIAKOLAS AND PIYABONGKARN: DEVELOPMENT OF A REAL-TIME DIGITAL CONTROL SYSTEM 81

xPC Target real-time kernel [4]. Subsequently, the generated ex-ecutable real-time code is downloaded to the target PC via theselected communication protocol without requiring the studentor the professor to write any low-level code. Then, the studentusing Simulink pull-down menus on the host initiates the com-munication of the model with the target and starts the real-timecode. The Simulink environment allows the user to experimentinteractively and in real-time by modifying any of the block pa-rameters in the model without the need to rebuild and re-down-load the model to the target.

The connection between the host and target computers is ac-complished either through serial (RS-232), or network (TCP/IP)communication. The communication interface must be definedduring the xPC setup process from within MATLAB since thecommunication protocol is required in creating the xPC bootfloppy for the target computer. In this paper, serial communi-cation was used since it is inexpensive, easy to install, alwaysavailable, and requires only a null modem cable. A DAQ cardprovides the interface between the target computer and the HILsystem. The xPC Target software supports and provides built-indrivers for many off-the-shelf industry standard DAQ interfacecards [4]. In this project, the PCI-6024E DAQ card by NationalInstruments [15] was used.

MathWorks, Inc. Tools: MATLAB is one of the popularmatrix-based math programs for scientists and engineers.RealTime Workshop (RTW) : The RTW is used to create ANSIC-code from the Simulink block diagram, to generate a make-file using an xPC Target template, and to create a target appli-cation. The target application is then downloaded to the targetcomputer and executed in real-time, without the need for thestudent to write any low-level or custom software.xPC Target:The xPC Target software is used in a dual PC, host-target, en-vironment. In this environment, a PC running the Windows op-erating system serves as the host with all the required software(MATLAB, Simulink, C-compiler, xPC, and RTW), to createmodels in Simulink, run simulations, and generate code. Thesecond PC, a standard AT compatible desktop, is the target. Thetarget is booted from the xPC boot floppy that is easily createdfrom within MATLAB on the host. When the target is booted,the generated code on the host is downloaded and executed inreal-time.

According to the MathWorks Inc. web page [16] and the xPCmanual [16], the xPC Target kernel runs only on PC compatiblesystems, and all it needs is the BIOS. When the BIOS is loaded,the target boot disk is searched for a bootable image (executable)that includes a 16-bit part and a 32-bit part. The 16-bit part runsfirst because the CPU is still in real mode, and switches the CPUto a 32-bit protected mode. Then, the 32-bit part runs and pre-pares the target PC for running the kernel, and finally starts thekernel. After the CPU switches to protected mode (32-bit), noneof the xPC Target components switch the CPU back to real mode(16-bit). When the kernel is loaded, the target PC does not makecalls to the BIOS or DOS functions, and all the resources on thetarget PC are addressed through I/O addresses. The real-timekernel activates the application loaded and waits to downloada target application from the host PC. The initialization codeof the target application reserves the remaining unused RAM asheap. The memory available for the heap is by default 4 MB less

Fig. 2. TargetScopedisplaying run information and four signals.

than the entire RAM installed (1 MB for the application and 3MB for the kernel). The largest part of the heap is set for signallogging. The model size, complexity, and target PC hardwarecharacteristics affect the maximum speed (minimum samplingtime) of execution. Small models could run with sample timesof s (100 MHz). For additional information or in depth ex-planation, the interested reader is referred to [16].

Full control of the target application and computer using theMATLAB command line interface and functions is provided tothe user through the xPC Target application. The RTW and xPCTarget support both the Microsoft Visual C/C++ and WatcomC/C++ compilers. In this project, the Microsoft Visual C++compiler was used.

Graphical display components calledscopescan be easily de-fined and controlled on both the host and target using the com-mand-line interface on the host. The scopes can display anysignal of the Simulink model. Multiple signals could be dis-played on a single scope for comparison purposes. An instanceof scopes on the target computer is shown in Fig. 2.

A. HIL Transition

When the control algorithm is developed and tested in a sim-ulated “virtual” environment, the transition to the HIL modeis easily performed. The block(s) describing the model of thephysical system are removed from the Simulink block diagramand replaced with DAQ blocks for the specific DAQ card in thetarget computer. The DAQ blocks represent the channels (I/Olines) of the board connected to physical sensors and other hard-ware components.

B. Software Tools Summary

A summary of the software tools used and their corre-sponding version as used in this project are MATLAB 5.3.1,Simulink 3.01, xPC Target 1.0, Real-Time Workshop 3.01, andMicrosoft Visual C++ 6.0.

C. Magnetic Levitation System – HIL

An attractive maglev device was chosen as the HIL for imple-menting and demonstrating this rapid prototyping environmentbecause it is nonlinear, open-loop unstable, and time varying.The basic principle of operation is that of applying and modu-lating the current to an electromagnet to keep a ferromagneticobject levitated. The object position is determined through a

Page 4: 01183670

82 IEEE TRANSACTIONS ON EDUCATION, VOL. 46, NO. 1, FEBRUARY 2003

Fig. 3. Maglev device and free body diagram.

TABLE IEXPLANATION OF VARIABLES IN MODELING EQUATION

sensor. The error between the actual and desired object posi-tion is used to modulate the current. The detailed operation andmodeling of maglev devices is beyond the scope of this paper,but ample references are available such as [7], [17], [18]. Themaglev device used in this paper is shown in Fig. 3. The systeminput is the current applied to the coil, and the output is thevoltage corresponding to the positionof the ball as shown inthe schematic in Fig. 3.

The traditional and extensively used model for an electro-magnet is that of a resistor in series with an inductor. This modelwas used in this analysis for identifying the dynamic equationsfor the system. The linearized open-loop system modeling equa-tion of this maglev device is shown in (1), and an explanation ofthe variables is given in Table I [19].

(1)

This maglev device was successfully controlled using theanalog, continuous time domain, lead-lag compensator shownin (2).

(2)

III. I MPLEMENTATION

In this section the implementation procedure and experi-mental results will be presented.

A. Digital Lead-Lag Controller and Simulink Block Diagram

The discrete controller is realized based on the continuoustime controller of (2) using the Tustin or bilinear transformationshown in (3)

(3)

where is the sampling rate. A sampling rate secwas used in this work, and it is used to obtain the equivalentdigital controller shown in (4)

(4)

B. Implementation of Simulink Block Diagram

A general Simulink block diagram for the xPC Targetbased prototyping environment is shown in Fig. 4. The maincomponents/blocks are the reference trajectory input, digitalcontroller, DAQ card interface block, and sensor gain. Thereference inputs are implemented using appropriate Simulinkblocks. The controller for xPC Target must be implemented indiscrete domain. The DAQ interface block pair is specific forthe DAQ card in the target computer. Auxiliary blocks, suchas position-to-voltage/voltage-to-position for the referencetrajectory or scopes for signal display, could also be defined.

One of the advantages of this environment is the capability touse the same software tools to perform control system analysis,design, and controller fine-tuning. Simulated responses usingthe Simulink model is shown in Fig. 5. When satisfactory perfor-mance is obtained in simulation, the Simulink block describingthe dynamics of the plant/hardware to be controlled is substi-tuted with a DAQ graphical interface block that defines the ap-propriate channels for sensor and other information for the HILsystem, and the continuous time with a digital controller for HILcontrol.

These substitutions result in an environment ready to con-trol the hardware and provide for real-time fine-tuning of thecontroller in order to meet the desired performance consideringthe effects of the disturbances and unmodeled dynamics or forexperimentation with other software parameters to demonstrateand reinforce learning of control fundamentals.

The Simulink block diagram implemented for HIL controlin this work is shown in Fig. 4. This diagram is used to buildthe model and then download it to the target PC. Once on thetarget, the maglev device is controlled, and experiments areperformed in real-time. Parameter changes are performed fromwithin Simulink, and their effect observed on the HIL device.

One of the important educational advantages of this environ-ment is the ability provided to the student to modify system pa-rameters on the host computer and observe their effect on thehardware dynamically in real-time without having to rebuildand redownload the target computer every time a parameter ischanged on the host. In the current experimental setup there

Page 5: 01183670

SHIAKOLAS AND PIYABONGKARN: DEVELOPMENT OF A REAL-TIME DIGITAL CONTROL SYSTEM 83

Fig. 4. A general simulink block diagram for xPC target.

Fig. 5. Simulated maglev responses in simulink.

are three reference trajectories: a step, a sinusoid, and a squarewave. The student could select any or combinations of the avail-able inputs on the host computer, modify any of their param-eters, and observe the hardware system behavior or responseplots in real-time. Any of the parameters of the inputs (ampli-tude or frequency) or of the controller could be modified, andtheir effects observed in real-time. Switching between the threeinputs or modifying any parameters do not require the model tobe rebuilt, recompiled, and redownloaded to the target, thus pro-viding an environment where experiments can be quickly per-formed by modifying controller or input parameters and theireffect on the performance of the HIL device immediately ob-served and studied.

C. Experimental Setup

The experimental setup requires two computers, a host and atarget. The host computer used in this project is a Pentium 166MHz with 64 MB RAM, running Windows 98 and the suite ofrequired software. The target computer is a Pentium 166 MHzwith 96 MB RAM and the DAQ card. The target computer is out-fitted with a hard drive and could be used as a regular computerwhen not used as the real-time controller. However, when em-ployed as the target computer, it is booted using a boot-disk thatloads the xPC Target real-time kernel. The host-target pair com-municates through a serial protocol using a null modem cable.The experimental hardware setup including the HIL maglev de-vice is shown in Fig. 6.

Page 6: 01183670

84 IEEE TRANSACTIONS ON EDUCATION, VOL. 46, NO. 1, FEBRUARY 2003

Fig. 6. Experimental setup – host-target PCs and maglev device.

The PCI-6024E DAQ card is the interface between the targetand components of the maglev device, such as the positionsensor and the power transistor. This card could be used toacquire other signals of interest from the system, such as thecurrent in the coil (measured as a voltage across a resistor). Theposition of the object is detected and measured using the IRsensor pair in analog mode. The control effort required to keepthe object levitated is calculated inside the Simulink diagramby the controller. This effort is converted to an analog signalusing the DAQ card and sent to the power transistor modulatingthe coil power.

IV. EXPERIMENTAL RESULTS

The operating point or offset is added as a reference inputto the system, and it is a function of the levitated object (ball)size, weight, or shape. The operating point for this experimentalsetup is at 14.8 mm below the coil. The values of the parame-ters of the reference input signals and control algorithms wereeasily modified in the Simulink diagram and the effects of thechanges observed in real-time on the scopes without rebuildingand redownloading the model to the target computer. The pa-rameter modifications in real-time were performed on the hostcomputer and immediately downloaded to the target computerthat controlled the HIL device, thus affecting the behavior of thesystem. The current Simulink diagram has three reference in-puts. The experiments consisted of switching between the threeinputs and modifying their respective characteristics. Experi-ments were conducted to demonstrate the features and capabili-ties of this prototyping environment using the lead-lag controlleras presented.

A. Step Reference Input

This experiment is used to verify the capability of modifyingthe input parameters and observing their effect in real-time. Thereference input was originally set at 14.7 mm. This referenceinput was changed, while the system was in operation, to 15.0mm and then to 15.25 mm. The reference input and the systemresponse are shown in Fig. 7(a). This figure is a live captureof the scope displayed on the host during the maglev systemoperation, and while data is exchanged between the host andtarget. The data displayed could also be saved for later analysis,such as plotting from the MATLAB command line as shown inFig. 7(b).

B. Sinusoidal Reference Input

A sine wave is characterized by amplitude and frequency. Theamplitude was changed to 0.2 and 0.4 mm (from the operatingpoint) with a frequency of 1 and 2 Hz. The response plots andthe tracking performance of the maglev system using these si-nusoidal reference inputs are shown in Fig. 8. The time scales inthese figures do not start from zero since the system was in op-eration when these modifications were performed. The trackingperformance indicates an error of approximately 0.05 mm, asdetected by the position sensor. The instructor explains to thestudents that this lead-lag controller is not the optimal controllerfor this HIL device since there are other effects, such as sensorresolution, disturbances, and unmodeled dynamics, which arenot considered in the controller design process. In addition, thediscussion for or by the students could address the effects of theamplitude and frequency of the reference signal on the systemperformance.

C. Square Wave Reference Input

A square wave is characterized by amplitude and frequency.The amplitude of the square wave was changed to 0.1 and 0.2mm (from the operating point) with a frequency of 1 and 2 Hz.The response plots and the tracking performance are shown inFig. 9. The discussion for or by the students can address the ef-fect of the amplitude and frequency on the system performance.It is observed that the system response depends on the magni-tude and frequency of the reference signal and the motion ofthe ball. The system response is different when the ball is com-manded to move against gravity (upwards) and pulled by themagnet as compared to the case when is commanded to movewith gravity (downwards).

D. xPC Target Observed Limitations

The experimentation with this environment identified alsolimitations for the xPC Target version 1.0. There was no pro-vision to use a MATLAB m-file as a block in the Simulink dia-gram. Thus, all the elements of a model, such as controller, con-verters, etc., must be implemented using Simulink blocks. Thislimitation could possibly make the implementation of complexor advanced control algorithms difficult. The other observedlimitation relates to the TargetScope, the scope displayed on thetarget computer. The ordinate-axis for each target scope did notshow the minimum and maximum numerical values so that theuser could better understand the displayed signals. Thus, anysignal displayed on the target provided qualitative information.Also, display and comparison of multiple signals on the samescope was qualitative as well. On the contrary, any scopes gener-ated on the host were showing ordinates with numerical values,thus a more quantitative comparison was possible.

E. Educational Experiments

The students were given three different diameter and weightferromagnetic balls as well as similar balls painted with differentcolors. The operating point for the electromagnetic system is afunction of the size and weight of the ball. The operating pointis defined using one ball. When the first ball is replaced withanother of different size and weight without performing any

Page 7: 01183670

SHIAKOLAS AND PIYABONGKARN: DEVELOPMENT OF A REAL-TIME DIGITAL CONTROL SYSTEM 85

Fig. 7. Tracking of step input changes. (a) Host scope interface plot capture. (b) MATLAB command line plot.

Fig. 8. Sine wave tracking and real-time amplitude and frequency modification.

changes on the controller, the student observes the performanceof the lead-lag controller if one considers the weight change asa change in the system parameters. Thus the concept of changesin the system output as the result of plant parameter changes areobserved, explained, and used for experimentation.

The coloring scheme is used to introduce the concepts ofunmodeled dynamics, especially in modeling the sensor. Thesensor has different characteristics depending on the color ofthe object being levitated. Thus changes in the sensor parame-ters are observed by levitating individual balls of same size but

different color. In addition, the students are provided the meansto model the sensor using the different colored balls. Then, theyeasily implement their models in the Simulink block diagramshown in Fig. 4 by modifying the values in the converters fromPosition to Voltage and Voltage to Position. These changes donot require the students to rebuild and re-download the newSimulink model but rather the changes immediately take effect.When the changes take place, the students experiment with thenew sensor model by comparing the system performance foreach colored ball and understanding sensor parameter changes.

Page 8: 01183670

86 IEEE TRANSACTIONS ON EDUCATION, VOL. 46, NO. 1, FEBRUARY 2003

Fig. 9. Square wave tracking and real-time amplitude and frequency modification.

The developed setup allows the students to easily save anysignal available in the Simulink diagram in MATLAB for lateruse, such as plotting as shown in Fig. 7(b). The students canbe introduced to the use of the MATLAB System IdentificationToolbox and then can perform system identification using col-lected experimental data and to compare the theoretical and ex-perimental transfer functions. The students can be required toidentify the sources of error and the reasons for the differencesbetween the two transfer functions.

The developed environment was used for the first time inteaching an Introductory Controls course. The students were ex-cited to have access to real hardware to evaluate their controllerdesigns, acquire data, and perform system identification. Also,the students indicated that they could do all their work usingonly one software package, allowing them to familiarize them-selves with the software and devote more time in understandingand learning the controls-related material rather than learningdifferent software packages.

V. CONCLUSION

An interactive real-time digital control system has been de-veloped, implemented, and demonstrated for educational pur-poses for modeling and controls courses. This environment was

implemented using off-the-shelf components, such as standardpersonal computers and data acquisition cards. The host-targetreal-time environment was implemented using the xPC Targetand other software tools from MathWorks in addition to a C++compiler. Some limitations of the xPC Target toolbox were ob-served.

The host-target environment provides for the implementationof control algorithms using Simulink blocks and allows for in-teractive real-time system monitoring. The interactive feature isuseful in an educational environment. A digital lead-lag con-troller was implemented using standard Simulink blocks. Allsystem parameters, such as controller gains, and reference in-puts, can be viewed and modified dynamically; their effects canbe observed on the HIL without having to rebuild and downloadthe new model to the target computer. The data for any signalavailable in the Simulink diagram or interfaced on the DAQ cardcan be observed and saved in MATLAB format for later use.

Another advantage of using MATLAB-based tools is theability to verify the controller operation before switching to theactual HIL. Simulations are performed to verify the designedcontroller operation by using a block for the transfer functionof the plant. Then, the plant transfer function block is removedand substituted with blocks that correspond to the DAQ card in

Page 9: 01183670

SHIAKOLAS AND PIYABONGKARN: DEVELOPMENT OF A REAL-TIME DIGITAL CONTROL SYSTEM 87

the target computer, and the appropriate channels are accessed.The use of a single environment for both Simulation and HILcontrol provides for quick experimentation and performancecomparison between real and simulated systems. The ease ofimplementing the lead-lag controller allows the students tofocus on the task of understanding, developing, and testing con-trol algorithms as comparing to learning and writing low-levelcontrol code in other software packages.

The use of the developed environment for teaching an Intro-ductory Controls course in this department excited the students.

REFERENCES

[1] Using MATLAB, MathWorks, Inc., MA, 1999.[2] Using Simulink, MathWorks, Inc., MA, 1999.[3] Real Time Workshop User’s Guide, MathWorks, Inc., MA, 1999.[4] xPC Target User’s Guide, MathWorks, Inc., MA, 1999.[5] A. W. Stylo and G. Diana, “An advanced real-time rese and teaching tool

for the design and analysis of control,” inIEEE Africon, vol. 1, 1999, pp.511–516.

[6] A. Barazzouk, A. Cheriti, and V. Rajagopalan, “Real-time implementa-tion of a rotor time-constant online estimation scheme,”Proc. 25th Ann.Conf. IEEE, vol. 2, pp. 927–932, 1999.

[7] S. A. Green, R. S. Hirsch, and K. C. Craig, “Magnetic levitation deviceas teaching aid for mechatronics at rensselaer,” inProc. ASME IMECEDynam. Syst. Contr. Division, 1995.

[8] A. M. Mohamed, B. Vestgaard, and I. Busch-Vishniac, “Real-time im-plementation of a robustH1 controller for a 2-DOF magnetic micro-levitation positioner,”ASME J. Dynam. Syst., Measure., Contr., vol. 117,pp. 637–640, Dec. 1995.

[9] J. Tang, “Real-time DC motor control using the MATLAB interfacedTMS320C31 digital signal processing starter kit (DSK),” inIEEE 1999Int. Conf. Power Electronics and Drive Systems, PEDS’99, Hong Kong,1999, pp. 321–326.

[10] D. Cho, Y. Kato, and D. Spilman, “Sliding mode and classical control ofmagnetic levitation system,”IEEE Contr. Syst. Mag., vol. 13, pp. 42–48,Feb 1993.

[11] M. Lairi and G. Bloch, “A neural network with minimal structure formaglev system modeling and control,” inIEEE Int. Symp. Intell. Con-trol/Intelligent Syst. Semiotics, Sept. 1999, pp. 40–45.

[12] (2000, Mar. 15). [Online]. Available: http://www.quanser.com

[13] (2000, Mar. 15). [Online]. Available: http://www.ecpsystems.com[14] (2000, Mar. 15). [Online]. Available: http:///www.dspaceinc.com[15] 6023E/6024E/6025E Families of DAQ Cards, National Instruments,

Austin, TX, 2000.[16] (2002, March). [Online]. Available: http://www.mathworks.com/ac-

cess/helpdesk/help/toolbox/xpc/xpc.shtml[17] K. Craig, T. Kurfess, and M. Nagurka, “Magnetic levitation testbed for

controls education,” inProc. ASME, Dynamic Systems and Control Di-vision, 1998.

[18] F. Zhang and K. Suyama, “H1 control of magnetic suspension system,”Proc. Third IEEE Conf. Control Applications, vol. 1, pp. 605–610, 1994.

[19] D. Piyabongkarn, “Digital control of a magnetic levitation systemthrough xPC-target real-time operating system: Classical, feedforwardand artificial neural network,” Master’s thesis, University of Texas,Arlington, 2000.

[20] S. A. Green and K. C. Craig, “Robust, digital, nonlinear control of mag-netic-levitation system,”Trans. ASME, vol. 120, no. 4, pp. 488–495,Dec. 1998.

Panayiotis S. Shiakolas(M’02) was born in Nicosia, Cyprus. He received theB.S. and M.S. degrees in mechanical engineering from the University of Texas,Austin, in 1986 and 1988, respectively, and the Ph.D. degree in 1992 from theUniversity of Texas, Arlington.

He joined the Mechanical and Aerospace Engineering Department of the Uni-versity of Texas at Arlington in 1996 and is currently an Assistant Professor. Hisresearch interests include robotics, manufacturing process automation, controls,and engineering education. He is currently expanding his research interests toinclude the manufacturing of biomicroelectromechanical systems (BioMEMS).

Dr. Shiakolas is a Member of ASME and SME.

Damrongrit Piyabongkarn received the B.Eng. degree in mechanical engi-neering from Chulalongkorn University, Bangkok, Thailand, in May 1996 andthe M.S. degree in mechanical engineering from the University of Texas at Ar-lington in 2000. He is currently pursuing the Ph.D. degree in mechanical en-gineering at the University of Minnesota-Twin Cities. His dissertation is titled“Development of a MEMS gyroscope for absolute angle measurement.”

His research interests include advanced controls, microelectromechanicalsystems, microgyroscopes, signal processing, and artificial neural networks.