ee357 control systems i: lab manual - university of...

46
Department of Electrical & Computer Engineering University of Alberta EE357 Control Systems I: Lab Manual Winter 2008 January 2008

Upload: others

Post on 25-Apr-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

Department of Electrical & Computer EngineeringUniversity of Alberta

EE357 Control Systems I: Lab Manual

Winter 2008

January 2008

Page 2: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

ii

Page 3: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

Contents

0 Preliminary 10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.2 Hardware Equipment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

0.2.1 Analog Plant Simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.2.2 Data Acquisition System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20.2.3 Universal Power Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40.2.4 Servo-motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

0.3 Software Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60.3.1 Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60.3.2 WinCon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

0.4 An Illustrative Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120.5 Safety and Caution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

1 Lab 1 151.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151.2 Using SIMULINK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151.3 Using the Analog Plant Simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161.4 Lab Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2 Lab 2 192.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.2 Lab Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

2.2.1 Implement and Measure K . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202.2.2 Implement the Closed-Loop System and Measure its Step Response . . . . . . . . . 202.2.3 Compute the Motor Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222.2.4 Validate the Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

2.3 Lab Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

3 Lab 3 233.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.2 Lab Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

3.2.1 Position Feedback: Measuring the Performance Curve . . . . . . . . . . . . . . . . . 253.2.2 Position plus Velocity Feedback: Measuring Performance . . . . . . . . . . . . . . . 263.2.3 Theoretical Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

3.3 Lab Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

4 Lab 4 294.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.2 Lab Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

4.2.1 Modeling Approximations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

iii

Page 4: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

iv Contents

4.2.2 Preliminary Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304.2.3 Root Locus Design Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314.2.4 Simulating the Ball and Beam Control System . . . . . . . . . . . . . . . . . . . . . 314.2.5 Testing the Ball and Beam Control System . . . . . . . . . . . . . . . . . . . . . . . 32

4.3 Lab Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

5 Lab 5 355.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355.2 Laboratory Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

5.2.1 Estimating α and β via Open-Loop Frequency Response . . . . . . . . . . . . . . . . 365.2.2 Design, Simulate and Test a Lead Compensation Controller . . . . . . . . . . . . . . 37

5.3 Lab Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

A Appendix 41

Page 5: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

0 Preliminary - Hardware and SoftwareOverview

0.1 Introduction

The undergraduate Control Systems Lab is located in ETLC E5-006. In the lab, there are 15 PCs equippedwith data acquisition systems running under the Windows XP environment. The hardware equipment andsome software tools, e.g., WinCon 5.0, are manufactured by Quanser Consulting (www.quanser.com), aCanadian company developing real-time control systems for education and research.

This chapter introduces some of the hardware equipment and software tools to be used in the ControlSystems Lab. Familiarity with this chapter is assumed in the labs. Briefly, this chapter is organized asfollows:

Section 0.2 describes the hardware equipment;

Section 0.3 describes the software tools;

Section 0.4 provides an example of using the hardware and software;

Section 0.5 lists the issues related to safety and caution

0.2 Hardware Equipment

The hardware devices to be introduced are analog plant simulators, data acquisition systems, power mod-ules, and servo-motors.

0.2.1 Analog Plant Simulator

An analog plant simulator (APS) is shown in Figure 1, which consists of a set of 11 independent electroniccircuits (building blocks) that can be interconnected to study the behavior of dynamical systems. A seriesof potentiometers allow you to adjust the parameters of each block within a certain range. RCA jacks areused throughout so you can easily connect the output of one block to the input of another. A DC powerunit converts AC (from a wall power outlet) to DC for the APS.

The 11 building blocks on the APS are listed below:

1

Page 6: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

2 Preliminary

Figure 1: The analog plant simulator (APS)

Qty Label I/O Relation or TF Parameter Range1 Sum y = u1 + u2

2 Diff y = u1 − u2

2 Gain y = K · u K: 0-10.3 Lag (1st-order) H1(s) = A

s+A A: 0-10.2 Lag (2nd-order) H2(s) = D0

s2+D1s+D0D0: 0-104; D1: 0-2000.

1 PID (with switchset to 1)

Y =(Kp + Ki

s

)(U−Ud)+KdsUd Kp: 0-10; Kd: 0-2; Ki: 0-10.

1 PID (with switchset to 2)

Y =(Kp + Kds + Ki

s

)(U − Ud) Kp: 0-10; Kd: 0-2; Ki: 0-10.

0.2.2 Data Acquisition System

For computer implemented controllers, analog-to-digital (A/D) and digital-to-analog (D/A) conversionsare necessary. These are done using the data acquisition and control board (DACB), which inputs themeasured signal(s) to the computer and outputs control action to the actuator in the control loop. TheDACB in this lab consists of two parts: the MultiQ-PCI data acquisition card and terminal board, whichare both made by Quanser Consulting.

Figure 2 shows a photo of the MultiQ-PCI data acquisition card, which has 8 analog inputs, 8 analogoutputs (only 4 available with our terminal board), 16 bits of digital inputs and outputs, 3 programmabletimers, and up to 6 encoder inputs decoded in quadrature. These data acquisition cards are installed inPCI slots inside the computers.

The MultiQ-PCI terminal board, shown in Figure 3, is a bench-top board for interfacing the MultiQ-PCI data acquisition card with other analog equipment such as the APS, servo-motor, and power module.Five grey ribbon cables are used for connection. Further details on proper connections will be discussed inthe later chapters.

Page 7: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

3

Figure 2: The MultiQ-PCI data acquisition card (inside the PC)

Analog Outputs(to UPM)

Analog Inputs(from Plant)

Encoder Inputs(from Plant)

To MultiQ PCI DataAcquisition Card

Digital I/OPorts

0

1

2

3

0

1

2

3

4

5

6

7

0

1

2

3

4

5

Figure 3: The MultiQ-PCI terminal board

Page 8: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

4 Preliminary

0.2.3 Universal Power Module

The universal power module (UPM-2405), part of which is shown in Figure 4, is a linear power operationalamplifier. The MultiQ-PCI data acquisition card cannot deliver enough power to the actuators used inthis lab; therefore, a signal buffer is needed. The UPM-2405 is used as our signal buffer since it can deliverup to 5A to an actuator in a non-inverting, unity-gain configuration.

Figure 4: Top front view of the universal power module

The following connections can be made to/from the UPM (see also Figure 4):

• From analog sensors: There are four (S1-S4) inputs which can be connected from analog sensors(and then subsequently to the computer); the cable used is a “6-pin mini-din/6-pin mini-din” cable(light tan color), which is now referred to as the analog sensor cable .

• To A/D: The four analog sensor signals (S1-S4) can then be connected to the MultiQ-PCI terminalboard for A/D conversion into the computer; the cable used is a “5-pin din-stereo/4×RCA” cable(black color), which is now referred to as the A/D cables.

• From D/A: This is where you input the D/A signal from the MultiQ-PCI terminal board to theUPM; the cable used is a “5-pin din-mono/RCA” cable (black color), which is now refereed to as theD/A cable.

