10.07.2015 Views

Lab Proposal for Integrated Real-time and Control - DCS - UPC

Lab Proposal for Integrated Real-time and Control - DCS - UPC

Lab Proposal for Integrated Real-time and Control - DCS - UPC

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1<strong>Lab</strong> <strong>Proposal</strong> <strong>for</strong> <strong>Integrated</strong> <strong>Real</strong>-<strong>time</strong> <strong>and</strong> <strong>Control</strong>Josep M. Fuertes, Ricard Villà, Jordi Ayza, Pere Marés, Pau Martí, Manel Velasco, José Yépez,Antonio CamachoAbstract—This paper presents a prototype laboratory experimentto be integrated in the education of embedded controlsystems engineers. The experiment, a real-<strong>time</strong> control of adynamical system, is designed to drive students to a deeperunderst<strong>and</strong>ing <strong>and</strong> integration of the diverse theoretical conceptsthat often come from different disciplines such as real<strong>time</strong>systems <strong>and</strong> control systems. Rather than proposing theexperiment <strong>for</strong> a particular course within an embedded systemsengineering curriculum, the paper describes how the experimentcan be tailored to the needs <strong>and</strong> diverse background of bothundergraduate <strong>and</strong> graduate students education.Index Terms—Embedded systems education, real-<strong>time</strong> systems,control systems, laboratory experiment.I. INTRODUCTIONTHE economic importance of embedded systems hasgrown exponentially as electronic components are ineveryday use devices. Hence, embedded systems education isa strategic asset, <strong>and</strong> university curricula are being adaptedaccordingly to cover this domain [1]. Since many embeddedsystems are control systems [2], <strong>and</strong> considering that thereis an increasing trend to adopt real-<strong>time</strong> technology <strong>for</strong> theembedded computing plat<strong>for</strong>m [3], laboratory experimentsincluding topics of real-<strong>time</strong> <strong>and</strong> control systems are becomingmore <strong>and</strong> more important <strong>for</strong> the education of embeddedsystems engineers. The traditional teaching approach to real<strong>time</strong>systems <strong>and</strong> to control systems courses can be quite mathintensive<strong>and</strong> abstract, thus failing to introduce students to therealities of embedded control system implementation. Moreover,the natural interaction <strong>and</strong> integration between these twodisciplines is often neglected due to the traditional compartmentalizednature of science <strong>and</strong> engineering education. Sincecontrol systems are real-<strong>time</strong> systems, control engineers musthave an underst<strong>and</strong>ing of computers <strong>and</strong> real-<strong>time</strong> systems,while computer engineers must underst<strong>and</strong> control theory.To overcome such limitations, this paper presents a laboratoryexperiment to be integrated in the education of embeddedcontrol systems engineers that flexibly combines two main disciplines:real-<strong>time</strong> systems <strong>and</strong> control systems. The flexibilityManuscript received March 10, 2009; revised June 15, 2009; accepted <strong>for</strong>publication December 23, 2009. This work was partially supported by NoEArtistDesign IST-FP7-2008-214373, <strong>and</strong> by Spanish Ministerio de Educacióny Ciencia Project ref. CICYT DPI2007-61527.Copyright c○ 2009 IEEE. Personal use of this material is permitted.However, permission to use this material <strong>for</strong> any other purposes must beobtained from the IEEE by sending a request to pubs-permissions@ieee.org.P. Martí, M. Velasco, Josep M. Fuertes <strong>and</strong> Antonio Camacho are withthe Automatic <strong>Control</strong> Department, Technical University of Catalonia, PauGargallo 5, 08028 Barcelona, Spain. E-mail: {pau.marti, manel.velasco,josep.m.fuertes, antonio.camacho.santiago}@upc.eduG. Buttazzo is with The Computer Engineering Department, Scuola SuperioreSant’Anna of Pisa, RETIS <strong>Lab</strong>, Area CNR Via Moruzzi, 1, 56124 Pisa,Italy. E-mail:giorgio@sssup.itis achieved by describing a set of problems/observations thatprovide the spectrum of possible choices that instructors/studentshave <strong>and</strong> the work that has to be done to complete theexperiment. This permits elaborating diverse assignments <strong>for</strong>the laboratory experiment with open problems rather than providingtight guidelines, while providing the tools <strong>for</strong> assessingwhether the students design <strong>and</strong> implementation choices werecorrect. Finally, through the experiment, it is shown that thecombination of both disciplines do not rise conflicts. It ratherprovides complementary approaches/views that help in themultidisciplinary learning process required in the embeddedsystems education.The experiment main activity includes the implementationof a real-<strong>time</strong> control application, consisting in controllinga physical plant by a controller implemented as a softwaretask executing on top of a real-<strong>time</strong> operating system (RTOS).Rather than proposing an experiment <strong>for</strong> a particular coursewithin an embedded systems engineering curriculum, the paperdescribes how the experiment can be tailored to the needsof both undergraduate <strong>and</strong> graduate students education, <strong>and</strong>to the diverse background of the target audience. A tentativelaboratory program covering the different stages required tocarry out the experiment is presented, <strong>and</strong> its integration intoa master-level students course is also reported.The rest of the paper is organized as follows. Section IIdiscusses the selection of the controlled plant <strong>and</strong> processingplat<strong>for</strong>m/RTOS. Section III introduces the set of problems/observations<strong>for</strong> carrying out the activity. Section IV presentsan outline of the experiment <strong>and</strong> its adaptation to a course.Section V concludes the paper.II. SELECTION OF THE CONTROLLED PLANT ANDPROCESSING PLATFORMThe controlled plant <strong>and</strong> processing plat<strong>for</strong>m (hardware <strong>and</strong>real-<strong>time</strong> operating system) have been carefully selected tohave a friendly, flexible, <strong>and</strong> powerful experimental set-up.Both must be simple to avoid discouraging those students withstrong control systems background but weak real-<strong>time</strong> systemsbackground when facing the programming part, or vice-versa,to avoid discouraging those students with strong real-<strong>time</strong>systems background but weak control systems backgroundwhen facing the controller design stage.A. PlantMany st<strong>and</strong>ard basic <strong>and</strong> advanced controller design methodsrely on the accuracy of the plant mathematical model. Themore accurate the model, the more realistic the simulations,<strong>and</strong> the better the observation of the effects of the controller on


