Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
University of Alberta
January 2008
ii
Contents
0 Preliminary 1
0.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
0.2 Hardware Equipment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
0.2.1 Analog Plant Simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
0.2.2 Data Acquisition System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
0.2.3 Universal Power Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
0.2.4 Servo-motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
0.3 Software Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
0.3.1 Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
0.3.2 WinCon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
0.4 An Illustrative Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
0.5 Safety and Caution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1 Lab 1 15
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.2 Using SIMULINK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.3 Using the Analog Plant Simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.4 Lab Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2 Lab 2 19
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.2 Lab Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2.1 Implement and Measure K . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2.2 Implement the Closed-Loop System and Measure its Step Response . . . . . . . . . 20
2.2.3 Compute the Motor Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.2.4 Validate the Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.3 Lab Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3 Lab 3 23
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.2 Lab Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.2.1 Position Feedback: Measuring the Performance Curve . . . . . . . . . . . . . . . . . 25
3.2.2 Position plus Velocity Feedback: Measuring Performance . . . . . . . . . . . . . . . 26
3.2.3 Theoretical Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.3 Lab Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4 Lab 4 29
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.2 Lab Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.2.1 Modeling Approximations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
iii
iv Contents
5 Lab 5 35
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
5.2 Laboratory Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.2.1 Estimating α and β via Open-Loop Frequency Response . . . . . . . . . . . . . . . . 36
5.2.2 Design, Simulate and Test a Lead Compensation Controller . . . . . . . . . . . . . . 37
5.3 Lab Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
A Appendix 41
0 Preliminary - Hardware and Software
Overview
0.1 Introduction
The undergraduate Control Systems Lab is located in ETLC E5-006. In the lab, there are 15 PCs equipped
with data acquisition systems running under the Windows XP environment. The hardware equipment and
some software tools, e.g., WinCon 5.0, are manufactured by Quanser Consulting (www.quanser.com), a
Canadian 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 Control
Systems Lab. Familiarity with this chapter is assumed in the labs. Briefly, this chapter is organized as
follows:
The hardware devices to be introduced are analog plant simulators, data acquisition systems, power mod-
ules, and servo-motors.
An analog plant simulator (APS) is shown in Figure 1, which consists of a set of 11 independent electronic
circuits (building blocks) that can be interconnected to study the behavior of dynamical systems. A series
of potentiometers allow you to adjust the parameters of each block within a certain range. RCA jacks are
used throughout so you can easily connect the output of one block to the input of another. A DC power
unit converts AC (from a wall power outlet) to DC for the APS.
The 11 building blocks on the APS are listed below:
1
2 Preliminary
For computer implemented controllers, analog-to-digital (A/D) and digital-to-analog (D/A) conversions
are necessary. These are done using the data acquisition and control board (DACB), which inputs the
measured signal(s) to the computer and outputs control action to the actuator in the control loop. The
DACB in this lab consists of two parts: the MultiQ-PCI data acquisition card and terminal board, which
are both made by Quanser Consulting.
Figure 2 shows a photo of the MultiQ-PCI data acquisition card, which has 8 analog inputs, 8 analog
outputs (only 4 available with our terminal board), 16 bits of digital inputs and outputs, 3 programmable
timers, and up to 6 encoder inputs decoded in quadrature. These data acquisition cards are installed in
PCI 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 in
the later chapters.
3
3
Digital I/O
2 Ports
1
0
2 5
3 7
2 6 1 4
1 5
0 4 0 3
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 terminal
board 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 the
UPM; the cable used is a “5-pin din-mono/RCA” cable (black color), which is now refereed to as the
D/A cable.
• To load: Here you connect the amplified D/A signal to an actuator (e.g. servo-motor); The cable
used 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 left
is for ±12 volts; the signals from analog sensors S1-S4 can be easily monitored by connecting to a
scope.
0.2.4 Servo-motor
The Quanser DC servo-motor (SRV02) is shown in Figure 5. A 3W motor is mounted in a solid aluminum
frame and drives a built-in Swiss-made 14.1 : 1 gearbox whose output drives an external gear, which is
attached to an independent output shaft that rotates in an aluminum ball-bearing block. The output shaft
is equipped with an encoder. The external gear on the output shaft drives an anti-backlash gear connected
to a precision potentiometer for measuring the output angle. The external gear ratio can be changed from
1 : 1 to 5 : 1 using different gears. Two inertial loads are supplied with the system in order to examine
5
the effect of changing inertia on motor performance. The motor is configured using the armature control
scheme.
Several connections are available for the servo-motor as seen in Figure 5. The input voltage connects to
the UPM using the load cable. The potentiometer and tachometer ports connect to the UPM-2405 using
sensor cables and are used to measure angular position and angular velocity, respectively. Additionally, the
shaft encoder port connects to the terminal board using an encoder cable and is used to measure angular
position.
The following calibration factors are needed in order to use the sensors in units of degrees or radians:
Two external gear ratios are available for the servo-motor: the low gear ratio (Figure 6) and the high
gear ratio (Figure 7). Normally, the first one is used in motor position control experiments, and the second
is used when the motor acts as an actuator to drive other plants such as the ball and beam, or the inverted
pendulum.
Different amounts of inertia can be bolted to middle gear of the servomotor. This achieves a different
plant for each servomotors.
6 Preliminary
• WinCon
• RTX Runtime
• Visual C++
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 to
build 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-group
Simulink; additionally, there are extended block libraries such as Communication Blockset, Control
System Toolbox, and so on. To create a Simulink model, drag and drop the required blocks into the
system window, as shown in Figure 9 (left side).
7
• Connecting inputs and outputs: To connect the output of block A to the input of block B, left click
the output port of block A, drag it to the input port of block B, and release the mouse button. To
connect a point in a data line with an input or output port, press and hold the Ctrl key, and then
click on the point in the line and drag it over to the port. When the ports are connected, the angle
brackets disappear and directed lines indicate information flow as shown in figure 9 (right side).
• Simulation parameters: View and edit the simulation parameters by selecting Parameters from the
Simulation 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 ODE5
when you are using blocks from the “continuous” toolbox.
(b) Start and stop time: 0 and 10 seconds is the default
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.
• Simulating: To start the simulation, select Start from the Simulation menu. The simulation begins
and 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 Simulink
sub-group. This block will save the data in a *.mat file. The data in the *.mat file can be loaded into
the MATLAB workspace using the load command. The data can subsequently be viewed, analyzed
and 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 constructed
in 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 with
several WinCon Clients, and visa versa.) In the simple case, one PC and no network, the configuration
and 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-Time
Workshop;
• Download the WinCon controller library file to run on the WinCon Client;
• Maintain communications with Simulink for updating real-time changes in the controller parameters;
• Plot the data streamed from a desired WinCon Client in real time;
• Offer an External Interface Window to allow outside applications to receive streamed data from a
WinCon 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 at
the sampling rate specified; its functions are summarized below:
• Receive the controller code from the WinCon Server as a WinCon controller library wcl-file;
• Analog input: The analog input dialog allows you to specify the channel number (i.e. the analog
input port used on the terminal board). The board number and sample time should be kept to their
respective defaults as shown in figure 13. The input voltage has a resolution of 12 bits and has a
programmable voltage range of up to ±10 volts.
10 Preliminary
• Analog output: The analog output dialog allows you to specify the channel number. (i.e. the analog
output port used on the terminal board). The board number, initial value, final value, and sample
time should be kept to their respective defaults as shown in figure 14. The output voltage, with a
set range of ±10 volts, has a resolution of 13 bits.
• Encoder input: The encoder input dialog allows you to specify the channel number (i.e. the encoder
input port used on the terminal board). The board number and initial value should be kept to their
respective defaults as shown in figure 15. The encoder gives a positive integer count with resolution
dependant on the type of encoders selected; the encoder counter has 24 bits.
• Digital input and output: The MultiQ series also have 8-bit digital input and output capability. There
are currently no plans to employ these I/O ports.
a wcl-file has been successfully created. A pop-up window will appear automatically for executing the
controller– see Figure 16
Running Controllers:
You can start and stop the controller on the WinCon Client to which the WinCon Server is connected
using 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.
• m-file: This creates a .m file. Typing the name of the file in the MATLAB command window brings
up 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 the
MATLAB workspace. The time vector is named plot time while the data vector has a name X Y
where 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. Use
the 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 MATLAB
workspace– 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 save
your data to a mat-file. The plot title is the name appear at the top of the visual scope.
0
Quanser Consulting
1
MultiQ-PCI DAC Display
Constant
Encoder Input
Scope
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. Refer
to figure 3 for terminal board channel location.
• The calibration factors need to be set so that the servo-motor angular position and velocity is acquired
in 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 we
are not using blocks from the continuous library. Therefore, the solver options do not need to be
changed.
• 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 of
the code generation task and when it is completed the message appears:
Following the code generation, WinCon Server and WinCon Client are automatically started. The
generated 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 all
blocks in the diagram appear in a Multi Select Variable Tree. You can select the variables which you
want to display.
• Once the generated code is downloaded to the client, click on Start/Stop button in the Wincon
Client window to start execution of the Simulink model in real-time. The open-loop response of
the 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 MATLAB
command wc saveplot as mentioned earlier.
• Read all instructions (this manual and relevant lab chapter) before coming to the lab. Mark down
things you do not understand or are not sure about, and discuss them with the lab instructor/TA.
14 Preliminary
180
160
140
120
80
60
40
20
0
0 1 2 3 4 5 6 7 8 9 10
Time(sec.)
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 the
APS. 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, make
sure the high-frequency components are removed– using band-limited differentiator. Normally, if one
hears a “buzz” noise in the motor, turn off the motor immediately and check the control system.
1 Lab 1 - Time Responses of Open- and
Closed-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-damper
systems, 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 the
analog 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 of
contents in Chapter 0 is required as preliminary reading.
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:
P (s)
G(s) = (1.2)
1 + P (s)
15
16 Lab 1
Proceed as follows:
Step 1 Construct in SIMULINK the open-loop system P as shown in Figure 1.2 – review the
procedure in Section 0.3.1 in Chapter 0 if necessary. Simulate the step response and record/save the
data 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).
Step 2 Construct the SIMULINK model for the closed-loop system G to represent the block diagram
in 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 parameters
remain same. Denote the new open-loop system by P1 (s) and the corresponding closed-loop system
by G1 (s). Repeat Steps 1 and 2 for P1 and G1 ; save the data of step responses of both open and
closed loop systems.
Step 4 Change the value of parameter b to b2 = 23 in (1.1) and obtain the new open-loop system
P2 (s) and closed-loop system G2 (s). Repeat Steps 1 and 2 for P2 and G2 ; save the step response
data.
Save the six sets of data from Simulation to a MAT file. Load the file later and plot them with the
results from Analog Plant Simulator (APS) for comparison.
Nominal P and G:
Summarized below is the procedure to simulate the step responses of the nominal open- and closed-loop
systems:
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-order
Lag Block (H2) with transfer function D0 /(s2 + D1 s + D0 ). The connection is shown in Figure 1.3,
the resulting transfer function is
KD0
. (1.3)
s2 + D1 s + D0
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 the
A/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 corresponding
SIMULINK module is shown in Figure 1.4, which applies a unit step through the analog output
channel (to the APS) and samples the APS output through the analog input channel, and finally
feeds the output to the Scope Block. A detailed procedure on how to build and run this type of
Step 3 Tuning the knobs to find the right values for K, D0 and D1 in (1.3) to mimic P (s) is
somewhat tricky. Because the knobs for these parameters on the APS can be tuned continuously
over a very large range, e.g., 0 ≤ D0 ≤ 104 and 0 ≤ D1 ≤ 2000 and there is no direct way to read
out the exact value. In this lab, the tuning of D0 and D1 is by trial and error using comparison of
plots from simulation response and APS response.
First, set K = 1. (How to achieve this?) Use the same interfacing module as Figure 1.4, you can
directly 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 Scope
Window from WinCon Server. Plot and compare the resulting step response with the corresponding
18 Lab 1
one obtained in Section 1.2 in MATLAB; Read the difference in frequency and amplitude and make
small changes in D0 and D1 until you find close fit. If they are close (e.g., there appear three peaks
in 0.5 sec, and the overshoot is about 70%), you have found the right D0 and D1 . Save the step
response 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) from
open-loop system untouched, close the loop on the APS to get the closed-loop system G; you need
to use a Diff Block and re-wire the connections appropriately. Observe and record the closed-loop
step 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 , the
only parameter b is changed from 1240 to 240. In APS, we want to get KD0 = 1240 and D0 = 240. Thus
we set K = 1240/240 = 5.17, keep D1 unchanged, and tune D0 until the observed open-loop step response
resembles the one recorded earlier in Section 3 for P1 . After obtaining good result on P1 , reconnect the
APS 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 reduce
the magnitude of the step input from 1 to, say 0.1, to avoid saturation at the output. After obtaining
good result on P2 , reconnect the APS to simulate the closed-loop system G2 without further tuning except
resetting 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 choose
to arrange several figures on the same plot or display using subplot in MATLAB.
• 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),
y −yfinal
P O (percentage overshoot peakyfinal ), and final values. In general, does the closed-loop system
exhibit better resilience to parameter variations than open-loop systems? Are these system
stable?
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 about
resilience and stability? (Hint: Poles are roots of denominator polynomial, zeros are roots of
numerator 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 with
b = 23? Find possible reasons for the difference between Simulink results and APS results.
2 Lab 2 - DC Motor Modeling by
Time-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 their
I/O connection;
Θ(s) α
P (s) = = (2.1)
V (s) s(s + β)
(What factors are ignored for this approximation?) Since the open-loop system P (s) has a pole at the
origin, we need to configure a simple closed-loop system as shown in Figure 2.1 for this purpose.
θr e v θ
- j - K - P (s) -
6
−
Here the controller is a pure gain K (already known), θr is the reference angle, and e is the tracking
error. You can verify that the closed-loop system from θr to θ is a standard second-order system of the
form:
ωn2
G(s) = (2.2)
s2 + 2ζωn s + ωn2
• First, adjust K so that the resulting closed-loop system is under-damped; measure the K value.
19
20 Lab 2
• From the closed-loop step response, measure the percent overshoot (P.O.) and the peak time Tp ; and
then compute ζ and ωn by solving
( )
−ζπ
P.O. = exp p (2.3)
1 − ζ2
π
Tp = p (2.4)
ωn 1 − ζ 2
• 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.)
• The input step applied within SIMULINK should be small in magnitude to avoid causing saturation
in the output. (If saturated, the gain obtained may be incorrect.)
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 implementing
K, the UPM for power amplification, the servo-motor for P (s), and the MultiQ-PCI terminal board for
computer interfacing. The associated SIMULINK setup is shown in Figure 2.3. The detailed steps are
described as follows:
1. The built-in encoder on the servo-motor unit is used to measure θ; thus we connect the encoder port
of the motor to encoder channel 0 on the MultiQ-PCI terminal board (see Figure 2.2), using the
encoder cable (beige). The encoder reading must be scale by −2π/4096 to convert to an angle in
radians – see Figure 2.3.
2. The summing (difference) junction in Figure 2.1 is implemented in SIMULINK in Figure 2.3, in which
a step of θr = 30◦ is applied, converted to radians, and compared with θ; the difference is the error
signal e.
3. The error e is written to a D/A channel of the MultiQ-PCI terminal board, which is then connected
to the APS input (Figures 2.2 and 2.3); the error is amplified on the APS by K and the output is
read into the computer via an A/D channel on the MultiQ-PCI terminal board (Figure 2.3).
21
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 gain
1); then the output of the UPM is used as the voltage input of the DC motor. You should verify
that 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-time
controller 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 step
response.
• Using K, ζ and ωn , compute the model parameters α and β for the DC servo-motor.
• Include the analytical work done in order to compute the motor parameters α and β from step
response.
• Compare and discuss the step responses obtained in Sections 2.2.2 and 2.2.4, organize data collected
such as, yfinal , ypeak , tstart , tpeak , calculate Tp and P.O. What can be possible sources for the modeling
error (refer to textbook for the first principle modeling assumptions of DC-motor and think about
possible experimental errors)?
• In the closed-loop implementation scheme (Figure 2.3), the reference angle θr is a step input with
magnitude π/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 in
practice, extreme large or small signal).
• Think of and discuss one alternative way for estimating the motor parameters α and β using the
existing equipment, derive or show the formula used for that method (Hint: new measurements from
step response, other setting of system connection, or frequency domain response).
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 velocity
feedback).
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 v
to the angular position θ, and the pure gain controller K is designable.
θr e v α θ̇ - 1 θ
- j - K - -
s+β s
6
−
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 in
Figure 3.1, you can verify that the closed-loop system G(s) from θr to θ is a standard second-order one
with
√ β
ωn = αK, ζ = √ . (3.1)
2 αK
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 PO
and 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 to
conduct the following:
• experimentally determine the performance curve by varying K and measuring PO and Tp in the
closed-loop step response;
• introducing a velocity feedback loop as in Figure 3.3 with both K and Kv designable, show that one
can break the performance limitation by doing better in terms of PO and Tp (getting a point below
the curve using the position plus velocity feedback).
23
24 Lab 3
0.9
0.8
0.7
0.6
P.O.
0.5
0.4
0.3
0.2
0.1
0
0 0.05 0.1 0.15 0.2 0.25 0.3
Tp(s)
θr v α θ̇ - 1 θ
- j - j - K - -
s+β s
6
− 6
−
Kv
Figure 3.3: The DC motor model with position plus velocity feedback
25
Several measurements need to be taken in order to measure the position feedback system performance
curve. You should aim to collect data points that adequately represent the performance curve. Run the
system with varying values for the pure gain controller K (find Kmax first) and collect at least 10 ordered
26 Lab 3
pairs (Tp , PO). Your collected data should contain PO’s spanning a range of [1%, 12%]. Obtain the largest
PO range possible without saturating any nodes (Quanser ADC or DAC element).
Please note the following when you are varying K:
Use MATLAB to plot your ordered pairs (Tp , PO) on a single graph.
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 feedback
performance 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 feedback
performance curve. Use MATLAB to plot your ordered pair (Tp , PO) on the same graph you obtained in
the previous section.
Please note the following when you are varying K and Kv :
By using the equations in (3.1) and (3.2), it can be shown that the performance curve in the position
feedback 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.
• Simulink block diagrams used and a graph with plots of performance curve of position feedback and
a position plus velocity feedback point below the curve from Sections 3.2.1 and 3.2.2. Label your
point with (K, Kv ) value;
1. Choose one pair of (Tp , P O), calculate α and β of experimental motor. Find the maximum K
value and maximum PO without saturation, and explain why the PO range is limited?
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 P O and Tp for position plus velocity feedback setting.
When Kv = 0, does your new equation agree with the P O and Tp equation for position feedback
only system? Does your analytical relationship suggest that position plus velocity feedback
achieves 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)?
4 Lab 4 - Ball and Beam: Controller Design
Using 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 DC
servo motor is used to manipulate the position of a ball bearing on a horizontal beam by tilting the beam
appropriately – 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, with
impedance proportional to length, covers one of the rods. The other rod is conductive; therefore, the
position of the ball can be determined by introducing a small current through the rods and measuring the
resulting voltage – see Figure 4.2.
I (mA)
+
V
_
It is shown in appendix A that the ball and beam apparatus can be approximately modeled by a transfer
function from the input θ (motor angular position) to the output ball position x (in volts) as follows:
X(s) 4.16
= 2 (volt./rad). (4.1)
Θ(s) s
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 and
beam apparatus to specification of:
29
30 Lab 4
(b) Tp = 3.5 s;
3. verify model accuracy by comparing the physical system response to a digitally simulated system
response.
− Kv
−
− KV 1
−
You have seen in lab 3 that the DC servo motor in a position plus velocity feedback control setup
exhibits a relatively fast response with a Tp on the order of 0.1 seconds, which is significantly less than our
specified total system Tp of 3.5 seconds. Therefore, our total system can be approximated without the DC
servo motor system as shown in Figure 4.4.
xr ex θ - 4.16 ẋ - 1 x
- j - j - K1 -
6 6 s s
− −
KV 1
• Derive the closed-loop transfer function from xr to x in Figure 4.4, and notice that it is a standard
second-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 will
use the MATLAB root locus method for designing KV 1 instead.
- j G - - j G -
6
− 6
−
K K F
SYS = G SYS = GF
The system of Figure 4.4 contains one unknown variable KV 1 , which can be designed using the following
steps (K value is from the calculation in preliminary design):
Comment on the stability of the system based on the designed characteristic equation roots.
• Amplitude = 1.67V
4.16 1
K1
Signal s s
Generator
K1 Transfer Fcn Integrator Scope
set_point.mat
Kv1
To File position.mat
K_v1
To File1
Run the simulation for two cycles (80 seconds). Use MATLAB to plot the input and output on the
same graph.
−K−
Signal Quanser Quanser
Generator 18
K1 MultiQ−PCI DAC MultiQ−PCI ADC
K
Demux Position
Ch0 To UPM Analog Input
Ch2 & Ch3
5
du/dt
s+5
−2*pi/4096 Quanser
MultiQ−PCI ENC Derivative Transfer Fcn
To Rad
Ch0 Motor Position
0.01
Kv
−K−
Kv1
To get good analog result, you would need to level the rail with ground and center the ball before
testing. Check the connection bolt between rail and gears to find good start position and run the Wincon
simulation for two cycles (80 seconds). Use MATLAB to plot the simulated position output and your
experimental results on the same graph.
33
• All Simulink block diagrams and all three graphs requested (Root locus plot, Input/Output response
from 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 from
theoretical calculation and root locus method close? Comment on the stability of the system based
on 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 simulation
results follow PO and Tp specifications? How about your analog testing results? Comment on their
relative accuracy. Discuss at least three sources of error that contribute to your observed discrepancies
between your analog testing and digital simulation results.
5 Lab 5 - Frequency-Domain Identification and
Phase Lead Compensator Design
5.1 Introduction
The goals in this labs are as follows:
2. to design a lead compensator for the DC motor to achieve the following closed-loop specifications:
We obtained the model parameters α and β in Lab 2 using time-domain transient response data. We
will now obtain α and β by measuring the frequency response of the DC motor. As discussed in class, the
motor input (armature voltage v) to the output (shaft angular velocity θ̇) can be approximately modeled
by a first-order system:
Θ̇(s) α
G(s) = = .
V (s) s+β
Directly exciting the system with sinusoids of varying frequencies and observing the steady-state outputs
will 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.
v sin( wt )
G(s)
Control design is readily done in the frequency domain using Bode plots. The general idea of the
lead compensator design is: First choose the gain required in the controller to achieve certain steady-state
performance requirement; then design the lead compensator to increase the phase margin (PM) of the
system; this will increase damping, and hence decrease, e.g., the percent overshoot (PO) in the closed-loop
step response. Some trial and error may be necessary to satisfy the time-domain specs. Design steps are
discussed and illustrated in the lecture notes .
The relevant closed-loop system is shown in Figure 5.3, where
1
P (s) = G(s)
s
is the DC motor’s model and C(s) is the lead compensator to be designed using the mentioned specifications.
35
36 Lab 5
4
A
Magnitude
0
-2
-4
-6
t w t w
-8
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4
Time (t)
θr e v θ
- j - C(s) - P (s) -
6
−
Angular
Quanser Consulting Quanser Consulting Velocity
MultiQ−PCI DAC MultiQ−PCI ADC
Signal Output
Generator
Analog Output Analog Input
Channel 0 Channel 2
Range 10
Input
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
37
different sine waves into the DC servo motor input with Vin = 1 and frequencies ranging from 5 to
100 rad/sec. Measure the steady-state output of the tachometer in each case. Collect all gain and
phase 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 corner
frequency 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.
aτ s + 1
C(s) = K · , K > 0, τ > 0, a > 1. (5.1)
τs + 1
Design a lead compensator to achieve specs (a) and (b) using the following procedure, which is very
similar to Section 6.4 in the notes:
a) Derive the frequency domain function of error signal E(s), using final value theorem to find the
relation 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 in
Figure 5.6, treating the controller as a pure gain obtained from step a, i.e. set a = 1, τ = 0 in
the compensator); record the PO in this case.
c) Multiply the calculated K with P (s); estimate the phase margin of the new uncompensated
system KP (s). The MATLAB functions useful here are margin and bode.
d) Select some desired PM value. Design the compensator parameters α and τ based on ∆φ =
P Mdesired − P Mold and the Bode plot of KP (s) (Read textbook for details).
38 Lab 5
e) Check the new actual PM of C(s)P (s), if desired PM is achieved, record the a and τ and actual
PM 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. The
SIMULINK model and wiring diagram are shown in Figures 5.7 and 5.8, respectively. Use a step
input 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-loop
bandwidth?
Angle
Step a*tau.s+1 alpha
−K−
tau.s+1 s2+beta.s
Manual Switch Phase−lead Gain DC Motor Output
Model
Ramp
digital_step.mat
To File
Figure 5.7: SIMULINK setup for analog test of the lead-compensated closed-loop system
The ball and beam apparatus, with ball mass m and moment of inertia J, is sketched in Figure A.1 with
several parameters shown.
Fg Fn
Fp
From the geometry of the physical system, we make the following approximation
R sin θ ≈ L sin α.
X(s) mgR 1
=¡ J
¢ · 2.
Θ(s) m + r2 L s
41
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) 0.208
= (m/rad).
Θ(s) s2
The beam detects position with a scale of 20 volts per meter. Therefore, it is convenient to express the
transfer function in units of volt./rad as follows:
X(s) 4.16
= 2 (volt./rad).
Θ(s) s