6
IEEE TRANSACTIONS ON EDUCATION, VOL. 48, NO. 1, FEBRUARY 2005 105 An Undergraduate Laboratory Course in Real-Time Dynamic Control Dong-Jin Lim, Member, IEEE Abstract—This paper describes a real-time control laboratory course for undergraduate students. To introduce the concept of real-time control with real-time programming in a feedback-con- trol laboratory course, a commercial software tool for a real-time operating system is adopted. Instead of using convenient graphical programming and automatic code generation methods, students in this course are required to write programs using C language to control and monitor analog dynamic simulators and experimental plants. Through step-by-step procedures, students are able to ac- quire the knowledge necessary for writing real-time programs to control dynamic systems. Index Terms—Dynamic control, laboratories, real-time control, real-time operating system, real-time programming. I. INTRODUCTION T EACHING an undergraduate feedback control laboratory course with real-time programming capabilities has gen- erally been considered difficult. However, the introduction of concepts of rapid prototyping and automatic code generation en- ables the students to perform feedback-control laboratory work without performing difficult real-time programming. One of the most popular tools for rapid prototyping is the Real-Time Work- shop from MathWorks, Inc. [1]. With this software tool, the direct coding of a real-time program can be replaced by an easy graphical programming method. Examples of laboratories that use automatic code generation can be found in the liter- ature [2]–[4], while in industry the number of companies that use rapid prototyping in the product-development process is in- creasing. However, although rapid prototyping and automatic code generation are becoming popular, the engineers involved in software development for real-time control must understand how the real-time program works, regardless of whether they will usually use rapid prototyping. Furthermore, students who are learning feedback control must learn how real-time pro- gramming is done. Using rapid prototyping tools such as the Real-Time Workshop enables students to do control laboratory work very easily, but these tools deprive students of a chance to learn real-time programming itself. In addition, many commercial laboratory devices for control system education come with Windows programs that have con- venient graphical user interfaces. With the software, students are required only to type in parameters and click button icons to run the system, without worrying about how to implement Manuscript received October 23, 2003; revised April 20, 2004. The author is with the School of Electrical Engineering and Computer Science, Hanyang University, Kyungki 426-791, Korea, South (e-mail: [email protected]). Digital Object Identifier 10.1109/TE.2004.837059 the controllers. Products from Feedback Instruments and ECP Systems are examples of such devices [5], [6]. Due to the soft- ware, which comes with the devices, students can concentrate on learning control theory and acquire needed real-world expe- rience in control systems. However, the problem with this kind of software is that it leaves little for the students to do; since the software performs all the detailed tasks needed to make the system work, students who are using the software do not need to know how the controller actually works or is implemented. Understanding how the control software is implemented is a big asset for today’s control engineers. In addition, con- trol system designers may be involved in the actual software coding needed to implement their designs. With advancing computer technology, the software for modern control systems is becoming more complex, and control engineers who want to design a good control system need to understand complex software issues. At the School of Electrical Engineering and Computer Sci- ence of Hanyang University, Ansan, Korea, offers the following sequence of courses in control systems: Sophomore: Systems Modeling; Junior: Control System Analysis & Design; Senior: Real-Time Control Laboratory, Digital Control. This paper describes the real-time control laboratory for senior students. Before taking this course, the students are required to take Control System Analysis & Design. In addition, the stu- dents are expected to have adequate C language programming skills. One of the objectives of the course is to teach students how to do real-time programming. Writing and debugging a program for real-time control is a very difficult task, especially when no appropriate tool is used. To minimize the program- ming burden for the students and to facilitate program devel- opment, a development environment based on a real-time op- erating system is adopted for the laboratory setup. Usually, a commercial real-time software tool is too expensive for most university programs. However, Hanyang University is partici- pating in the Wind River University Partner Program, through which the software is donated for educational purposes [7]. The objective of the proposed course is to teach the following items: 1) the concept and implementation of real-time data pro- cessing and monitoring; 2) how to implement dynamic control algorithms in soft- ware; 3) real-world control system experience; 4) development environments for advanced embedded sys- tems. Similar courses have adopted real-time operating systems at other institutions; however, they concentrate on real-time pro- gramming concepts, such as task scheduling and semaphores 0018-9359/$20.00 © 2005 IEEE