• To load: Here you connect the amplified D/A signal to an actuator (e.g. servo-motor); The cableused is a “6-pin din/4-pin din” cable (black color), which is now refereed to as the load cable.

• Others: A few other connections are possible for convenience: e.g., the power supply on the top leftis for ±12 volts; the signals from analog sensors S1-S4 can be easily monitored by connecting to ascope.

0.2.4 Servo-motor

The Quanser DC servo-motor (SRV02) is shown in Figure 5. A 3W motor is mounted in a solid aluminumframe and drives a built-in Swiss-made 14.1 : 1 gearbox whose output drives an external gear, which isattached to an independent output shaft that rotates in an aluminum ball-bearing block. The output shaftis equipped with an encoder. The external gear on the output shaft drives an anti-backlash gear connectedto a precision potentiometer for measuring the output angle. The external gear ratio can be changed from1 : 1 to 5 : 1 using different gears. Two inertial loads are supplied with the system in order to examine

Page 9: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

5

the effect of changing inertia on motor performance. The motor is configured using the armature controlscheme.

Figure 5: rear view of the servo-motor

Several connections are available for the servo-motor as seen in Figure 5. The input voltage connects tothe UPM using the load cable. The potentiometer and tachometer ports connect to the UPM-2405 usingsensor cables and are used to measure angular position and angular velocity, respectively. Additionally, theshaft encoder port connects to the terminal board using an encoder cable and is used to measure angularposition.

The following calibration factors are needed in order to use the sensors in units of degrees or radians:

Connection Conversion (Rad) Conversion (Deg)Encoder − 2π

4096rad − 3604096deg

Tachometer 1 radsec

180π

radsec

Potentiometer 14096rad 180

4096π rad

Two external gear ratios are available for the servo-motor: the low gear ratio (Figure 6) and the highgear ratio (Figure 7). Normally, the first one is used in motor position control experiments, and the secondis used when the motor acts as an actuator to drive other plants such as the ball and beam, or the invertedpendulum.

Different amounts of inertia can be bolted to middle gear of the servomotor. This achieves a differentplant for each servomotors.

Page 10: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

6 Preliminary

Figure 6: Servo-motor: low gear ratio

Figure 7: Servo-motor: high gear ratio

0.3 Software Tools

The software tools used in the lab are:

• MATLAB/Simulink with its Control Systems Toolbox

• WinCon

• RTX Runtime

• Visual C++

WinCon is developed by Quanser Consulting to interface MATLAB/Simulink with hardware equipment,e.g., the MultiQ-PCI data acquisition system. WinCon uses a Simulink model to generate, compile usingVisual C++, and run the program to control the MultiQ-PCI data acquisition system. Venturcom producesthe RTX Runtime application, which gives a real time running environment for the MultiQ-PCI controlprograms despite using Windows, a non real time OS. In this section, we will focus on Simulink andWinCon.

0.3.1 Simulink

Simulink allows a MATLAB user to simulate complex control systems through block diagram connections.In this section, we briefly introduce the steps to use Simulink.

• Starting: Typing in Simulink in the MATLAB command window will open the Simulink window,see Figure 8. By selecting New from the File menu, you get a new system window, which you use tobuild a Simulink model. This model can be saved as a mdl-file for further editing and simulation.

• Creating blocks: Simulink has a standard block library shown in Figure 8 under the sub-groupSimulink; additionally, there are extended block libraries such as Communication Blockset, ControlSystem Toolbox, and so on. To create a Simulink model, drag and drop the required blocks into thesystem window, as shown in Figure 9 (left side).

Page 11: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

7

Figure 8: Initial Simulink Window

• Connecting inputs and outputs: To connect the output of block A to the input of block B, left clickthe output port of block A, drag it to the input port of block B, and release the mouse button. Toconnect a point in a data line with an input or output port, press and hold the Ctrl key, and thenclick on the point in the line and drag it over to the port. When the ports are connected, the anglebrackets disappear and directed lines indicate information flow as shown in figure 9 (right side).

Figure 9: Placing and connecting blocks in Simulink

• Simulation parameters: View and edit the simulation parameters by selecting Parameters from theSimulation menu as shown in figure 10. The parameters worth noting are:

(a) Solver method: fixed-step is the default. You should change this to variable step using ODE5when you are using blocks from the “continuous” toolbox.

(b) Start and stop time: 0 and 10 seconds is the default

Page 12: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

8 Preliminary

(c) Step size: 0.001 seconds is the default; this parameter should be increased (e.g. 0.01 seconds)for longer simulations.

After setting the simulation parameters as required, close the dialog box by clicking OK.

Figure 10: Simulink simulation parameters

• Simulating: To start the simulation, select Start from the Simulation menu. The simulation beginsand the scope stores the output time response; double click on the scope to see the plot.

• Plotting: The best way to capture the generated data is to use the To File block under the Simulinksub-group. This block will save the data in a *.mat file. The data in the *.mat file can be loaded intothe MATLAB workspace using the load command. The data can subsequently be viewed, analyzedand plotted.

0.3.2 WinCon

WinCon, a software package from Quanser Consulting, is a real-time application that runs Simulink gen-erated code using RTX Runtime on a PC under running Windows. WinCon allows controllers constructedin Simulink diagrams to be implemented in real time via the computer. For such a typical application,you need to start a WinCon Server and a WinCon Client. (One WinCon Server can communicate withseveral WinCon Clients, and visa versa.) In the simple case, one PC and no network, the configurationand required software tools are illustrated in Figure 11.

WinCon Server:

The WinCon Server performs the following tasks:

• Converts a Simulink diagram into a WinCon controller library wcl-file using the MATLAB Real-TimeWorkshop;

• Compile and link the code using Visual C++;

• Download the WinCon controller library file to run on the WinCon Client;

• Start and stop the WinCon Client;

Page 13: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

9

Figure 11: Stand-alone PC configuration

• Maintain TCP/IP communications with the WinCon Client;

• Maintain communications with Simulink for updating real-time changes in the controller parameters;

• Make changes to WinCon Client parameters using Control Panels;

• Plot the data streamed from a desired WinCon Client in real time;

• Save data to disk;

• Offer an External Interface Window to allow outside applications to receive streamed data from aWinCon Client and to perform real-time changes to the WinCon Client parameters.

WinCon Client:

The WinCon Client is a real-time application that runs the code generated from the Simulink diagram atthe sampling rate specified; its functions are summarized below:

• Receive the controller code from the WinCon Server as a WinCon controller library wcl-file;

• Run the controller code in real time;

• Maintain communications with the WinCon Server;

• Stream real-time data to any WinCon Server(s) requesting it.

MultiQ-PCI Terminal Board and WinCon in Simulink:

WinCon is fully compatible with the MultiQ-PCI terminal board. Open the Simulink Library Browser andfind the library of board drivers – see Figure 12. The blocks can be placed in a system window. Doubleclicking on the block opens the block properties dialog.

