Developing Networked Control Labs: A Matlab and Easy Java Simulations Approach
Developing Networked Control Labs: A Matlab and Easy Java Simulations Approach
Developing Networked Control Labs: A Matlab and Easy Java Simulations Approach
Abstract—The new information technologies provide great op- control labs (see, for instance, [4] and [8]). Our approach uses
portunities in control education. One of them is the use of remote an alternative architecture, considering the controller at the
control labs to teach the behavior of control systems through client side. The insertion of the communication network in the
a network. In this paper, a new approach to create interactive
networked control labs is described. Two main software tools are feedback control loop makes the analysis and design of these
used: Matlab and Easy Java Simulations. The first one is a widely systems complex. Network delays in control loops can impose
used tool in the control community, whereas the second one is an severe degradation on system performance. These delays have
authoring tool, designed to build interactive applications in Java interesting consequences from the control education point of
without special programming skills. The remote labs created by view, and they will be analyzed for a particular plant.
this approach give to students the opportunity to face the effects of
network delays on the controlled system and also to specify on the The approach presented here considers mainly two software
fly their own control algorithm. tools: Matlab [9] and Easy Java Simulations (EJS) [10], [11].
Matlab is widely used software in the control community, being
Index Terms—Control education, Easy Java Simulations (EJS),
Matlab, networked control labs, virtual labs. one of the reasons why we decided to use this tool to control a
real plant. On the other hand, EJS is an authoring tool which
is designed to create interactive applications in Java without
I. I NTRODUCTION special programming skills. By using these tools, teachers can
build networked control labs with a high degree of interactivity
C ONTROL education has to adapt to the new scenario
that the information technologies provide [1], [2]. In this
context, interactive remote labs take advantage of these new
and visualization.
Commonly, remote labs come with predefined controllers
that can only be tuned or mixed by end users in order to
possibilities to improve the understanding of the system be-
produce a customized controller (see, for example, [4], [6], and
havior [3], [4]. Interactivity is a crucial aspect when designing
[8]). However, and taking advantage that Matlab script is an
software applications that are to be used in the field of control
interpreted language, our approach enhances the customization,
engineering for pedagogical purposes. This interactivity should
also allowing students to define on the fly their own control
allow the student to simultaneously visualize the response of
algorithm, which provides great flexibility for the designing of
the system on the fly to any change, such as a step or a
many control strategies.
new PID configuration, introduced by the user. This immediate
This paper is organized as follows. In Section II, the connec-
observation of the change in the system output, as response to
tion between EJS and Matlab is presented. Section III describes
user interaction, is what really helps the student to get useful
the required process to build a networked control lab. A real
practical insight into control system theory [5].
implementation of a lab is described in Section IV. Finally,
This paper is focused on providing new tools to teachers that
some conclusions of the work are presented.
want to use networked control labs as part of the educational
process in the course on industrial electronic and/or control en-
gineering. A networked control system is a remote lab wherein II. L INKING EJS AND M ATLAB
the control loops are closed through a network [6], [7]. The
In this section, the connection between EJS and Matlab will
location of the controller at the server side, i.e., next to the real
be described in detail.
plant, is a widely used architecture for the design of remote
A. EJS
Manuscript received December 28, 2008; revised May 28, 2009 and
July 31, 2009; accepted December 23, 2009. Date of publication February 8, EJS is a free software tool for rapid creation of applica-
2010; date of current version September 10, 2010. tions in Java with high-level graphical capabilities and with
G. Farias and S. Dormido are with the Department of Computer Science
and Automatic Control, Universidad Nacional de Educación a Distancia, 28040
an increased degree of interactivity. The applications created
Madrid, Spain (e-mail: gfarias@bec.uned.es; sdormido@dia.uned.es). by EJS can be standalone Java applications or applets, and
R. De Keyser is with the Department of Electrical energy, Systems and for simplicity, we call them here EJS applications or simply
Automation, Ghent University, 9000 Ghent, Belgium (e-mail: rdk@autoctrl.
UGent.be). applications. The source files of the EJS applications are saved
F. Esquembre is with the Department of Mathematics, University of Murcia, in a customized xml format. EJS is different from most other
30100 Murcia, Spain (e-mail: fem@um.es). authoring tools in that EJS is not designed to make life easier for
Color versions of one or more of the figures in this paper are available online
at http://ieeexplore.ieee.org. professional programmers but has been conceived for science
Digital Object Identifier 10.1109/TIE.2010.2041130 students and teachers.
B. Using Matlab as an External Application in EJS command changes the values of the Matlab variables, the virtual
oscilloscope plots the corresponding function.
EJS can set a link with external applications like Scilab,
The required steps to build the virtual oscilloscope in EJS
Sysquake, and Matlab/Simulink [12]. The connection with
will be presented in detail in the following.
Matlab is quite interesting because Matlab is a well-known
technical software tool in the engineering community. This link Steps 1 and 2) To select Matlab as an external application, the
uses the JMatlink library [13] and the Engine library to control authors simply need to introduce the string matlab in
Matlab from EJS applications. the text field External File in the subsection Variables of
Authors can create virtual or remote labs (i.e., pedagogical the Model (see Fig. 3). After that, authors have to create
applications) with a high level of interactivity and visualization and connect EJS variables with Matlab variables using the
using the EJS–Matlab link. In this case, Matlab is used for com- column connected to. In this case, time and value are EJS
puting and processing data by means of the toolboxes, whereas variables which are connected to Matlab variables t and x,
EJS provides the graphical support and the user interaction of respectively. There are also built-in functions in EJS that
the Java application. The procedure to connect the application directly read or write variables in the Matlab workspace.
and Matlab can be summarized in four steps. Step 3) To control the execution of Matlab code from the
Java application, EJS provides different built-in func-
1) Select Matlab as an external application in EJS. tions. One of them is _external.step(), which allows the
2) Create and connect the EJS variables with Matlab. execution of a specific command. Normally, this built-
3) Control the execution of Matlab code. in function is located in the subsection Evolution to
4) Define the view and the user interaction. execute the code in an iterative way. The command
A simple example will be used to explain in more detail has to be previously defined using the built-in function
the link between Matlab and the Java application created by _external.setCommand(commandM). Notice that this func-
EJS. The example is a virtual oscilloscope which shows a tion needs a string variable (in this case, commandM)
plot of a function versus time. The idea is that end users whose value is the command that will be executed by
enter a command which will be evaluated in Matlab, and the _external.step(). In the example (see Fig. 3), the command
application depicts in a plot (see Fig. 2) the values of two to execute has the following initial value: t = t + 0.1 and
Matlab variables (x and t). As the continuous iteration of the x = sin(t).
3268 IEEE TRANSACTIONS ON INDUSTRIAL ELECTRONICS, VOL. 57, NO. 10, OCTOBER 2010
Fig. 4. Properties of the text field used by end users to enter a function. Notice
that the function will be evaluated in Matlab when a user presses the return key
(property Action) in the text field.
Fig. 5. Scheme of the remote Matlab–EJS connection.
III. B UILDING N ETWORKED C ONTROL L ABS Listing 1. Initiate data acquisition process
%Create input channels
In this section, the main tools and actions required to create a AI = analoginput (“nidaq,” “1”);
networked control lab will be presented. First, the software and Speed = addchannel (AI,1);
hardware issues will be discussed. Later on, the communication Position = addchannel (AI,0);
process with the plant will be detailed. Finally, the core control set (AI, “InputType,” “SingleEnded”);
code of the lab will be presented. AI.Channel.InputRange = [−10 10];
%Create output channels
AO = analogoutput (“nidaq,” “1”);
A. Software and Hardware Required
VoltOutSpeed = addchannel (AO, 0);
The approach presented in this work can be summarized in VoltOutPosition = addchannel (AO,1);
Fig. 7. As shown in this figure, there are other tools in order to %Configurate sampling and trigger
put online the control lab for students. Among others, we need set ([AI, AO], “SampleRate,” 1/0.05);
at least a Web server, an IP camera, and a data acquisition card set (AI, “TriggerType,” “Immediate”);
(DAQ card). set (AO, “TriggerType,” “Immediate”);
The Web server is required if authors want to put the remote %Acquire data continuously
labs as applets. Moreover, a Web server is needed if the teacher set (AI, “SamplesPerTrigger,” inf);
adds some virtual labs, simulations, or documentation in the %Send out initial volts
Web site. A good option to provide this service could be Apache putdata (AO, [0, 1]);
Tomcat. This Web server also offers security features called start ([AO AI]);
authorization, authentication, and access control in order to
allow only access to authorized students. After the initialization has been done, the channels can be ac-
To show students a view of the real plant, a simple Web cessed from the EJS application (by means of the EJS–Matlab
camera can be used. However, it is preferable to use an IP link). The code listing 2 shows the Java code used to read and
camera since it has a built-in Web server that can stream video write the input/output channels. Notice that the code required
images directly to the Internet. Moreover, EJS has a specific to interface the DAQ card is sent to Matlab from the application
visual element to display the video from stream servers, so the using the built-in function _external.eval(String).
3270 IEEE TRANSACTIONS ON INDUSTRIAL ELECTRONICS, VOL. 57, NO. 10, OCTOBER 2010
Fig. 10. Remote servo (a) as a second-order system plus dead zone and (b) as a second-order system plus dead time. Note that the block “Controller” represents
a PID controller, which can be computed in the remote lab by the Matlab function computeControl described in listing 4.
ωgc (gain cross over frequency) and φm (phase margin). These saturation, respectively. The function f (γ) is called saturation
approximations are given by function, and its values are given by (8)
K K δ2 δ1
20 log = 0 → ωgc ≈ (3) N (A) = f −f (7)
ω ω2 τ 2 + 1 τ A A
gc gc ⎧
⎨ −1,
for γ < −1
φm = π −
π
− arctan ωgc τ → φm ≈ √
1 f (γ) = 2
arcsin γ + γ 1 − γ , for |γ| ≤ 1 (8)
2
. (4) ⎩π
2 Kτ 1, for γ > 1.
Finally, by using ωgc and φm , the delay margin (T ) can be √
Solving (6) and assuming that (1/ τ KN ) ≈ 0, we can find
calculated using (5). Therefore, this last equation tells us that
useful approximations for the frequency of the limit cycle (ω)
the delay margin is inversely proportional to the product of
and also for the delay margin (T ). These approximations, given
kc · κ · kp
by the following equations, can be used for control design
1 purposes:
φm = ωgc T → T ≈ . (5)
kc κkp
KN 1
ω≈ T ≈ . (9)
Notice that even small delays could lead to an unstable closed τ KN
loop. For example, when the full brake is selected (κ = 10 and
τ = 1) and assuming that kp = kc = 1, the delay margin is Interesting analysis can also be done observing the polar plot
approximately 0.1 s, which is a usual value for Internet delays. (see Fig. 11) of (6). In this figure, we can see that the limit
This result implies that if the system has less brake, then it cycles appear when there is an intersection of GH(jω) and
is less stable. Obviously, this delay margin can be modified −(1/N (A)). Notice that the curve of −(1/N (A)) has been
changing the value of kc in the P controller. distorted to see both limit cycles. Hence, it is clear that there
4) Dead Time, Saturation, and Dead Zone: Consider the are no limit cycles if there is no dead time (curve GH(jω)).
linear model of the motor plus the dead time, saturation, and However, if there is enough delay (curve GHT (jω)), there will
the dead zone controlled by a P controller. In this situation, be one or two limit cycles. In the case of two limit cycles, one
the system could produce limit cycles if there is enough dead is unstable, and the other one is stable. However, the effect
time. To effect an approximate limit cycle study of this non- of the unstable cycle limit is constrained by the stable cycle
linear system, the nonlinear elements can be characterized by limit.
their describing functions (N (A, ω)) and the linear part by Observing the polar plot in Fig. 11, it is possible to conclude
its frequency response function (GH(jω)). Then, the solu- that at least one limit cycle will occur in the maximum value of
tion of (6) yields the amplitudes and frequencies of the limit −(1/N (A)) (i.e., when A = δ2 ). The minimum value of the
cycle [22] delay required for this situation can be calculated using (9).
For example, if kp = kc = 1, δ1 = 0.1, δ2 = 0.2, and the full
1 + N (A, ω)GH(jω) = 0. (6) brake is selected as the previous case, then the minimum delay
is about T ≈ (1/10N (0.2)) ≈ 0.26 s.
In our case, the linear part is given by (1), and the dead 5) Complete Model: In this case, we are considering the
zone, combined with the saturation, has the describing function model shown in Fig. 9 controlled by a P controller. The
shown in (7), where A is the amplitude of the limit cycle after analysis is quite similar to the previous case; the only one
the P controller and δ1 and δ2 are the limits of the dead zone and difference is the automatic reset mechanism of the integrator.
FARIAS et al.: DEVELOPING NETWORKED CONTROL LABS: A MATLAB AND EASY JAVA SIMULATIONS APPROACH 3273
Fig. 11. Polar plot representation to determine the limit cycle conditions.
E. Using and Evaluating the Networked Control Lab add interesting and challenging features from the control point
of view.
From a wide set of tasks to do with the networked control
Two main software tools have been used, Matlab and EJS.
lab, we asked our students to do the following activities.
Matlab was selected because it is a very well known tool
1) Control the plant indicating suitable values for the con- in the control engineering community, whereas EJS allows
troller (by default, a PID controller). teachers to build complex Java applications with high levels
2) Apply a step to the motor input voltage. of interactivity and visualization, but with minimum skills on
3) Identify the main time constant and the gain from the computer programming.
“speed” response. Future work will mainly consist in adding new function-
4) On the basis of this identification exercise, derive a model ality and improvements to this approach. In this sense, in
for the “position” response. order to provide a better experience for users, large delays
5) On the basis of the position model, design a controller on far Internet connections should be mitigated until suitable
transfer function for position control. values.
6) Apply the position controller to the motor, and evaluate
the result. R EFERENCES
This exercise was done in a basic course on control engineer- [1] B. S. Heck, “Special report: Future directions in control education,” IEEE
Control Syst. Mag., vol. 19, no. 5, pp. 35–58, Oct. 1999.
ing in Ghent University, taken by some 130 students. At the [2] S. Dormido, “Control learning: Present and future,” Annu. Control Rev.,
end of the use of the networked control lab, the students were vol. 28, no. 1, pp. 115–136, 2004.
invited to evaluate it using an online poll (which allows students [3] L. Gomes and S. Bogosyan, “Current trends in remote laborato-
ries,” IEEE Trans. Ind. Electron., vol. 56, no. 12, pp. 4744–4756,
to vote in a confidential way). The results, from teacher and Dec. 2009.
students point of views, were very good specially considering [4] L. Gomes, F. Coito, A. Costa, L. Palma, and P. Almeida, “Remote labora-
that it was our first experience. The online questionnaire (based tories support within teaching and learning activities,” in Proc. Int. Conf.
REV, Jun. 25–27, 2007, pp. 1–6.
on [8]) was rated for students as strongly agree, agree, neutral, [5] J. Sánchez, S. Dormido, and F. Esquembre, “The learning of control
disagree, and strongly disagree. The questions were divided concepts using interactive tools,” Comput. Appl. Eng. Educ., vol. 13, no. 1,
into the following categories. pp. 84–98, 2005.
[6] C. Lazar and S. Carari, “A remote-control engineering laboratory,” IEEE
1) Learning value: The lab helps to learn the relevant Trans. Ind. Electron., vol. 55, no. 6, pp. 2368–2375, Jun. 2008.
[7] W. Zhang, M. S. Branicky, and S. M. Phillips, “Stability of networked
contents. control systems,” IEEE Control Syst. Mag., vol. 21, no. 1, pp. 84–99,
2) Value added: The lab has advantages over traditional Feb. 2001.
learning methods. [8] R. Dormido, H. Vargas, N. Duro, J. Sánchez, S. Dormido-Canto, G. Farias,
F. Esquembre, and S. Dormido, “Development of a web-based control lab-
3) Usability: The lab was easy to use. oratory for automation technicians: The three-tank system,” IEEE Trans.
4) Technical functionality: The lab works well from soft- Educ., vol. 51, no. 1, pp. 35–44, Feb. 2008.
ware and hardware points of view. [9] Mathworks’ Home Page. [Online]. Available: http://www.mathworks.com
[10] F. Esquembre, “Easy Java simulations: A software tool to create scientific
The results indicate that Technical Functionality was not a simulations in Java,” Comput. Phys. Commun., vol. 156, no. 2, pp. 199–
204, Jan. 2004.
problem for most of the students because only 11% of them
[11] Easy Java Simulations’ Home Page. [Online]. Available: http://fem.
evaluated this category as disagree. Regarding the Usability, um.es/Ejs
about 84% of the students did not find some difficulty to use [12] S. Dormido, F. Esquembre, G. Farias, and J. Sanchez, “Adding interac-
the lab. About 55% of the students think that the lab helps to tivity to existing Simulink models using Easy Java Simulations,” in Proc.
44th IEEE Conf. Decision Control, Seville, Spain, 2005, pp. 4163–4168.
understand the matters (Learning Value), while only 13% of [13] S. Müller, JMatlink’s Home Page. [Online]. Available: http://jmatlink.
them disagree. Regarding the Value Added, 30% of the students sourceforge.net/
think that the lab has advantages over other learning meth- [14] G. Farias, F. Esquembre, J. Sanchez, S. Dormido, H. Vargas,
S. Dormido-Canto, R. Dormido, N. Duro, and M. Canto, “Desarrollo
ods; however, about 25% of the students think the opposite. de Laboratorios Virtuales, Interactivos y Remotos Utilizando Easy Java
Probably, this item indicates the value that students give to the Simulations y Modelos Simulink,” in Proc. 12th Latin-Amer. Congr.
traditional practice in the labs, which means that the remote or Autom. Control, Salvador de Bahı´a, Brazil, 2006.
[15] JIM Server’s Home Page. [Online]. Available: http://lab.dia.uned.es/
virtual labs have to be considered as a complement (and not a rmatlab/
replacement) of the industrial electrical teaching. [16] The MathWorks, Inc., Data Acquisition Toolbox, User’s Guide, v.2.5.
[17] K. J. Åström and T. Hägglund, Advanced PID Control. Research
Triangle Park, NC: ISA, 2005.
[18] J. Normey-Rico and E. Camacho, Control of Dead-Time Processes.
V. C ONCLUSION AND F URTHER W ORK Berlin, Germany: Springer-Verlag, 2007.
[19] S. Cristea, C. de Prada, and R. De Keyser, “Predictive control of a process
In this paper, a new approach to build interactive networked with variable dead-time,” in Proc. IFAC 16th World Congr., Prague, Czech
control labs has been presented. The work allows nonpro- Republic, 2005.
gramming instructors to create innovative pedagogical tools, [20] G. Liu, Y. Xia, J. Chen, D. Rees, and W. Hu, “Networked predictive con-
trol of systems with random network delays in both forward and feedback
which can be used to motivate students to apply the theory of channels,” IEEE Trans. Ind. Electron., vol. 54, no. 3, pp. 1282–1297,
automatic control to new challenges, like the remote control Jun. 2007.
of plants. This kind of labs can be used as part of a basic [21] R. Dorf and R. Bishop, Modern Control Systems, 10th ed. Englewood
Cliffs, NJ: Prentice-Hall, 2004.
industrial electronic control course or even a benchmark for [22] A. Gelb and W. Vander Velde, Multiple-Input Describing Functions and
advanced students since the network delays and nonlinearities Nonlinear System Design. New York: McGraw-Hill, 1968.
FARIAS et al.: DEVELOPING NETWORKED CONTROL LABS: A MATLAB AND EASY JAVA SIMULATIONS APPROACH 3275
Gonzalo Farias received the M.S. degree in com- Sebastián Dormido received the B.S. degree in
puter science from the University de la Frontera, physics from Complutense University, Madrid,
Temuco, Chile, in 2001. Spain, in 1968 and the Ph.D. degree in science from
Since 2005, he has been with the Department of the University of the Basque Country, Bilbao, Spain,
Computer Science and Automatic Control, Univer- in 1971.
sidad Nacional de Educación a Distancia, Madrid, Since 1981, he has been a Professor of con-
Spain. His current research interests include control trol engineering with the Universidad Nacional de
of dynamic system and virtual and remote labs. Educación a Distancia, Madrid, Spain. His scien-
tific activities include computer control of industrial
processes, model-based predictive control, robust
control, and model and simulations of continuous
processes. He has authored or coauthored more than 150 technical papers in
international journals and conferences. Since 2002, he has promoted academic
Robin De Keyser received the M.Sc. degree in and industrial relations as President of the Spanish Association of Automatic
electromechanical engineering and the Ph.D. degree Control CEA–IFAC (Comité Español de Automática–International Federation
in control engineering from Ghent University, Ghent, on Automatic Control).
Belgium, in 1974 and 1980, respectively.
He is currently a Full Professor of control en-
gineering with the Faculty of Engineering, Ghent
University. He was an External Review expert in sev- Francisco Esquembre received the Ph.D. degree in
eral European Commission research programs and mathematics from the University of Murcia, Murcia,
is one of the pioneers who produced the original Spain, in 1991.
concepts of “predictive control” during the 1980s. Since 1986, he has been with the University of
He is the author/coauthor of about 250 publications Murcia, where he has been holding the position of
in journals, books, and conference proceedings. His current research interests Associate Professor since 1994. His academic exper-
include model predictive control, autotuning and adaptive control, modeling tise includes differential equations, dynamical sys-
and simulation, system identification, and pilot implementations in technical tem, and numerical analysis. His research includes
and nontechnical systems, such as chemical, steel, marine, mechatronic, semi- computer-assisted teaching and learning.
nconductor, power electronics, and biomedical.