An undergraduate laboratory course in real-time dynamic control

Embed Size (px)

Citation preview

Page 1: An undergraduate laboratory course in real-time dynamic control

IEEE TRANSACTIONS ON EDUCATION, VOL. 48, NO. 1, FEBRUARY 2005 105

An Undergraduate Laboratory Course in Real-TimeDynamic Control

Dong-Jin Lim, Member, IEEE

Abstract—This paper describes a real-time control laboratorycourse for undergraduate students. To introduce the concept ofreal-time control with real-time programming in a feedback-con-trol laboratory course, a commercial software tool for a real-timeoperating system is adopted. Instead of using convenient graphicalprogramming and automatic code generation methods, students inthis course are required to write programs using C language tocontrol and monitor analog dynamic simulators and experimentalplants. Through step-by-step procedures, students are able to ac-quire the knowledge necessary for writing real-time programs tocontrol dynamic systems.

Index Terms—Dynamic control, laboratories, real-time control,real-time operating system, real-time programming.

I. INTRODUCTION

T EACHING an undergraduate feedback control laboratorycourse with real-time programming capabilities has gen-

erally been considered difficult. However, the introduction ofconcepts of rapid prototyping and automatic code generation en-ables the students to perform feedback-control laboratory workwithout performing difficult real-time programming. One of themost popular tools for rapid prototyping is the Real-Time Work-shop from MathWorks, Inc. [1]. With this software tool, thedirect coding of a real-time program can be replaced by aneasy graphical programming method. Examples of laboratoriesthat use automatic code generation can be found in the liter-ature [2]–[4], while in industry the number of companies thatuse rapid prototyping in the product-development process is in-creasing.

However, although rapid prototyping and automatic codegeneration are becoming popular, the engineers involved insoftware development for real-time control must understandhow the real-time program works, regardless of whether theywill usually use rapid prototyping. Furthermore, students whoare learning feedback control must learn how real-time pro-gramming is done. Using rapid prototyping tools such as theReal-Time Workshop enables students to do control laboratorywork very easily, but these tools deprive students of a chance tolearn real-time programming itself.

In addition, many commercial laboratory devices for controlsystem education come with Windows programs that have con-venient graphical user interfaces. With the software, studentsare required only to type in parameters and click button iconsto run the system, without worrying about how to implement

Manuscript received October 23, 2003; revised April 20, 2004.The author is with the School of Electrical Engineering and Computer

Science, Hanyang University, Kyungki 426-791, Korea, South (e-mail:[email protected]).

Digital Object Identifier 10.1109/TE.2004.837059

the controllers. Products from Feedback Instruments and ECPSystems are examples of such devices [5], [6]. Due to the soft-ware, which comes with the devices, students can concentrateon learning control theory and acquire needed real-world expe-rience in control systems. However, the problem with this kindof software is that it leaves little for the students to do; sincethe software performs all the detailed tasks needed to make thesystem work, students who are using the software do not needto know how the controller actually works or is implemented.

Understanding how the control software is implementedis a big asset for today’s control engineers. In addition, con-trol system designers may be involved in the actual softwarecoding needed to implement their designs. With advancingcomputer technology, the software for modern control systemsis becoming more complex, and control engineers who wantto design a good control system need to understand complexsoftware issues.

At the School of Electrical Engineering and Computer Sci-ence of Hanyang University, Ansan, Korea, offers the followingsequence of courses in control systems:

• Sophomore: Systems Modeling;• Junior: Control System Analysis & Design;• Senior: Real-Time Control Laboratory, Digital Control.

This paper describes the real-time control laboratory for seniorstudents. Before taking this course, the students are required totake Control System Analysis & Design. In addition, the stu-dents are expected to have adequate C language programmingskills. One of the objectives of the course is to teach studentshow to do real-time programming. Writing and debugging aprogram for real-time control is a very difficult task, especiallywhen no appropriate tool is used. To minimize the program-ming burden for the students and to facilitate program devel-opment, a development environment based on a real-time op-erating system is adopted for the laboratory setup. Usually, acommercial real-time software tool is too expensive for mostuniversity programs. However, Hanyang University is partici-pating in the Wind River University Partner Program, throughwhich the software is donated for educational purposes [7]. Theobjective of the proposed course is to teach the following items:

1) the concept and implementation of real-time data pro-cessing and monitoring;

2) how to implement dynamic control algorithms in soft-ware;

3) real-world control system experience;4) development environments for advanced embedded sys-

tems.Similar courses have adopted real-time operating systems atother institutions; however, they concentrate on real-time pro-gramming concepts, such as task scheduling and semaphores

0018-9359/$20.00 © 2005 IEEE

Page 2: An undergraduate laboratory course in real-time dynamic control

106 IEEE TRANSACTIONS ON EDUCATION, VOL. 48, NO. 1, FEBRUARY 2005

Fig. 1. Booting process for the real-time operating system.

Fig. 2. Downloading a program.

[8]–[10]. The course described in this paper deals with softwarefor controlling dynamic systems.

II. SOFTWARE DEVELOPMENT ENVIRONMENT

Each station is equipped with two Pentium personal com-puters (PCs): one is a host computer that is running a MicrosoftWindows operating system, and the other is the target computer.The host PC is used to develop the software, and the targetcomputer is used to control the plants. The real-time operatingsystem for the target computer is Wind River’s VxWorks [11].There is a board support package (BSP) of VxWorks for manycommercially available target boards; however, generic PentiumPCs were chosen for the target hardware. There are many ad-vantages in choosing Pentium PCs as the target. First, there isno need to build an input–output (I/O) hardware interface forthe target since many plug-in boards are available at reasonableprices on the market. In addition, Pentium PCs already have allthe resources to run a real-time operating system built in. More-over, they are an economical choice since older PCs can be ob-tained at no cost from PC laboratories. Although old PentiumPCs are too slow and do not have enough resources to run thenew Windows XP operating system, they are fast enough to runthe embedded real-time operating system.

The host PC runs Wind River’s Tornado, which is the inte-grated development environment (IDE) for VxWorks [12]. ThePCs are connected through Ethernet. The real-time operatingsystem kernel and the application object files are downloadedthrough an file transfer protocol (FTP). Fig. 1 shows the bootingprocess for the real-time operating system.

The kernel of VxWorks can be built to include the shell andtelnet server. After the kernel finishes booting, students can ac-cess the shell using the telnet client program running on the hostcomputer. Students have to write their application programs inC language and compile them on the host computer using theIDE. Then, they can download and execute their application pro-grams using the shell commands. Fig. 2 shows the downloadingprocess of an application program. Fig. 3 shows the shell screen.

Fig. 3. Screen capture of the shell.

The target computer is equipped with analog-to-digital (A/D)and digital-to-analog (D/A) converter boards for the I/O inter-face. To control the process, students must write the interrupt-driven software. If the students had to write the interrupt-drivensoftware from scratch, they would never be able to make it workwithin the scheduled laboratory hours. Thus, a program tem-plate whose pseudocode is shown in Fig. 4 is supplied.

The program template has a complete setup for handling in-terrupts and will run when it is compiled. However, the programwill not do anything but interrupt processing. Students must ana-lyze and understand the template to write their own control soft-ware.

Besides implementing a control algorithm, students are re-quired to write a portion of the program to monitor real-timedata. The client–server concept is used for real-time data mon-itoring. The server program runs on the host PC and draws areal-time graph using the data being transmitted from the targetPC through a TCP data stream. Fig. 5 shows the concept ofthe client-server model for real-time graphing. The transmissioncontrol protocol (TCP) message format is shown in Fig. 6.

The message is actually – data for plotting. The server pro-gram running on the host computer simply accepts data trans-mitted over a TCP socket and draws a graph on the screen. Fig. 7shows a screen capture of the graphing server program.

For the TCP data stream programming, students are also sup-plied with a template whose pseudocode is shown in Fig. 8.Since the VxWorks kernel can be built to include the networkcomponents for the TCP, the setup for the TCP data stream canbe accomplished by calling corresponding functions [13]. Thetemplate tells the students how to call the necessary functions.