2Fig. 1.Plant <strong>and</strong> control setup.(a) RCRC circuit(b) <strong>Control</strong> setupthe plant. Hence, the plant was selected among those <strong>for</strong> whichan accurate mathematical model could easily be derived.Plants such as an inverted pendulum or a direct currentmotor are the defacto plants <strong>for</strong> benchmark problems in controlengineering [4]. However, their modelling is not trivial <strong>and</strong>the resulting model is often not accurate. This leads to a firstcontroller design that has to be adjusted by ”engineering experience”,thus requiring knowledge that is difficult to <strong>for</strong>malize<strong>and</strong> transmit to the students. To avoid such a kind of drawbacks,a simple electronic circuit in the <strong>for</strong>m of an RCRC(Figure 1a) was selected. The simplicity of its components <strong>and</strong>their simple <strong>and</strong> intuitive physical behavior have been the mainreasons <strong>for</strong> its selection. Note however that experiments usingother plants can be complementary to the approach presentedhere, e.g. [2], [5]–[7]. Indeed, Lim [6] also proposes electroniccircuits. However, they are slightly more sophisticated becausethey include operational amplifiers. Although richer dynamicscan be achieved, the intuitive behavior <strong>and</strong> thus the modelingof operational amplifiers is not straight<strong>for</strong>ward.The selection of an electronic circuit as a plant has alsoanother important advantage: depending on the specific circuit,it can be directly plugged into a micro-controller without usingintermediate electronic components, as shown in Figure 1b,where the zoh box (zero order hold) represents the actuator <strong>and</strong>the box above represents the sampler. That is, the transistortransistorlogic (TTL) level signals provided by the microcontrollercan be enough to carry out the control. Notethat this is not the case, <strong>for</strong> example, <strong>for</strong> many mechanicalsystems. Such a simplification in terms of hardware reducesthe modelling ef<strong>for</strong>t to study the plant <strong>and</strong> no models <strong>for</strong>actuators or sensors are required. Additional benefits of thesetypes of plants are that systems can be easily built, are cheap,have light weight, <strong>and</strong> can be easily transported <strong>and</strong> powered.The control objective would be to have the circuit outputvoltage V out (controlled variable) to track a reference signal orto settle to a constant value while meeting <strong>for</strong> example giventransient response specifications, which m<strong>and</strong>ates to use trackingstructures. The control will be achieved by sampling V out ,executing the control algorithm <strong>and</strong> applying the calculatedcontrol signal to the circuit via varying the circuit input voltageV in (manipulated variable). Disturbances can be injected by avariable load voltage placed in parallel to the output voltage.B. Processing plat<strong>for</strong>mThe processing plat<strong>for</strong>m consists of the hardware plat<strong>for</strong>m<strong>and</strong> the real-<strong>time</strong> operating system. As hardware plat<strong>for</strong>m,a micro-controller based architecture was selected becauseembedded systems are typically implemented using this typeof hardware. Note, however, that too small micro-controllersmay not be powerful enough <strong>for</strong> running an RTOS, as discussedin [9]. Among the several possibilities available on themarket [10], it was decided to adopt the Flex board [11].The Flex board (in its full version) represents a good compromisebetween cost, processing power, <strong>and</strong> programmingflexibility. It was produced as a development board <strong>for</strong> building<strong>and</strong> testing real-<strong>time</strong> applications using st<strong>and</strong>ard components<strong>and</strong> open source software. The board includes a MicrochipdsPIC DSC micro-controller dsPIC33FJ256MC710, a socket<strong>for</strong> the 100 pin Plug-In Module (PIM), an ICD2 (in-circuit debugger)programmer connector, a USB (Universal Serial Bus)connector <strong>for</strong> direct programming, power supply connectors,a set of leds <strong>for</strong> monitoring the board, an on-board MicrochipPIC18F2550 micro-controller <strong>for</strong> integrated programming, <strong>and</strong>a set of connectors <strong>for</strong> daughter boards piggybacking.The board has several key benefits that make it suitable tobe used <strong>for</strong> educational purposes. First has a robust electronicdesign, which is an important feature when it is employedby non skilled users. Second, it has a modular architecture,which allows users to easily develop home-made daughterboards using st<strong>and</strong>ards components. A set of daughter boardscan be added to the Flex board <strong>for</strong> easy development, suchas a multi-bus board equipped with CAN (<strong>Control</strong>ler AreaNetwork), Ethernet, I2C (Inter-<strong>Integrated</strong> Circuit), <strong>and</strong> othercommunication protocols. On one h<strong>and</strong>, the availability ofCAN or Ethernet permits to build <strong>and</strong> experiment with networkedcontrol applications. On the other h<strong>and</strong>, the availablenetworks can be used <strong>for</strong> debugging purposes or <strong>for</strong> extractingdata from the board, which is a difficult task when dealing withembedded systems.As far as the real-<strong>time</strong> kernel is concerned, different possibilitieswere considered. First, many well-known real-<strong>time</strong>operating systems, such as real-<strong>time</strong> Linux [12], target processorsthat may be too powerful <strong>for</strong> embedded applications. Butmore important, their internal structure is often too complex<strong>for</strong> those students with a low profile in (real-<strong>time</strong>) operatingsystems. Hence, it looks more desirable to work with smallreal-<strong>time</strong> kernels (see e.g. [13]–[18] <strong>for</strong> small real-<strong>time</strong> kernelstargeting small architectures) whose internals are accessible,easy to underst<strong>and</strong> <strong>and</strong> modify, in order to tailor them to thespecific application needs. On the other h<strong>and</strong>, from a userpoint of view, programming <strong>and</strong> configuring the kernel (includingcreating tasks, assigning priorities/periods/deadlines,


3<strong>and</strong> setting the scheduling policy) should be friendly enoughto attract non-skilled programmers.From the considerations mentioned above, Erika Enterprisereal-<strong>time</strong> kernel [11] was selected. Erika provides full supportto the Flex board in terms of drivers, libraries, programmingfacilities, <strong>and</strong> sample applications. The kernel, available underthe General Public License <strong>and</strong> OSEK (Open Systems <strong>and</strong>their Interfaces <strong>for</strong> the Electronics in Motor Vehicles, [19])compliant, is a RTOS <strong>for</strong> small micro-controllers based on anAPI similar to those proposed by the OSEK consortium. Thekernel gives support <strong>for</strong> preemptive <strong>and</strong> non-preemptive multitasking,<strong>and</strong> implements several scheduling algorithms [20].The API provides support <strong>for</strong> tasks, events, alarms, resources,application modes, semaphores, <strong>and</strong> error h<strong>and</strong>ling. All thesefeatures permits to en<strong>for</strong>ce real-<strong>time</strong> constraints to applicationtasks to show students the effects of sampling periods, delays<strong>and</strong> jitter on control per<strong>for</strong>mance.The development environment <strong>for</strong> Erika Enterprise is basedon cross-compilation, avoiding typical students misconceptionswhen the development plat<strong>for</strong>m <strong>and</strong> the target sharethe same hardware. A tool, named RT-Druid [11] (based onEclipse [21]), can be used as a default development plat<strong>for</strong>mto program in C, with support from Microchip <strong>for</strong> the compiler<strong>and</strong> <strong>for</strong> the programming development kit. The latteris important because Microchip web-pages [22] are always agood place where to share experiments experiences <strong>and</strong> code:a good place <strong>for</strong> instructors <strong>and</strong> students to visit. RT-Druid implementsan OIL (OSEK Implementation Language) languagecompiler, which is able to generate the kernel configurationfrom an OIL specification. Apart from programming in C, theFlex board can also be programmed automatically using theScilab/Scicos [23] code generator (similar to what can be donewith MATLAB/Simulink [24] <strong>and</strong> its <strong>Real</strong>-Time Workshop, asused <strong>for</strong> example in [25] <strong>for</strong> rapid control prototyping). Thisis an important benefit <strong>for</strong> non-skilled C programmers.From an education point of view, it is also important to notethat there is the possibility to build a community around thisprocessing plat<strong>for</strong>m to create a repository of control software<strong>for</strong> education. In fact, a set of application notes that describe aset of control experiments (inverted pendulum, ball <strong>and</strong> plate,etc.) developed with Erika on Flex can be found in [11].Finally, it must be stressed that the price of the Flex boardlies in the lower bound of evaluation board prices, <strong>and</strong> thatthe Erika kernel <strong>and</strong> the associated development tools areopen source, available <strong>for</strong> free, or available <strong>for</strong> free in studentedition <strong>for</strong>mat. Hence, it is an economically atractive option.III. EXAMPLE OF THE LAB EXPERIMENTThis section presents some of the activities in the <strong>for</strong>m ofproblems <strong>and</strong> solutions (<strong>and</strong> observations) required to carryout the lab experience, which are later ordered in the workplan. The emphasis is in the control analysis <strong>and</strong> design part.A. Problem 1. Plant modellingIf q i represents the charge on capacitor C i , the differentialequations of the circuit, in terms of the currents ˙q i at each R i ,are given by˙q 1 R 1 +(q 1 −q 2 ) 1 C 1= V in˙q 2 R 2 +(q 2 −q 1 ) 1 1+q 2C 1 C 2= 0 (1)q 21C 2= V out ,For example, using state-space <strong>for</strong>malism, a state-space<strong>for</strong>m is given byẋ(t) =y(t) =[]0 1−1x(t)R 1R 2C 1C 2−[ ]R1C1+R2C2+R1C2R 1R 2C 1C 20(2)+ 1 u(t)[ R 1R] 2C 1C 21 0 x(t)where u(t) is the control signal, y(t) is the plant output, <strong>and</strong>x(t) = [ x 1 x 2 ] is the state vector, where x 1 correspondsto the output voltage V out , <strong>and</strong> x 2 is ˙q 2 /C 2 .Observation 1: The modelling of the plant could have beenalso done in terms of a transfer function (see [26] <strong>for</strong> theanalysis). Even obtaining the differential equations is a goodexercise. Adopting the state space <strong>for</strong>malism may add anotherbenefit if using model (2). Since only the output voltagex 1 canbe physically measured, the control algorithm requires the useof observers <strong>for</strong> predicting x 2 . This opens the door to experimentwith several types of observers <strong>and</strong> the implementationof the controller has to include them. Also, the selection of thestate variables is arbitrary, <strong>and</strong> there<strong>for</strong>e, students have to takedesign decisions. For example, the voltages in both capacitorscould also have been chosen as a state variables. In any case,if possible, it is interesting to chose the state variables in sucha way that the controlled variable is directly available throughthe output matrix in order to minimize computations in themicro-controller.B. Problem 2. Electronic componentsThe selection of the electronic components is very important<strong>for</strong> several reasons. The output impedance must be lowenough to properly connect the circuit to the analog-to-digitalconverter (ADC) or to some external instrumentation, suchas an oscilloscope. For example, given the initial componentsR 1 = R 2 = 1 KΩ <strong>and</strong>C 1 = C 2 = 33µF, a manageable circuitimpedance is obtained. With these components, the state spacemodel becomes[ ] [ ]0 1 0ẋ(t) =x(t)+ u(t)−976.56 −93.75 976.56y(t) = [ 1 0 ] x(t).(3)Observation 2: Students can be given other values. Forexample, with R 1 = R 2 = 330 KΩ <strong>and</strong> C 1 = C 2 = 100ηF, it is easy to see that the equivalent output impedance istoo high <strong>for</strong> the ADC. To derive such a conclusion, studentshave to consult the dsPIC data sheet.


