Learn Mat Lab on Web

Embed Size (px)

DESCRIPTION

yeah don't know about this book LOL

Citation preview

  • Industrial Electronics Society Newsletter14

    Web-based MATLAB and Controller design learning

    Suzana Uran, Darko Hercog, Karel JezernikUniversity of Maribor, Maribor, Slovenia

    AbstractThis paper presents a web-based virtu-al laboratory for learning of MATLAB.Using this virtual laboratory, studentscould write their own MATLAB M-filesand execute them using the MATLABweb server. In addition, web-basedremote laboratory-experiment RCoscillator for learning of control designis presented. In RC oscillator experi-ment, interactivity between the con-troller design parameters in Bode plotand Root Locus with real experimenthas been implemented in order to sup-port full visualisation of the controllerdesign.

    I. IntroductionThe Internet (Web) has become awidespread tool for teaching and learn-ing. The Web enables more flexibledelivery (anytime), distance education(anyplace), new visualisation possibili-ties (interactivity), and cost reduction.Virtual and remote web-based labora-tories [1, 2] have been developed todate. Remote web-based laboratoriesare based on sharing the sameresources over the Internet [2, 3, 4].Therefore, remote laboratories arerarely opened to the public rather theiruse is limited to the assigned students.In the paper two web-based laborato-ries are presented. The first one is avirtual laboratory that supports learningof MATLAB. In this virtual laboratorystudents can write their own MATLABM-files and execute them using theMATLAB web server. The second web-based laboratory is a remote laborato-ry that supports the learning of controltheory and control design. RC oscilla-tor web-based remote control experi-ment is represented. For RC oscillatorcontroller design, a visualisation ofcontroller design parameters is imple-mented interactively with the remotecontrol experiment.

    II. Learning of MATLABIn engineering education, MATLAB isfrequently one of the tools used to sup-

    port the learning of Maths. Over thelast five years, a hands-on introductionto the MATLAB programme has beengiven to our undergraduate mechatron-ic and automation students. Lack oftime and lab availability for practicingmotivated us to develop a virtual lab,which enables students to learn MAT-LAB outside official lab time. MATLAB web server was designed foruse with fixed MATLAB applications asproposed by MATLAB web serverinstructions. In such fixed MATLABapplications, the capabilities of theWorld Wide Web are utilized to senddata to MATLAB server for computa-tion and to display the results in a clientWeb browser. The computation ofMATLAB is defined in advance byselected application and can not beinfluenced by the remote user.Therefore, fixed MATLAB applicationscould not be used for learning of MAT-LAB, but only as a computation tool.Web-based learning of MATLAB isbased on MATLAB programming capa-bilities. MATLAB enables writing of aseries of MATLAB statements (a pro-gram) into a file with extension .m, andthen executing them with a single com-mand. Files with extension .m arecalled M-files. A MATLAB applicationhas been written, which enables trans-mission of the M-file over the web tothe MATLAB web server, and a displayof the results in a client Web browser.The m-file sent to the MATLAB webserver should contain all data defini-tions, as well as computation com-mands. Students learning MATLABcan use any ASCII editor (Notepad orsimilar) to write the MATLAB m-file. Astandard web browser (InternetExplorer, Mozilla, etc.) is needed forlearning of MATLAB over the web. TheInternet address of the MATLAB appli-cation supporting web-based MATLABlearning is http://hl1.uni-mb.si/

    III. Learning of Controller designA remote lab at Faculty of ElectricalEngineering and Computer Science,

    University of Maribor was establishedin order to support the learning of con-trol. This remote lab provides variousremote experiments (cascade controlof DC motor, two axes mechatronicdevice control, RC oscillator). Remotelab experiments are available on:h t t p : / / r e m o r e l a b . r o . f e r i . u n i -mb.si/eng/experiments.asp.The RC oscillator is a web-based ver-sion of interactive controller design andexperiment (in the following WICDE).The RC oscillator experiment is used inan introductory control course at ourfaculty. The objectives of WICDE are: to teach students control design, to minimize the gap between controltheory and practice, by teaching con-trol implementation [5, preface], to show students how to learn by Weband how to use it and to support learning by doing.The WICDE was designed to be avail-able to a broad range of our students.Therefore, it was designed with mini-mum software requirements from thestudents prospective. To perform theWICDE experiment, a standard webbrowser (Internet Explorer, Mozilla,etc.) and LabVIEW Run Time Engineare needed. Unfortunately, theassumption of minimum students soft-ware requirements sets an undesirablelimitation on the implementation ofLearning through doing. This limita-tion means that students can not buildtheir own experiment but could onlyvary the parameters of the already pre-pared experiment. Such a limitation iswidely accepted for web-based experi-ments. Only a web-based experimentpresented in [3] assumes the MAT-LAB/Simulink software environment tobe possessed by the students.Therefore, in the case of the web-based experiment in [3], students couldbuild their own experiment from home.

    System architecture of WICDE

    WICDE is implemented using a DSP-2learning module, and a breadboardwith an RC circuit (Figure 1). The DSP-2 learning module is an embedded,

  • light and small in volume DSP-basedcontrol system. It was developed at theFaculty of Electrical Engineering andComputer Science, University ofMaribor. The DSP-2 learning module ispresented in detail on the Internetaddress: http://www.ro.feri.uni-mb.si/projekti/dsp2.The DSP-2 learning module representsan open framework for rapid controlprototyping (RCP) and rapid remotecontrol experiment development.Figure 2 presents the block scheme ofthe DSP-2 learning module-basedremote laboratory. A DSP-2 learningmodule, connected to a lab PC throughthe serial port, implements a controlalgorithm developed using Simulink[6], and through the analog and digitalI/O signals, drive the real plant.LabVIEW virtual instrument and theLabVIEW server run on the same labPC for the purpose of enabling remotecontrol of the real plant. LabVIEW VIperforms communication between thelab PC and the DSP-2 learning mod-ule, and enables DSP-2 data visualiza-tion and parameter tuning, whileLabVIEW server enables remote oper-ation of the LabVIEW VI. Remoteusers, connected to the server throughthe Internet, must have a LabVIEWRun-Time Engine installed on theirpersonal computer in order to performremote experiments. During remoteexperimentation, the remote user canadjust the controller parameters andsend experimental results via email.The DSP-2 learning module-basedRCP system is based on two commer-cially-available software packages i.e.MATLAB/Simulink and LabVIEW, andcustom-made hardware i.e. DSP-2learning module. MATLAB, Simulinkand Real-Time Workshop (RTW) are

    used for control algorithm develop-ment, simulation, offline analysis andrapid executable code generation [6],while the LabVIEW provides on-the-flydata visualization and parameter tun-ing tasks. LabVIEW virtual instrument(VI) is automatical-ly generated dur-ing the binary codegeneration process, from Simulinkmodel, where the user front end of cre-ated VI depends on special DSP-2blocks used in the Simulink model.Using Remote Panels (LabVIEW add-on toolkit), generated VIs can be easi-ly viewed and controlled over theInternet. LabVIEW VIs can be pub-lished on the Internet with no addition-al programming and can be remotely

    observed or controlled by using onlythe standard web browser.

    RC oscillator controller design and

    experiment

    RC oscillator exercise is described inthis subsection and the tools for itssolution are presented.Task description of the RC oscillatorexercise:Build the RC oscillator shown in Figure3, which is based on the 3rd order RCcircuit.R1 = R2 = R3 = R = 47 ohm,

    C1 = C2 = C3 = C = 1 F.

    Build a mathematical model of the RCcircuit and verify your model using thestep and sinusoidal responses. UsingBode plot or Root locus methods,design a P controller with gain KR for

    RC oscillator. RC oscillator is used forgeneration of sinusoidal signals, there-fore, design gain KR for the margin of

    stability. Verify your design by theexperiment. Observe the responses ofthe RC oscillator before, and after, themargin of stability.Mathematical model (transfer function)of the RC circuit shown in

    Figure 3 is given by equation (1). The MATLAB/Simulink scheme imple-mented for the WICDE RC oscillator isshown in Figure 4. The open-loop con-trol of RC circuit and feedback controlof RC circuit are combined in oneSimulink block scheme. Switch S1 isused to select between open-loop orfeedback control. When open-loopcontrol is selected switch S2 is used to

    select the step or the sinusoidal inputto the RC circuit. When feedback con-trol is selected another switch takesaction. This switch selects between theinitial condition (IC) input and feedbackwith gain KR for input into the RC cir-

    cuit. Therefore two phases of the RCoscillator response are observed. Thecapacitors of the RC circuits are charg-ing to the value IC when IC input isselected. This phase is called thecharging phase. When feedback withgain KR is selected the RC oscillator

    response is observed. This phase iscalled the RC oscillator relaxationphase. Signals Uref, Uin, Uout1 and

    Uout2 from the Simulink block scheme

    Fig. 1 DSP-2 learning module with RC circuit on thebreadboard.

    Fig. 2 DSP-2 based remote laboratory block scheme.

    Uout

    Uin

    KR0 -

    +

    R1

    R2

    R3

    C1

    C2

    C3

    Fig. 3 RC oscillator control loop

    Eq. 1

    Industrial Electronics Society Newsletter 15

  • could be observed. Online tuning of theKR (RC oscillator feedback gain), IC

    (the value to which capacitors shouldcharge) and per the period of the pulsegenerator switching between thecharging and the relaxation phase ispossible. Due to delays appearing inInternet connections, delays alsoappear between the variation of thegain KR and the interactive view of theRC oscillator response. The RC oscillator Bode plot or RootLocus plot can be observed interactive-ly with the RC oscillator response. Bothmentioned plots are calculated byMATLAB on the basis of the RC circuittransfer function given in (1). Controllerdesign parameters, such as phasemargin and crossover frequency, areclearly marked in the Bode plot.Accordingly in Root Locus the actualroots of the control loop are clearlymarked. Bode plot or Root Locusdesign is selected with the left buttonabove the design diagrams in theLabVIEW front panel (Figures 5 and 6).

    ConclusionA MATLAB web server application hasbeen written to enable students to writetheir own MATLAB M-files and executethem using MATLAB web server. In thisway students could learn MATLABover the web. In the future it is desir-able to achieve web-basedMATLAB/Simulink learning for stu-dents.For controller design, a visualisation ofcontroller design parameters interac-tively with the control loop stepresponse is very important. In MAT-LAB, the environment SISOtool offerssuch visualisation capabilities but onlyfor simulated control loops. In RC oscil-lator WICDE, experiment interactivitybetween the controller design parame-ters in Bode plot and Root Locus with

    real experiment has been established.According to our knowledge none ofthe web-based experiments [2, 3, 4]incorporates controller design interac-tive with experiment. More remote lab

    experiments with interactive controllerdesign are planned for the future.

    References[1] S. Dormido, Control Learning: Present and Future,In Proc. 15th IFAC World Congres on AutomaticControl,Barcelona, Spain, 2002.[2] C. Schmid, Internet-basiertes Lernen,Automatisierungstechnik, vol. 51, No. 11, 2003, pp. 485-493.[3] M. Casini, et all, The Automatic Control Telelab,IEEE Control Systems Magazine, vol. 24, No. 3, 2004,pp.36-44.[4] H. Hoyer et all, A multiuser Virtual-RealityEnvironment for a Tele-Operated Laboratory , IEEETransactions on education , vol. 47, No. 1, 2004, pp.121-126.[5] G. Ellis, Control System design guide, A PracticalGuide, Elsevier Academic Press, 2004[6] D. Hercog, K. Jezernik: Rapid Control Prototypingusing MATLAB/Simulink and DSP-based MotorController, International Journal of EngineeringEducation (IJEE), Vol. 21, No. 4, 2005

    Industrial Electronics Society Newsletter16

    Fig. 4. Matlab/Simulink block scheme for RC oscillator

    Fig. 6. Root Locus method design with interactive experiment (KR=20)

    Fig. 5. Bode plot design with interactive experiment (KR = 5)