The TCP template has a complete setup for a TCP socketconnection and sends sine-curve data over a TCP socket. Whenthe students compile and run this program template, they can seethat the sine curve is being drawn from the data transmitted fromthe target computer in real time. The students must decide where

Page 3: An undergraduate laboratory course in real-time dynamic control

LIM: AN UNDERGRADUATE LABORATORY COURSE IN REAL-TIME DYNAMIC CONTROL 107

Fig. 4. Pseudocode for the program template.

Fig. 5. Client–server model for real-time graphing.

Fig. 6. TCP message format.

and how to insert the TCP program section into their controlsoftware.

III. LABORATORY ASSIGNMENTS

To help students learn using a step-by-step procedure, labo-ratory assignments are divided into three parts.

Part 1: Real-time data processing:

Lab 1) Digital filter using the interrupt in DOS;Lab 2) Development environment for VxWorks: Tornado;Lab 3) Real-time data processing and monitoring;Lab 4) Second-order digital filter using the interrupt in Vx-

Works.

Part 2: Controller implementation for the analog dynamic sim-ulator:

Lab 5) Proportional, derivative (PD) controller for theanalog dynamic simulator;

Lab 6) State feedback controller for the analog dynamicsimulator;

Lab 7) Estimator-based controller for the analog dynamicsimulator.

Part 3: Control of electromechanical systems:

Lab 8) Parameter estimation of a dc servo motor;Lab 9) Proportional, integral, derivative (PID) controller

for a dc servo motor;Lab 10) Control of a magnetic levitation system.

In the first group of assignments, students learn how to doreal-time data processing using interrupts. During this part ofthe course, students are expected to implement and test dig-ital filters. In the second part, they control the analog dynamicsimulator, which is made using op-amps. When students arewriting control software for the first time, they usually makemistakes. However, very few things can go wrong with analogdynamic simulators, even when students make mistakes. Theyare also very inexpensive to build. By writing control softwarefor an analog dynamic simulator, students acquire the skills nec-essary to write control software and become ready to control realplants. In Part 3, the students have to control a dc servo motorand a magnetic levitation system, which allow them to addresstypical real-world problems. Each assignment is explained inmore detail hereafter.

A. Lab 1: Digital Filter Using DOS Interrupts

Students are required to write a simple digital filter programusing DOS interrupts. The DOS environment is very simple con-ceptually as compared with a real-time operating system envi-ronment. By being exposed to a real-time DOS program beforethey use VxWorks, the students are able to understand how dif-ferent the programming in a multitasking operating system en-vironment is from the programming in a single-tasking DOSenvironment.

B. Lab 2: Development Environment for VxWorks: Tornado

This session is the first for Tornado and VxWorks. Studentslearn how to build and boot the kernel. In addition, they learnhow to write and run user programs in VxWorks.

Page 4: An undergraduate laboratory course in real-time dynamic control

108 IEEE TRANSACTIONS ON EDUCATION, VOL. 48, NO. 1, FEBRUARY 2005

Fig. 7. Screen capture of the graphing server.

Fig. 8. Pseudocode for the TCP socket program template.

C. Lab 3: Real-Time Data Processing and Monitoring

In this laboratory, students learn how to use VxWorks inter-rupts and to process real-time data. Students are required to dothree things. First, they have to write a program to generate atiming signal using the interrupt. Second, they have to write aprogram to save real-time data from an A/D converter in a file.Finally, they have to write the client program that sends the datacaptured from the A/D converter to the graphing server running

Fig. 9. Analog dynamic simulator.

on the host computer through the TCP data stream. They con-nect a signal generator to an A/D converter channel and, if theyhave done everything correctly, should be able to see the signaldisplayed on the run.

D. Lab 4: Second-Order Digital Filter Using VxWorksInterrupts

This is the first actual VxWorks application. Students are re-quired to write a more complex digital filter program than theone that they wrote in the DOS environment. They have to im-plement a digital filter algorithm and save the time responses ofthe filter in files.

E. Lab 5: PD Controller for the Analog Dynamic Simulator

For this laboratory, the students are provided with an analogdynamic simulator. Fig. 9 shows the circuit diagram for the sim-ulator.