5CPU mySystem {OS myOs {EE_OPT = "DEBUG";CPU_DATA = PIC30 { APP_SRC = "code.c";MULTI_STACK = FALSE;ICD2 = TRUE;};MCU_DATA = PIC30 { MODEL = PIC33FJ256MC710;};BOARD_DATA = EE_FLEX { USELEDS = TRUE;};KERNEL_TYPE = EDF { NESTED_IRQ = TRUE;TICK_TIME = "25ns";};};TASK myTask {REL_DEADLINE = "10ms";PRIORITY = 1;STACK = SHARED;SCHEDULE = FULL;};COUNTER myCounter;ALARM myAlarm {COUNTER = "myCounter";ACTION = ACTIVATETASK {TASK = "myTask";};};};int main(void){T1_program();EE_<strong>time</strong>_init(); // EDF initializationADC_init(); // ADC1 configurationPWM_config(); // PWM1 configurationSetRelAlarm(myAlarm, 1, 10);<strong>for</strong> (;;){ // generationDelay(100000);reference = 2.5;Delay(100000);reference = 1;}return 0;}Fig. 4.Main code// reference signalFig. 3.Kernel configuration fileObservation 6: As be<strong>for</strong>e, simulations can be done usingdifferent methods.G. Problem 7. <strong>Control</strong>ler design: observersFor the simulation, the two state variables are available.However, in the real experiment, an observer must be included.For simplicity in coding the control task, a reduced observercan been chosen <strong>for</strong> observing the second state variablex 2 . Forexample, the observer discrete gain is K r = −37.81 or K r =−13.42 <strong>for</strong> the fast <strong>and</strong> overshoot controller if the observercontinuous closed loop pole are located at p ob = −50.Observation 7: Students can design <strong>and</strong> evaluate by simulationdifferent types of observers (reduced, complete, etc.)with different dynamics. That is, they can also evaluate theeffect of different locations <strong>for</strong> the observer poles. Froman implementation point of view, students can also assessthe effect that splitting the control algorithm into two parts(calculate control signal <strong>and</strong> update state) has on input-outputdelays <strong>and</strong> schedulability [28].H. Problem 8. Implementation: kernel configuration <strong>and</strong> controlalgorithmThe first implementation involves coding the controller ina periodic task that will execute in isolation on top of Erika.The main pseudo-codes are illustrated in Figures 3, 4 <strong>and</strong> 5.Figure 3 is the conf.oil file that specifies the kernel configurationwith EDF (Earliest Deadline First, [27]) schedulingalgorithm <strong>and</strong> a periodic task that will be used to implement,<strong>for</strong> instance, the fast controller. The basics of the main codeare illustrated in Figure 4. First, the <strong>time</strong>r T1 is initialized <strong>and</strong>,together with SetRelAlarm, will produce the periodic activationof the control task every 10 ms (the processor speed wasconfigured at 40 MIPS - Million Instructions Per Second).Figure 5 shows the control task code including the observer<strong>and</strong> the tracking structure.Observation 8: Carrying out the kernel configuration <strong>and</strong>programming the controller could be taught following anordered sequence of steps, such as: 1) introduction to kernelconfiguration, 2) introduction to periodic tasks, 3) introductionto input/output operations (PWM, ADC).TASK(myTask){x_1 = read_adc()r = reference;x_2 = observer(Kr,x1,r,x_1old,x_2old);u = r*NU + K_1*(r*NX_1 - x_1) + k_2*(r*NX_2 - x_2);write_pwm(u);x_1old = x_1;x_2old = x_2;}Fig. 5.<strong>Control</strong> task codeI. Problem 9. Implementation: setup <strong>and</strong> monitoring detailsFigure 6a shows the experimental setup that includes anoscilloscope (<strong>for</strong> displaying the circuit output voltage) toshow the open loop response (Figure 6b) <strong>and</strong> the closed loopresponses (Figures 7a <strong>and</strong> b) achieved by each controllerexecuting in isolation. The oscilloscope screen-shots confirmthat the implementation achieves the control goal: the systemoutput per<strong>for</strong>ms the desired fast tracking or achieves thespecified overshoot.Observation 9: An oscilloscope has been used to monitorboth the responses. It can also be of interest to monitor whetherthe control task executes when specified. Another option couldbe to use the Multibus board to send the data of interest viaEthernet or any other available communication protocol. Thiswould pose interesting challenges in terms of the real-<strong>time</strong>system such as non-invasive debugging.J. Problem 10. Multitasking: simulationA second implementation is introduced to illustrate moreadvanced concepts. In the previous implementation a controltask was executing in isolation. However, in many hightechsystems, the processor is used not only <strong>for</strong> the controlcomputation, but also <strong>for</strong> interrupt h<strong>and</strong>ling, error management,monitoring, etc. And it is known that in a multitaskingreal-<strong>time</strong> control systems, jitters, i.e. timing interferences oncontrol tasks due to the concurrent execution of other tasks,deteriorate control loops per<strong>for</strong>mance [28]. The objective ofthis implementation is to observe these degrading effects <strong>and</strong>implement corrective actions, e.g. [29]–[31].A starting point is to inject a new task in the kernel <strong>for</strong>each control task. The new task, named noisy task, when tobe executed together with the fast controller, is given a period(<strong>and</strong> relative deadline) of 11 ms, <strong>and</strong> it is imposed an artificial


6(a) Fast closed loop response(a) Setup(b) Overshoot closed loop response(b) Open loop responseFig. 7.RCRC responses.Fig. 6.Experiment setup <strong>and</strong> monitoring.execution <strong>time</strong> of 9 ms. The noisy task that goes together withthe overshoot controller has a period <strong>and</strong> relative deadline of110 ms with 90 ms of execution <strong>time</strong>. The simulation of eachmultitasking system was done in the TrueTime simulator [32].Putting together each control task with the corresponding noisytask under EDF results in timing variability (jitter) <strong>for</strong> thecontrol task, as illustrated <strong>for</strong> the first multitasking system inthe schedule of Figure 8a. In this figure, the bottom curverepresents the execution of the fast controller task, whereasthe top curve represents the execution of the noisy task. Ineach graph, the low-level line denotes no-execution (that is,intervals in which the processor is idle), the middle level linedenotes a task ready to execute (i.e., waiting in the readyqueue), whereas the high-level line denotes a task in execution.Note that the control task has a measured execution <strong>time</strong> of0.12 ms, which is much less than the noisy task.Looking at the plant responses in Figures 8 b) <strong>and</strong> c), it canbe appreciated that the fast controller does not exhibit a controlper<strong>for</strong>mance degradation, while the overshoot controller sufferssome degradation: overshoots are bigger, square amplitudediffers, transient response varies, etc. This fact indicates thatthe current control design <strong>for</strong> the fast controller is robustagainst jitters induced by scheduling, while the second oneis more fragile.Observation 10: Adopting an iterative simulation study,students can learn which parameters play an important rolewhen jitters appear. Are shorter sampling periods, or nonovershoottedresponses, a guarantee <strong>for</strong> having robust controldesigns? Which role do deadlines play in reducing jitters? Forfurther questions <strong>and</strong> solutions, see [33] <strong>and</strong> references therein.K. Problem 11. Multitasking: implementation <strong>and</strong> monitoringdetailsThe new implementation requires specifying the noisy taskby modifying the kernel oil file in terms of defining thenew task <strong>and</strong> the associated alarm. Also, the new task hasto be coded: <strong>for</strong>cing an artificial execution <strong>time</strong> is achievedby placing a delay into the code. The main code has to bemodified to configure the new alarm associated to the newtask.After the implementation, in the first multitasking system,it can be verified that scheduling conflicts (as illustrated inthe simulated schedule shown in Figure 8a) may occur, asillustrated in Figure 9a. In this sub-figure, the execution ofthe fast controller task sets an output pin to 0 <strong>and</strong> 1 ateach job start <strong>and</strong> finishing <strong>time</strong>. And the noisy task setsan output pin to 0 <strong>and</strong> 0.5 at each job start <strong>and</strong> finishing<strong>time</strong>. In addition, similar responses <strong>for</strong> the fast <strong>and</strong> overshootcontroller are obtained (see sub-figures 9 b) <strong>and</strong> c)), showingthat the overshoot controller suffers degradation from jitters,while the fast controller shows the same response as it isexecuted in isolation. To illustrative purposes, Figure 10ashows the overshoot controller response when executing inisolation (dark curve) <strong>and</strong> when executing in the multitaskingsystem (grey curve).Observation 11: Undergraduate students may work the experimentup to this problem. It shows the importance of