• Analog input: The analog input dialog allows you to specify the channel number (i.e. the analoginput port used on the terminal board). The board number and sample time should be kept to theirrespective defaults as shown in figure 13. The input voltage has a resolution of 12 bits and has aprogrammable voltage range of up to ±10 volts.

Page 14: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

10 Preliminary

Figure 12: Viewing the library of board drivers in Simulink

Figure 13: Dialog for the MultiQ-PCI analog input block

Page 15: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

11

• Analog output: The analog output dialog allows you to specify the channel number. (i.e. the analogoutput port used on the terminal board). The board number, initial value, final value, and sampletime should be kept to their respective defaults as shown in figure 14. The output voltage, with aset range of ±10 volts, has a resolution of 13 bits.

Figure 14: Dialog for the MultiQ-PCI analog output block

• Encoder input: The encoder input dialog allows you to specify the channel number (i.e. the encoderinput port used on the terminal board). The board number and initial value should be kept to theirrespective defaults as shown in figure 15. The encoder gives a positive integer count with resolutiondependant on the type of encoders selected; the encoder counter has 24 bits.

Figure 15: Dialog for the MultiQ-PCI encoder input block

• Digital input and output: The MultiQ series also have 8-bit digital input and output capability. Thereare currently no plans to employ these I/O ports.

Generating Controller Codes for Simulink Diagrams:

If WinCon is installed properly, a WinCon menu item appears in the Simulink Window, which allows you togenerate and run the real-time code seamlessly. Simply construct/load the controller diagram you want torun in real time; and then in the WinCon menu select Build. This will initiates the process of generatingthe real-time code. When the process is done, a message appears in the MATLAB window indicating that

Page 16: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

12 Preliminary

a wcl-file has been successfully created. A pop-up window will appear automatically for executing thecontroller– see Figure 16

Figure 16: Pop-up window for executing controllers

Running Controllers:

You can start and stop the controller on the WinCon Client to which the WinCon Server is connectedusing one of the following two ways:

1. Use the Start/Stop button on the WinCon pop-up window to manually start and stop the simulation.

2. Use the MATLAB commands wc start and wc stop to start and stop the simulation, respectively.These commands are particularly useful for automating multiple trial operation.

Displaying and Saving Data:

Signals can be displayed from both Simulink by selecting the WinCon→Plot Open menu and the WinConServer using the Plot→Open menu. You can then choose to display a desired variable as a real-time plot(e.g., x(t) vs. t), a digital meter form (like a digital volt-meter), or an x-y plot (y vs. x).

To save data from a Wincon Server plot, simply click on File→Save The data can be saved in one ofthree ways:

• m-file: This creates a .m file. Typing the name of the file in the MATLAB command window bringsup the MATLAB plot saved; the vector plotted are loaded into the MATLAB workspace.

• mat-file: (Recommended) This creates a .mat file. Use the command load to load the data into theMATLAB workspace. The time vector is named plot time while the data vector has a name X Ywhere X is the Simulink model name and Y is the Simulink scope name, which is “Scope” by default.Use MATLAB command whos to check the name of the variables from the stored data arrays. Usethe commands plot and (optionally) subplot to plot the data.

• To workspace: This is equivalent to saving to a .mat file and then loading it into the MATLABworkspace– except that you do not have the data saved in a file.

Alternatively, You can use MATLAB script wc saveplot(’plot title’, ’filename.mat’) to saveyour data to a mat-file. The plot title is the name appear at the top of the visual scope.

0.4 An Illustrative Example

This section illustrates how to use Simulink and WinCon in order to perform basic a I/O task withthe DC servo-motor. Follow the outlined procedure below to familiarize yourself with the hardware andsoftware.

Page 17: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

13

Scope

Quanser ConsultingMultiQ-PCI ENC

Encoder Input

Display1

0

Display1

Constant

-K-

Calibration

Quanser ConsultingMultiQ-PCI DAC

Analog Output

Figure 17: Final Simulink diagram for the open-loop servomotor system

• Build a Simulink model as shown in Figure 17. The model applies a constant voltage to the servo-motor. The encoder is employed to acquire the angular position over time.

• The input and output channel numbers should match the channels used on the terminal board. Referto figure 3 for terminal board channel location.

• The calibration factors need to be set so that the servo-motor angular position and velocity is acquiredin appropriate units. Refer to subsection 0.2.4 for calibration details of the servo-motor.

• Click on Simulation → Simulation Parameters from your Simulink screen. In our example weare not using blocks from the continuous library. Therefore, the solver options do not need to bechanged.

• Click on WinCon → Build from Simulink menu. This generate real-time C code for the diagram.Wait until the compilation process is completed. The MATLAB window displays the progress ofthe code generation task and when it is completed the message appears:

Successful completion of RTW build procedure for model: xxxxx

Following the code generation, WinCon Server and WinCon Client are automatically started. Thegenerated code is then automatically downloaded to the client and the system is ready to run.

• Click on the Plot button in Wincon Server and select Plot → New → Scope. The names of allblocks in the diagram appear in a Multi Select Variable Tree. You can select the variables which youwant to display.

• Once the generated code is downloaded to the client, click on Start/Stop button in the WinconClient window to start execution of the Simulink model in real-time. The open-loop response ofthe motor position measured from the encoder (Display1) is shown in figure 18

• You can save the data by clicking on File→Save on the plot window, or by using the MATLABcommand wc saveplot as mentioned earlier.

0.5 Safety and Caution

Because mechanical and electrical/electronic devices are involved, always handle them with care. Our goalis to eliminate unsafe operations and damage to equipment. Listed below are some important points:

• Read all instructions (this manual and relevant lab chapter) before coming to the lab. Mark downthings you do not understand or are not sure about, and discuss them with the lab instructor/TA.

Page 18: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

14 Preliminary

0 1 2 3 4 5 6 7 8 9 100

20

40

60

80

100

120

140

160

180

Time(sec.)

Ang

el o

f Ser

vom

otor

(de

g.)

Figure 18: Open-loop motor position response with applied 1-volt input

• Whenever possible, the lab instructor will demonstrate wiring the required equipment at the begin-ning of each lab; make sure you come to the lab on time and observe the demos.

• When connecting wires, keep power off the equipment, e.g., the MultiQ-PCI terminal board and theAPS. Ask the lab instructor/TA to check you wiring before turn on power.

• For experiments involving a servo-motor unit, it is very important to remember not to send high-frequency voltage signals directly to the motor or damage will occur in the motor gearbox and brushes.As an example, if one uses a differentiator to compute the speed signal from the position signal, makesure the high-frequency components are removed– using band-limited differentiator. Normally, if onehears a “buzz” noise in the motor, turn off the motor immediately and check the control system.

Page 19: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

1 Lab 1 - Time Responses of Open- andClosed-Loop Systems

1.1 Introduction

The purpose of this lab is three-fold:

• study time responses of second-order systems;

• compare sensitivities of open-loop and closed-loop systems to parameter variations;

• get familiar with some hardware and software used in the EE 357 labs.

