TeachingPIDwithLabview_07

download TeachingPIDwithLabview_07

of 10

Transcript of TeachingPIDwithLabview_07

  • 7/28/2019 TeachingPIDwithLabview_07

    1/10

    Teaching PID and Fuzzy Controllerswith LabVIEW*

    J. P. KELLER

    Oensingen Institute of Technology, Switzerland. E-mail: [email protected]

    This paper presents an educational concept for teaching PID and fuzzy controllers with LabVIEW.The simulation trainers for PID and fuzzy controller design are described. In addition, personalexperiences with the trainer are summarised. Finally, programming considerations and costestimates are presented.

    INTRODUCTION

    USING ATTRACTIVE simulations, students canefficiently acquire a lot of experience in controllertuning. Suitable tasks are in designing fuzzycontrollers or tuning PID controllers in variouscontrol structures. Different types of plants,measurement noise or nonlinearities such as actua-tor saturation form a large field of simulationproblems. Simulation is an inexpensive and fastway to practice many problems unimaginablein laboratory experiments. Simulation does notreplace laboratory experiments. Analysis of plantstructure and dynamics is better done with a realplant, but with the simulation experience and thealready familiar control panel, students need only

    about 14 of the time to complete an experiment.This also shows that simulation experience istransferable to real-life problems.

    This contribution presents simulation trainers forPID and fuzzy-controller design. The PID-trainer isdescribed and possible problems are formulated.The trainer for fuzzy controller design is documen-ted, personal experience with the simulation traineris summarised, and programming considerationsand estimation of costs are given.

    EDUCATIONAL CONCEPT

    Simulation isn't a priori an efficient tool ineducation. Incorporating simulation into a demon-stration is most likely a waste of time. The risk isthat students only remember a fancy simulation,but the information, if even realised, is forgottenvery quickly. This changes completely if studentshave to work with simulation, e.g. solve a chal-lenging problem. The role of simulation is thentwofold. First, it may contain an unwritten part ofthe problem formulation. For controller design,analysis of plant dynamics is an important step.This can be carried out by simulating the plant.

    Second, simulation is the student's tool to verifytheir solution. Without any risk of hazardous

    situations, students can explore the whole rangeof controllers.The consequences are that simulation is not very

    suitable as an education tool for fundamentalsand basic problems, but is best used in the trainingphase. In contrast to laboratory experiments,simulation is a cheap and fast way to experiencea diverse field of control problems. The dimensionsof our field are:

    . Plant parameters: defining sets of plantparameters, several typical controller designproblems can be formulated.

    . Noise: disturbance rejection is one of the funda-

    mental control tasks. Simulating the plant withdifferent noise levels, controller performancecan easily be investigated. Furthermore, includ-ing noise into simulation is a very importantissue in bringing simulation closer to reality. In asimulation, sensor signals are generally at least10 digits too accurate in comparison to realworld signals. This leads to controller designswith unrealistic amplification of high frequenciesusing controllers with a large derivativepart. As aconsequence it is possible, for instance, to achievesimilar, although unrealistic closed loop per-formance with a single PID controller as with acascaded control structure. This is due to the fact

    that plant disturbances can easily be monitored atthe 16-digit plant output signal.

    . Selection of control structure: in a laboratoryexperiment, the control structure is usuallypredetermined by installed equipment. Moredegrees of freedom can be incorporated into asimulation. Since almost all possibly measurablevariables are available in simulation, it is veryeasy to realise a simulation, where the task ofselecting the measured variables is left to thestudent.

    The educational risk of simulation exercises is that

    a solution is found by trail and error method.Either the exercises have to be so difficult that* Accepted 9 September 1999.

    1

    Int. J. Engng Ed. Vol. 16, No. 2, pp. 000000, 2000 0949-149X/91 $3.00+0.00Printed in Great Britain. # 2000 TEMPUS Publications.

  • 7/28/2019 TeachingPIDwithLabview_07

    2/10

    they can't be solved by trial and error, or a meanfor quality assurance has to be used. The followingtools can be recommended: a working sheet inwhich the student has to document and justifythe design steps and an assessment sheet whichfocuses the student's work on the principal goals ofthe simulation exercise.

    Finally, simulation can be replaced with alaboratory experiment. Due to the simulationexperience and being familiar with the HMI(human-machine-interface), the rate of success inthe laboratory work is almost 100% and completedin 1

    4of the time without simulation training. But

    having several simulation exercises done, the

    students are very demanding, so they have to beconvinced of the additional value of a laboratoryexperiment. The laboratory exercises have to beadapted to the changed conditions. For example,more emphasis can be put onto the problem ofcontroller realisation on a PC.

    LabVIEW Gsim Control and Simulation toolkitis not a well known simulation tool, but there areseveral reasons for using LabVIEW for simulationas well. If you have to make a simulation tool forsomebody who is not interested in simulationtechniques or modelling, who does not want tospend $10,000 on a simulation tool or spend oneweek learning how to use the simulation environ-ment, then you are well advised with LabVIEW.The only limits of an HMI may be the screen sizeof a notebook. A LabVIEW VI is easy to run andif each control and indicator has its description,online-help is available. The VI Info may be usedfor general explanations of the simulation prob-lem. With the application builder, an exe-file canbe created and distributed to the students. Since noadditional software has to be installed, the simula-tion-exe can be copied to any location. There areno installation problems.

    A LabVIEW programmer familiar with system

    theory can create LabVIEW simulations by study-ing some of the examples, i.e. the Gsim Tool is easyto use.

    SIMULATOR FOR PIDCONTROLLER TUNING

    Since there is large variety of PID controllers,the implemented control law has to be documen-ted. Afterwards the simulation tasks are described.They cover the following topics:

    . Test of a PID controller.

    . Tuning of a single PID controller for differentplant models.

    . Design of a feedforward controller.

    . Tuning cascaded controllers.

    The PID controllerA parallel configuration of the proportional,

    integral and derivative part is used. The derivativepart is calculated with respect to a filtered errorsignal. The PID controller C in Fig. 1 basicallyimplements the following control law:

    ut K

    et 1aTn

    et dt TV deftadt 1deft

    dt

    1

    NTVet ef t 2

    with K controller gain, Tn

    reset time,Tv

    raise time, N time constant of derivativefilter with respect to T

    v, (although: derivative gain

    limit). The variables are defined in Fig. 1.The controller output is limited to the range

    [100, 100]. As anti-windup strategy, the control-ler implements the strategy proposed by Astro m.For a complete study on anti-windup strategies,

    Fig. 1. Feedback control.

    Fig. 2. Anti-windup with tracking time Tt.

    J. P. Keller2

  • 7/28/2019 TeachingPIDwithLabview_07

    3/10

    see [1]. The amount the control signal exceeds theactuator limits modifies the integral part. Figure 2shows a block diagram of the controller with anti-windup. With negative feedback and weightedwith a constant called tracking time the differencebetween the limited and the unlimited controlleroutput is added to the integrator input. For a

    constant controller error et , the ratio betweenthe rise time and the tracking time determines thelimits of the integrator. This anti-windup strategyis insensitive to short time changes in the controlerror i.e. the integral part is not reset to anarbitrary value as with some other anti-windupmethods. Since anti-windup problems are not themain topics of this simulation trainer, the trackingtime is fixed as Tna3. This gives a reasonablecontroller behaviour and the students do nothave to be concerned with this value.

    If the controller is operated in manual mode, thecontroller output can be set manually. This isuseful to produce step responses of the plant. Abumpless switch to the auto-mode is possible.

    PID testBetter than believing is testing the functionality

    of the implemented PID controller. Three signalsare available to change the controller setpointautomatically. The process value can be changedmanually to produce any desired error signal et .This VI can be used as introduction to the con-troller trainer. The well known textbook step andramp responses can easily be reproduced by simu-lation. The students get familiar with the controllerpanel and have confidence that the control law is

    calculated reliably. This becomes important whena reason for problems with controller tuning has tobe found.

    PID trainerTuning a PID controller is one of the most

    frequent controller design problems. It is thereforea compelling chapter in basic control education.Based on tuning rules, such as the well knowntables of Ziegler/Nichols or Chien/Hrones andReswick or more sophisticated schemes, a good

    initial guess for the controller parameters can bedetermined. Real-life control problems usuallyforce an engineer to optimise the controller para-meters. In my opinion there is a lack of docu-mented methods for controller optimisation. Bymeans of simulation, a student can acquire a lot ofexperience in optimising existing controllers.

    A set of 6 plants is available. Random noise canbe added at the plant output. The plant transferfunctions are documented in Table 2 (Appendix).A brief qualitative description of the plants is thefollowing:

    . Plant 0 and 1: typical plants for step response

    controller tuning of stable plants.. Plant 2: typical plant for step response controller

    tuning of an unstable plant.. Plant 3: first-order plant, a method other than

    Ziegler/Nichols is required.. Plant 4: third-order plant, unstable control

    system for tuning rules with small phasemargin. Can be used to determine critical gainand frequency according to Ziegler/Nichols.

    . Plant 5: second-order with damping factor 0.6.

    . Noise: a random signal is added at the plantoutput. Two nonzero noise levels can beselected.

    Step response controller tuning can be done withall the plants. In order to simulate a step responsethe PID controller is set to manual operation

    Fig. 3. PID-control panel.

    Teaching PID and Fuzzy Controllers with LabVIEW 3

  • 7/28/2019 TeachingPIDwithLabview_07

    4/10

    mode. The `manual control' slider or the digitalcontrol can be used to change the controlleroutput. The simulated response is plotted on achart. Using the chart measurement tools ofLabVIEW the step response parameters can beidentified. Different control objectives lead to awide palette of tuning problems. Minimising rise

    time, settling time or rise time with no overshootare typical examples. Always let the students checkdisturbance attenuation. To avoid trial and errortuning, a worksheet as in the following example isrecommended:

    1. Analysis: draw a sketch of the step response andindicate important step response measures.

    2. Select a controller and explain the selection.Determine the controller parameters forminimal rise time.

    3. Draw a sketch of the closed-loop response.Explain how to change controller parametersto improve performance.

    4. Give an estimate of the variance of the plantoutput when the noise level is set to large.

    It is preferable to let the students draw the sketchmanually than to produce prints of the simulationwindow.

    The control panel of the PID Trainer is shownin Fig. 3. All controls and indicators have adescription and the VI Info is used for a generalexplanation of the exercise.

    Start the main panel and select the exercise `PIDTrainer'. You may select the real-time option toget a time feeling during simulation as well.Pressing the start button on the main panel, the

    PID Trainer becomes visible. The PID Trainer isstarted with the start button and stopped with thestop button. If a simulation is stopped, all internalvariable shift registers are reset to their initialvalue. All controller parameter changes will alsohave effect during simulation. For a change of themodel number to become effective, the simulationhas to be stopped and restarted.

    In order to analyse the controller behaviour, youcan press the `Analyse PID' button. The PID panelis opened and two charts are available for con-troller analysis. The upper chart shows the usualcontroller signals. In the second chart, the indivi-dual contributions of the P, I and D parts of the

    controller are shown. This chart gives a lot ofinsight into how a PID controller works. Forinstance you might use this tool to demonstratethe problem of steady-state control errors forcontrollers without integral action. This can bedone with the following procedure. Put thecontroller in manual mode and set the controloutput to 20 or any other value. The processvariable will reach some final value. Use thisvalue as setpoint. For a given proportional gain,it is easy to calculate the steady-state control errorof a P controller necessary to achieve the controlleroutput of 20. This can be verified with simulation.

    Now, using a PI controller, you restart the simula-tion and verify that the integral part will `learn' the

    value 20 of the controller output. You need torestart the simulation, because as you can see in theanalysis chart, the integral part is set equal to themanual controller output for a bumpless switch toauto-mode.

    Feedforward controllersDuring the exercises with the PID Trainer, it

    becomes obvious that a controller design with nostep response overshoot will have a reduced dis-turbance attenuation. In order to circumvent thisproblem, a feedforward controller is advisable.The feedback controller can be optimised withrespect to disturbance attenuation and a low passfeedforward controller is used to achieve theacquired step response. Typically setpoint rampor first-order filters are available on classicalcontrollers. The parameterisation of such con-trollers can be practised with simulation. In afirst step the feedback controller is optimised

    with respect to disturbance attenuation. In thesecond step, the parameters of the feedforwardcontroller are chosen to minimise rise time, butto avoid overshoot. The simulation model is model0 of the PID Trainer exercise.

    The control panel is similar to all PID controlpanels. In addition, two types of feedforwardcontrollers can be chosen: first-order filter (PT1)and setpoint ramp. With the control labelled `timeconstant' both controllers are parameterised. Forthe first-order filter, the value is the time constant;for the ramp function it is the rise time for onesetpoint unit.

    Cascaded controlPID controllers are often applied in multi-loop

    structures. A frequently used candidate is thecascaded control structure. Tuning cascadedcontrollers can be easily explained in theory, butwhen faced with a real-life cascaded controller theprocedure is not always obvious. This might be dueto the fact that the controller interface is morecomplex, mainly in compact controllers with asmall display. It is also possible that the controllerimplementation or the plant do not allow thetuning of the controllers sequentially.

    Figure 4 shows a diagram of a cascaded controlloop. One motivation to use cascaded control is toattenuate noise, labelled d1, within the first subsys-tem P1. This is possible and controller tuning iseasy, if the dominant time constant of the firstsubsystem P1 in Fig. 4 is much smaller than thetime constant of the second subsystem P2. If thedominant time constants are similar, the con-trollers interact strongly and controller tuning isnot simple. Advantages of cascaded control struc-tures become questionable. If the dominant timeconstant of P1 is large compared to the timeconstant of P2, cascaded control is useless.

    These well known properties of cascaded control

    can also be explored with the simulator. Threedifferent plant models are available:

    J. P. Keller4

  • 7/28/2019 TeachingPIDwithLabview_07

    5/10

    fast-slow:P1(z) 0.4/(z 0.8);P2(z) 0.05/(z 0.99)

    2

    (sample time: 0.1 seconds)equal:

    P1(z) 0.02/(z 0.99);P2(z) 0.05/(z 0.99)

    2

    slow-fast:P1(z) 0.002/(z 0.999);P2(z) 0.05/(z 0.99)

    2

    Disturbance: d1 is a small sine function added to arandom signal and d2 is a purely random signal.The amplitude of d2 is only about 10% of theamplitude of d1 in order to make the attenuationof d1 evident at the plant output. Unless there is adisturbance d2, good control can also be achievedby a single PID controller.

    Since a cascaded control structure consists oftwo controllers, it is not easy to design a clearlyarranged control panel. It is reasonable that bothcontrollers have the same controls and indicatorsas the single loop controller. Moreover, time chartsshowing the controller behaviour are mandatory.

    As a consequence the control panel is slightly

    overloaded. Figure 5 shows the relations of thecontrols and indicators to the signals in the controlstructure diagram.

    Tuning the cascade starts with identification ofthe inner loop plant P1. Select the `Slave only'operation mode, set the slave controller to manualoperation mode and simulate a step response ofplant P1. The `manual control' slider or the digitalcontrol can be used to change the controlleroutput. The simulated response y1t is plotted ina chart. Using the chart measurement tools ofLabVIEW the step response parameters can beidentified. Select controller type (P, PI, PD orPID) and determine the controller parameters.Put the slave controller in `auto' mode and checkthe performance of the inner loop (slave control-ler). In the `slave-only' mode, the setpoint of theslave controller can be entered at the `setpointslave' control.

    Which plant is controlled by the master control-ler? The students must be able to answer thisquestion to be able to determine the controllerparameters. The master controller's plant is theinner control loop in series with the second part of

    the physical plant. Therefore, the plant output

    Fig. 4. Cascaded control structure.

    Fig. 5. Signals on the panel of the cascaded controller.

    Teaching PID and Fuzzy Controllers with LabVIEW 5

  • 7/28/2019 TeachingPIDwithLabview_07

    6/10

    response y2t to a setpoint change at the innercontrol loop must be produced. This can be donein the same configuration as before, where perfor-mance of the slave controller was checked. Thesignal of interest is now y2t and its step responseparameters can be measured in the master con-troller's chart. Configure the master controller,

    change the operation mode to `cascade' and testthe controller performance.

    This tuning procedure can be done for all plantconfigurations, i.e. for fast-slow, equal and slow-fast. The students might experience difficultieswith the equal and slow-fast plant configurationsand hopefully will remember suitable plant struc-tures for cascaded control. It is clear that con-troller performance can not be compared withrespect to the different plants. But for each plant,it is interesting to compare the cascaded controlstructure with a single-loop PID controller.This can be done by setting the operation modeto `single PID'. The differences become evidentwhen noise is added to the simulation.

    FUZZY CONTROLLER DESIGN

    The fuzzy controllerThe fuzzy simulator is based on the fuzzy

    controller of the LabVIEW Fuzzy Logic Toolkitfor G. A fuzzy membership function editor allowsthe user to quantitatively define linguistic terms forinput variables. A rule-base editor is used to definerules for the controller output based on the linguis-tic terms defined. The Fuzzy Logic Toolkit for G is

    used to implement rule-based feedback controllers.A fuzzy controller VI is used in the application VIto process input data based on the fuzzy controllerdesigned. The toolkit is well suited for controlapplications on nonlinear or complex systemsthat are difficult to model mathematically butmay be controlled by human operators.

    House temperature controlMany students have some experience with house

    temperature control. There is no need to explainwhy and how to heat a house. With housetemperature simulation, two problems can bepractised. The first is to select physically sensible

    controller inputs from the set of directly measuredor derived variables. The following variables canbe chosen:

    . indoor temperature, its time derivative andintegral;

    . outdoor temperature and its time derivative;

    . control error, its time derivative and integral;

    . indoor minus outdoor temperature and its timederivative.

    It is clear that not all the available variables aremeaningful, only a few are well suited as fuzzycontroller inputs.

    The second problem is how to systematicallycompensate disturbances. The outdoor temperature

    changes with time. The heating power necessaryto compensate the heat loss can be determinedexperimentally. Ideally the heat loss is repre-sented as a function of the indoor to outdoortemperature difference. This knowledge can beincorporated into the fuzzy controller design.With suitable membership functions and rules

    the input/output characteristics of the fuzzycontroller can be tuned to compensate theheat loss.

    The simulation model of the house is thefollowing:

    Pel kT To cd T

    dt3

    (d Ti

    dt T Ti 4

    with: Pel heating power range: 0 F F F 10Y 000 W;k heat loss coefficient 400 W/8; c heatcapacity, 330,000 J/8; To outdoor temperature;Ti measured indoor temperature; ( sensortime constant, 3 min.

    The temperature setpoint is reduced during thenight. Setpoint during the day is 208C, at nighttime 158C. The outdoor temperature is a sinefunction. The simulation creates the setpoint andthe outdoor temperature automatically.

    Controller performance: the simulation VIdetermines a measure for controller perfor-mance. It is a weighted sum of the squaredcontrol error and a measure for the controleffort integrated over the simulation timerange of 3 days. The control effort is measured

    with the variance of the 8 last control values.This aims to punish fast changing, thoughunrealistic control signals.

    The worksheet of the simulation is as follows, inanalysis:

    . Disturbance compensation: a) What is the majordisturbance of the system? b) Find a function(equation or graph) and its arguments to deter-mine the amount of heating power required tocompensate the disturbance.

    . Chose sensible fuzzy controller inputs andjustify each selection with sound physicalarguments. The controller function, as far as

    is possible, must be independent of thetemperature setpoint.

    In design and optimisation:

    . Design a fuzzy controller for the temperaturecontrol problem. The fuzzy controller mustimplement the disturbance compensation func-tion of 1b. Verify it with the I/O characteristictool.

    . Minimise the performance measure!

    The assessment sheet in Table 1 is given to thestudents with the exercise. It should meet thefollowing goals: minimise trial and error

    approaches and avoid frustration after havingspent several hours on the exercise.

    J. P. Keller6

  • 7/28/2019 TeachingPIDwithLabview_07

    7/10

    Race trackThe race track simulation is suitable for a fuzzy

    controller design competition. Students are highlymotivated to take part in such a competition. Thesimulation time is given and the car with the bestfuzzy controllers will run the longest distance.

    . Sensors: the car speed is available. Furthermorethe racing car is equipped with three sensors, onelooking to the right, one straight ahead and theother to the left. All three measure the distanceto the edge of the track. When the car exits thetrack, the sensor value will most likely be 1. Toadapt the sensors to the control strategy, theangle 9 between the sensor directions can beconfigured.

    . Controls: the controls of the racing car is the caracceleration and the steering angle. The car isequipped with anti-sliding control, i.e. the maxi-mum steering angle is a function of the carspeed. The range of the steering angle is 80degrees. The car acceleration is limited to 20acceleration units. The car speed is modelled as afirst-order system.

    Two fuzzy controllers are to be designed, the firstfor steering control, the second for speed control.As in the preceding simulator, a large set of inputvariables are available. These are:

    . distances: d1, d2, d3, d3 d1

    . distance derivatives: dd2/dt, d(d3 d1)/dt

    . car speedIn Fig. 5, the control panel is shown. In an x/y plotthe race track and the moving car are plotted.Steering angle, acceleration and car speed areshown in the time plot on the left for analysispurposes. The example plot in Figure 6 clearlyshows the limiting of the steering angle. Themaximal steering angle only increases when thecar speed is reduced as can be seen in the middle ofanalysis plot. This forces the speed controller toreduce car speed to be able to turn on curves.

    Often, the simulation is too fast to allow analysisof the controller behaviour. For this purpose, a

    time zoom control is available. Its value is thewaiting time between two simulation steps.

    EXPERIENCE WITH THE SIMULATIONTRAINER

    The PID trainer has been a part of basic controleducation for 2 years. The students' feedback isgood, but they complained about the time theyhave spent on simulation. The laboratory experi-ments showed that it was time well spent, becausealmost all of the students were able to solve thelaboratory control problem with good results.Without simulation training, the students neededmore than 8 hours to complete the experiment.Familiarity with the control panel and having theexpertise of controller tuning, most studentsfinished the experiment in less than two hours.As an engineer, they will tackle a control problemwithout any hesitation.

    The PID trainer is also well accepted and usedby colleges at the same and at other engineeringschools. Due to the online help, there is no needfor large documentation. New versions can beproduced easily.

    The content of the control theory course was

    changed this year and the course now starts withfuzzy control as the first topic. A training tool thatdoes not need any knowledge of system theory wasnecessary. It was obvious that a LabVIEW fuzzysimulator meets these requirements. After an intro-duction to fuzzy control and to the LabVIEWFuzzy Controller Design tool, the studentsdesigned a fuzzy controller for the tank exampleof the fuzzy toolkit. The race track competitionwas launched and one week later, the results werepresented. It was astonishing that after 24 lessonsof control theory, including an introduction tofuzzy control, the students presented good solu-tions for this control problem. An experiencedcontrol engineer has to spend at least two hoursto produce a competitive solution. With classicalPID control it is hardly imaginable to solve thismultivariable, nonlinear control problem with only24 lessons of control theory. In the laboratory, allthe students were able to design a fuzzy controllerfor a laboratory experiment. The VIs were avail-able and the students only had to design a fuzzycontroller.

    Since a lot of time was spent on simulation, theexam should test the same skills. In the examthe students had to design a fuzzy controller forthe house temperature control problem. The feed-

    back on an exam with simulation was not alwaysgood, because the students claimed that the result

    Table 1. Assessment of the fuzzy simulation exercise

    Topic Criteria

    Disturbance compensation I/O characteristics: sensiblefunction for disturbancecompensation (meets functionin 1b)

    Choice of input variables physically sound justificationcontroller independent ofsetpoint valuedistinctness of arguments

    Linguistic variables rangesnaming of termssensible number of termsmembership function sensible

    rules appropriatecontroller performance

    Fig. 6. Measuring directions of the car sensors.

    Teaching PID and Fuzzy Controllers with LabVIEW 7

  • 7/28/2019 TeachingPIDwithLabview_07

    8/10

    is strongly influenced by luck. But the assessmentsheet revealed that non-optimal controller perfor-mance is strongly correlated to the assessmentcriteria of the fuzzy controller. Obscure names ofvariables and terms, strange membership functions

    were always paired with non-optimal controllerperformance.

    The benefits of simulation training and the useof LabVIEW control panels became evident inthe laboratory experiments and in this examina-tion. Before using the simulation trainer, thelaboratory fuzzy control experiments had neverled to satisfactory results.

    PROGRAMMING CONSIDERATIONS

    Modern simulation tools try to hide the numeri-cal simulation problem, i.e. the integration algo-rithms. This is usually coupled with an increasingneed for computational performance. Since asimulation trainer is usually not based on sophis-ticated physical models, the continuous-timemodel can easily be discretised and implementedas difference equations. This leads to lean and easycomputable models.

    Simulations may produce results so fast that itis not possible to follow a `live' simulation.Analysing a simulation after completion hassome advantages, but needs more skills to repro-duce situations. If it is possible to follow a livesimulation, the interaction with the system is

    immediate and problems with a control law areeasily detected. For this reason, all simulation

    trainers are capable of slowing down the simula-tion using waiting time between the simulationsteps. This possibility to zoom simulation timecan also be used to produce real-time simulation.In real-time simulation, the results are produced

    with the respect to the real time-scale, comparableto the physical plant.

    The online-help capabilities of LabVIEW arevery convenient tools. For each control and indi-cator a short description can be provided foronline-help and for documentation of the VI.

    A major problem of the first versions of thesimulation trainer was the initialisation of vari-ables. The simulator had the capability to stop andresume the simulation. The students rarely usedthis feature. When resuming a simulation, theywere often irritated because of the almost unpre-dictable values of the state variables. As a conse-quence the trainer was simplified. Stopping thesimulation resets all internal variables to theirinitial values. At the same time the problems withinternal variables with value NaN were alsosolved. It is not easy to ensure that all variablesnever have a value NaN. If the variables are notchecked for NaN, only closing and restarting a VIcan reset the variables to useful values. Thisproblem is solved if all variables are reset toinitial values before the simulation starts. Thisis accomplished with the VI structure given inFig. 8.

    All sub-VIs with internal variables have themain loop counter as input signal. Using a case

    structure as shown in Fig. 6, the initial values canbe set.

    Fig. 7. Front panel of the race track fuzzy simulator.

    J. P. Keller8

  • 7/28/2019 TeachingPIDwithLabview_07

    9/10

    The PID trainer now accumulates approxi-mately three weeks of LabVIEW programming.The maintenance costs are negligible and there areno problems in distributing an exe-file. In zippedform it is still less than 1.4 Mb and can bedistributed on a floppy disc. The workload forrealising the race track simulation was under-

    estimated. Moving a car and efficiently calculatingthe sensor signals were the main problems. Thetotal work time is estimated at two weeks ofprogramming. The house temperature controlproblem was realised in one day. Because bothfuzzy applications are quite large, they were notcombined on one fuzzy trainer.

    Compared to C programming, a lot oftime was saved with LabVIEW because of con-venient possibilities for creating controls panel.Even more important were the very usefuldebugging tools.

    CONCLUSIONS

    Simulation is an efficient and inexpensive tool incontrol education. Tuning PID and fuzzy con-trollers are well suited problems for simulation

    training. After a simulation training the studentsare capable of solving a laboratory controlproblem about four times faster than withoutsimulation training. Simulation does not replacelaboratory experiments but it offers the opportu-nity of changing the goals of the laboratory experi-ments from simple controller design problems to

    the control of real-life plants. Results of exami-nations show clearly that with simulation, thestudents have a significantly larger expertise incontroller design. These achievements are mainlydue to the fact that simulation is well accepted bystudents. They spend more time with a fancysimulation than studying from a textbook. Theinstructor's challenge is to assure that the inter-pretation of simulation experiments are based ontheoretical understanding and physical insight.Worksheets and assessment criteria are helpfultools.

    LabVIEW is a powerful environment fordeveloping simulation trainers. Besides the

    mathematical functions it offers a lot of possi-bilities for easily creating control panels. Online-Help and simulator documentation can beincluded without special tools. Powerful debug-ging tools allow the fast development and testingof simulation software.

    REFERENCES

    1. M. V. Kothare, P. J. Campo, M. Morari and C. N. Nett, A unified framework for the study of anti-windup designs, Automatica, 30, 12 (December 1994) pp. 18691883.

    APPENDIX

    Table 2. Plant models of PID Trainer.

    # Transfer function in z, sampling time 0.1s0 num0 [4e-4 5e-4 5e-4]; den0 [1 1.94 0.9405];1 num1 [0.121 0.0117]; den1 [1 1.903 0.9048];2 num2 [9.900E-3 9.900E-3]; den2 [1 1.98 0.98];3 num3 1; den3 [1 0.995];4 num4 [1e-4 1e-4 1e-4 1e-4 ]; den4 [1 3.6 4.86 2.916 0.6561];5 num5 [4.9e-3 4.8e-3]; den5 [1 1.942 0.951];

    Fig. 8. VI structure for initialisation of variables.

    Teaching PID and Fuzzy Controllers with LabVIEW 9

  • 7/28/2019 TeachingPIDwithLabview_07

    10/10

    Jurg Keller was born in Switzerland in 1958. He received the diploma in ChemicalEngineering in 1983 and the Ph.D. degree in 1989, both from the ETH Zurich. After 5

    years of practical control experience with Hoffmann-La Roche, Basel, he is now Professorin Control Engineering at the Institute of Automation, Oensingen, Switzerland. His areasof interest are `filling the gap between theory and application', simulation and sampled datasystems.

    Fig. 9. Step responses of the PID trainer.

    J. P. Keller10