732.521.510.50 0.5 1 1.5(a) Partial schedule(a) Partial schedule3.532.521.510.500 0.5 1 1.5 2(b) Faster multitasking closed loop response(b) Faster multitasking response3.532.521.510.500 0.5 1 1.5 2(c) Overshoot multitasking closed loopresponseFig. 8.Simulated multitasking RCRC responses <strong>and</strong> schedule.(c) Overshoot multitasking responseconcurrency <strong>and</strong> resource sharing with respect to controlper<strong>for</strong>mance in a multitasking embedded control system.L. Problem 12: Multitasking: design <strong>for</strong> eliminating or minimizingthe jitter problemRecent research literature has faced the problems introducedby jitter <strong>and</strong> many solutions have been proposed. Here, thesolution proposed by Lozoya et al. [31] has been adopted.The basic idea is to synchronize the operations within eachcontrol loop at the actuation instants. In this way, the <strong>time</strong>elapsed between consecutive actuation instants, named t k−1<strong>and</strong> t k , is exactly equal to the sampling period, h. Within this<strong>time</strong> interval, the system state is sampled, named x s,k , <strong>and</strong>the sampling <strong>time</strong> recorded, t s,k ∈ (t k−1 ,t k ). The differencebetween this <strong>time</strong> <strong>and</strong> the next actuation <strong>time</strong>τ k = t k −t s,k (4)is used to estimate the state at the actuation instant asˆx k = Φ(τ k )x s,k +Γ(τ k )u k−1 (5)Fig. 9.Implemented multitasking RCRC responses <strong>and</strong> schedule.where Φ(t) = e At <strong>and</strong> Γ(t) = ∫ t0 eAs dsB, being A <strong>and</strong> Bthe system <strong>and</strong> input matrices in (3), <strong>and</strong> u k−1 the previouscontrol signal. Then, making use of ˆx k , the control comm<strong>and</strong>is computed using the original control gain K asu k = Kˆx k . (6)The control comm<strong>and</strong> u k is held until the next actuationinstant. A control strategy using (4)-(6) relies on the <strong>time</strong>reference given by the actuation instants, if u k is applied to theplant by hardware interrupts, <strong>for</strong> example. In addition, samplesare not required to be periodic because τ k in (4) can vary ateach closed-loop operation.After implementing this strategy on the overshoot controllerin the multitasking system, Figure10 b) shows the result.Specifically, it shows the overshoot controller response whenexecuting in isolation (dark curve) <strong>and</strong> when executing in themultitasking system using the algorithm that eliminates jitters(grey curve).