Second-order systems often arise in modeling physical systems, e.g., RLC circuits, spring-mass-dampersystems, and DC motors. In this lab we study 2nd order system of the following form

k

s2 + as + b,

with varying parameter b. You will simulate these second-order systems using both SIMULINK and theanalog plant simulator (APS).

The hardware and software used in this lab include the APS, MultiQ-PCI terminal board, MAT-LAB/SIMULINK, WinCon, and RCA cables for connection, refer Chapter 0 for the usage. Familiarity ofcontents in Chapter 0 is required as preliminary reading.

1.2 Using SIMULINK

The nominal open-loop system is given by

P (s) =k

s2 + as + b, k = 1240, a = 9.23, b = 1240. (1.1)

Closing the loop by unity feedback and a proportional controller with C(s) = Kp, we get Figure 1.1;throughout the lab, we take Kp = 1.

C(s) P (s)j- - - -

6

r e y

Figure 1.1: The closed-loop system

Denote the closed-loop transfer function from r to y in Figure 1.1 by G(s) (nominal closed-loop tf).The closed-loop transfer function of this system can be derived from open-loop transfer function P (s) as:

G(s) =P (s)

1 + P (s)(1.2)

15

Page 20: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

16 Lab 1

Proceed as follows:

Step 1 Construct in SIMULINK the open-loop system P as shown in Figure 1.2 – review theprocedure in Section 0.3.1 in Chapter 0 if necessary. Simulate the step response and record/save thedata for later analysis and plotting (Choose fixed step and run for 5 seconds; Use ”Scope Parameters- Save Data to Workspace” or use Simulink building block ”To File” to record data).

Figure 1.2: Nominal open-loop SIMULINK model

Step 2 Construct the SIMULINK model for the closed-loop system G to represent the block diagramin Figure 1.1, and simulate the closed-loop step response; record the data.

Step 3 Next change the value of parameter b to b1 = 240 in (1.1) and keep the other parametersremain same. Denote the new open-loop system by P1(s) and the corresponding closed-loop systemby G1(s). Repeat Steps 1 and 2 for P1 and G1; save the data of step responses of both open andclosed loop systems.

Step 4 Change the value of parameter b to b2 = 23 in (1.1) and obtain the new open-loop systemP2(s) and closed-loop system G2(s). Repeat Steps 1 and 2 for P2 and G2; save the step responsedata.

Save the six sets of data from Simulation to a MAT file. Load the file later and plot them with theresults from Analog Plant Simulator (APS) for comparison.

1.3 Using the Analog Plant Simulator

The goal here is to build the open loop and closed-loop system in the previous section on hardware simulator- APS. The APS is interfaced with SIMULINK through the MultiQ-PCI terminal board and the softwareWinCon – see Chapter 0 for details.

Nominal P and G:

Summarized below is the procedure to simulate the step responses of the nominal open- and closed-loopsystems:

Step 1 Connect the APS blocks to build a second order system of the nominal open-loop system in(1.1), which can be realized by cascading a Gain Block with transfer function K and a second-orderLag Block (H2) with transfer function D0/(s2 + D1s + D0). The connection is shown in Figure 1.3,the resulting transfer function is

KD0

s2 + D1s + D0. (1.3)

Page 21: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

17

Figure 1.3: Connecting the open-loop P on the APS and MultiQ-PCI terminal board

On the MultiQ-PCI terminal board, connect the D/A channel 0 to the input on the APS, and theA/D channel 0 to the output on the APS – see also Figure 1.3.

Step 2 Build a SIMULINK Module to interface the hardware with the PC. The correspondingSIMULINK module is shown in Figure 1.4, which applies a unit step through the analog outputchannel (to the APS) and samples the APS output through the analog input channel, and finallyfeeds the output to the Scope Block. A detailed procedure on how to build and run this type of

Figure 1.4: Simulink structure using the APS.

interfacing module in SIMULINK is given in Section 0.4 of Chapter 0.

Step 3 Tuning the knobs to find the right values for K, D0 and D1 in (1.3) to mimic P (s) issomewhat tricky. Because the knobs for these parameters on the APS can be tuned continuouslyover a very large range, e.g., 0 ≤ D0 ≤ 104 and 0 ≤ D1 ≤ 2000 and there is no direct way to readout the exact value. In this lab, the tuning of D0 and D1 is by trial and error using comparison ofplots from simulation response and APS response.

First, set K = 1. (How to achieve this?) Use the same interfacing module as Figure 1.4, you candirectly measure the output of the gain block and obtain the K value by simple division calculation.As D1 = 9.23 is relative small compared to the range [0, 2000], you can set D1 to zero, and D0

to approximately 1200 as the starting point. Start the simulation and save the data from ScopeWindow from WinCon Server. Plot and compare the resulting step response with the corresponding

Page 22: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

18 Lab 1

one obtained in Section 1.2 in MATLAB; Read the difference in frequency and amplitude and makesmall changes in D0 and D1 until you find close fit. If they are close (e.g., there appear three peaksin 0.5 sec, and the overshoot is about 70%), you have found the right D0 and D1. Save the stepresponse data for later analysis and comparison (Use Save to File sub-menu from Scope).

Step 4 Construct the closed-loop system on APS. Keeping the knobs of D0 and D1 (and K) fromopen-loop system untouched, close the loop on the APS to get the closed-loop system G; you needto use a Diff Block and re-wire the connections appropriately. Observe and record the closed-loopstep response.

P1 and G1:

Repeat the same procedure for P and G and record the step responses for P1 and G1. From P to P1, theonly parameter b is changed from 1240 to 240. In APS, we want to get KD0 = 1240 and D0 = 240. Thuswe set K = 1240/240 = 5.17, keep D1 unchanged, and tune D0 until the observed open-loop step responseresembles the one recorded earlier in Section 3 for P1. After obtaining good result on P1, reconnect theAPS to simulate the closed-loop system G1 without further tuning.

P2 and G2:

Repeat for P2 and G2 and observe/save the step responses. Note that in this case, the gain, K = 1240/23 =53.9, exceeds the maximum gain of 10 of a single Gain Block – two Gain Blocks in series are required.Furthermore since the gain is larger than the maximum measured value of hardware, you should reducethe magnitude of the step input from 1 to, say 0.1, to avoid saturation at the output. After obtaininggood result on P2, reconnect the APS to simulate the closed-loop system G2 without further tuning exceptresetting the step size of step block to 1.

Plot and compare the step responses observe in this section with those in Section 1.2; You may chooseto arrange several figures on the same plot or display using subplot in MATLAB.

1.4 Lab Report

An individual lab report is required and due 4pm one week after the lab.

• A cover page with title, student name, ID and section numbers should be included.

• Include Simulink blocks used in the lab and all plots of step response (Include title, labels with unit,legends etc.).

• Analyzing of the results generated in the lab and answer following questions:

1. Compare the step responses of open-loop and closed-loop systems, such as Tp (first peak time),PO (percentage overshoot ypeak−yfinal

yfinal), and final values. In general, does the closed-loop system

