54
Project NATIONAL UNIVERSITY OF SINGAPORE EE4307: Control System Design and Simulation Project This project constitutes a major part (80%) of the final module score. Students are to work on the project independently, although parts of this manual are designed for their guidance. Laboratory assistants will also be available to provide limited guidance. The objectives of this project are:- 1. to provide hands-on experience in the acquisition and processing of real data from real physical systems and the use of computer-based data acquisition devices; 2. to familiarize with key non-parametric approaches to system identification for control design purposes; 3. to familiarize with some common and important functions collected within the System Identification ToolBox of MATLAB 4. to provide learning experience over the entire cycle of parametric system identification; 5. to provide the experience with computer simulation of dynamical systems; 6. to simulate and implement real-time control systems which are designed based on the models obtained earlier.

EE4307 Project Manual 2014

Embed Size (px)

DESCRIPTION

manual

Citation preview

  • Project

    NATIONAL UNIVERSITY OF SINGAPORE EE4307: Control System Design and Simulation

    Project

    This project constitutes a major part (80%) of the final module score. Students are to work on the project independently, although parts of this manual are designed for their guidance. Laboratory assistants will also be available to provide limited guidance. The objectives of this project are:-

    1. to provide hands-on experience in the acquisition and processing of real data from real physical systems and the use of computer-based data acquisition devices;

    2. to familiarize with key non-parametric approaches to system identification for control design purposes;

    3. to familiarize with some common and important functions collected within the

    System Identification ToolBox of MATLAB

    4. to provide learning experience over the entire cycle of parametric system identification;

    5. to provide the experience with computer simulation of dynamical systems;

    6. to simulate and implement real-time control systems which are designed based on the models obtained earlier.

  • EE4307 Control System Design and Simulation Page 1

    Project

    1. Introduction Controller designs for dynamical systems are centred around a system model, which can be in a non-parametric or parametric form. There are systematic steps which should be undertaken before a control system can be designed and finally implemented.

    First, control variables and objectives are defined, based on which the relevant information of the system should be collected in the form of raw data. Modern computer-based data acquisition devices can be used efficiently for this data logging process. The raw data collected may need to be further conditioned, in view of noise and other disturbances inevitably present, before it can be used for the next phase of system modelling.

    System modelling can be carried out with a physical approach, using fundamental first principles to relate the variables of interests. However, this physical approach is typically constrained to small and relatively simple systems. Even then, there are unknown physical parameters to be determined. Another approach is based on system identification which uses only the logged data of the system and a pre- selected model structure to yield a model. In a way, this can be considered a black- box approach as the system, to be identified, is treated as an unknown black box to be fitted to the model structure based on observations of the system only. In this project, the two approaches of system identification mentioned above will be explored.

    System identification approaches can be broadly classified under a non-parametric or parametric approach. A non-parametric approach will yield a non-parametric mode of the system, unconstrained to any parametric structure. For simple control design, such information, which can be in the time or frequency domain, is sufficient. A parametric approach, on the other hand, will yield a full parametric model and it involves an iterative loop to arrive at the final model. This process involves decision making on the part of the person in search of models, as well as fairly demanding computations to furnish bases for these decisions. A user will typically go through several iterations in the process of arriving at a final model, where at each step, earlier decisions are revised. Model-based control designs can be carried out when the parametric model is obtained.

    For system identification, interactive software is a natural tool for approaching system identification. It is also a convenient way to package the rather extensive theory, making it available to the user. MATLAB is an excellent environment for such interactive calculations, with its workspace concept, graphing facilities, and easy data import and export. The System Identification Toolbox is a collection of M-files that implement the most common and useful parametric and non-parametric techniques available. It is specifically aimed at giving the user help, not only at computing, but also at evaluating models. Through this project, students will realize how easily a system identification task may be accomplished through the use of such modern interactive software.

    Once a model becomes available and the controller designed, a simulation study on the adequateness of the model and the control system can be done prior to actual implementation on the real system. Simulation is usually done for prediction, control or even training purposes. The simulation study will allow fine adjustment to the model and/or controller until a satisfactory level of performance is achieved. This step is useful and necessary in many case, as it is not always possible to do an experiment directly on the actual system over a prolonged period for time, due to cost and safety

  • EE4307 Control System Design and Simulation Page 2

    Project

    concerns, or due to the fact that the actual system simply have not yet being developed.

    The project will bring the students through all the phases of control design and simulation. In Part 2, an introduction on the three assigned systems is given. In Part 3, acquisition device and control platform is elaborated. The main project comprises of 5 parts which includes Parts 4 to 8 of the project manual, corresponding to each key phase of the process. The lectures pertaining to Parts 4, 5 and 8 will be covered by Prof. Sam Ge, while the lectures for the remaining parts will be covered by Prof. K. K. Tan. In Part 9, requirements on the project report is given.

  • EE4307 Control System Design and Simulation Page 3

    Project

    2. Desktop Systems Available for Project The following pilot plants are available in the laboratory for the project.

    2.1 DC Motor System A photograph of the D.C. servomotor setup is given in Figure 2.1.

    Figure 2.1: DC Servomotor

    There are two DC motors in the setup. The first DC motor is capable of being driven at speeds of up to 2500 rpm in either direction. The second DC motor, driven directly by the first, provides an analog voltage feedback proportional to the speed and direction of rotation. It acts as a tachogenerator. A continuous rotation potentiometer provides an analog output proportional to the angular position of the output shaft. In this system, the controlled variable of interest is the velocity of the shaft, with the electrical input to the first DC motor acting as the controlling variable.

    2.2 Coupled-Tanks System Figure 2.2 and Figure 2.3 show the front and back views of the KRi Coupled_tank Control Apparatus PP-100. The equipment consists of two small perspex tower-type tanks mounted above a reservoir which functions as storage for the water. A baffle separates the two tanks and it can be adjusted to change the level of coupling. The level of the water in each tank may be visually read on the scale attached to the front of the tanks. Each tank is fitted with an outlet, at the side near the base, and this outlet is connected by a plastic hose with a return through the reservoir lid. The amount of water which returns to the reservoir is approximately proportional to the level of the water in the tank since the plastic water-return tube at the base of the tank functions as a hydraulic resistance. If needed, this resistance may be increased by the use of a screw-type clamp.

    The level of water in each tank is monitored by a capacitive-type probe. Signal conditioning circuits (at the rear of the unit) convert the measured capacitance (a function of the water level) to electrical signals in the range of 0 to +5 volts dc. The zero level has been calibrated to represent the rest point of the water level, that is, when the tank is nearly empty (approximately 20mm on the scale), while the full state (+5volts) is calibrated at the level of the opening to the rear overflow stand- pipes. This occurs at approximately 300mm on the scale.

  • EE4307 Control System Design and Simulation Page 4

    Project

    Figure 2.2 Front view of Coupled-Tank Control Apparatus PP-100

    Figure 2.3 Back view of Coupled-Tank Control Apparatus PP-100

    2.3 Thermal Chamber System Figure 2.4 shows the setup of the thermal chamber system. In this equipment, the thermal chamber unit is mounted on NI SC-2345 with configurable connectors. SC-2345 is connected to DAQ device by a 68-pin shielded cable. The power module SCC-PWR01 is used to supply digital power (+5V) and analog power (15V) to SCC modules in the SC-2345 carrier. One NI SCC-TC02 J-type thermocouple input module is used as the temperature sensor to measure the air temperature in the chamber. Two SCC-FT01 (Feedthrough Module) are used to control the light and the fan. The power supply on the back of the chamber provides the power for both the light and fan in the chamber, by being routed through either SCC-FT01 (Feedthrough Module) in the SC-2345 and then back into the light and fan. The air temperature can be controlled by adjusting the light and fan. Figure 2.5 shows the configuration of the chamber unit. It is a self-contained unit complete with power supply. The real-time

  • EE4307 Control System Design and Simulation Page 5

    Project

    experiment can be easily implemented by connecting the setup with the DAQ device in the PC.

    Figure 2.4 Setup of thermal chamber system

    Figure 2.5 Configuration of the chamber

    2.4 Inverted Pendulum System Figure 2.6 shows the setup of the inverted pendulum system. An inverted pendulum is a pendulum which has its center of mass above its pivot point. It is often implemented with the pivot point mounted on a cart. The inverted pendulum is a classic problem in dynamics and control theory and is used as a benchmark for testing control strategies, such as the stabilization of unstable systems.

    Whereas a regular pendulum is stable when hanging downwards, an inverted pendulum is inherently unstable and nonlinear, and must be actively balanced in order to remain upright. To balance the inverted pendulum system, a torque is required to apply at the pivot point so as to move the pivot point as part of a feedback system. A

  • EE4307 Control System Design and Simulation Page 6

    Project

    simple demonstration of moving the pivot point in a feedback system is achieved by balancing an upturned broomstick on the end of one's finger.

    The inverted pendulum system consists of a 24V DC motor that is coupled with an encoder and is mounted vertically in the metal chamber. The L-shaped arm, or hub, is connected to the motor shaft and pivots between 180 degrees. At the end of the arm, there is a suspended pendulum attached. The pendulum angle is measured by an encoder. The objective of the control system is to balance the inverted pendulum by applying a force to the arm pivot by the DC motor that the pendulum is attached to. The system is connected and controlled by the NI Educational Laboratory Virtual Instrumentation Suite (NI ELVIS II+).

    In the system identification part, find the model of the regular pendulum instead of the inverted pendulum is required to be identified using the methods in part 5 and 6. During the controller design part (part 7 and 8), the inverted pendulum is required to be controlled and part of its model will be given in Appendix E for controller simulation and design.

    1 DC motor & encoder 4 LED indicators 2 Rotary Arm Pivot 5 PCI connector to ELVIS 3 Pendulum Encoder 6 24V Power Jack

    Figure 2.6 Inverted pendulum system

    2.5 Other Preferred Systems Other than these standard systems, students can also propose their own preferred systems to work with, for example, other pilot plants that they work with in their final year projects, etc. In this case, students must be able to somehow acquire the input- output signals for your analysis.

  • EE4307 Control System Design and Simulation Page 7

    Project

    3. Data Acquisition and Control Platform 3.1 Data Acquisition Device In this project, a data acquisition device is used to acquire or generate data. It provides the link between the computer and the pilot plants. For the DC motor system, two types of the DAQ cards, PCI-6024E and AT-MIO-16E-10, are used respectively. For the coupled-tanks system, the DAQ card Lab-PC-1200 is used. For the thermal chamber system, the DAQ card PCI-6014 is used. For the inverted pendulum system, the NI ELVIS II+ is used.

    (1) PCI-6024E

    PCI-6024E features 16 channels of analog input, two channels of analog output, a 68-pin connector and eight lines of digital I/O. It uses the National Instruments DAQ- STC system timing controller for time-related functions. The DAQ-STC consists of three timing groups that control analog input, analog output and general-purpose counter/timer functions. The important specifications are given as follows.

    Table 3.1: Analog input

    Input Characteristics

    Number of channels 16 single-ended or 8 differential (software- selectable per channel)

    Type of ADC Successive approximation

    Resolution 12 bits, 1 in 4096

    Sampling rate 200 kS/s guaranteed (kS: kilo samples) Input signal ranges Bipolar only Max working voltage (signal + common mode)

    Each input should remain within 11V of ground

    Dynamic Characteristics

    Signal Bandwidth

    Small (-3dB) 500 kHz

    Large (1% THD) 225 kHz

    Table 3.2: Analog output

    Output characteristics

    Number of channels 2 (voltage)

    Resolution 12 bits, 1 in 4096

    Max update rate

    DMA 10 kHz, system dependent

  • EE4307 Control System Design and Simulation Page 8

    Project

    Interrupts 1kHz, sytem dependent

    Type of DAC Double buffered, multiplying

    Dynamic characteristics Settling time for full- scale step 10s to s0.5LSB accuracy

    Slew rate 10V/s

    Table 3.3: Digital I/O

    Number of channels 8 input/output

    Compatibility TTL/CMOS

    Input low voltage 0 to 0.8V

    Input high voltage 2 to 5V

    Power-on state Input (High-Z)

    Power requirement.0.7A at +5VDC (5%) Physical

    Dimensions (not including connectors)..17.5 by 10.6cm

    I/O connector68-pin male SCSI-II type

    * The pin configuration of PCI-6024E can be found in the Appendix A.

    (2) AT-MIO-16E-10

    AT-MIO-16E-10 card is one of the AT E Series devices. The AT E Series devices are the first completely Plug and Play-compatible multifunction analog, digital and timing I/O devices for the PC AT and compatible computers. This family of devices features 12-bit and 16-bit ADCs with 16 and 64 analog inputs, 12-bit and 16-bit DACs with voltage outputs, eight and 32 lines of TTL-compatible DIO, and two 24-bit counter/timer for TIO. The important specifications are given as follows.

    Table 3.4: Input characteristics

    Input Characteristics

    Number of channels 16 single-ended or 8 differential (software- selectable)

    Type of ADC Successive approximation

    Resolution 12 bits, 1 in 4096

    Sampling rate 100 kS/s guaranteed (kS: kilo samples) Input signal ranges Bipolar only

  • EE4307 Control System Design and Simulation Page 9

    Project

    Max working voltage (signal + common mode)

    Each input should remain within 11V of ground

    Dynamic Characteristics

    Signal Bandwidth

    Small (-3dB) 150 kHz

    Large (1% THD) 120 kHz

    Table 3.5: Analog output

    Output characteristics

    Number of channels 2 (voltage)

    Resolution 12 bits, 1 in 4096

    Max update rate 10 kS/s, system dependent

    Type of DAC Double buffered, multiplying

    Dynamic characteristics Settling time for full-scale step 10s to s0.5LSB accuracy

    Slew rate 10V/s

    Table 3.6: Digital I/O

    Number of channels 8 input/output

    Compatibility TTL/CMOS

    Input low voltage 0V to 0.8V

    Input high voltage 2V to 5V

    Power-on state Input (High-Z)

    Power requirement 0.7A at +5VDC (5%)

    Physical

    Dimensions (not including connectors)..17.45 by 10.56cm

    I/O connector68-pin male SCSI-II type

    * The pin configuration of PCI-6024E can be found in the Appendix B.

    (3) Lab-PC-1200

    Lab-PC-1200 board has eight analog input channels that you can configure as eight single-ended or four differential inputs, a 12-bit successive-approximation ADC, 24

  • EE4307 Control System Design and Simulation Page 10

    Project

    lines of TTL-compatible digital I/O, and three 16-bit counter/timers for timing I/O. This board is designed for high-performance data acquisition and control for applications in laboratory testing, production testing, and industrial process monitoring and control. The important specifications are given as follows.

    Table 3.7: Input characteristics

    Input Characteristics

    Number of channels 8 single-ended, 8 pseudodifferential or 4 differential (software-selectable per channel)

    Type of ADC Successive approximation

    Resolution 12 bits, 1 in 4096

    Sampling rate 100 kS/s single channel

    Dynamic Characteristics

    Small signal (-3dB)

    Gain Bandwidth

    1-10 250 kHz

    20 150 kHz

    50 60 kHz

    100 30 kHz

    Table 3.8: Analog output

    Output characteristics

    Number of channels 2 (voltage)

    Resolution 12 bits, 1 in 4096

    Typical update rate 1kS/s, system dependent

    Type of DAC Double buffered, multiplying

    Dynamic characteristics Settling time for full-scale range 5s

    Table 3.9: Digital I/O

    Number of channels 24 I/O (three 8-bit ports; uses the 82C55A PPI) Compatibility TTL

    Input low voltage -0.3V to 0.8V

  • EE4307 Control System Design and Simulation Page 11

    Project

    Input high voltage 2.2V to 5.3V

    Power-on state All ports mode 0 input

    Power requirement.185 mA at +5 VDC (5%)

    Physical

    Dimensions ...17.45 by 10.56cm

    I/O connector50-pin male

    *The pin configuration of PCI-6024E can be found in the Appendix C.

    (4) PCI-6014

    NI PCI-6014 has 16 channels (eight differential) of 16-bit analog input, two channels of 16-bit analog output, a 68-pin connector, and eight lines of digital I/O. The NI 6014 uses the NI data acquisition system timing controller (DAQ-STC) for time related functions. The important specifications are given as follows.

    Table 3.10: Input characteristics

    Input Characteristics

    Number of channels 16 single-ended, or 8 differential (software-selectable per channel) Type of ADC Successive approximation

    Resolution 16 bits, 1 in 65,536

    Sampling rate 200 kS/s guaranteed

    Dynamic Characteristics

    Signal Bandwidth

    Small (-3dB) 500kHz

    Large (1% THD) 225kHz

    Table 3.11: Analog output

    Output characteristics

    Number of channels 2 (voltage)

    Resolution 16 bits, 1 in 65,536

    Max update rate

    DMA 10 kHz, system dependent

    Interrupts 1kHz, sytem dependent

    Type of DAC Double buffered, multiplying

  • EE4307 Control System Design and Simulation Page 12

    Project

    Dynamic characteristics Settling time for full-scale step 8 Ps to s1 LSB accuracy

    Slew rate 4V/s

    Table 3.12: Digital I/O

    Number of channels 8 input/output

    Compatibility TTL/CMOS

    Input low voltage 0V to 0.8V

    Input high voltage 2V to 5V

    Power-on state Input (high-impedance), 1.5 k pull down to DGND

    Power requirement.0.7A at +5VDC (5%)

    Physical

    Dimensions ...17.5 by 10.6cm

    I/O connector...68-pin male SCI-II type

    *The pin configuration of PCI-6014 can be found in the Appendix D.

    *Interested students may refer to DAQ User Manuals for the detailed information about the mentioned DAQ cards.

    (5) ELVIS II+

    The NI ELVIS II+ features an integrated suite of 12 of the most commonly used instruments in the lab - including the oscilloscope, digital multimeter, function generator, variable power supply, and Bode analyzer in a compact form factor for the lab or classroom demonstrations. The ELVIS II+ with a Prototyping Board (which will be replaced by the inverted pendulum system during the experiments) is shown in Fig. 3.1.

    Figure 3.1 ELVIS II+ with a Prototyping Board

  • EE4307 Control System Design and Simulation Page 13

    Project

    The important specifications are given as follows.

    Table 3.13: Input characteristics

    Input Characteristics

    Number of channels 16 single-ended, or 8 differential

    Resolution 16 bits, 1 in 65,536

    Sampling rate 1.25 MS/s single channel, 1.00 MS/s multi-channel

    Dynamic Characteristics

    Signal Bandwidth

    Small (-3dB) 1.2MHz

    Table 3.14: Analog output

    Output characteristics

    Number of channels 2 (voltage)

    Resolution 16 bits, 1 in 65,536

    Max update rate

    1 channel 2.8MS/s

    2 channels 2.0MS/s

    Output range 10V, 5V

    Dynamic characteristics

    Timing accuracy 50ppm of sample rate

    Timing resolution 50ns

    Slew rate 20V/s

    Table 3.15: Digital I/O

    Number of channels 24 DIO, 15PFI

    Compatibility TTL/CMOS

    Input low voltage 0V to 0.8V

    Input high voltage 2.2V to 5.25V

    Pull-down resistor 50k typ, 20k min

    Power requirement.15VDC, +5VDC (5%)

  • EE4307 Control System Design and Simulation Page 14

    Project

    Physical

    Dimensions ... 34.3 by 28.0 by 7.6cm

    Bus interface . USB 2.0 Hi-Speed

    *Interested students may refer to NI ELVIS II+ User Manuals for the detailed information about the mentioned system.

    3.2 Software Development Platform The recommended software development platform for this miniproject is Laboratory Virtual Instrument Engineering Workbench (LabVIEW). It is a graphical programming language. The software is windows-driven, and various functions can be performed simply by placing icons and carrying out the soft-wiring connections. LabVIEW is integrated fully for communication using standards such as GPIB, RS232, RS485, and it facilitates interfacing to plug-in data acquisition cards.

    Using LabVIEW, 32-bit compiled programs that provide fast execution speeds needed for custom data acquisition, test and measurement solutions can be created. As LabVIEW is a true 32-bit compiler, standalone executables can also be created easily. It contains comprehensive libraries for data collection, analysis, presentation and storage. Traditional program tools are also included in LabVIEW. Breakpoints and single-stepping through the program can be done in the LabVIEW environment. These make debugging and program development easier. LabVIEW provides numerous mechanisms for connecting to external code or software through DLLs, shared libraries, ActiveX and more. In addition, many add-ons toolkits (for example, the internet toolkit and DSP toolkit) are available for a variety of application needs.

    The introduction to the needed LabVIEW function blocks for ELVIS II+ is given in Appendix H.

  • EE4307 Control System Design and Simulation Page 15

    Project

    4. Data Acquisition and Conditioning In this part of the project, the students will be guided through the process of acquiring the data using LabVIEW and using MATLAB to condition and plot the acquired data.

    4.1 A Guided Example (LabVIEW) In this example, you will be using the LabVIEW software to acquire data from your assigned system. You will be guided through the process of acquiring data and saving the data for use with MATLAB.

    First open LabVIEW and open the file step.vi in the folder EE4307/Part4, you will be able to set the magnitude of the step input. The figure below shows the front panel of a LabVIEW program.

    Figure 4.1 LabVIEW Front Panel

    In Fig. 4.1, the numbered annotations represent:

    1. Magnitude dial sets the magnitude of the step input

    2. Graph shows the output value of the plant

    3. Go button starts the experiment

    4. Show block diagram go to the block diagram of the LabVIEW program

    After setting the magnitude, click on the Go button as shown in Fig 4.1 to start the experiment.

    Once the experiment is completed, a save file dialog will open. Save the data in

    c:\EE4307\your_name\part4_1.dat

  • EE4307 Control System Design and Simulation Page 16

    Project

    The file will contain the output data of your assigned plant, which you will be able to retrieve using MATLAB.

    4.2 A Guided Example (MATLAB) In this example, you will be guided through MATLAB to plot a given set of data and using the tools in MATLAB to condition the data for analysis.

    Load the data file that was saved above using the following command

    load c:\EE4307\your_name\part4_1.dat You will get an n by 2 matrix in the workspace. The name of the matrix will be

    part4_1 Rename the matrix by assigning

    X = part4_1 Using the commands below you will be able to obtain a plot of the input and output.

    plot(X(:,1)) Gives a plot of the input vs. sample number plot(X(:,2)) Gives a plot of the output vs. sample number plot(a, b(:,1:2))) Gives a plot of b(1) and b(2) vs. a

    Before the data can be used for non-parametric or parametric analysis, it has to be post treated and conditioned.

    Post-treatment of the data can be done by choosing a part of the data which is suitable for analysis, removing the offset and high frequency noise.

    Certain data range can be chosen by using the following command. Assume the index of the start sample of the range to be Start and the index of the end sample to be Final.

    Y = X(:,Start:Final); You can remove the offset by deducting all the output values by a constant, min, which is to be determined by you.

    for i = Start:Final Y(i Start + 1,2)=X(i,2) min;

    end After removing the offset, the data can be filtered to remove high frequency noise by using the following command. Assume the cut-off frequency in terms of the Nyquist frequency is given by w and the order of filter required is N.

    W = idfilt(Y(:,2), N, w, noncausal); The high frequency noise can also be removed by resampling at m times the original sampling period.

  • EE4307 Control System Design and Simulation Page 17

    Project

    j = 1; for i = Start:Final if(rem(i,m) == 0)

    Y(j,1) = X(i,1);

    Y(j,2) = X(i,2);

    j = j+1;

    end

    end

    The data will be ready for analysis after conditioning. List and explain any additional conditioning that you have done on the data.

    Plot the input and output data using the data file obtained in Part 4.1 and conditioned using the methods described above.

    4.3 Exercise on Data Conditioning A set of data is given in the file cond.dat in the folder EE4307/Part4, load the file into MATLAB. Using the methods described above or otherwise obtains a conditioned data set.

    The following conditions are given:

    The data is of the form:

    Time Input Output

    A step analysis of the system is to be done using the data, The output is contaminated with high frequency noise with zero mean. Plot the

    conditioned input and output data.

    4.4 Design of LabVIEW Program In this part you will be required to design a LabVIEW experiment to perform an impulse response analysis and step response analysis on your assigned system.

    To open the block diagram of the LabVIEW program, click on the Show Block Diagram option in the Window menu as shown in Fig. 4.1

    The figure below shows the block diagram of a sample LabVIEW program for the thermal chamber system.

  • EE4307 Control System Design and Simulation Page 18

    Project

    Figure. 4.2 LabVIEW Block Diagram

    In Fig. 4.2, the annotation 1 represents the Help button which opens the context help.

    By clicking on the Help button shown in Fig 4.2, a context help window will appear that will provide information on the blocks used in the LabVIEW program. You will be able to obtain the information by placing your mouse cursor over the required block. The following figure shows an example of the context help window.

    Figure 4.3 Context Help

    You are allowed to use the file EE4307/Part4/step.vi as reference. The design requirements are as follows.

  • EE4307 Control System Design and Simulation Page 19

    Project

    The output file should be of the following format.

    Time Input Output

    The program should allow the user to set the impulse/step magnitude and impulse width.

    The program should allow the user to set the sampling rate for the system. These requirements are non-exhaustive and insufficient for a proper non-

    ideal impulse response analysis. Define your own requirements, and explain its purpose with respect to the

    experiment.

    Include your LabVIEW program in your report with design requirements and explanations.

    This program will be required for Part 5.4 of this project.

  • EE4307 Control System Design and Simulation Page 20

    Project

    5. System Identification: Non-Parametric Approach In this part of the project, the students will familiarize themselves with the different non-parametric approaches in identifying a system. They will be guided through a few examples using MATLAB before applying it on their assigned system.

    5.1 A Guided Example (Time-Domain Method) In this example, you will be guided through the process of using time-domain methods of non-parametric identification using MATLAB. Given a digital system described below

    () = + 0.5 = 1

    Using MATLAB, define the system using the following command

    G = tf([1 0],[1 0.5], 1); Get the impulse response of the system by

    X = impulse(G, [0:1:15]) As discussed in the lectures, the impulse-response coefficients of the system is given by

    () = () For a unit impulse input to the system. Therefore the impulse-response coefficients are given by the matrix X.

    Given a system described below

    () = 0.32 + + 2

    Using MATLAB, define the system using the following command

    G = tf([1],[1 1 2],inputdelay, 0.3); Get the step response of the system by

    step(G) Find the parameters , time delay, , settling time, and M from the figure.

    5.2 Non-Parametric Identification (Time-Domain Methods) Given two sets of data, you are to perform conditioning and identify the system using non-parametric approach, based on the following requirements:

    The data is corrupted at the output with high frequency noise, The data is of the form:

    Time Input Output

    The data is stored in two separate files, EE4307/Part5/set1.dat and EE4307/Part/set2.dat, and they are based on two different sets of input to the same system.

    You are required to;

    Perform an identification, either by finding the impulse response coefficients

  • EE4307 Control System Design and Simulation Page 21

    Project

    or/and fitting a transfer function, on the system using both sets of data. The sampling period for the required system model is 1 sec,

    Perform the analysis with conditioning and compare the results, Find the time domain equations of the system.

    5.3 A Guided Example (Defining Operating Point) In this part, we will need to define the operating point for a given plant. Open SIMULINK in MATLAB by typing the following command in the MATLAB command window.

    simulink Open the following SIMULINK file EE4307/Part5/operating.mdl Given that an unknown nonlinear system below, due to the operation requirements, we want to identify the system about a few particular operating points.

    Figure 5.1 Unknown System Block Diagram

    Given that the first operating point is to be at

    0 = 3 Find the corresponding 0.

    Given that the second operating point is to be at

    0 = 6 Find the corresponding u0. Change the above block diagram to the following form, where C1 is given by 0 and C2 is given by 0.

    Figure 5.2 Setting Operating Point

    Save the SIMULINK file under

    c:\EE4307\your_name\part5_3.mdl Perform a step response identification, for both operating points, on the unknown system and record your results. Allow the system to reach a steady state at the operating point before performing the step response analysis. Find a suitable step time

  • EE4307 Control System Design and Simulation Page 22

    Project

    for the identification process and change it in the step block accordingly.

    Figure 5.3 Setting Step Time

    5.4 Non-Parametric Identification of Assigned System (Time-Domain Methods) Based on the assigned plant, perform a non-parametric identification using both step and impulse inputs.

    You are required to:

    Specify a suitable operating point and explain your choice, Specify the sampling period used and explain your choice, Compare the results obtained from both methods and explain your observations, Find an estimate of the transfer function using any of the non-parametric

    methods taught in the lectures, Find the time domain equations of the system.

    Use the LabVIEW programs you design in Part 4.4 to perform the above identification. 5.5 Non-Parametric Identification (Frequency-Domain Method) You are given a set of data, perform conditioning and find the gain and phase of the system at the given frequency, based on the following requirements:

    The data is corrupted at the output with high frequency noise. The data is of the form:

    Time Input Output

    The data is stored in EE4307/Part5/set3.dat

  • EE4307 Control System Design and Simulation Page 23

    Project

    5.6 Non-Parametric Identification of Assigned System (Frequency-Domain Method) Based on the assigned plant, the following tasks are to be completed:

    Obtain a Bode plot of your assigned system using frequency analysis or otherwise,

    Find an estimate of the transfer function of the system, Determine the time domain equations of the system.

    You are required to design your own LabVIEW program to perform the above identification of the plant. Include your LabVIEW program in your report with design requirements and explanations.

    For the DC motor, the input is the excitation voltage and the output is the motor speed.

    For the thermal chamber, the input is the heater voltage and the output is the chamber temperature.

    For the inverted pendulum, students will identify the DC motor as well. The input is the excitation voltage and the output is arm angle. If the students are more interested in the pendulum system, they can try to identify the regular pendulum instead (see Appendix E). The input is the excitation voltage and the output is the pendulum angle.

  • EE4307 Control System Design and Simulation Page 24

    Project

    6. System Identification: Parametric Approach In this part of the project, we will first learn the essential steps of a parameter estimation cycle. After that, you will work on your selected/assigned pilot plant to derive a parametric model.

    6.1 A Guided Example This example is designed to familiarize you with the software quickly and to guide you through the steps of system identification covered in the lectures. You must understand the rationale for each of the step.

    Data has been collected from a laboratory scale process. The process operates very much like a common hand-held hair dryer. Air is blown through a tube after being heated at the inlet to the tube. The input to the process is the voltage applied to a mesh of resistor wires that constitutes the heating device. The output of the process is the air temperature at the outlet measured in volts by a thermocouple sensor.

    One thousand input-output data points were collected from the process as the input was changed in a random fashion between two levels. The sampling interval used is

    80 ms. The data were loaded into MATLAB in ASCII form and are now stored as the vector y (output) and u (input) in the file ee4307a.mat. First load the data

    load ee4307a

    (At any stage, you may use >help cmd to know more about cmd, e.g., >help load) This example selects the first 300 data points for building a model. For convenience,

    the input-output vectors are merged into a matrix, z :

    z = [y(1:300) u(1:300)];

    You may take a look at the data using:

    idplot(z)

    Note the sampling interval used in the graph by default is one time unit, and all data points are plotted.

    You can select the values between sample numbers 200 and 300 for a close-up view, and at the same time, obtain correct time scales with the sampling interval of

    80ms instead, using:

    idplot(z,200:300,0.08)

    We will also select and reserve a portion of the data to be used to cross-validate the model:

    zr=[y(700:900) u(700:900)];

    Data treatment The plot of the data points provides an opportunity to check for any deficiencies which may be treated

    In this experiment, we are not keen in modelling the DC equilibrium conditions. We want to model the changes in temperature corresponding to the changes in input voltage. We will remove the constant levels and make the data zero mean with

  • EE4307 Control System Design and Simulation Page 25

    Project

    z = dtrend(z);

    zr = dtrend(zr);

    Other actions typically taken by user at this stage include removal of outliers, data pre-filtering, lowering of sampling rate, etc. Some relevant commands available for use are idfilt and decimate.

    Ready-made model We shall work with models of the following kind (ARX):

    () + 1( 1) + + ( ) = 1( ) + + ( + 1) (6.1) Correlation analysis When a ready-made model is to be selected, the user has to specify the delay and model order. A gross estimate of the delay may be obtained from the impulse response of the system.

    Obtain the impulse response of the system with a correlation analysis:

    ir=cra(z);

    The function pre-whitens the input so that it approximates the behavior of white noise.

    Briefly explain why this pre-whitening process is necessary.

    The impulse response of system is shown in the 4th plot.

    Estimate the time delay of the system.

    Time-delay estimate A more accurate value may also be estimated in the following way. The order of the model is fixed to second-order (na=nb=2), we then choose likely values of the delay between 1 and 10. The loss function, which show how good is the fit (the lower the better), can tell us which is the more accurate delay. We may use arxstruc for this purpose:

    V = arxstruc(z,zr,struc(2,2,1:10));

    The loss function is inherently computed by comparing model data set z to validation data set zr. We now select that delay that gives the best fit for the reference set using: nn = selstruc(V,0)

    Compare the estimation of the delay obtained with cra and arxstruc.

    Choice of model structure Now that the delay has been obtained, we will obtain the model order na and nb. As in the case for the delay, we check the fit for all 25 combinations of up to 5 b- parameters and up to

  • EE4307 Control System Design and Simulation Page 26

    Project

    5 a-parameters, all with delay obtained earlier:

    V = arxstruc(z,zr,struc(1:5,1:5,3));

    The best fit for the reference data set is obtained for

    nn = selstruc(V,0)

    It is advisable to check yourself how much the fit is improved for the higher order models. We are more interested in the settled-in point (Figure 6.1). Beyond this point (see Figure 6.1), the improvement is marginal and yet we will have a more complicated model. You can use the following command:

    nns = selstruc(V)

    Figure 6.1 Selection of model order

    The plot shows the fit as a function of the number of parameters used. You will then be asked to enter the number of parameters you think gives a sufficiently good fit. The routine then selects that structure with this many parameters that gives the best fit.

    To ensure you are still on track, verify that the best fit is obtained for nn = [ 4 5 3 ], while we see that the improvement compared to nn = [ 2 2 3 ] is rather marginal.

    Model computation We will now compute the four parameters for the model corresponding to nn = [ 2 2 3 ] using

    () + 1( ) + 2( 2) = 1( 3) + 2( 4) (6.2) where T is the sampling interval. This ARX model predicts the value of output at time t, given previous values of y and u. The best values of the coefficients 1,2, 1,2 can be computed using the least squares method with:

    th = arx(z,[2 2 3]);

    The result is stored in the matrix th in a somewhat coded form. To specify the sampling interval, enter:

  • EE4307 Control System Design and Simulation Page 27

    Project

    th = sett(th, 0.08);

    Display the coefficient estimates and estimated standard deviations with:

    present(th)

    The System Identification Toolbox also include functions specific to other model structures e.g. ARMAX and Box-Jenkins models. The use of these functions is similar to arx. We shall compute the model parameters for a second-order ARMAX model. The steps are similar to the case of the ARX model:

    am = armax(z,[2 2 2 3]); am = sett(am, 0.08);

    present(am);

    Compare the loss function for the ARMAX model to that of the ARX model.

    Model validation You may wonder how well the model fits the data. We will check the residuals (leftovers) of this model, i.e., what is left unexplained by the model.

    e = resid(z,th);

    The 99% confidence intervals for these values are also computed and displayed as dotted red curves. We see that the residual are quite small compared to the signal level of the output.

    Another simple test is to run a simulation whereby real input data is fed into the model, and to compare the simulated output with the actual measured output. For this, select a portion of the data that was not used to build the model, for example, from sample 501-1000 (called cross-validation):

    u = dtrend(u(501:1000));

    y = dtrend(y(501:1000));

    ysim=idsim(u,th);

    plot([y(100:500) ysim(100:500)])

    Print the result and attach to your report. Comment on the comparison.

    Frequency response If you want to know the frequency response, you can compute the frequency function of the model and present it as a Bode plot by entering:

    gth = th2ff(th);

    bodeplot(gth)

    Step response Finally, plot the step response of the model. The model comes with an estimate of its own uncertainty. Ten different step responses are computed and graphed. They correspond to possible models, drawn from the distribution of the true system

    (according to our model):

  • EE4307 Control System Design and Simulation Page 28

    Project

    Step = ones(30,1);

    idsimsd(Step,th)

    Print the step responses.

    6.2 Working on the Selected System Now, you should be ready to identify an adequate model of the selected system in the laboratory. This part will require you to gather the data and iterate through the steps in the identification cycle till you arrive at a satisfactory model.

    If you have not done Section 4, you may have a quick practice session using the quick notes on LabVIEW contained in Appendix G which will be sufficient to allow you to be able to generate inputs and acquire outputs from your system.

    Explain all the steps you take to arrive at your model. You should cross-validate your model by comparing simulated output of your model to actual output from the system. This model can also be the basis for the control design which you will carry out in Section 8.

    For the DC motor, the input is the excitation voltage and the output is the motor speed.

    For the thermal chamber, the input is the heater voltage and the output is the chamber temperature.

    For the inverted pendulum, students will identify the regular pendulum instead (see Appendix E). The input is the excitation voltage and the output is the pendulum angle.

  • EE4307 Control System Design and Simulation Page 29

    Project

    7. System Simulation Simulation is a cost effective way of verifying the performance of a system based on its model. It does not require experimentation with the actual system which may not be possible due to various reasons such as costs and safety issues. Furthermore, with amplitude and time scaling, simulation can help to speed up the design process, by providing prediction of a system performance in a very short time via powerful computer systems. In this section, students will first work on a modelling and simulation example, where simulation is used to predict the outcome of a hypothetic scenario. Next, students will familiarise themselves with how simulation can help in control design once a model becomes available, using a commonly available tool in the form of Microsoft Excel spreadsheet.

    7.1 Predator-Prey Modelling and Simulation In this part, we will first experiment with how a model can be simulated and the results used for analysis and prediction purposes. Let us digress from the typical engineering problems to consider a predator-prey model.

    Two animal species (lynx and hare) are in a predator-prey situation. We are interested in deriving a model which shows the variations in the surviving number of each species with time.

    Let

    1() denotes the number of lynx at time t 2() denotes the number of hare at time t 1 denotes the birth rate of lynx (number per unit time per lynx)

    2 denotes the birth rate of hare (number per unit time per hare)

    1 denotes the mortality rate of lynx (number per unit time per lynx)

    2 denotes the mortality rate of hare (number per unit time per hare)

    Since lynx needs hare to survive, 1 reduces with 2 (less lynx will die per unit time when number of hare increases). We assume a simple proportional relationship:

    1 = 1 12, 1 < 0 Since hare is eaten by lynx, 2 increases with 1 (more hare will die when number of lynx increases). We assume a simple proportional relationship:

    2 = 2 21, 2 > 0 Thus, derive the predator-prey model relating d1

    d and d1

    d to 1 and 2. Verify that

    you obtain the following results: dd 1() = (1 1)1() + 11()2() dd 2() = (2 2)2() + 21()2()

  • EE4307 Control System Design and Simulation Page 30

    Project

    Let us use some reasonable numbers for the various constants for simulation.

    If there is no hare (2 =0), number of lynx is expected to decrease, i.e. d1d < 0 . Therefore, 1 1 < 0. Let 1 = 1, 1 = 2. If there is no lynx (N1=0), number of hare is expected to increase, i.e. d2d < 0. Therefore, 2 2 > 0. Let 2 = 2, 2 = 1. Let 1 = 2 = 1. Thus, the models become: dd 1() = 1() + 1()2() dd 2() = 2() 1()2() Now, let us simulate based on the models. We need to convert the models to discrete time to simulate on computers.

    Show that using a simple Eulers (forward difference) method, the following discrete- time models can be obtained:

    1( + 1) = 1() + (1() + 1()2()) 2( + 1) = 2() + (2() 1()2())

    Assuming an initial population of 1(0) = 2(0) = 2 (in thousands) and sampling interval of T=0.01, simulate the models using any languages of your choice (MATLAB, C, PASCAL, etc.).

    Log your results in your final report and comment.

    To make the simulation more interesting, let us also simulate a disturbance. Assume a disaster (wild fire) broke out at time =10 which reduces the population of both species by 50% at that time.

    Log your results in your final report and comment.

    Do you expect the overall population of the species to decrease after years have passed as a result of the fire? Check if the prediction from your simulation tallies with your expectation.

    7.2 Simulation of a PID Control System Proportional + Integral + Derivative controllers are widely used in industry, due to their relative simplicity and ability to control a wide range of processes reasonably well. This part of the project investigates the main features of these controllers by analyzing the responses of each component through simulation on commonly available spreadsheet software: Microsoft EXCEL.

    In order to illustrate the main concepts of this type of controller, the development

  • EE4307 Control System Design and Simulation Page 31

    Project

    proceeds in stages; generating first a simple first order plus delay process model, and then a P, PI, and finally full PID controller.

    The process model used in this simulation is the standard first order lag plus delay model used in many process control applications as follows:

    () = 1 + () (7.1) where U(s) corresponds to the input to the process, Y(s) corresponds to the output of the process, T is the time constant, A is the gain, and L is the time delay of the process (see Figure 7.1).

    Figure 7.1: Process model

    Suggest any non-parametric method where simple estimates of T, L, and A can be obtained. The model in Equation (7.1) is a time-continuous model. In order to simulate it on a computer, the model must first be discretized using numerical methods.

    The time delay ( e - sL ) can be represented by integer samples of delay:

    = (7.2) where yk is the process output at sample time k, and vkn is the output from the lag model at sample time . A time delay is L will correspond to samples, where h is the sampling interval.

    The first order lag (with time constant T) will be simulated using the difference equation. This is obtained via a backward difference approximation by replacing s with 11

    , resulting in:

    = 1 + ( 1) + (7.3) where is the time interval between subsequent samples and 1. Show how Equation (7.3) is obtained.

    The closed-loop control system with a PID controller is shown in Figure 7.2. The PID controller transfer function is given, in the time and frequency domains, as follows:

    () = + 1

    0+ (7.4)

    () = 1 + 1

    + () (7.5) where is the error between the set-point, , and the process value ,, i.e., = , and is the controller output.

  • EE4307 Control System Design and Simulation Page 32

    Project

    Figure 7.2: Closed-loop PID control of the process

    This controller may be implemented as the sum of the three separate components. The proportional component is as follows:

    = (7.6) The integral component may be implemented in discrete time, as an accumulator, as follows:

    = 1 + (7.7) and the derivative component may be implemented in difference form as follows:

    = ( 1) (7.8) Show how Equation (7.7) and Equation (7.8) are obtained.

    These three components are then added to give the PID controller output, .

    Preparation Open Microsoft Excel application to conduct the simulation.

    Procedures Time (Column A) In Column A (label it as Time in A1), generate a time axis for your simulation, which runs from time 0 to time 400 in 0.5 second increments. The value of 0.5 is therefore the sampling interval ().

    To do this, select spreadsheet cell A10 and enter the value 0. Press the down arrow to enter this data and select the next cell (A11), then enters 0.5. Select the two cells (A10 and A11), then position the mouse to point at the handle in the lower-right corner of selected range. The pointer will change to a cross. Drag the cross to the end of range (A810) to fill with the sequence of time and release the mouse button. You should now have a column of 800 time samples running from 0 to 400 seconds.

    Setpoint (Column B) The next step is to generate a setpoint profile for the PID control system. In this spreadsheet, the setpoint signal is in Column B (label it as w in B1). Set the setpoint from 0 at time 0, to 60 at time 0.5 until time 200, and then down to 40 at time 200.5 until

  • EE4307 Control System Design and Simulation Page 33

    Project

    time 400. Do this by using the same method as described for Column A.

    Error (Column E)

    To generate an error signal (xk = w yk), enter an equation in Column E (label it as in E1). The error signal is generated by subtracting the setpoint () from the process output, which is generated in Column D (label it as in D1).

    To do this, generate the first sample of the process output by selecting cell E11 and enter the following formula:

    =B11-D11

    When you press the return key, you will notice that the cell now contains the numerical difference between the values in the two preceding columns. Since Column D contains no data at this time, it defaults to 0, resulting in an error which is equal to the setpoint.

    Position the mouse to point at the handle in the lower-right corner of cell E11; the pointer changes to a cross. Drag the cross to the end of range (E810) to fill Column E with the sequence of error and release the mouse button. You should now have 800 error signals in Column E.

    Process Output (Column D) Formulae in spreadsheet cells can refer to any other cells, and you will use this feature in generating the process output (Column D). We will choose a delay of 2.5 second (5 samples) and a process gain (A) of 2 (see Equation (7.2)).

    Select column D10 and enter the following formula:

    =2*C5

    where Column C is vk in Equation (7.2) (label it as vk in C1). The formula you just entered reflects the gain and the delay of the process. Copy this formula from cell D10 to D810. Since there is no data in Column C, it defaults to 0.

    You can test that this delay works by entering any data into cells C10 to C20. You should see the result (delayed by 2.5 seconds and amplified by 2) in Column D.

    Lag (Column F) and Controller Output (Column G) Set the lag time constant in Column F (label it as T in F1) to 100 seconds (from F10 to F810).

    Column G (label it as in G1) is the controller output. The value is dependent on the calculation of Equation (7.6) (7.8), with other specification, such as saturation, if any. For now, we will leave it empty.

    Process (Column C)

    Column C (label it as in C1) represent the process/plant (see Figure 7.1). Select cell C11 and enter a formula corresponding to the difference equation in Equation (7.3). The input to your lag should be the controller output for the corresponding time sample, i.e., cell G11. Fill in Column C with this equation.

    P+I+D Controller (Column I)

  • EE4307 Control System Design and Simulation Page 34

    Project

    Before designing our PID controller, we will configure the platform of the PID controller. Column J is the proportional controller (label it as in J1), column L is the integral controller (label it as in L1), and column N is the derivative controller (label it as in N1).

    Column I is the PID controller (label it as PID in I1). Bearing in mind that PID is the summation of P, I, and D (see Equation (7.4) and (7.5)), configure Column I to give the sum P+I+D (sum of proportional term in Column J, integral term in Column L, and derivative term in Column N).

    Now that we have configured the platform of PID controller, we can implement it to control the process. At this moment, we do not consider any constraint, such as saturation. Therefore, the controller (Column G) is set as the same as PID controller (Column I).

    Proportional Gain (Column H) and Proportional Controller (Column J) In our first step, only P controller is used, with a gain determined by the value in the proportional gain (Column H, label it as G in H1). Generate the proportional term in Column J according to the formula of Equation(7.6). Set the proportional gain as 10.

    Column L and Column N contain no data at the moment and they default to 0.

    After filling Column J, the control loop will be closed with proportional only controller and a gain of 10.

    Select the data in Column D and Column B with mouse + Ctrl, and then select Chart from the Insert menu to create a chart. Select Line type, which is a smooth line without points. Choose the data in Column A as the x-axis. You may choose other options in the chart menu to improve the presentation of your chart.

    You should now have the graph of the closed-loop response of the system to setpoint steps from 0 60 40 against time.

    Highlight this graph and print it. Comment on the resulting control error magnitude in your report.

    Integral Time (Column K) and Integral Controller (Column L) The second step will be to include the integral controller. The integral time is given in Column K (label it as in K1). Add integral action to the controller by inserting the formula given in Equation (7.7) in Column L. Set the integral time as 30 seconds.

    Create a chart similar to the proportional section to view the result and attach it to your report.

    Create another chart to display the process output, , error signal, , controller output, , and integral output, , against time, and attach this chart to your report. Explain the new control performance and the values of , , and when the control loop has stabilized at each set-point value.

  • EE4307 Control System Design and Simulation Page 35

    Project

    Derivative Time (Column M) and Derivative Controller (Column N) The third step will be to introduce the derivative controller. The derivative time is given in Column M (label it as in M1). Add derivative action to the controller by inserting the formula given in Equation (7.8) in Column N. Set the derivative time as 2.5. Observe especially the overshoot and the initial derivative kick when the setpoint changes.

    Create the charts similar to the integral section and attach them to your report.

    Tuning The process is moderately tuned in the above simulation. Experiment by varying the Gain,, and values to achieve an improved performance in terms of faster response and small overshoot. Describe any improvements measured. Ziegler- Nichols tuning rules can be used to obtain good PID parameters based on the model of Equation (7.1).

    Discuss all the points mentioned in the above notes and answer all the questions. The results of each stage of this simulation should be logged.

    Simulation of the Actual System from Previous Experiment Based on the steps given previously, simulate the performance of the system of your choice with PID control. You can use the model that you have obtained.

    You can now simulate the actual constraint of your system, e.g. saturation. To do this, instead of making G11=I11, a saturation function is included in G11 by entering, for example, G11=MAX(0,MIN(I11,1)) to limit the control signal to between 0 and 1.

    For students who chose the DC motor or the thermal chamber, the model obtained before can be used for this simulation.

    For students who chose the inverted pendulum, you have two options for simulation and controller design:

    (1) use the regular pendulum model obtained; (2) use the inverted pendulum model given in Appendix F. For this option, you need

    to convert the state-space model to a second-order transfer function (for this part, the input of the transfer function is chosen as the angular acceleration of the arm = while the output is still the pendulum angle , so that a second-order system can be obtained), and that transfer function can be used for the simulation study.

  • EE4307 Control System Design and Simulation Page 36

    Project

    8. Control Design and Implementation In this part of the experiment, the student will be required to design a controller for their assigned system using the model obtained in Part 5 or Part 6 of the experiment. The student will be required to test the designed controller on the assigned systems. Guided examples on the use of digital-to-analog converters and control design process will be provided.

    8.1 Design of Continuous-time Control Systems The plant dynamics is given by the transfer function below

    () = 12 + 2 + 1

    Design a continuous-time controller for the plant using unity feedback and the corresponding PID gains such that the plant has dominant roots at s = -5. The block diagram of the system is given by

    Figure 8.1 Continuous-time Block Diagram

    Simulate the system using SIMULINK. Define D(s) in your report and plot the output () for an unit step input () for a suitable time range. 8.2 Digital-to-Analog Converters The continuous-time control systems are implemented in the past using analog devices such as resistors, capacitors, inductors and operational amplifiers. These devices are not economical or durable. It is much more efficient and economical to implement control systems using computers which operates in a discrete-time setting. Therefore there is a need to design digital control systems so that it can be realized using computers.

    There are two methods to design the digital controller. A continuous-time PID controller, (), can be designed first and then transformed into its digital counterpart, (). The second method is to discretize the plant and design a digital controller () for the discrete-time plant.

    Find (), the digital counterpart of the controller, you have designed in the previous part by using the transformation given below.

    () = + + 1

    () = + 1 + Tzz 1 To convert the digital output signal to a continuous-time signal, a digital-to-analog converter can be used as illustrated in the following diagram:

  • EE4307 Control System Design and Simulation Page 37

    Project

    Figure 8.2 Zero-order Hold

    where ZOH represents a zero-order hold digital-to-analog converter.

    Simulate the system using SIMULINK. The block diagram should be of the following form.

    Figure 8.3 Continuous-time Plant with Discrete Controller

    There are many ways to transform () to (). For example, using bilinear (Tustins) transformation where

    = 2

    ( 1) + 1 , = Sample period

    You can use either of the methods described above to find (). Plot your results in your report and compare the results of the continuous-time controller and the discrete-time controller. Repeat for a number of different sampling periods, T, and compare your results.

    8.3 Control Design and Simulation (A Guided Example) Another method to design D(z) is to discretize the continuous-time plant ()

    Figure 8.4 Equivalent Discrete Plant

    A continuous time domain transfer function with a zero-order hold can be approximated by a discrete transfer function using the following transformation

  • EE4307 Control System Design and Simulation Page 38

    Project

    () = (1 1)(()

    ) where Z stands for the z-transform. D(z) can be designed using pole placement after () is found. In this example, the plant dynamics, digitized using zero-order hold, is given by the transfer function below

    () = 2 1.6 + 0.64 = 1

    Design a PID controller such that the dominant poles of the system under unity feedback is at = 0.2. Since we are using a PID controller, define the PID controller as

    () = + 1 + 1 , = 1 where the proportionate gain, integral gain and derivative gain is given by , and respectively.

    The system transfer function under unity feedback is given by

    () = ()()1 + ()() Calculate the gains of the PID controller by comparing coefficients and assign extra poles such that they are faster then the dominant poles.

    Simulate your system with SIMULINK, giving the system a step reference. Record your observations.

    8.4 Control Design and Simulation using Assigned System In this part, you will be designing a controller for your assigned system using results obtained in all the previous parts. After completing this portion, you would have gone through the entire process of control system design and simulation as shown in the flow chart below.

    Using the model obtained in Part 5 or Part 6; design a PID controller for the plant using the steps taken above.

    The system, under unity feedback with the designed PID controller, must have;

    A faster response than the original plant, Zero steady-state error

    Define the dominant poles accordingly.

    Simulate the controller with MATLAB before using it on the assigned system.

    Design a LabVIEW program to test your controller design on the plant, observe the performance of the system and record your observations.

    The design considerations are as follows:

    Operating point of system must be the same as that used in the identification process,

    Ensure that the input to the plant is not saturated due to system constraints,

  • EE4307 Control System Design and Simulation Page 39

    Project

    Ensure that the sampling period is suitable for the system, i.e. the computer must be able operate properly at the frequency specified.

    Include your LabVIEW program in your report with design requirements and explanations.

    Compare the results obtained from the simulation with that obtained from the assigned system.

    Plot the input and output results of both the simulation and actual experiment.

    Explain the differences in the results, if any.

    Figure 8.5 Flow Chart of Project

    For students who chose the DC motor or the thermal chamber, the model obtained before can be used for this control design and simulation.

    For students who chose the inverted pendulum, you can use the state-space model given in Appendix F but convert it to a transfer function from the input which is the excitation voltage to the output which is the pendulum angle . During the real application, you need to build a PD controller ( = 6.50, = 2.75 are recommended) for the arm (motor) angle control first, and then design your own PID controller for the inverted pendulum in order to stabilize it and meet the requirements. Furthermore, you can use the function blocks given in Appendix H to build your control system.

  • EE4307 Control System Design and Simulation Page 40

    Project

    9. Report The results of each stage of the project should be logged, and important displays printed. Important data such as, the operating point, must be included in the report. In particular, there should be concise explanations and interpretation of the results thus obtained.

    References

    Lecture notes for EE4307 (Control System Design and Simulation) L.Ljung. System Identification - Theory for the User, Prentice-Hall, Englewood

    Cliffs, N.J., 1987. T. Soderstrom and P. Stoica System identification, Prentice-Hall International,

    London, 1989. Astrom, K.J. & Wittenmark, B., Computer-Controlled Systems, 2nd Edition,

    Prentice Hall, 1990 Rolf Johansson, System Modeling & Identification, Prentice-Hall, Englewood

    Cliffs, N.J., 1993 Darrell Williamson, Digital Control and Implementation, Prentice-Hall

    International, Sydney, 1991.

  • EE4307 Control System Design and Simulation Page 41

    Project

    Appendix A

    Figure A: I/O Connector pin assignments for the 6023E/6024E

  • EE4307 Control System Design and Simulation Page 42

    Project

    Appendix B

    Figure B: I/O Connector pin assignments for the AT-MIO-16-1, AT-MIO-16E-2, AT- MIO-16E-10, AT-MIO-16XE-10, AT-AI-16XE-10, and AT-MIO-16XE-50

  • EE4307 Control System Design and Simulation Page 43

    Project

    Appendix C

    Figure C: Lab-PC-1200 I/O Connector pin assignments

  • EE4307 Control System Design and Simulation Page 44

    Project

    Appendix D

    Figure D: PCI-6014 I/O Connector pin assignments

  • EE4307 Control System Design and Simulation Page 45

    Project

    Appendix E Information of Inverted Pendulum System The model block diagrams of the regular pendulum (such as gantry) and the inverted pendulum are shown in Fig. E.1 and Fig. E.2, respectively. The difference between the regular pendulum and the inverted pendulum is that the pendulum position is different. As a result, the regular pendulum is actually a stable system while the inverted pendulum is an unstable system. In the figures, m is the mass of the pendulum, M is the mass of the cart, L is the length of the pendulum, is the angle of the pendulum, u is the applied force, b is the friction coefficient and I is the pendulums moment of inertia.

    Figure E.1: Model of regular pendulum

    Figure E.2: Model of inverted pendulum

    The transfer function (from the applied force to the angle ) of both pendulums (with linearization: sin = and cos = 1) is generally a fourth order model. If we let the carts accelerometer be the input of the system, the two systems can be rewritten to be a simple second-order system.

    *Interested students are encouraged to derive the mathematic models and the transfer functions, validate the models and observe the differences.

    The problem of balancing an inverted pendulum is like balancing a vertical stick with your hand by moving it back and forth. Thus by supplying the appropriate linear force, the stick can be kept more-or-less vertical. In this case, the pendulum is being balanced by applying a torque to the arm. The balance controller supplies a motor voltage that applies a torque to the pendulum pivot and the amount of voltage supplied depends on the angular position and speed of both the arm and the pendulum.

  • EE4307 Control System Design and Simulation Page 46

    Project

    Appendix F Model of Rotary Inverted Pendulum System (ROTPEN) The ROTPEN is free to move in two rotary directions. Thus, it is a two degree of freedom, or 2 DOF system. As seen in Fig. F.1, the arm rotates about the 0 axis and its angle is denoted by the symbol while the pendulum attached to the arm rotates about its pivot and its angle is . The shaft of the DC motor is connected to the arm pivot and the input voltage of the motor is the input or control variable.

    Figure F.1: Model of inverted pendulum

    In the inverted pendulum experiment, the pendulum angle, , is defined to be positive when it rotates counter-clockwise. That is, as the arm moves in the positive clockwise direction, the inverted pendulum moves clockwise (i.e., the suspended pendulum moves counter-clockwise) and that is defined as > 0. The linear state-space representation of the ROTPEN Inverted Pendulum is shown below:

    () = () + (t) () = () + ()

    where = [1 2 3 4] = [ ] is the states of the system, () is the motor voltage input, () is the system output. The model parameters are given in Table F.1 and the matrices , , and are given in Table F.1.

    Table F.1: Analog output

    Symbol Description Value Unit

    Mass of the pendulum assembly (weight and link combined). 0.027 Kg

    Length of pendulum center of mass from pivot. *0.153 m

    Total length of pendulum. 0.191 m

    Length of arm pivot to pendulum pivot. 0.08260 m

    Motor shaft moment of inertia. 3x10-5 kgm2

  • EE4307 Control System Design and Simulation Page 47

    Project

    Mass of arm. 0.028 kg

    Gravitational acceleration constant. 9.810 m/s2

    Equivalent moment of inertia about motor shaft pivot axis. 1.23x10

    -4 kgm2

    Pendulum moment of inertia about its pivot axis. *7.01x10-4 kgm2

    Arm viscous damping. 0.000 Nm/(rad/s)

    Pendulum viscous damping. 0.000 Nm/(rad/s)

    Motor armature resistance. 3.30

    Motor torque constant. 0.02797 Nm

    Motor back-electromotive force constant. 0.02797 V/(rad/s) The viscous damping which is a friction that opposes the velocity, when the structure is moving, is regarded as being negligible.

    *Interested students may try to calculate those two parameters from the known parameters or propose a method to identify them.

    Table F.2: Analog output

    State-Space Matrix Expression

    A

    B

    C

    D [0 0 0 0]

  • EE4307 Control System Design and Simulation Page 48

    Project

    Appendix G Quick Notes on LabVIEW LabVIEW is a graphical programming language. The software is windows-driven, and various functions can be performed simply by placing icons and carrying out the soft-wirings. A typical LabVIEW Programme includes two workspaces: Block diagram and front panel. Use the LabVIEW palettes, tools, and menus to build the front panels and block diagrams of Vis (virtual instruments). LabVIEW includes three palettes: the Controls palette, the Functions palette, and the Tools palette. The Controls palette is available only on the front panel and contains the controls and indicators you use to create the front panel. The Functions palette is available only on the block diagram and contains the VIs and functions you use to build the block diagram. To get the palette, the easier way is to right click the corresponding workspace. The controls and indicators are located on subpalettes based on the types of controls and indicators. The VIs and functions are located on subpalettes based on the types of Vis and functions. This appendix provides introduction on some basic functions and program structure of LabVIEW Programme which you may find useful to complement this project. If you have difficulty finding a palette object by its short name, use the Search button on the Functions/Controls palette to find the palette object by name. The Context Help window displays basic information about LabVIEW objects when you move the cursor over each object.

    1. Execution Control

    Directory: Functions->Programming->Structures or Functions->Express->Execution

    Control

    Figure F.1 While loop and time delay

    Use the Execution Control Express VIs and structures to add control and timing to VIs. An example using the While loops and time delay functions are given as shown in Fig. F.1. The While loop iterates the sub-program within until the conditional terminal r e c e i v e s a particular Boolean value. The sampling time of the computer controlled system should be set through the time delay function. Fig. F.1 provides the basic structure of LabVIEW program. More components, including data acquisition, control strategy and signal output, can be added in the sub-program so that the program would be running continuously to implement a practical objective. This directory also includes the Case structure, which may be useful in your project.

  • EE4307 Control System Design and Simulation Page 49

    Project

    2. Data Acquisition Directory: Functions->Measurements I/O->DAQmax, Functions->Express->Signal analysis and Functions->Programming->Waveform

    DAQ assistant can be configured to acquire raw output data and generate them on a plot. Simulate signal allows the generation of various waveforms for the project; the MLS sequence waveform provides PRBS signal.

    3. File I/O

    Directory: Functions->Programming->File I/O

    Use the File I/O VIs and functions to open and close files, read from and write to files, create directories and files you specify in the path control, retrieve directory information, and write strings, numbers, arrays, and clusters to files.

    4. Other Basic Functions

    Directory: Functions->Express->Arithmetics & Comparisons

    Use the Arithmetic & Comparison Express VIs and functions to perform arithmetic functions and to compare Boolean values, strings, and numeric values.

    Directory: Functions->Programming->Array/Cluster, Class, & Variants

    Use the Array functions to create and manipulate arrays; Use the Cluster, Class & Variant functions to create and manipulate clusters and LabVIEW classes, convert LabVIEW data to a format you can manipulate independent of data type, add attributes to the data, and convert variant data to LabVIEW data.

    5. Some Basic Controls

    Directory: Controls->Express->Numeric Controls/ Buttons & Switches

    Use Numeric Controls, Buttons and Switches to create and manipulate various types variables, including real and Boolean types.

    Directory: Controls->Express->Graph Indicators

    Use Graph Indicators to display the trend of output, input or other signals in the front panel when programme in running.

  • EE4307 Control System Design and Simulation Page 50

    Project

    Appendix H LabVIEW Function Blocks for NI ELVIS II+ All of the needed LabVIEW function blocks for NI ELVIS II+ (for inverted pendulum system) can be found in the folder: EE4307/Part6/. The detailed descriptions of the function blocks for ELVIS II+ and the other needed functions in LabVIEW are given as below:

    1. DAQ Initialization

    Purpose:

    To configure the DAQ hardware for encoder, speed and current sensors.

    Inputs:

    [1] Device IO name: Connect to control specifying device IO name.

    Outputs:

    [1] Cluster of references: Connect to System reference IN of next function.

    2. DAQ Acquisition

    Purpose:

    To perform DAQ acquisition of sensors to acquire and calculate pendulum and arm angles, voltage and current readings of motor.

    Inputs:

    [1] System reference IN: Connect to the System reference OUT of previous function.

    Outputs:

    [1] System reference OUT: Connect to system reference IN of next function.

    [2] ROTPEN Angles OUT: Connect to ROTPEN Angles IN of the next function, includes: arm angle and pendulum angle.

    [3] Parameters OUT: Connect to front panel indicator to display real time values.

  • EE4307 Control System Design and Simulation Page 51

    Project

    3. Error Calculation

    Purpose:

    This VI obtains the ROTPEN angle actual outputs and the references to calculate the errors, the differential of the errors and the integral of the errors. This function block is required to run in the Control & Simulation Loop. Inputs:

    [1] ROTPEN Angles IN: Connect to ROTPEN Angles OUT of the previous function, includes arm angle and pendulum angle.

    [2] Arm angle reference: Set the arm angle reference (theta_r).

    [3] Pendulum angle reference: Set the pendulum angle reference (alpha_r).

    Outputs:

    [1] Errors OUT: Connect to the controller. The errors include: the arm angle error (e_theta), the differential of the arm angle (e_theta_dot), the pendulum angle (e_alpha), the differential of the pendulum angle (e_alpha_dot) and the integral of the pendulum angle (integral_e_alpha).

    4. DAQ Generate

    Purpose:

    This VI accepts the control signal and system references to generate the analog voltage output to the motor. This function should be within the control and simulation loop.

    Inputs:

    [1] System reference IN: Connect to System reference OUT of previous function.

    [2] Motor volts: Use to control the DAQ voltage output (u) to the DC motor.

    Outputs:

    [1] System reference OUT: Connect to system reference IN of next function.

  • EE4307 Control System Design and Simulation Page 52

    Project

    5. DAQ Close

    Purpose:

    This VI closes the hardware references of ELVIS II DAQ hardware. This function should be put in the end out of the control and simulation loop.

    Input:

    [1] System Reference IN: Connect to System reference OUT of previous function.

    [2] Error In: Connect to error output of control and simulation loop.

    6. Control & Simulation Loop

    Directory: Functions->Control Design & Simulation->Simulation->Control & Simulation loop

    Purpose:

    Executes the simulation diagram until the Control & Simulation Loop reaches the simulation end time or until the Halt Simulation function stops the execution programmatically. You must place all Simulation functions within a Control & Simulation Loop or in a simulation subsystem. You also can place simulation subsystems within a Control & Simulation Loop or another simulation subsystem, or you can place simulation subsystems on a block diagram outside a Control & Simulation Loop or run the simulation subsystems as stand-alone VIs.

    Recommended settings are shown below:

    (1) Initial time: 0s

    (2) Final Time: inf

    (3) Step size: 0.01s

    (4) ODE Solver: Runge-Kutta 1(Euler)

    (5) Timing source: Source type: 1kHz Clock; Source: 1kHz

    (6) Loop timing attributes: Period: 10; Priority: 100

  • EE4307 Control System Design and Simulation Page 53

    Project

    7. Halt Simulation

    Directory: Functions->Control Design & Simulation->Simulation->Utilities->Halt Simulation

    Purpose:

    Stops the simulation at the end of the current time step, if the value of the Halt? parameter is TRUE. This function does not have a configuration dialog box.

    Input:

    [1] Halt?: Specifies whether you want to stop the simulation at the end of the current time step. Specify a value of TRUE to stop the simulation. Specify a value of FALSE if you do not want to stop the simulation. The default value is FALSE.

    * Example of Open-loop System The LabVIEW program shown in the Figure below is an example of the open-loop system for inverted pendulum system.

    1. Introduction2. Desktop Systems Available for Project3. Data Acquisition and Control Platform4. Data Acquisition and Conditioning5. System Identification: Non-Parametric Approach6. System Identification: Parametric Approach7. System Simulation8. Control Design and Implementation9. ReportAppendix AAppendix BAppendix CAppendix DAppendix E Information of Inverted Pendulum SystemAppendix F Model of Rotary Inverted Pendulum System (ROTPEN)Appendix G Quick Notes on LabVIEWAppendix H LabVIEW Function Blocks for NI ELVIS II+