8Fig. 10.(a) Overshoot controller with/withoutjitters(b) Overshoot controller eliminatingthe jitter problemOvershoot controller: degradation <strong>and</strong> solutionObservation 12: The problem presented above <strong>and</strong> its solutioncan be split into several tasks, like analysis <strong>and</strong> modellingof the new control algorithm, implementation of the controlalgorithm, etc. An interesting issue is how synchronized actuationinstants can be <strong>for</strong>ced in the kernel. For example, asolution could be to use a periodic task <strong>for</strong> computing u k <strong>and</strong>another periodic task <strong>for</strong> applying u k at the required <strong>time</strong>.Another solution could be to en<strong>for</strong>ce synchronized executionsat the kernel level, using the EDF tick counter. Moreover,since different solutions to the jitter problem such as [29]or [30] could have also been applied, students more confidentor interested in specific fields can select the solution that bettermeets their preferences.IV. TENTATIVE WORK PLAN AND ITS APPLICATION TO ASPECIFIC COURSEThe previous section has detailed some of the steps requiredto successfully carry out the lab activity presented in this paper.This section summarizes them in order to propose a tentativework plan that is divided into several sessions, each one beinga two-hour lab.S1 - Introduction: Introduction to the activity, <strong>and</strong> simulationof the open-loop response after obtaining the statespace<strong>for</strong>m of the RCRC circuit from the circuit differentialequations (1) (consider r<strong>and</strong>om values <strong>for</strong> R <strong>and</strong> C). Here itis assumed that state-space notation is chosen.S2 - Problem specification (a): This session should beused to specify the problem in terms of the levels <strong>for</strong> thereference signal <strong>and</strong> <strong>for</strong> discrete controller design, whichincludes selecting the sampling period <strong>and</strong> closed loop polelocations, if pole placement is used. Other control approaches,like optimal control, could also be used.S3 - Problem specification (b): To complement the previoussession, observers should also be designed <strong>and</strong> simulated.The outcome of this session should be the complete simulationsetup.S4 - Basic implementation (a): Build the RCRC circuit<strong>and</strong> verify its dynamics in open-loop. Start the controller implementationin a periodic hard real-<strong>time</strong> task in the processingplat<strong>for</strong>m.S5 - Basic implementation (b): Finish the controllerimplementation <strong>and</strong> test its correctness.S6 - Multitasking (a): Incorporate a noisy task in thesimulation setup to evaluate the effects of jitter. This stepwould require to use, <strong>for</strong> example, the TrueTime simulator.S7 - Multitasking (b): Incorporate the noisy task in theimplementation <strong>and</strong> validate the previous simulation results.S8 - Advanced implementation (a): If degradation in controlper<strong>for</strong>mance is detected in the previous session, simulateadvanced control algorithms or adopt real-<strong>time</strong> techniques tosolve or reduce the jitter problem.S9 - Advanced implementation (b): Implement the previoussolutions <strong>and</strong> validate them.Note that the program timing, layout <strong>and</strong> the set of coveredtopics should be adapted to particular needs/background of thetarget audience or to the goals of the specific curriculum. Forexample, the proposed activity has been introduced as a partof the curriculum of the 2-year master degree on Automatic<strong>Control</strong> <strong>and</strong> Industrial Electronics in the Engineering Schoolin Vilanova i la Geltrú (EPSEVG) of the Technical Universityof Catalonia (<strong>UPC</strong>) [34]. In particular, since 2007, theexperiment was tailored to become part of the laboratory <strong>for</strong>the <strong>Control</strong> Engineering course, which covers continuous <strong>and</strong>discrete linear <strong>time</strong> invariant (LTI) control systems, as well asnon-linear control systems, all using state-space <strong>for</strong>malism.Sessions S1 to S5 were adopted <strong>for</strong> the laboratory of thediscrete LTI control systems part.The <strong>Control</strong> Engineering course can be followed by studentseither in the first semester of the first year or in the firstsemester of the second year. Students choosing the secondoption simultaneously attend a course on real-<strong>time</strong> systems.There<strong>for</strong>e, within the same classroom, not all the students arefamiliar with real-<strong>time</strong> systems. To overcome this apparentdrawback, teams of three students were <strong>for</strong>med containing atleast a student with competence on real-<strong>time</strong> systems. Withinsuch heterogeneous teams in terms of skills <strong>and</strong> theoreticalbackground, it was observed that students took their responsibilities<strong>and</strong> team-work was significantly improved.As in every course edition, after finishing the discrete LTIcontrol systems part, a short <strong>and</strong> simple questionnaire is givento the students to let them evaluate several aspects of this partof the course. The question Do the laboratory activities permitto better underst<strong>and</strong> the theoretical concepts? is the only onerelated to the laboratories. Looking at the students answers,<strong>and</strong> taking into account that be<strong>for</strong>e introducing the presentedexperiment the lab activities were focused on the simulation of