exhibit better resilience to parameter variations than open-loop systems? Are these systemstable?

2. Calculate the poles and zeros (if any) for the three open-loop and three closed-loop systems.Do the pole locations make sense and explain your conclusion from previous question aboutresilience and stability? (Hint: Poles are roots of denominator polynomial, zeros are roots ofnumerator polynomial.)

3. Explain why we have to reduce the step input magnitude from 1 → 0.1 in third case for open-loop setting when using APS, and why we reset step size back to 1 for closed-loop test withb = 23? Find possible reasons for the difference between Simulink results and APS results.

Page 23: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

2 Lab 2 - DC Motor Modeling byTime-Domain Experiments

2.1 Introduction

The goals in this lab are as follows:

• to introduce new hardware, the DC servo-motor and the universal power module (UPM), and theirI/O connection;

• to study position control of a DC motor via a simple pure gain controller;

• to determine motor parameters from the closed-loop step response.

The DC servo-motor manufactured by Quanser Consulting is armature controlled. As we discussedin class, from the input (armature voltage v) to the output (angular position θ), the DC motor can beapproximately modeled by a first-order system with an integrator:

P (s) =Θ(s)V (s)

s(s + β)(2.1)

(What factors are ignored for this approximation?) Since the open-loop system P (s) has a pole at theorigin, we need to configure a simple closed-loop system as shown in Figure 2.1 for this purpose.

K P (s)j- - - -

6

θre v θ

Figure 2.1: The closed-loop DC motor system

Here the controller is a pure gain K (already known), θr is the reference angle, and e is the trackingerror. You can verify that the closed-loop system from θr to θ is a standard second-order system of theform:

G(s) =ω2

n

s2 + 2ζωns + ω2n

(2.2)

The main idea of finding α and β in this lab is summarized below:

• First, adjust K so that the resulting closed-loop system is under-damped; measure the K value.

19

Page 24: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

20 Lab 2

• From the closed-loop step response, measure the percent overshoot (P.O.) and the peak time Tp; andthen compute ζ and ωn by solving

P.O. = exp

{−ζπ√1− ζ2

}(2.3)

Tp =π

ωn

√1− ζ2

(2.4)

• Given the closed-loop system G(s) and K in Figure 2.1, compute the open-loop parameters α andβ. (Please derive the formulas for α and β in terms of ζ, ωn, and K.)

2.2 Lab Procedure

The following steps are suggested for estimating α and β.

2.2.1 Implement and Measure K

For an under-damped closed-loop system (0 < ζ < 1), we need to set the controller gain K to be in theneighborhood of 18. Such a gain is achieved on the APS (analog plant simulator) using two Gain Blocks inseries; the input is connected to a D/A channel and output to an A/D channel of the MultiQ-PCI terminalboard. Use SIMULINK and WinCon to apply a small step to the APS; observe the APS output and tunethe knobs for proper gain. Record the gain K.

Note the following points of caution:

• The input step applied within SIMULINK should be small in magnitude to avoid causing saturationin the output. (If saturated, the gain obtained may be incorrect.)

• Leave the two knobs untouched in the following steps.

2.2.2 Implement the Closed-Loop System and Measure its Step Response

The new hardware required includes the DC servo-motor and the universal power module (UPM) units –please consult Chapter 0 for details on the UPM and servo-motor.

One way to connect the necessary equipment is shown in Figure 2.2, where the APS is for implementingK, the UPM for power amplification, the servo-motor for P (s), and the MultiQ-PCI terminal board forcomputer interfacing. The associated SIMULINK setup is shown in Figure 2.3. The detailed steps aredescribed as follows:

1. The built-in encoder on the servo-motor unit is used to measure θ; thus we connect the encoder portof the motor to encoder channel 0 on the MultiQ-PCI terminal board (see Figure 2.2), using theencoder cable (beige). The encoder reading must be scale by −2π/4096 to convert to an angle inradians – see Figure 2.3.

2. The summing (difference) junction in Figure 2.1 is implemented in SIMULINK in Figure 2.3, in whicha step of θr = 30◦ is applied, converted to radians, and compared with θ; the difference is the errorsignal e.

3. The error e is written to a D/A channel of the MultiQ-PCI terminal board, which is then connectedto the APS input (Figures 2.2 and 2.3); the error is amplified on the APS by K and the output isread into the computer via an A/D channel on the MultiQ-PCI terminal board (Figure 2.3).

Page 25: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

21

Figure 2.2: Wiring the closed-loop DC motor system

Figure 2.3: SIMULINK setup of the closed-loop DC motor system

Page 26: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

22 Lab 2

4. The amplified error v is used to drive the DC servo-motor: First, it is passed to a D/A channel(Figure 2.3), which is connected to the UPM (Figure 2.2) for power amplification (with voltage gain1); then the output of the UPM is used as the voltage input of the DC motor. You should verifythat this input signal is not clipping at ±10 volts (add a scope to observe the input signal).

Once the wiring is complete and the SIMULINK configuration is done, you can generate the real-timecontroller code in WinCon and run the closed-loop system. Record and save the closed-loop step response.You may want to review Section 0.3.2 in Chapter0 for details. Estimate the P.O. and Tp from the stepresponse.

2.2.3 Compute the Motor Parameters

• Using the P.O. and Tp obtained in the previous step, compute ζ and ωn for the closed-loop systembased on formulas given in (2.3) and (2.4).

• Using K, ζ and ωn, compute the model parameters α and β for the DC servo-motor.

2.2.4 Validate the Model

We can now simulate the step response of the estimated model using SIMULINK, and compare it with theactual one recorded in Section 2.2.2.

Using the motor parameters (α and β) and the same gain K in the closed-loop system in Figure 2.1,simulate the closed-loop step response in SIMULINK or MATLAB; save and compare with the actual stepresponse observed earlier. Discuss the model accuracy.

2.3 Lab Report

An individual lab report is required, which should be concise and relevant. Contents such as cover page,simulation block diagrams, step response plots as previous lab are required; pay particular attention to thefollowing questions:

• Include the analytical work done in order to compute the motor parameters α and β from stepresponse.

• Compare and discuss the step responses obtained in Sections 2.2.2 and 2.2.4, organize data collectedsuch as, yfinal, ypeak, tstart, tpeak, calculate Tp and P.O. What can be possible sources for the modelingerror (refer to textbook for the first principle modeling assumptions of DC-motor and think aboutpossible experimental errors)?

• In the closed-loop implementation scheme (Figure 2.3), the reference angle θr is a step input withmagnitude π/6 radians. If a step with different magnitude is used at θr, will the results for α andβ be different in experiment? Explain your answer (Hint: consider situations both in theory and inpractice, extreme large or small signal).

• Think of and discuss one alternative way for estimating the motor parameters α and β using theexisting equipment, derive or show the formula used for that method (Hint: new measurements fromstep response, other setting of system connection, or frequency domain response).

Page 27: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

