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.

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.

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

Saved successfully!

Ooh no, something went wrong!