9an inverted pendulum, the percentage of students appreciatingthe practical part has increased significantly. Although thest<strong>and</strong>ard course evaluation indicates this positive trend, amore complete evaluation tailored to the introduction of thisexperiment is required.V. CONCLUSIONSThis paper has presented a laboratory activity to be integratedin the education curriculum of embedded controlsystems engineers. The activity consists of a real-<strong>time</strong> controllerof a RCRC electronic circuit. The potential benefits,competences to be acquired, <strong>and</strong> expected learning outcomes<strong>for</strong> students have been presented. The selection of the plant <strong>and</strong>processing plat<strong>for</strong>m has been discussed. Extensive details ofa sample implementation have been presented <strong>and</strong> a tentativework plan <strong>for</strong> carrying out the activity has been provided.In summary, the proposed activity poses several real challengesto the students that can be met by putting togetherinterdisciplinary skills (electronics, real-<strong>time</strong> systems, controltheory, programming) towards a single goal: building a workingsystem.REFERENCES[1] D. J. Jackson <strong>and</strong> P. Caspi, “Embedded systems education: future directions,initiatives, <strong>and</strong> cooperation”, SIGBED Rev., vol. 2, no. 4, pp. 1-4,Oct. 2005.[2] K.-E. Årzén, A. Blomdell, <strong>and</strong> B. Wittenmark, “<strong>Lab</strong>oratories <strong>and</strong> real<strong>time</strong>computing: integrating experiments into control courses,” IEEE<strong>Control</strong> Systems Magazine, vol. 25, no. 1, pp. 30-34, Feb. 2005.[3] G. Buttazzo, “Research trends in real-<strong>time</strong> computing <strong>for</strong> embeddedsystems”, ACM SIGBED Review, vol. 3, no. 3, Jul. 2006.[4] P. Horacek, “<strong>Lab</strong>oratory experiments <strong>for</strong> control theory courses: Asurvey,” Annual Reviews in <strong>Control</strong>, vol. 24, pp. 151162, 2000.[5] M. Moallem, “A laboratory testbed <strong>for</strong> embedded computer control,”IEEE Transactions on Education, vol. 47, no. 3, pp. 340-347, Aug. 2004.[6] D.-J. Lim, “A laboratory course in real-<strong>time</strong> software <strong>for</strong> the control ofdynamic systems”, IEEE Transactions on Education, vol. 49, no. 3, pp.346-354, Aug. 2006.[7] M. Huba <strong>and</strong> M. Simunek, “Modular approach to teaching PID control,”IEEE Transactions on Industrial Electronics, vol. 54, no. 6, pp. 3112-3121, Dec. 2007.[8] VxWorks operating system from WindRiver, http://www.windriver.com/[9] R. Marau, P. Leite, M. Velasco, P. Martí, L. Almeida, P. Pedreiras, <strong>and</strong>J. M. Fuertes, “Per<strong>for</strong>ming flexible control on low cost microcontrollersusing a minimal real-<strong>time</strong> kernel”, IEEE Transactions on IndustrialIn<strong>for</strong>matics, vol. 4, no. 2, pp. 125-133, May 2008.[10] F. Salewski, D. Wilking, <strong>and</strong> S. Kowalewski, “Diverse hardware plat<strong>for</strong>msin embedded systems lab courses: a way to teach the differences”,SIGBED Rev., vol. 2, no. 4, pp. 70-74, Oct. 2005.[11] Evidence srl., http://www.evidence.eu.com/[12] <strong>Real</strong>-<strong>time</strong> Linux Foundation, Inc., http://www.real<strong>time</strong>linuxfoundation.org/[13] J. A. Stankovic <strong>and</strong> K. Ramamritham, “The spring kernel: a newparadigm <strong>for</strong> real-<strong>time</strong> operating systems,” SIGOPS Oper. Syst. Rev.,vol. 23, no. 3, pp. 54–71, 1989.[14] K. M. Zuberi, P. Pillai, <strong>and</strong> K. G. Shin, “Emeralds: a small-memoryreal-<strong>time</strong> microkernel,” in 7th ACM symposium on Operating SystemsPrinciples, pp. 277–299, 1999.[15] P. Gai, G. Lipari, L. Abeni, M. di Natale, <strong>and</strong> E. Bini, “Architecture <strong>for</strong>a portable open source real-<strong>time</strong> kernel environment,” in Proceedings ofthe Second <strong>Real</strong>-Time Linux Workshop <strong>and</strong> H<strong>and</strong>’s on <strong>Real</strong>-Time LinuxTutorial, Nov. 2000.[16] E. Mumolo, M. Nolich, <strong>and</strong> M. Noser, “A hard real-<strong>time</strong> kernel <strong>for</strong> motorolamicrocontrollers,” in 23rd International Conference on In<strong>for</strong>mationTechnology Interfaces, Jun. 2001.[17] P. Gai, L. Abeni, M. Giorgi, <strong>and</strong> G. Buttazzo, “A new kernel approach<strong>for</strong> modular real-<strong>time</strong> systems development,” in 13th IEEE EuromicroConference on <strong>Real</strong>-Time Systems, Jun. 2001.[18] D. Henriksson <strong>and</strong> A. Cervin, “Multirate feedback control using theTiny<strong>Real</strong>Time kernel,” in Proceedings of the 19th International Symposiumon Computer <strong>and</strong> In<strong>for</strong>mation Sciences, Antalya, Turkey, Oct. 2004.[19] OSEK/VDX Portal, http://www.osek-vdx.org/.[20] G. Buttanzo, Hard <strong>Real</strong>-Time Computing Systems: Predictable SchedulingAlgorithms <strong>and</strong> Applications, Norwell, MA, USA: Kluwer AcademicPublishers, 1997.[21] Eclipse portal, http://www.eclipse.org/.[22] Microchip portal, http://www.microchip.com/.[23] Scilab/Scicos portal, http://www.scilab.org/.[24] MathWorks portal, http://www.mathworks.com/.[25] D. Hercog, B. Gergic, S. Uran, <strong>and</strong> K. Jezernik, “A DSP-based remotecontrol laboratory,” IEEE Transactions on Industrial Electronics, vol. 54,no. 6, pp. 3057-3068, Dec. 2007.[26] K. Ogata, Modern <strong>Control</strong> Engineering, 4th Edition, Prentice Hall, 2001.[27] C. L. Liu <strong>and</strong> J. W. Layl<strong>and</strong>, “Scheduling algorithms <strong>for</strong> multiprogrammingin a hard-real-<strong>time</strong> environment,” Journal of the Association <strong>for</strong>Computing Machinery, vol. 20, no. 1, pp. 46–61, Jan. 1973.[28] K.-E. Årzén, A. Cervin, J. Eker, <strong>and</strong> L. Sha, “An introduction to control<strong>and</strong> scheduling co-design,” in 39th IEEE Conference on Decision <strong>and</strong><strong>Control</strong>, 2000.[29] J. Skaf <strong>and</strong> S. Boyd, “Analysis <strong>and</strong> synthesis of state-feedback controllerswith timing jitter,” IEEE Transactions on Automatic <strong>Control</strong>, vol.54, no. 3, pp. 652-657, March 2009.[30] P. Balbastre, I. Ripoll, J. Vidal, <strong>and</strong> A. Crespo, “A task model to reducecontrol delays,” <strong>Real</strong>-Time Systems, vol. 27, no. 3, pp. 215-236, Sep.2004.[31] C. Lozoya, M. Velasco, <strong>and</strong> P. Martí, “The one-shot task model<strong>for</strong> robust real-<strong>time</strong> embedded control systems”, IEEE Transactions onIndustrial In<strong>for</strong>matics, vol. 4, no. 3, pp. 164-174, Aug. 2008.[32] D. Henriksson, A. Cervin, <strong>and</strong> K.-E. Årzén, “TrueTime: simulation ofcontrol loops under shared computer resources,” in 15th IFAC WorldCongress, 2002.[33] Y. Wu, E. Bini, <strong>and</strong> G. Buttazzo, “A framework <strong>for</strong> designing embeddedreal-<strong>time</strong> controllers”, in 14th IEEE International Conference on Embedded<strong>and</strong> <strong>Real</strong>-Time Computing Systems <strong>and</strong> Applications, Aug. 2008.[34] EPSEVG School portal, http://www.epsevg.upc.edu/.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!