3 Lab 3 - DC Motors: Position Feedback vs.Position plus Velocity Feedback

3.1 Introduction

Continuing with the DC servo-motor system in Lab 2, we would like to explore the following in this lab:

• understand the performance limitation of only using pure gain position feedback;

• demonstrate the advantage of introducing an additional velocity feedback (position plus velocityfeedback).

You have seen a DC motor system with position feedback in Lab 2, which is redrawn in Figure 3.1,where an approximate second-order model is used for the DC motor system from the armature voltage vto the angular position θ, and the pure gain controller K is designable.

s + β

1

sj- - - - -

6

θre v θ θ

Figure 3.1: The DC motor model with pure gain position feedback

In Lab 2, you estimated α and β from the closed-loop step response. Using the DC motor model inFigure 3.1, you can verify that the closed-loop system G(s) from θr to θ is a standard second-order onewith

ωn =√

αK, ζ =β

2√

αK. (3.1)

Setting K makes ωn and ζ deterministic, which then makes the peak time Tp and the percent overshoot(PO) deterministic, when 0 < ζ < 1 (under damped). Therefore, there exists a relationship between POand Tp, which is show graphically in Figure 3.2 using α = 73.9 and β = 40.9.

The curve in Figure 3.2 indicates a performance limitation using position feedback only: Any (Tp, PO)pair below this curve is not achievable with pure gain position feedback. In this lab, you are required toconduct the following:

• experimentally determine the performance curve by varying K and measuring PO and Tp in theclosed-loop step response;

• introducing a velocity feedback loop as in Figure 3.3 with both K and Kv designable, show that onecan break the performance limitation by doing better in terms of PO and Tp (getting a point belowthe curve using the position plus velocity feedback).

23

Page 28: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

24 Lab 3

0 0.05 0.1 0.15 0.2 0.25 0.30

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

Tp(s)

P.O

.

Figure 3.2: Position feedback: PO vs. Tp

s + β

1

s

Kv

6

j j- - - - - -

6

θrv θ θ

− −

Figure 3.3: The DC motor model with position plus velocity feedback

Page 29: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

25

3.2 Lab Procedure

Use the following steps to explore the performance issues for the motor systems with position feedback andposition plus velocity feedback.

3.2.1 Position Feedback: Measuring the Performance Curve

A similar setup to Lab 2 is used. The most notable difference is the exclusion of the Analog Plant Simulator.The wiring diagram and SIMULINK model is shown in Figure 3.4 and Figure 3.5 respectively.

Figure 3.4: Wiring the motor position feedback system

Figure 3.5: SIMULINK motor position feedback system

Several measurements need to be taken in order to measure the position feedback system performancecurve. You should aim to collect data points that adequately represent the performance curve. Run thesystem with varying values for the pure gain controller K (find Kmax first) and collect at least 10 ordered

Page 30: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

26 Lab 3

pairs (Tp, PO). Your collected data should contain PO’s spanning a range of [1%, 12%]. Obtain the largestPO range possible without saturating any nodes (Quanser ADC or DAC element).

Please note the following when you are varying K:

• all step responses must demonstrate an under damped closed-loop system;

• do not saturate any nodes at ±5 volts or ±10 volts.

Use MATLAB to plot your ordered pairs (Tp, PO) on a single graph.

3.2.2 Position plus Velocity Feedback: Measuring Performance

Modify your setup to incorporate the velocity feedback, using the build-in tachmeter of the DC motoras a velocity sensor. The wiring diagram and SIMULINK model are shown in Figure 3.6 and Figure 3.7respectively.

Figure 3.6: Wiring the motor position plus velocity feedback system

You will only need to make one measurement in order to find a point below the position feedbackperformance curve obtained in the previous section. Run the system with varying values for K and Kv.Collect at least one ordered pair (Tp, PO) such that the point is indisputably below the position feedbackperformance curve. Use MATLAB to plot your ordered pair (Tp, PO) on the same graph you obtained inthe previous section.

Please note the following when you are varying K and Kv:

• all closed-loop step responses must demonstrate an under damped system;

• do not saturate any nodes at ±5 volts or ±10 volts;

• start with small values for Kv, say 0.01.

Page 31: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

27

Figure 3.7: SIMULINK motor position plus velocity feedback system

3.2.3 Theoretical Analysis

Recall the following formulas for the step response specs of the standard second-order system:

PO = exp

{−ζπ√1− ζ2

}, Tp =

π

ωn

√1− ζ2

(3.2)

By using the equations in (3.1) and (3.2), it can be shown that the performance curve in the positionfeedback case in Figure 3.1 satisfies the following relationship

PO = e−βTp/2. (3.3)

Plot the theoretical performance curve with measured one. Compare two curves and find discrepancies.

3.3 Lab Report

The individual lab report must include the following:

• Cover page with title, name, ID and section number;

• Simulink block diagrams used and a graph with plots of performance curve of position feedback anda position plus velocity feedback point below the curve from Sections 3.2.1 and 3.2.2. Label yourpoint with (K, Kv) value;

• Answer following questions of analysis and discussion.

1. Choose one pair of (Tp, PO), calculate α and β of experimental motor. Find the maximum Kvalue and maximum PO without saturation, and explain why the PO range is limited?

Page 32: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

28 Lab 3

2. Does your performance curve measured from Section 3.2.1 agree with theoretical one(3.3)?Discuss any discrepancies and explain possible causes.

3. Derive the analytical equation between PO and Tp for position plus velocity feedback setting.When Kv = 0, does your new equation agree with the PO and Tp equation for position feedbackonly system? Does your analytical relationship suggest that position plus velocity feedbackachieves better control than position feedback (Hint: derive the overall transfer function fromθr to θ of the position plus velocity system, find the new ωn and ζ first)?

Page 33: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

4 Lab 4 - Ball and Beam: Controller DesignUsing Root Locus

4.1 Introduction

You have seen in lab 3 that the DC servo motor can be controlled using position plus velocity feedback.This lab utilizes the same DC servo motor control setup to control the ball and beam apparatus. The DCservo motor is used to manipulate the position of a ball bearing on a horizontal beam by tilting the beamappropriately – see Figure 4.1.

Figure 4.1: Coupling the ball and beam module to the servo plant

The conductive ball lies on the beam, which is comprised of two parallel rods. A resistive strip, withimpedance proportional to length, covers one of the rods. The other rod is conductive; therefore, theposition of the ball can be determined by introducing a small current through the rods and measuring theresulting voltage – see Figure 4.2.

I (mA)

+

V

_

Figure 4.2: Detecting ball position

It is shown in appendix A that the ball and beam apparatus can be approximately modeled by a transferfunction from the input θ (motor angular position) to the output ball position x (in volts) as follows:

X(s)Θ(s)

=4.16s2

(volt./rad). (4.1)

The purpose of this lab is to:

1. approximate the ball and beam apparatus as an infinitely slower system than the DC servo motor;

2. utilize the MATLAB root locus design method to design a stabilizing control system for the ball andbeam apparatus to specification of:

(a) PO = 6%, and