With the jumper installed, the transfer function has a simplepole at the origin and another real pole. Although this system isunstable, it can be stabilized using simple feedback gain. Thissystem is a good example for the first control experience. Withthe jumper removed, the system is a double integrator plantwhich is more difficult to control and offers a greater challengeto the students. For this plant, students must implement a PDcontroller and monitor the step response.

Page 5: An undergraduate laboratory course in real-time dynamic control

LIM: AN UNDERGRADUATE LABORATORY COURSE IN REAL-TIME DYNAMIC CONTROL 109

TABLE ISTUDENT EVALUATION RESULTS (KEY: SA—STRONGLY AGREE, A—AGREE, N—NEUTRAL,

D—DISAGREE, SD—STRONGLY DISAGREE, AVG—AVERAGE). (a) 2002. (b) 2003.

F. Lab 6: State Feedback Controller for the Analog DynamicSimulator

For the analog dynamic simulator described previously, thestudents are required in this laboratory to implement a statefeedback controller. Since the system is a second-order system,they have to use two A/D converter channels for the feedback ofstate variables. For comparison with the PD controller, they usethe same closed-loop pole locations as the PD control system inLab 5 and monitor the control signals. This comparison allowsthem to observe how vulnerable the PD controller is to noise.

G. Lab 7: Estimator-Based Controller for the Analog DynamicSimulator

Implementing an estimator-based controller is not a simpletask for students. Therefore, this assignment is divided into twoparts. In the first part, students are only required to implementstate estimators for the system controlled by the state feedbackcontroller, a procedure already accomplished in the previouslaboratory. By taking this step, they do not have to worry aboutstabilizing the system and can concentrate on implementing thecorrect estimator. In the second part, once they have a state es-timator working correctly, they can move on to implement theestimator-based controller.

H. Lab 8: Parameter Estimation of a dc Servo Motor

This laboratory uses Feedback’s Modular Servo Workshop[14]. Originally, the equipment came with a Windows programwritten by using MathWorks’ Real-Time Workshop [1]. Feed-back’s original control program has a nice graphical user inter-face which is not used for this laboratory. Instead, students haveto write their own programs to control the servo system. In addi-tion, students must determine the servo motor parameters fromthe data captured using their own programs. At this point, thestudents already know how to generate test inputs and acquiredynamic responses from the servo system. They can determinethe necessary parameters by analyzing the data.

I. Lab 9: PID Controller for a dc Servo Motor

In this laboratory, students are required to design and imple-ment PID controllers for the dc motor system. They have to de-sign the controllers and do the simulations using the parametersobtained from Lab 8. Once they have found a satisfactory con-troller using computer simulations, they have to implement aPID algorithm with an anti-wind-up function. This step allowsthem to note the similarities and differences between the controlof real systems and the control of a simulator.

Page 6: An undergraduate laboratory course in real-time dynamic control

110 IEEE TRANSACTIONS ON EDUCATION, VOL. 48, NO. 1, FEBRUARY 2005

J. Lab 10: Control of a Magnetic Levitation System

A magnetic levitation system is a good example of an un-stable, nonlinear system. This laboratory uses Feedback Instru-ments’ Magnetic Levitation System [15]. This system comeswith an analog PID controller. Students have to design and im-plement a digital PID controller in place of the furnished analogcontroller. When the students are designing the controller, theymust ascertain some linearized parameters from the capturedsystem response data and perform simulations using parametersto design the satisfactory controller. By comparing the simulatedand actual responses, they discover the difference between thelinear system and the linearized system model. Since many pa-pers have been written on the control of magnetic levitation sys-tems, the details are not repeated here.

IV. STUDENT REACTIONS AND FUTURE PLANS

At the end of the semester, students in this course are askedto fill out standardized evaluation forms. The form contains15 standard multiple-choice questions and a space for writtencomments. This course has been offered since the Fall 2002semester. Table I shows the evaluation data for the questionsrelated to the course content.

In the tables, the number in each cell is the number of stu-dents who selected that particular choice, and the averages arecomputed by assigning a score ranging from 1 to 5 for eachchoice. For each question, the maximum score is 5. The stu-dents’ reactions to this course are relatively positive. However,as the results show, the students have difficulty applying whatthey have learned from the lecture courses to the experiments.In addition, in their comments, several students expressed diffi-culty in relating the classroom theories to the experiments. Se-nior students are expected to have a good theoretical backgroundand adequate programming skills. They have already learned theconcepts of interrupts and how to design dynamic controllers.However, utilizing their knowledge to make things work is notan easy task. To help the students to understand the material, thiscourse will be modified in 2004 to combine lectures and labo-ratories. Students will have two hours of lectures and two hoursof laboratory work per week. The lecture will explain the basicconcepts and details of the experiments. Although the officiallength of the laboratory is two hours, students are expected tospend at least three hours in the laboratory per week.

V. CONCLUSION

This paper describes a real-time control laboratory course forundergraduate students. Students are required to write real-time

software to control systems ranging from a simple analog dy-namic simulator to a sophisticated magnetic levitation system.The goal of this course is to teach students real-time program-ming concepts and the knowledge necessary to control real-world plants. The software tools that they use in this labora-tory are the same embedded software tools used by professionalengineers in industry. The primary objective of this course isto educate future control engineers. However, those who willnot be involved in control system design can also acquire usefulconcepts and skills from this course.

REFERENCES

[1] MathWorks. (2003, Feb.). [Online]. Available: http://www.mathworks.com/access/helpdesk/help/toolbox/rtw/rtw.shtml

[2] P. S. Shiakolas, “Development of a real-time digital control system witha hardware-in-the-loop magnetic levitation device for reinforcement ofcontrols education,” IEEE Trans. Educ., vol. 46, no. 1, pp. 79–87, Feb.2003.

[3] A. B. Koku and O. Kaynak, “An internet-assisted experimental envi-ronment suitable for the reinforcement of undergraduate teaching of ad-vanced control techniques,” IEEE Trans. Educ., vol. 44, no. 1, pp. 24–28,Feb. 2001.

[4] A. Leva, “A hands-on experimental laboratory for undergraduatecourses in automatic control,” IEEE Trans. Educ., vol. 46, no. 2, pp.263–272, May 2003.

[5] Feedback Instruments. (2003, Feb.). [Online]. Available: http://www.fbk.com

[6] ECP. (2003, Feb.). [Online]. Available: http://www.ecpsystems.com[7] Wind River Systems. (2003, Feb.). [Online]. Available: http://www.win-

driver.com/universities/universities-classroom.html[8] A. Kornecki, “Real-time systems course in undergraduate CS/CE pro-

gram,” IEEE Trans. Educ., vol. 40, no. 4, pp. 295–296, Nov. 1997.[9] A. Kornecki, J. Zalewski, and D. Eyassu, “Learning real-time program-

ming concepts through VxWorks lab experiments,” in Proc. 13th Soft-ware Engineering Education and Training (SEE&T) Conf., 2000, pp.294–301.

[10] M. Soklic, “Laboratory for real-time and embedded systems,” Computerin Education J., vol. XII, no. 4, 2002.

[11] VxWorks Programmer’s Guide 5.4, Wind River Systems, Alameda, CA,1999.

[12] Tornado 2.0 User’s Guide, Wind River Systems, Alameda, CA, 1999.[13] VxWorks Network Programmer’s Guide 5.4, Wind River Systems,

Alameda, CA, 1999.[14] MS150 Modular Workshop Ref. Manual 33-008-2M5, Feedback Instru-

ments, Crowborough, U.K., 1999.[15] Magnetic Levitation System Reference Manual 33-006-2M5 MATLAB

5 Version, Feedback Instruments, Crowborough, U.K., 1999.

Dong-Jin Lim (S’79–M’84) received the B.S. and M.S. degrees from SeoulNational University, Korea, in 1979 and 1981, respectively, and the Ph.D. degreefrom the University of Iowa, Iowa City, in 1988, respectively.

He was a Research Engineer at the Research Institute of Science and Tech-nology, Korea, from 1988 to 1991. Since 1991, he has been with the Schoolof Electrical Engineering and Computer Science, Hanyang University, Ansan,Korea. His current research interests include real-time control and robust con-trol of dynamic systems.