29

Page 34: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

30 Lab 4

(b) Tp = 3.5 s;

3. verify model accuracy by comparing the physical system response to a digitally simulated systemresponse.

4.2 Lab Procedure

Use the following steps to design, implement, and test a closed-loop stable control system for the ball andbeam apparatus.

4.2.1 Modeling Approximations

The complete system is modeled in Figure 4.3, where the DC servo motor with properly designed positionplus velocity feedback is used as the actuator, the ball and beam system is modeled by (4.1), a doubleintegrator.

Inner Loop: DC Servo Motor

s + β

1

s

Kv

- +

��

- - - - -

θr ve θ θKK1

4.16

s

1

s

KV 1

-+

-

x-

��

exxr x

Figure 4.3: Complete ball and beam control system

You have seen in lab 3 that the DC servo motor in a position plus velocity feedback control setupexhibits a relatively fast response with a Tp on the order of 0.1 seconds, which is significantly less than ourspecified total system Tp of 3.5 seconds. Therefore, our total system can be approximated without the DCservo motor system as shown in Figure 4.4.

K1

4.16

s

1

s

KV 1�

6

j j- - - - - -

6

xr θex x x

− −

Figure 4.4: Ball and beam system approximation

4.2.2 Preliminary Design

The following can be completed before the lab session:

Page 35: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

31

• Using the formulas

PO = exp

{−ζπ√1− ζ2

}, Tp =

π

ωn

√1− ζ2

,

translate the specs on PO and Tp into desired values for ζ and ωn.

• Derive the closed-loop transfer function from xr to x in Figure 4.4, and notice that it is a standardsecond-order system – express ζ and ωn in terms of K1 and KV 1.

• Choose K1 based on desired specs; KV 1 could also be designed using this method; however, we willuse the MATLAB root locus method for designing KV 1 instead.

4.2.3 Root Locus Design Method

The root locus plot is the collection of roots of system characteristic equation when a single parameteris varying. MATLAB provides some commands to generate root locus plot for systems, with variable K.The closed-loop system is required to transformed to either one of the following two forms in Figure 4.5,in which the rlocus command can isolate K from rest of system and test different K values.

- j

G

K

6

-

SYS = G

- j

G

K F

6

-

SYS = GF

Figure 4.5: MATLAB root locus required forms

The system of Figure 4.4 contains one unknown variable KV 1, which can be designed using the followingsteps (K value is from the calculation in preliminary design):

1. Modify Figure 4.4 into either form of Figure 4.5.

2. Determine transfer function of the SYS.

3. Use the following MATLAB code:num = [ ]; % enter your SYS numeratorden = [ ]; % enter your SYS denominatorsys = tf(num, den); % SYSrlocus(sys); % build the root locussgrid(ζ, ωn); % plot your calculated ζ and ωn

[Kv1, roots] = rlocfind(sys) % pick the root locus point with your ζ and ωn.

4. Record your designed KV 1 and roots.

Comment on the stability of the system based on the designed characteristic equation roots.

4.2.4 Simulating the Ball and Beam Control System

Build a digital simulation test bench as shown in Figure 4.6. The input is from a function generator withthe following properties:

• Wave Form = square

Page 36: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

32 Lab 4

• Amplitude = 1.67V

• Frequency = 0.025 Hertz

4.16

s

Transfer Fcn

position.mat

To File1

set_point.mat

To File

SignalGenerator Scope

Kv1

K_v1

K1

K1

1

s

Integrator

Figure 4.6: Ball and beam digital simulation

Run the simulation for two cycles (80 seconds). Use MATLAB to plot the input and output on thesame graph.

4.2.5 Testing the Ball and Beam Control System

Build the Simulink model as shown in Figure 4.7 and connect the hardware as Figure 4.9. In the Simulinkmodel a derivative module with a low pass filter is used to derive ball velocity from the position sensor,which requires use ODE1 solver to build the model. Ensure that you do not saturate any nodes at ±5volts or ±10 volts. Use the same square wave form input from Section 4.2.4. For Analog Input block ofthe module, we use multiplexing technique to measure two inputs from channel 2 and 3, see Figure 4.8 forblock parameter setting.

Demux

5

s+5

Transfer Fcn−2*pi/4096

To Rad

SignalGenerator

Position

−K−

Kv1

0.01

Kv

−K−

K118

K

du/dt

Derivative

QuanserMultiQ−PCI DAC

Ch0 To UPM

QuanserMultiQ−PCI ENC

Ch0 Motor Position

QuanserMultiQ−PCI ADC

Analog InputCh2 & Ch3

Figure 4.7: Ball and beam analog simulation

To get good analog result, you would need to level the rail with ground and center the ball beforetesting. Check the connection bolt between rail and gears to find good start position and run the Winconsimulation for two cycles (80 seconds). Use MATLAB to plot the simulated position output and yourexperimental results on the same graph.

Page 37: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

33

Figure 4.8: Parameter setting for Analog Input block

Figure 4.9: Ball and beam wiring

Page 38: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

34 Lab 4

4.3 Lab Report

The individual lab report must include

• Cover page with title, name, ID and section number;

• All Simulink block diagrams and all three graphs requested (Root locus plot, Input/Output responsefrom digital simulation, and Input/Output response from analog test);

• All relevant design calculations in prelab and results of root locus method; Are the Kv1 value fromtheoretical calculation and root locus method close? Comment on the stability of the system basedon the designed characteristic equation roots (using Kv1 derived from root locus method).

• Compare the simulate closed-loop results with analog testing results. Do your digital simulationresults follow PO and Tp specifications? How about your analog testing results? Comment on theirrelative accuracy. Discuss at least three sources of error that contribute to your observed discrepanciesbetween your analog testing and digital simulation results.

Page 39: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

5 Lab 5 - Frequency-Domain Identification andPhase Lead Compensator Design

5.1 Introduction

The goals in this labs are as follows:

1. to determine the motor parameters α and β from open-loop frequency responses,

2. to design a lead compensator for the DC motor to achieve the following closed-loop specifications:

(a) ess ≈ 0.01 when the input is a unit ramp,

(b) P.O. ≤ 10% when the input is a unit step.

We obtained the model parameters α and β in Lab 2 using time-domain transient response data. Wewill now obtain α and β by measuring the frequency response of the DC motor. As discussed in class, themotor input (armature voltage v) to the output (shaft angular velocity θ) can be approximately modeledby a first-order system:

G(s) =Θ(s)V (s)

s + β.

Directly exciting the system with sinusoids of varying frequencies and observing the steady-state outputswill produce frequency responses – see Figure 5.1. For each frequency, the gain and phase can be measured,as shown in Figure 5.2. These gain and phase measurements can be used to produce Bode plots. Finally,the motor parameters α and β can be estimated from the Bode plots.

G ( s ) ) sin( wt v

Figure 5.1: Input sinusoidal signal to G(s).

Control design is readily done in the frequency domain using Bode plots. The general idea of thelead compensator design is: First choose the gain required in the controller to achieve certain steady-stateperformance requirement; then design the lead compensator to increase the phase margin (PM) of thesystem; this will increase damping, and hence decrease, e.g., the percent overshoot (PO) in the closed-loopstep response. Some trial and error may be necessary to satisfy the time-domain specs. Design steps arediscussed and illustrated in the lecture notes .

The relevant closed-loop system is shown in Figure 5.3, where

P (s) =1sG(s)

is the DC motor’s model and C(s) is the lead compensator to be designed using the mentioned specifications.

35

Page 40: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

36 Lab 5

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 -8

-6

-4

-2

0

2

4

6

8

Magnitude

Time (t)

Input sine signal ( = 50 rad/sec) and open-loop response

Input sine wave

output signal

w t w t

A

Figure 5.2: Open-loop time-domain response of G(s) with sinusoidal input.

C(s) P (s)j- - - -

6

θre v θ

Figure 5.3: The closed-loop DC motor system

5.2 Laboratory Procedure

Use the following steps to estimate α and β, design the lead compensator, and test your design for speci-fications.

5.2.1 Estimating α and β via Open-Loop Frequency Response

The wiring diagram and SIMULINK model are shown in Figures 5.4 and 5.5, respectively. We use thetachometer to measure the angular velocity of the motor; the measurement is a voltage signal (1 volt inthe output approximately corresponds to 1 rad/sec).

AngularVelocity

SignalGenerator

Output

Input

Quanser ConsultingMultiQ−PCI DAC

Analog Output Channel 0

Quanser ConsultingMultiQ−PCI ADC

Analog Input Channel 2 Range 10

Figure 5.4: SIMULINK setup for measuring the open-loop frequency response

1. Several measurements need to be taken in order to obtain a complete Bode plot. Use at least 10

Page 41: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

37

Figure 5.5: Wiring for measuring the open-loop frequency response

different sine waves into the DC servo motor input with Vin = 1 and frequencies ranging from 5 to100 rad/sec. Measure the steady-state output of the tachometer in each case. Collect all gain andphase measurements.

2. Plot the points on a magnitude Bode plot (dB vs. ω in log scale) and phase Bode plot (degrees vs. ωin log scale). Do straight line approximation on the magnitude Bode plot, and estimate the cornerfrequency and DC gain.

3. Estimate the motor parameters α and β based on the corner frequency and DC gain estimated.

4. Plot the Bode plots of the transfer function using the motor parameters α and β that you estimated.Compare with the measured ones. Briefly discuss discrepancies.

5.2.2 Design, Simulate and Test a Lead Compensation Controller

1. The lead compensator is of the form:

C(s) = K · aτs + 1τs + 1

, K > 0, τ > 0, a > 1. (5.1)

Design a lead compensator to achieve specs (a) and (b) using the following procedure, which is verysimilar to Section 6.4 in the notes:

a) Derive the frequency domain function of error signal E(s), using final value theorem to find therelation between ess and K. Find the desired gain K to achieve spec (a).

b) Simulate the step response of the uncompensated closed-loop system (use block diagram inFigure 5.6, treating the controller as a pure gain obtained from step a, i.e. set a = 1, τ = 0 inthe compensator); record the PO in this case.

c) Multiply the calculated K with P (s); estimate the phase margin of the new uncompensatedsystem KP (s). The MATLAB functions useful here are margin and bode.

d) Select some desired PM value. Design the compensator parameters α and τ based on ∆φ =PMdesired − PMold and the Bode plot of KP (s) (Read textbook for details).

Page 42: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

38 Lab 5

e) Check the new actual PM of C(s)P (s), if desired PM is achieved, record the a and τ and actualPM value. Otherwise, add some additional degree (usually a 5− 10 degree surplus is necessary)to the design PM value. Repeat step d and design new a and τ .

2. Simulate the ramp and step responses of the closed-loop system using SIMULINK block as Figure 5.6.If PO requirement is not satisfied, choose a larger desired PM value, and repeat step d from above.

3. Test the ramp and step responses of the closed-loop system using the DC Servo motor. TheSIMULINK model and wiring diagram are shown in Figures 5.7 and 5.8, respectively. Use a stepinput with magnitude 0.15V. Does your compensator meet specifications?

Briefly summarize your design process for the lead compensator. Compare and discuss the step re-sponses obtained in steps 2 and 3 of Section 5.2.2. How does the lead compensation affect the closed-loopbandwidth?

Angle

digital_step.mat

To File

Step

Ramp

a*tau.s+1

tau.s+1

Phase−lead OutputManual Switch

−K−

Gain

alpha

s +beta.s2

DC Motor Model

Figure 5.6: Simulation setup for the lead-compensated closed-loop system

Step

Ramp

OutputManual Switch

Quanser ConsultingMultiQ−PCI ENC

Encoder Input Channel 0

−2*pi/4096

Convert to Radian

K*a*tau.s+K

tau.s+1

Compensator

Quanser ConsultingMultiQ−PCI DAC

Analog Output Channel 0

Figure 5.7: SIMULINK setup for analog test of the lead-compensated closed-loop system

5.3 Lab Report

Individual lab reports are not required for this lab, because it is too close to the end of the term. However,at the end of the lab session, you and your lab partner together should approach the lab instructor/TAand show all your graphs/results and design calculations. The lab instructor/TA may ask a few questionsrelevant to the lab steps. Based on the correctness of your results and your answers to the questions, amark for this lab will be given.

Page 43: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

39

Figure 5.8: Wiring for the lead-compensated closed-loop system

Page 44: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

40 Lab 5

Page 45: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

A Appendix - Ball and Beam Modeling

The ball and beam apparatus, with ball mass m and moment of inertia J , is sketched in Figure A.1 withseveral parameters shown.

x

F g

F n

F p

R

L

Figure A.1: Physical model of the ball and beam apparatus

The net force parallel to the beam is approximately modeled as

Fp = mg sinα =(

m +J

r2

)x,

where r is the ball radius. For small α, use sinα ≈ α to get

(mg)α =(

m +J

r2

)x.

From the geometry of the physical system, we make the following approximation

R sin θ ≈ L sinα.

For small α and θ, this is

α =R

Lθ.

Substitute this into (A.1), and take Laplace transforms with zero initial conditions:

X(s)Θ(s)

=mgR(

m + Jr2

)L· 1s2

.

41

Page 46: EE357 Control Systems I: Lab Manual - University of Albertashuonan/461lab/files/ee357-lab-manual.pdf · EE357 Control Systems I: Lab Manual Winter 2008 January 2008. ii. Contents

42 Appendix

Now evaluate using L = 0.428 m, R = r = 0.0127 m, g = 9.81 m/s2, m = 0.0659 kg, and J = 4.25×10−6

kg·m2:X(s)Θ(s)

=0.208

s2(m/rad).

The beam detects position with a scale of 20 volts per meter. Therefore, it is convenient to express thetransfer function in units of volt./rad as follows:

X(s)Θ(s)

=4.16s2

(volt./rad).