Professional Documents
Culture Documents
Lab Manual
1|Page
3.4.4 State Space Representation using MATLAB .................................................................................................. 34
3.5 LAB EXERCISE ........................................................................................................................................................ 34
3.5.1 Task 1 ............................................................................................................................................................ 34
3.5.2 Task 2 ............................................................................................................................................................ 34
3.5.3 Task 3 ............................................................................................................................................................ 35
3.5.4 Task 4 ............................................................................................................................................................ 36
3.5.5 Task 5 ............................................................................................................................................................ 37
LAB-4 STEP AND IMPULSE RESPONSE OF SYSTEM .................................................................................................38
4.1 OBJECTIVE ............................................................................................................................................................ 39
4.2 EQUIPMENT/APPARATUS......................................................................................................................................... 39
4.3 THEORY BACKGROUND ............................................................................................................................................ 39
4.3.1 Unit impulse Response .................................................................................................................................. 39
4.3.1.1 Impulse response using MATLAB command .......................................................................................................... 39
4.3.1.2 Impulse response using Simulink ........................................................................................................................... 40
4.3.2 Step Response ............................................................................................................................................... 41
4.3.2.1 Step response using MATLAB command ............................................................................................................... 41
4.3.2.2 Step response using Simulink ................................................................................................................................ 41
4.3.3 Lab Task 1 ..................................................................................................................................................... 42
4.3.4 Relationship between unit step and unit impulse function ........................................................................... 44
4.3.5 Relationship between unit step and unit impulse response .......................................................................... 45
4.3.5.1 Lab Task 2 .............................................................................................................................................................. 45
4.3.6 Lab Task 3 ..................................................................................................................................................... 46
LAB-5 PERFORMANCE SPECIFICATIONS OF FIRST ORDER SYSTEM .........................................................................48
5.1 OBJECTIVE ............................................................................................................................................................ 49
5.2 EQUIPMENT/APPARATUS......................................................................................................................................... 49
5.3 THEORY OF FIRST ORDER SYSTEM .............................................................................................................................. 49
5.3.1 Time Constant ............................................................................................................................................... 49
5.3.2 System speed (exponential frequency).......................................................................................................... 49
5.3.3 Rise time ........................................................................................................................................................ 50
5.3.4 Settling time .................................................................................................................................................. 50
5.3.5 Lab Task 1 ..................................................................................................................................................... 50
5.3.6 Lab Task 2 ..................................................................................................................................................... 51
5.3.7 Lab Task 3 ..................................................................................................................................................... 53
5.3.8 Lab Task 4 ..................................................................................................................................................... 55
5.3.9 Lab Task 5 ..................................................................................................................................................... 55
LAB-6 PERFORMANCE SPECIFICATIONS OF SECOND ORDER SYSTEM ....................................................................57
6.1 OBJECTIVE ............................................................................................................................................................ 58
6.2 THEORY OF SECOND ORDER SYSTEM .......................................................................................................................... 58
6.2.1 Natural Frequency ( ) .............................................................................................................................. 59
6.2.2 Damping Ratio ( ) ........................................................................................................................................ 59
6.2.3 Task 1: Finding effect on system due to poles location ................................................................................. 59
6.2.4 Task 2: Spring mass system with damper ..................................................................................................... 61
6.3 FEEDBACK SYSTEM AND STABILITY.............................................................................................................................. 64
6.3.1 Negative Feed back ....................................................................................................................................... 64
6.3.2 Positive feed back ......................................................................................................................................... 64
6.3.3 Unity Feedback System ................................................................................................................................. 65
6.3.4 Lab Task 3 ..................................................................................................................................................... 65
LAB-7 STEADY STATE ERROR ANALYSIS OF SYSTEM ..............................................................................................68
7.1 OBJECTIVE ............................................................................................................................................................ 69
2|Page
7.2 TASKS 1 STEP RESPONSE AND STEADY STATE ERROR....................................................................................................... 69
7.3 TASK 2 EFFECT OF CONTROLLER ................................................................................................................................ 70
7.4 TASK 3 EFFECT OF DISTURBANCE AND UNITY FEEDBACK ................................................................................................. 71
7.5 TASK 4 UNITY FEEDBACK ......................................................................................................................................... 72
7.6 TASK 5 STEADY STATE ERROR CALCULATIONS............................................................................................................... 73
7.7 TASK 6 STEADY STATE ERROR USING MATLAB ........................................................................................................... 74
LAB-8 EFFECT OF CONTROLLERS ON SYSTEM PARAMETERS ..................................................................................77
8.1 OBJECTIVE ............................................................................................................................................................ 78
8.2 CONTROLLERS TYPES ............................................................................................................................................... 78
8.2.1 OnOff Control ............................................................................................................................................... 78
8.2.2 Proportional Control ..................................................................................................................................... 78
8.2.3 Proportional + Derivative Control ................................................................................................................. 79
8.2.4 Proportional + Integral + Derivative Control ................................................................................................. 79
8.2.5 Proportional + Integral Control ..................................................................................................................... 80
8.3 PID CONTROLLER USING MATLAB ........................................................................................................................... 80
8.4 LAB EXERCISE ........................................................................................................................................................ 80
8.4.1 Task 1 Open loop step response and performance parameters.................................................................... 81
8.4.2 Task 2 Effect of Proportional Controller ........................................................................................................ 81
8.4.3 Task 3 Effect of ProportionalDerivativeController ...................................................................................... 82
8.4.4 Task 4 Effect of ProportionalIntegral Controller .......................................................................................... 83
8.4.5 Task 5 Effect of ProportionalIntegralDerivative Controller......................................................................... 84
LAB-9 ACTIVE REALIZATION OF PI CONTROLLER (TWO WEEKS) .............................................................................85
9.1 OBJECTIVE ............................................................................................................................................................ 86
9.2 COMPONENTS REQUIRED......................................................................................................................................... 86
9.3 OPAMP BASIC CIRCUIT REVIEW ............................................................................................................................... 86
TASK 1 .............................................................................................................................................................................. 87
9.4 TASK 2 ................................................................................................................................................................. 87
9.5 HARDWARE REALIZATION OF PI CONTROLLER ............................................................................................................... 88
9.5.1 Task 4 ............................................................................................................................................................ 88
9.5.2 Arduino setup (as server) .............................................................................................................................. 89
9.5.3 MATLAB Package Installation ....................................................................................................................... 89
9.5.4 Hardware software setup ............................................................................................................................. 89
9.5.5 Task 3 ............................................................................................................................................................ 90
LAB-10 LEVITATING A BALL IN AIR USING PID CONTROLLER (TWO WEEKS) ............................................................91
10.1 OBJECTIVE ............................................................................................................................................................ 92
10.2 COMPONENTS REQUIRED......................................................................................................................................... 92
10.3 BLOCK DIAGRAM.................................................................................................................................................... 92
10.4 SETUP DIAGRAM .................................................................................................................................................... 92
LAB-11 ANTI-WINDUP CONTROL AND DESIGNING VIA ROOT LOCUS ......................................................................93
11.1 OBJECTIVE ............................................................................................................................................................ 94
11.2 ANTIWINDUP CONTROLLER...................................................................................................................................... 94
11.2.1 Performance without Using AntiWindup................................................................................................. 94
11.2.2 Configuring the Block for AntiWindup Based on BackCalculation ......................................................... 96
11.2.3 Configuring the Block for AntiWindup Based on Integrator Clamping .................................................... 97
11.3 DESIGNING VIA MATLAB ROOT LOCUS ...................................................................................................................... 98
11.3.1 How to sketch root locus .......................................................................................................................... 98
11.3.2 Problem: ................................................................................................................................................... 98
11.3.3 Part 1 ........................................................................................................................................................ 98
11.3.4 Part 2 ........................................................................................................................................................ 99
3|Page
11.3.5 Part 3 ...................................................................................................................................................... 100
11.3.6 Part 4 ...................................................................................................................................................... 100
LAB-12 IDENTIFY BLACK-BOX MODELS USING SYSTEM IDENTIFICATION APP (ACTIVITY) ......................................101
12.1 OBJECTIVES ......................................................................................................................................................... 102
12.2 DATA DESCRIPTION .............................................................................................................................................. 102
12.3 WHAT ARE NONLINEAR BLACKBOX MODELS? .......................................................................................................... 102
12.3.1 Types of Nonlinear BlackBox Models..................................................................................................... 102
12.4 PREPARING DATA ................................................................................................................................................. 102
12.4.1 Loading Data into the MATLAB Workspace............................................................................................ 102
12.4.2 Creating iddata Objects .......................................................................................................................... 103
12.5 STARTING THE SYSTEM IDENTIFICATION APP .............................................................................................................. 103
12.5.1 Importing Data Objects into the System Identification App ................................................................... 104
12.6 ESTIMATING NONLINEAR ARX MODELS ................................................................................................................... 105
12.6.1 Estimating a Nonlinear ARX Model with Default Settings ...................................................................... 105
12.7 ESTIMATING TRANSFER FUNCTION ........................................................................................................................... 107
4|Page
List of Figures
Figure 11 RL series circuit ................................................................................................................................. 13
Figure 12 MATLAB plot for solution of diff equation ....................................................................................... 14
Figure 13 Invoking Simulink ............................................................................................................................. 14
Figure 14 Simulink model ................................................................................................................................. 14
Figure 15 Simulink plot ..................................................................................................................................... 15
Figure 16 RLC Series Circuit .............................................................................................................................. 15
Figure 17 SpringMass System ......................................................................................................................... 18
Figure 21RLC series circuit................................................................................................................................ 27
Figure 22 SpringMass System ......................................................................................................................... 29
Figure 31 poles zero map ................................................................................................................................. 32
Figure 32 Mechanical System........................................................................................................................... 33
Figure 33 Circuit diagram for task 2 ................................................................................................................. 34
Figure 34 Circuit diagram for task 3 ................................................................................................................. 35
Figure 35 System for task 4 .............................................................................................................................. 36
Figure 41 RL Circuit for example 1 ................................................................................................................... 39
Figure 42 Impulse response of circuit .............................................................................................................. 40
Figure 43 Simulink model for above example .................................................................................................. 40
Figure 44 Simulink impulse response ............................................................................................................... 40
Figure 45 Impulse response of circuit .............................................................................................................. 41
Figure 46 Simulink model for step response. ................................................................................................... 42
Figure 47 Simulink Step Response ................................................................................................................... 42
Figure 48 RLC circuit for lab task 1 ................................................................................................................... 42
Figure 49 Simulink result and current wave form on oscilloscope .................................................................. 42
Figure 410 step and impulse function .............................................................................................................. 45
Figure 411 System for task 4 ............................................................................................................................ 46
Figure 51 First order system pole plot ............................................................................................................. 49
Figure 52 Performance specifications for fist order system ............................................................................ 50
Figure 53 Step Response for task 1 .................................................................................................................. 50
Figure 54 Circuit Diagram. ................................................................................................................................ 53
Figure 61 Parameters of second order response ............................................................................................. 58
Figure 62 Spring mass system with damper..................................................................................................... 61
Figure 63 (a) pzmap of the systems (b) Step response for all systems ......................................... 62
Figure 64 (a) pzmap of all three systems (b) Step response for all system .................................. 63
Figure 65 System with Feedback Combination ................................................................................................ 64
Figure 66 System with Feedback Combination ................................................................................................ 64
Figure 67 System with Unity Negative Feedback ............................................................................................. 65
Figure 68 System with Unity Positive Feedback............................................................................................... 65
Figure 69 (a) Step response of open loop transfer function (b) Step response of close loop transfer
function with unity feedback............................................................................................................................. 66
Figure 71 Car cruise model ............................................................................................................................... 69
Figure 72Model for task 1 ................................................................................................................................ 69
Figure 73 Velocity response under step input ................................................................................................. 70
Figure 74Model for observing difference b/w input and output ..................................................................... 70
Figure 75 Effect of Controller ........................................................................................................................... 70
Figure 76 Model for velocity response for different disturbance .................................................................... 71
5|Page
Figure 77 Model for open loop and closed loop feedback .............................................................................. 72
Figure 78 Unity feedback system ..................................................................................................................... 73
Figure 79 Response due to input 5 , and K =1 .............................................................................................. 74
Figure 710 Response due to input 5t u(t), and K = 1 ........................................................................................ 74
Figure 711 Response due to input 5 ut2(t), and K = 1 ...................................................................................... 74
Figure 712 Response due to input 5 , and K =1 ............................................................................................ 75
Figure 713 Response due to input 5t u(t), and K = 1 ........................................................................................ 75
Figure 714 Response due to input 5 ut2(t), and K = 1 ...................................................................................... 75
Figure 715 Response due to input 5 , and K =1 ............................................................................................ 76
Figure 716 Response due to input 5t u(t), and K = 1 ........................................................................................ 76
Figure 717 Response due to input 5 ut2(t), and K = 1 ...................................................................................... 76
Figure 81 OnOff control .................................................................................................................................. 78
Figure 82 Proportional (P) control.................................................................................................................... 79
Figure 83 Proportional + derivative (PD) control ............................................................................................. 79
Figure 84 Proportional + integral + derivative (PID) control ............................................................................ 80
Figure 91 Opamp basic configuration review ................................................................................................. 86
Figure 92 System and its block diagram ........................................................................................................... 87
Figure 93 Block diagram of plant with PI controller ......................................................................................... 87
Figure 94 Circuit diagram of plant with PI controller ....................................................................................... 88
Figure 111 Simulink model of PID control of a plant with input saturation .................................................... 94
Figure 112 Enabling the backcalculation antiwindup method ...................................................................... 96
Figure 113 Undermask view of the PID Controller block with backcalculation............................................. 96
Figure 114 Aircraft ............................................................................................................................................ 98
Figure 115 Pitch Rate Control System .............................................................................................................. 98
Figure 121 Two Tank System.......................................................................................................................... 102
6|Page
List of Tables
Table 11 Solver options in Simulink ................................................................................................................. 12
Table 12 Comparison between Simulink and experimental result .................................................................. 17
Table 41 Impulse Response using MATLAB ...................................................................................................... 39
Table 42 Step Response using MATLAB ........................................................................................................... 41
Table 51 Nominal and Measured Value of Capacitors ..................................................................................... 53
Table 52 Observations...................................................................................................................................... 53
Table 61 Observations...................................................................................................................................... 60
Table 62 observation table for springmass system ........................................................................................ 62
Table 63 observation table for springmass system ........................................................................................ 63
Table 71 Calculated and observed errors for task 5 and task 6 ....................................................................... 73
Table 91 Nominal and calculated value ........................................................................................................... 89
Table 92 PI gain using nominal and measured values ..................................................................................... 89
7|Page
Student learning outcomes
Control Systems lab has been designed to enhance students ability of system modeling
and system designing. In this lab students will get insight of control systems. Student will learn
desired response generation of a system and how to change system response according to
need. It will be a motivational lab along with learning and hands on Experience. Overview of
each lab session is given below.
1. In first lab student will learn how to model a system using Simulink, to give practical
view, Simulink result will be verified with obtained result in hardware
implementation. (Hardware + Software)
2. Second lab will be conducted on numerical solution of ODE using MATLAB. System
will be considered to understand the solution. (Software)
3. Third lab deals with transfer function and state space representation of systems.
(Software)
4. Step and impulse response of system is covered in lab 4. (Hardware + Software)
5. First order system specifications will be analyzed using MATLAB and practical
setup. (Hardware + Software)
6. Second order system specifications will be analyzed using MATLAB. (Software)
7. Effect of system type, controller gain and type of input on system error. (Software)
8. Different controllers are used and effect of each controller will be demonstrated
(Software)
9. Design and Implementation PI controller using op-amp will be done according to
desired performance parameters for an RC circuit. (Hardware)
10. A ball will be levitated in air according to desired height by user, PID controller for
motor will be used to control air pressure on ball to achieve desired goal.
(Hardware)
11. Root locus for system designing and Anti-windup control will be learnt in this lab.
(Software)
12. How to Identity transfer function of a black box system. (Software)
8|Page
Grading Criteria
Total Credit hours 01
Total Labs 15
Each Lab has equal weightage and each lab Marks will contain marks according to
nature of the lab. Relevant grading policy will be adopted. A letter grade will be
awarded to each student based on his/her overall relevant performance in a lab.
9|Page
Supporting Staff
Course Instructor
Mr. Usama Bin Sikandar usama.sikandar@itu.edu.pk
Lab Instructors
1. Mr.Yasir Manzoor yasir.manzoor@itu.edu.pk
2. Mr.Zafarullah zafarullah@itu.edu.pk
Teaching Assistant
1. Mr. Muhammad Awais
2. Mrs. Amna Maqbool amna.maqbool@itu.edu.pk
Lab Technician
1. Mr.Muhammad Faisal muhammad.faisal@itu.edu.pk
2. Mr. Faisal Azmi faisal.azmi@itu.edu.pk
Lab Attendant
1. Mr.Awais Zaheer awais.zaheer@itu.edu.pk
Software resources
MATLAB,
Multisim
10 | P a g e
Department of Electrical Engineering
Control Systems
11 | P a g e
1.1 Objective
In this lab student will learn how to model a system using Simulink.
Simulink solves Ordinary Differential Equations (ODE) numerically. The whole idea is to break the
ODE into small time segments and to calculate the solution numerically for only a small segment. The length
of each segment is called step size. Since the method is numerical and not analytical there will be an error
in the solution. The error depends on the specific method and on the step size (usually denoted by h).
There are various formulas that can solve these equations numerically. Hence higher the order of
method, smaller the error is. Unfortunately the high order methods are very slow. To overcome this problem
variable step size solvers are used. When the systems states change very slowly then the step size can
increase and hence the simulation is faster. On the other hand if the states change rapidly then the step size
must be sufficiently small.
12 | P a g e
1.4 System modeling example
Given electric network shown in Figure 11.
a. Write differential equation for the nework. If source is unit step function.
b. Plot solution of differential equation for i(t) if R/L = 1.
c. Use simulink to model the differential equaiton and plot current if R/L = 1.
+ = ( )
If we solve above differential equation with zero initial conditions, we will get following equation
1
( )= (1 )
>> t=linspace(0,10,500);
>> plot(t,(1-exp(-t)))
>> grid on
13 | P a g e
Figure 12 MATLAB plot for solution of diff equation
14 | P a g e
5. Run Simulink model and double click on scope. Normally ODE (45) solver is used in
Simulink; Solver configuration can be changed in Model Configuration Parameter.
6. You can compare Figure 15 and Figure 12, both are exactly same.
1.5 Exercise # 1
Consider a series RLC circuit show in figure.
1.5.1 Task 1
1. Use digital multimeter to measure value of each component.
Measured value of C1______ ____________
2. Write differential Equation for the network if, ( ) = 10 ( ), a unit step. (Hint: use KVL)
________________________________________________________________________________
15 | P a g e
1.5.2 Task 2
Model the differential equation using Simulink. Paste snap shot of model here. Use measured values for
accurate results.
1.5.3 Task 3
Run Simulink model and take snap shot of current wave form obtained.
1.5.4 Task 4
1. Connect the circuit shown in figure 16 on bread board.
2. Set function generator
a. Frequency 1.5 KHz
b. Amplitude 10 V pp
c. Offset 5V
d. Mode High Impedance (HighZ), using shift + output
3. Set oscilloscope
a. Xaxis 50us
b. Yaxis 10mV
c. Coupling AC
16 | P a g e
[Hint: Use Run/Stop button to make waveform still]
1.5.5 Task 5
1. Remove resistances R1 and R2 from your circuit on bread board, connect function generator
across series combination of L1 and C1. Connect oscilloscope across inductor and paste
wave form here. (Other configuration remains same as stated in task 4).
17 | P a g e
2. What is the effect of removing resistance from the circuit?
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
3. Calculate frequency of oscillation (called resonant frequency or undamped natural
frequency) from the oscilloscope?
___________________________________________________________________________
___________________________________________________________________________
4. Formula for undamped natural frequency for a series RLC circuit is = ( / ),
compare result obtained in above question (3) with answer from equation and comment on
result. [Keeping in view rad/sec vs Hertz]
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
1.6 Exercise # 2
1. A springmass system is shown in Figure 17.
18 | P a g e
1.6.1 Task 5
Model above equation in Simulink, use ( ) as unit step function, B =1, K=1 and m=2, Paste model here.
1.6.2 Task 6
Plot wave form of ( ).
1.6.3 Task 7
1. Remove source (unit step) from above model. Put | = 0, and | =0 = 0, in integrator
blocks. Plot wave form of ( ).
19 | P a g e
2. Put | = 1, and | =0 = 0 in integrator blocks. Plot wave form of ( ).
20 | P a g e
4. Put | = 1, and | =0 = 1 in integrator blocks. Plot wave form of ( ).
21 | P a g e
Department of Electrical Engineering
Control Systems
2.1 Objective
In this lab student will learn Numerical Solution of ODEs using MATLAB.
22 | P a g e
2.2 Euler Method to Solve First Order ODE
In order to use Euler's Method to generate a numerical solution to an initial value problem of the
form:
= ( , ), ( )=
We decide upon what interval and initial conditions, we desire to find the solution. We chop this interval
into small subdivisions of length h. Then, using the initial condition as our starting point, we generate the
rest of the solution by using the iterative formulas:
= +
= + ( , )
2. Create m file for function ( , ) and save it with any name say ode1st.m.
3. For example,
a. to numerically solve
function dydt=ode1st(t,y)
dydt=(1/t^2)*(y+3*t);
end
2.3.2 Second function file
1. Create second function file with name euler_func.m for solution of above function using
Eulers method. In this program first function will be invoked.
2. You can use or update following MATLAB function.
function euler=euler_func(step_size,time_length,t_ini,y_ini)
h=step_size;
T=time_length;
23 | P a g e
n=T/h;
t(1)=t_ini;
y(1)=y_ini;
for i=1:1:n
y(i+1)=y(i)+h*ode1st(t(i),y(i))
t(i+1)=t(i)+h;
end
plot(t,y,'r')
xlabel('time')
ylabel('fucn value')
hold on
grid on
2.3.3 Executing Eulers Function
To solve example stated in 2.3.1, write following command in command window:
euler_func(0.1,4,1,-2)
Here, Initial value of t and y are 1 and 2 respectively, and final value of x is 4. Where, we have taken step
size of 0.1. You can choose any step size you want.
The rate of loss of heat/temperature change in in a body is directly proportional to the temperature
difference between body and surroundings, provided the difference is small
= ( )
= 0.1(23 ),
1. Solve above differential equation for following step sizes and Plot Temperature of processor
vs time for time period 0 t 50, if (0) = 60,
a. Step size h = 10;
b. Step size h = 5;
c. Step size h = 1;
d. Step size h = 0.1;
2. Create first function file and name it Lab2_1f_16_15.m. Replace 16 and 15 with your group
members roll no.(file and function name should be same) Points 5
24 | P a g e
Do not delete TEXT BOX
Replace Only TEXT with your MATLAB function code.
5. Title of plot should be your roll no Lab2_1_16_15. replace 16,15 with your group members
roll no) Points 5
6. Use same figure to plot all four graph. Points 10
25 | P a g e
1. Initial values of t and y are 1 and 2 respectively, and domain is 1 to 4.
2. At MATLAB command window type:
[t,y]=ode45(@ode1st,[1,4],-2);% ode1st is function created in sec 2.3.1
3. To print results type : [t,y]
4. To plot results type : plot(t,y)
Other commands:
hold on %% to plot another graph on previous graph
plot(t,y,r) %% color red, blue, green, use r,b,g
2.5.1.2 Lab Task 2
1. Solve lab task 1 using ODE45 method and plot graph between temperature of processor and
time. Points 10
2. Use proper legends. Points 5
3. Title of plot should be your roll no Lab2_2_ODE45_16_15. replace 16,15 with your group
members roll no) Points 5
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
26 | P a g e
2.5.2 Second Order Equations
1. Suppose we have second order differential equation in the form
2. First convert 2nd order equation to an equivalent system of 1st order equations.
3. Create and save a .m file which will return a vectorvalued function. This is a little tricky so
here is a specific example. Suppose the system is as below for 0 t 4,
27 | P a g e
1. Write second order differential equation associated with it. (Use KVL and then take its
derivative). Consider (0) = 7 (0) = 28 Points 5
_________________________________________________________________________
2. Convert second order system to equivalent first order system and write equations
below. Points 5
_________________________________________________________________________
4. To solve above system using ODE45 for 0 < t < 10. Write MATLAB command here.
Points 5
Do not delete TEXT BOX
Replace Only TEXT with your MATLAB function code.
_______________________________________________________________
28 | P a g e
2.5.4 Lab Task 3
1. A springmass system is shown in Figure 21.
2. Where B is friction constant, K is spring constant, F is force applied and y is distance traveled
by body of mass m from its mean point.
3. Differential equation that can explain motion of mass is given below
( ) 1 ( )
= ( ) , (0) = 0 (0) = 0
4. If B =1, K=1, m=2 and F(t) = 1, Solve differential equation using ODE 45 method as stated
above, for following conditions. Plot y, t for time 0 t 20
a. (0) = 0 (0) = 0 Points 10
29 | P a g e
Department of Electrical Engineering
Control Systems
30 | P a g e
3.1 Objective
To obtain a transfer function from given RLC circuit and plot its poles and zeroes using MATLAB.
3.2 Equipment/Apparatus
1. Software: MATLAB
3.3 Conduct of Lab
1. Students are required to perform this experiment using the equipment provided.
2. Students are required to work in groups specified by lab engineers.
3. Students are advised to seek help from the course instructor, lab engineers, assigned teaching
assistants (TA) and lab attendants.
3.4 Theory of Transfer Function and State Space
A transfer function is also known as the network function is a mathematical representation, in terms
of spatial or temporal frequency, of the relation between the input and output of a (linear time invariant)
system. The transfer function is the ratio of the output Laplace Transform to the input Laplace Transform
assuming zero initial conditions. Many important characteristics of dynamic or control systems can be
determined from the transfer function.
The transfer function is commonly used in the analysis of singleinput singleoutput electronic system, for
instance. It is mainly used in signal processing, communication theory, and control theory. The term is often
used exclusively to refer to linear timeinvariant systems (LTI). In its simplest form for continuous time input
signal x(t) and output y(t), the transfer function is the linear mapping of the Laplace transform of the input,
X(s), to the output Y(s).
Zeroes are the value(s) where the numerator of the transfer function equals zero (The complex frequencies
that make the overall gain of the filter transfer function zero). Poles are the value(s) where the denominator
of the transfer function equals zero (The complex frequencies that make the overall gain of the filter transfer
function infinite).
The transfer function provides a basis for determining important system response characteristics without
solving the complete differential equation. As defined, the transfer function is a rational function in the
complex variable = + j that is
+ + ++
( )=
+ + + +
It is often convenient to factor the polynomials in the numerator and the denominator, and to write the
transfer function in terms of those factors:
( ) ( )( )( )( )( )
( )= =
( ) ( )( )( )( )( )
As written in the above equation,
The zs are the roots of the equation N(s) = 0 and are defined to be the system zeroes and The ps are the
roots of the equation D(s)=0 and are defined to be the system zeroes.
31 | P a g e
3.4.1 Example of Creating Transfer Function Models in MATLAB:
You can create transfer function (TF) models by specifying numerator and denominator coefficients. For
example,
MATLAB Commands:
s
-------------
s^2 + 2 s + 1
We can plot the poles and zeroes of an LTI system using pzmap command.
pzmap(sys)
[p,z] = pzmap(sys)
pzmap(sys) plots the polezero map of the continuous or discretetime LTI model sys.
[p,z] = pzmap(sys) returns the system poles and zeroes in the column vectors p and z.
No plot is drawn on the screen.
3.4.2 Example of PoleZero Map in MATLAB
Plot the poles and zeroes of the continuoustime system.
2 +5 +1
( )=
+2 +3
>> H = tf([2 5 1],[1 2 3]);
>> pzmap(H);
32 | P a g e
3.4.3 Statespace
Consider the mechanical system shown in Figure 32. We assume that the system is linear. The
external force u(t) is the input to the system, and the displacement y(t) of the mass is the output. The
displacement y(t) is measured from the equilibrium position in the absence of the external force. This system
is a singleinput, singleoutput system. From the diagram, the system equation is
+ + =
+ 0.9 + =
Its Transfer Function is given as
( + 0.9 + 1) ( ) = 1 ( )
( ) 1
=
( ) ( + 0.9 + 1)
This system is of second order. This means that the system involves two integrators. Let us define state
variables x1(t) and x2(t) as
( )= ( ) ( ) = ( )
Then we obtain
= = = 0.9 +
The output of the Equation is
=
State Space is given as
= +
= +
0.9 1 1
= +
1 0 0
= [0 1] + [0]
33 | P a g e
3.4.4 State Space Representation using MATLAB
The MATLAB code is given as below. Compare the theoretical results with MATLAB results
num=[1] %numerator
den=[1 0.9 1] %denominator
transf=tf(num, den) %transfer Function
[A,B,C,D]=tf2ss(num, den) % transfer function to State Space
3.5 Lab Exercise
3.5.1 Task 1
Consider the transfer function
6 +1
( )=
+3 +3 +7
a. Write the poles and zero values Points 6
Poles: __________, _____________, ___________
Zeros: __________, _____________, ___________
b. Plot pole zero map of the system Points 4
3.5.2 Task 2
Consider the following circuit
( )=
34 | P a g e
b. Write the poles and zero values Points 3
Poles: _______________________
Zeros: _______________________
c. Plot pole zero map of the system Points 4
3.5.3 Task 3
Consider the following circuit
( )=
35 | P a g e
Do not delete this text box
Use snipping tool to copy your MATLAB figure Replace Only
TEXT with your MATLAB plot, legends and title of plot
should be visible
3.5.4 Task 4
Consider a DC Motor, shown in figure below, we can derive the following governing equations based on
Newton's 2nd law and Kirchhoff's voltage law.
+ =
+ + =
Considered the output is rotational speed and armature voltage as input. With parameters as follows
J = 0.01; b = 0.1; K = 0.01; R = 1; L = 0.5;
= , =
( )
( )= =
( )
b. Write the poles and zero values Points 4
36 | P a g e
Poles: _____________, _____________
Zeros: _____________, _____________
3.5.5 Task 5
Consider the following differential equation of a system. Consider ( ) is input and ( ) is output
+ 14 + 56 + 160 = ( )
( )=
b. Find the state space model of the system (Theoretical and MATLAB) Points 8
= +
=[ ] + [0]
37 | P a g e
Department of Electrical Engineering
Control Systems
38 | P a g e
4.1 Objective
In this lab, we will use MATLAB and Simulink library to find the output of the systems with subjected
to different type of inputs and to know how system act under different types of inputs.
4.2 Equipment/Apparatus
1. Software: MATLAB
4.3 Theory Background
Simulation means studying the system behavior without actually constructing the system. We will
start by understanding some of the useful commands for system simulation and then we will apply these
commands on our developed systems.
Example 1:
2. We are interested in finding out voltage , Then transfer function for above circuit is:
( )=
+ +1
39 | P a g e
3. Following commands will execute impulse response of above system for time 0 to 15
second with step size 0.01.
LTI_sys = tf([1 0 0] ,[1 1 1])
t=0 : 0.01 : 15;
impulse(LTI_sys,t,'r');
grid on
4. Impulse response for above circuit is shown in figure 42.
40 | P a g e
4.3.2 Step Response
From a practical standpoint, knowing how the system will respond to a sudden input is important
because large and possibly fast deviations from the long term steady state may have extreme effects on the
component itself and on other portions of the overall system dependent on this component. Normally,
knowing the step response of a dynamical system gives information on the stability of such a system, and on
its ability to reach one stationary state when starting from another.
For RLC circuit in example 1, following commands will execute step response of above system for time 0 to
15 second with step size 0.01.
LTI_sys = tf([1 0 0] ,[1 1 1])
t=0 : 0.01 : 15;
step(LTI_sys,t,'r');
grid on
Step response for above circuit is shown in figure 45.
41 | P a g e
For above example Simulink model is
Current wave forms obtained on Simulink and oscilloscope are shown below.
42 | P a g e
1. Write transfer function for current of circuit shown in figure 48. 2 Points
( )
=
( )
2. What should be minimum simulation time required to observe transient and steady
state response of circuit. _____________(Hint: Observe from figure 49) 1 Point
3. Use Simulink to plot impulse response of circuit. Title of plot should be Task1.3Rollno1
Rollno2. Label the axis as well. 6 Points
(Hint) Right click on scope plot and print display to figure, where you can edit title etc.
4. What happens to current when we suddenly apply a voltage of 1 volt at t = 0. Plot circuit
current vs time for above circuit. Title of plot should be Task1.4Rollno1Rollno2. Label
the axis as well. Points 6
43 | P a g e
5. Signal generator can be found in Simulink >> sources >> signal generator.
6. Use signal generator to attain following response of circuit shown in figure 48.
Amplitude: ____________________
Frequency: ____________________
Unit: ____________________
b. Simulator setting
Simulation Time: ___________________
Solver: ___________________
4.3.4 Relationship between unit step and unit impulse function
The unit step function, also known as the Heaviside function, is defined as such:
0, 0
( )=
1, >0
Whereas, an ideal impulse function is a function that is zero everywhere but at the origin, where it is
infinitely high.
0, 0
( )=
1, ( ) =0
The unit step function is level in all places except for a discontinuity at t = 0. For this reason, the derivative of
the unit step function is 0 at all points t, except where t = 0. Where t = 0, the derivative of the unit step
function is infinite. The derivative of a unit step function is called an impulse function. Since we can't show
the height of the impulse on our graph, we use the vertical axis to show the area. The unit impulse has
area=1.
44 | P a g e
Figure 410 step and impulse function
45 | P a g e
3. From figure prove that impulse response is derivative of step response. 4 Points
+ + =
Considered the output is rotational speed and armature voltage as input. With parameters as follows
J = 0.01; b = 0.1; K = 0.01; R = 1; L = 0.5;
= =
( )
( )= =
( )
46 | P a g e
2. Use Simulink to plot impulse response of motor. Title of plot should be Task3.2
Rollno1Rollno2. Label the axis as well. 6 Points
(Hint) Right click on scope plot and print display to figure, where you can edit title etc.
47 | P a g e
Department of Electrical Engineering
Control Systems
48 | P a g e
5.1 Objective
In this lab, student will learn performance parameters of first order and second order systems.
MATLAB will be used for analysis and modeling.
5.2 Equipment/Apparatus
1. Software: MATLAB
5.3 Theory of First Order System
Consider a first order system without zero (or zero at infinity), that has transfer function given below
( )=
+
Response of system can be calculated using ( )= ( ) ( )
Let ( )= ( )
If step input is applied to above system then, we can write response of system
( )=
( )= ( )+ ( )=1
Where, input pole due to step function generated forced response ( ) = 1 and pole due to transfer
function at generated natural response ( )= . The value of " " is only parameter that
describes transient response of first order system.
( ) =1
We can say pole is located reciprocal of time constant; farther is the pole from imaginary axis faster is
transient response.
49 | P a g e
5.3.3 Rise time
Rise time is defined as the time for the wave form to go from 0.1 to 0.9 of its final value.
If form of transfer function is , then calculate performance specifications for the system shown in figure.
50 | P a g e
5.3.6 Lab Task 2
a) A system has transfer function +
, let a = 50, Use MATLAB to Find the time constant ,
Settling time and Rise time from its step response curve.
i. Time constant ( ) _______________ 1 Point
ii. Rise time ( ) _______________ 1 Point
iii. Settling time( ) _______________ 1 Point
b) For system considered above, use MATLAB to plot step response of system on same figure
considering a = 50, a = 100, a= 200. 9 Points
51 | P a g e
e) Based on above observation, if system pole becomes very close to origin will be effect on
system response? 5 Points
f) Plot impulse response of system for a = 1, and a = +1, Transfer function is given below.
6 Points
g) Comment about stability of both systems. 4 Points
52 | P a g e
5.3.7 Lab Task 3
1. You have provided a capacitor and a resistor. Measure value of capacitor and
resistors using digital multimeter and record in table51. 2 Points
2. We know that charge time for capacitor is five time constant and discharge time is
approximately (because of source resistance) five time constant, so to show total
charging and discharging, our applied wave should have time period > 10 time
constant. Calculate frequency required to apply and record in table 52. 3 Points
Table 52 Observations
53 | P a g e
10. Find following parameters using oscilloscope. 3 Points
i. Time constant ( ) _______________
ii. Rise time ( ) _______________
iii. Settling time ( ) _______________
11. Write transfer function for above circuit? 3 Points
( )= =
+
15. Compare calculate values of rise and settling time with values obtained in point g,
and comment on argument that only time constant is = 1 is enough to calculate
all specifications parameters of first order system. 5 Points
54 | P a g e
5.3.8 Lab Task 4
1. How can we get settling time of 22ms for above circuit, if frequency and capacitor is
kept constant? 5 Points
2. Construct RC circuit to get 22mS rise time and observe following values using
oscilloscope.
3. Find following parameters using oscilloscope.
i. Time constant ( ) _______________ 2 Points
ii. Rise time ( ) _______________ 2 Points
iii. Settling time ( ) _______________ 2 Points
4. Draw wave form here. 6 Points
55 | P a g e
1. Find the polynomial for numerator and denominator
3. Comment about the stability by observing the unit impulse and step response
6. Comment about the stability by observing the unit impulse and step response
56 | P a g e
Department of Electrical Engineering
Control Systems
57 | P a g e
6.1 Objective
In this lab, student will learn performance parameters of second order systems. MATLAB will be used for
analysis and modeling.
1. Rise Time( ): Time to reach from 10% of steady state to 90% of steady state value.
1.8
=
3. Settling Time ( ): Time to settle output between (0.98%1.02%) of steady state value.
4
=
4. % age overshoot: % age of final value by which the signal initially rises above the final.
1 2
% . = 100
58 | P a g e
Based on poles locations, we can categorize second order system in four types:
The properties of response of second order system depend on the values of the parameters and . How,
these parameters affects the system, lets have a lab activity.
System 1
9
+9 +9
59 | P a g e
System 2
9
+2 +9
System 3
9
+0 +9
System 4
9
+6 +9
3. Data cursor will show different parameters of system response on pole zero map of the
system. Observe values and write in observation table 61.
System Response Pole 1 Pole 2 Damping Ratio Overshoot
System 1
System 2
System 3
System 4
Table 61 Observations
4. Based on observations, can you describe relation between poles location and %age
overshoot of step response of the system?
60 | P a g e
[Write here]
5. Based on observations, can you describe relation between poles location and damping ratio
of step response of the system?
[Write here]
6. Observe overdamped and critical damped responses of system obtained in point 2, How can
you differentiate between two responses?
[Write here]
7. If you have a system of series RLC circuit where R = 0, what type of step response of current
your will get and explain its reason?
[Write here]
+ + = ( )
Figure 62 Spring mass system with damper
61 | P a g e
( )
( )= =
( ) +( ) +
Note: if you have pole locations you can use following commands to plot pzmap and step response.
>> exp=poly([p1,p2]);
>> sys1=tf([num],[den]);
>> pzmap(sys1,sys2,..)
>> step(sys1,sys2,.)
Figure 63 (a) pzmap of the systems (b) Step response for all systems
62 | P a g e
8. If poles of system moves on straight having angle ( = tan ( )) then damping ratio of
system will:
Remain unchanged __________
Decrease _________
Increase __________
Pole 1 Pole 2 m b k % .
Sys 1 1 + 2i 1 2i
Sys 2 1 + 3i 1 3i
Sys 3 1 + 4i 1 4i
Table 63 observation table for springmass system
Figure 64 (a) pzmap of all three systems (b) Step response for all system
1. If poles of system moves up (only imaginary part changes) then rise time, peak time will:
Remain unchanged __________
Decrease _________
Increase __________
2. Observe table 63 and write your observation.
63 | P a g e
[Write here]
3. [do yourself] If poles of system moves towards left (only real part changes) then what will
happen to natural frequency;
Remain unchanged __________
Decrease _________
Increase __________
G2(s)
G2(s)
MATLAB command feedback is used to resolve transfer functions connected in feedback style.
= ( 1, 2)
64 | P a g e
Note: By default, feedback ( 1, 2) assumes negative feedback and is equivalent to
( 1, 2, 1). For positive feedback +1 has to be written explicitly as third argument.
= ( 1, 1)
Here 1 represents unity negative feedback. To get the unity Positive feedback use 1 instead.
65 | P a g e
Figure 69 (a) Step response of open loop transfer function (b) Step response of close loop transfer function with unity feedback
3. Comment about stability of the system from open loop step response.
[Write here]
6. Find step response of the close loop unity ve feedback system and paste it in figure 69(b).
Adjust figure in designated area.
7. Comment about stability of the close loop unity ve feedback system by observing its step
response.
[Write here]
10. Find step response of the close loop system (+ve feedback) and paste it in figure 610. Adjust
figure in designated area.
66 | P a g e
Paste your figure here
11. Comment about stability of the system from close loop with positive feedback step response.
[Write here]
67 | P a g e
Department of Electrical Engineering
Control Systems
68 | P a g e
7.1 Objective
In this lab, student will learn effect of different parameters of the system on system steady state error.
Following parameters have been covered system type, controller, disturbance, feedback and type of input.
69 | P a g e
Paste plot here
2. Change numerator value of controller and observe difference between input and
output, find value of K to get steady state error zero._____________.
70 | P a g e
3. Use snipping tool and past your velocity response here for proposed value of k.
4. Comment about error between input and output as controller gain increases.
71 | P a g e
4. Our applied set point (input force) is 500 unit, As disturbance Increases car velocity
__________________ set point. (increases from, decreases from, remains at)
5. So, we conclude that if only controller is used, then error will be increase/decrease in
proportion with disturbance.
7.5 Task 4 Unity Feedback
1. Till now we were dealing with open loop system with controller and disturbance, Know
suppose that car velocity is fed back by unity negative feedback system.
2. To observe effect of ve feedback on system response. Create a model in Simulink as
shown below:
72 | P a g e
6. What effect did you noticed after applying ve feedback in the system, regarding steady
state error.
Write your comment here
( + 6)
( )= ( )=1
( + 4)( + 7)( + 9)( + 12)
( )
( )
( )
Table 71 Calculated and observed errors for task 5 and task 6
73 | P a g e
7.7 Task 6 Steady State Error Using MATLAB
1. Using Simulink set up the negative feedback system for type 0 system G0(s). Plot input and
response on same graph to so that steady state error could be observed in the system for
an input of 5 ( ) and K = 1, Repeat for inputs of 5 ( ), and 5 ( ). Observe error from
graph and write in table 71.
74 | P a g e
2. Using Simulink set up the negative feedback system for type 0 system G1(s). Plot input and
response on same graph to observe error in the system for an input of 5 ( ) and K = 1,
Repeat for inputs of 5 ( ), and 5 ( ). Observe error from graph and write in table 71.
75 | P a g e
3. Using Simulink set up the negative feedback system for type 0 system G2(s). Plot input and
response on same graph to observe error in the system for an input of 5 ( ) and K = 1,
Repeat for inputs of 5 ( ), and 5 ( ). Observe error from graph and write in table 71.
76 | P a g e
Department of Electrical Engineering
Control Systems
77 | P a g e
8.1 Objective
In this lab, we will use MATLAB to see effect of different types of controllers on system performance
parameters.
The fluctuations in temperature (Green line) as shown on the graph in Figure 81 are significantly large.
= P (Ts To)
Where P is known as the proportional gain of the controller. As its gain is increased the system responds
faster to changes in set point but becomes progressively underdamped and eventually unstable. Where P is
known as the proportional gain of the controller. As its gain is increased the system responds faster to
changes in set point but becomes progressively underdamped and eventually unstable. The final oven
78 | P a g e
temperature lies below the set point for this system because some difference is required to keep the heater
supplying power.
d
= P (Ts To) + D (Ts To)
dt
This technique is known as PD control. The value of the damping constant, D, can be adjusted to achieve a
critically damped response to changes in the set point temperature, as shown in the figure 83.
Too little damping results in overshoot and ringing, too much causes an unnecessarily slow response.
79 | P a g e
eliminate this while using relatively low gain by adding an integral term to the control function which
becomes
d
W = P (Ts To) + D (Ts To) + I (Ts To) dt
dt
where I, the integral gain parameter is sometimes known as the controller reset level. This form of function
is known as proportional + integral + differential, or PID, control. The effect of the integral term is to change
the heater power until the timeaveraged value of the temperature error is zero. The method works quite
well but complicates the mathematical analysis slightly because the system is now third order.
>>my_tf=tf([num],[den])
>>pid_sys= pid (Kp, Ki, Kd)
>>pid_contrlr=tf (pid_sys) % to get PID controller
>>my_tf_with_pid=feedback ((pid_contrlr*my_tf), 1) % for feedback
>>step (my_tf_with_pid, 7) % for step response
>>grid on
>>stepinfo(my_tf_with_pid) % to show performance parameters
8.4 Lab Exercise
Suppose we have a simple mass, spring, and. damper problem. The transfer function between the
displacement ( ) and the input ( )
1
( )=
+ +
Let, M = 1 kg, b = 2.5 N s/m, k = 20 N/m, F = 1 N
The goal of this problem is to obtain
Fast rise time
Minimum overshoot
No steadystate error
80 | P a g e
8.4.1 Task 1 Open loop step response and performance parameters
1. Plot the OpenLoop Step Response of the system for 7 seconds.
[Copy your figure here]
81 | P a g e
4. Note down the performance Parameters
Parameters Values for Kp = 10 Values for Kp = 100
Rise Time
Settling Time
Overshoot
Peak value
Steady state value
Steady State error
5. What are the observations when Proportional controller is introduced and what
happens when we increase the Kp?
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
82 | P a g e
8.4.4 Task 4 Effect of ProportionalIntegral Controller
8. Introduce an integral controller with unity feedback. Plot step response for Ki=5 and
Ki=20 in same plot, simulate step response for 80 seconds. (Set proportional gain to 100
for both values of Ki)
[Copy your figure here]
_________________________________________________________________________________
_________________________________________________________________________________
10. Can you make difference between effect of proportionalderivative and proportional
_Integral controller?
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
11. If changing is needed in system transient response, which controller is better, PI or PD?
_________________________________________________________________________________
12. If changing is needed in system steady state error, which controller is better, PI or PD?
__________________________________________________________________________________
__________________________________________________________________________________
83 | P a g e
8.4.5 Task 5 Effect of ProportionalIntegralDerivative Controller
13. You have to use PID controller to get following parameters for the system. Choose any
value: Kp must be less than 100, Kd and Ki must be less than 40. Minimum values will be
preferred.
Parameters Values Kp Ki Kd
Settling Time Less than 7.2 sec
Overshoot 0%
Steady state > 0.99
value
Steady State < 0.1 %
error
84 | P a g e
Department of Electrical Engineering
Control Systems
Course Instructor: Mr. Usama Bin Sikandar Dated: 03 & 10 April, 2017
85 | P a g e
9.1 Objective
In this lab, we will design a PI controller to get desired performance parameters for a first order
system.
86 | P a g e
Task 1
1. Consider following first order system, a simple RC circuit shown in figure 91, in which
output across capacitor is matter of interest. We can call it our plant .
2. Control effort is value of voltage (u = ei) after controller ( ), also shown in block diagram.
3. Calculated value of is ____________________
4. Calculated value of is ____________________
87 | P a g e
5. Now, overall system become second order, for this system performance parameters are:
a. Settling time ____________
b. % overshoot (M.P) ____________
c. Peak time ____________
d. Control effort ____________
9.5 Hardware realization of PI controller
Now, you can use following circuit diagram to implement plant with controller,
1. Difference amplifier will be used to add up applied reference input and feedback signal from
output. You can choose Ro = 4.7 K Ohm.
2. To implement PI controller opamp with inverting configuration will be used, we have to use
another inverting amplifier with gain 1 to get original signal.
3. Formula for gain of inverting amplifier:
=
88 | P a g e
Parameter Nominal Value Measured Value
R1
R2
R3
R4
R
C
Table 91 Nominal and calculated value
89 | P a g e
4. The Sample Time for the two Analog read blocks will be 0.01.
5. The Gain blocks are included to convert the 10 bit data into units of Volts (by multiplying
the data by 5/1023).
6. The given Simulink model then plots the commanded reference voltage and recorded
output voltage on a scope and also writes the output data to the MATLAB workspace for
further analysis.
7. Once the potentiometers have been set and the Simulink model has been created, the
model can then be run. During the running of the model, you must give one volt step
reference for the circuit using jumper.
8. Observe performance parameter form scope and write in following table.
90 | P a g e
Department of Electrical Engineering
Control Systems
Course Instructor: Mr. Usama Bin Sikandar Dated: 17 & 24 April, 2017
91 | P a g e
10.1 Objective
In this lab, student will design and implement a PID controller to levitate a ball in air using Arduino and
Matlab.
92 | P a g e
Department of Electrical Engineering
Control Systems
93 | P a g e
11.1 Objective
In this lab, student will understand effect of antiwindup controller using PID and designing via root
locus using MATLAB.
Figure 111 Simulink model of PID control of a plant with input saturation
4. Here
( ) is set point.
( ) is difference between feedback and set point.
( ) is PID controller output.
( ) is input to the plant (saturation block output).
( ) is output of the plant.
5. The controlled plant is a saturated firstorder process with deadtime of 2 second described by
1
( )=
10 + 1
6. The plant has known input saturation limits of [10, 10], which are accounted for in the Saturation block
labeled Plant Actuator.
7. The PID Controller has been tuned with saturation ignored using the PID tuner of Simulink Control
Design.
8. PID Controller block in Simulink has two builtin antiwindup methods backcalculation & clamping.
1. First, we examine the effect of saturation on the closedloop when the saturation model is not
considered by the PID Controller block.
2. Simulate the model.
3. Click on scope attached with PID controller block. This will show you Controller output ( ) and
saturated input ( ). Plot waveform below in left side.
4. Click on scope attached with dead time block. This will show you set point ( ) and output of system
( ). Plot waveform below in right side.
94 | P a g e
Copy wave form of control effort Copy wave form of system output
u(t)here y(t)here
7. Ideally Time delay between set point and system output should be _______________________.
8. There are two problems associated with the system. Analyze above figures and highlight two of the
problems that arise when controlling a system with input saturation:
Problem # 1
Problem # 2
95 | P a g e
Designing the PID controller to account for the effect of saturation will improve its performance by allowing
it to operate in the linear region most of the time and recover quickly from nonlinearity. Antiwindup
circuitry is one way to achieve this.
11.2.2 Configuring the Block for AntiWindup Based on BackCalculation
1. The backcalculation antiwindup method uses a feedback loop to discharge the PID Controller's internal
integrator when the controller hits specified saturation limits and enters nonlinear operation.
2. To enable antiwindup, go to the PID Advanced tab in the block's dialog; select Limit output; and enter
the plant's saturation limits. Then, select back-calculation from the Anti-windup method menu and
specify the backcalculation gain Kb=1.
3. Once backcalculation is enabled, the block has an internal tracking loop that discharges the Integrator
output.
Figure 113 Undermask view of the PID Controller block with backcalculation
96 | P a g e
Copy wave form of system ouput
y(t)here
Copy wave form of control effort
u(t)here
7. Observe the above figures and comment about problems highlighted in 11.2.1.
97 | P a g e
11.3 Designing via MATLAB root locus
11.3.1 How to sketch root locus
11.3.2 Problem:
A highperformance aircraft, shown in Figure 11.4.
It uses the ailerons, rudder, and elevator to steer through a threedimensional flight path. The pitch rate
control system for a fighter aircraft at 10,000 m and Mach 0.9 can be represented by the system in Figure
11.5,
Where
18( + 0.015)( + 0.45)
( )=
( + 1.2 + 12)( + 0.01 + 0.0025)
11.3.3 Part 1
Sketch the root locus when the controller ( ) = , and determine when for the roots with > is
larger than 0.15 (seek a maximum ).
=0
2. Sketch the root locus using MATLAB. Highlight the point where > 0.15 and >2
98 | P a g e
3. Find value of gain K at that point and write here. _______
11.3.4 Part 2
Plot step response of the system with observed K in part 1.
1. Find % age overshoot from step response plotted above and write here._____________________
11.3.5 Part 3
A designer suggests an anticipatory controller with ( ) = + = ( + ). Sketch the root locus
for this system as K varies and determine a K so that the of all the closed-loop roots is > 0.8.
99 | P a g e
=0
2. Sketch the root locus using MATLAB. Highlight the point where > 0.90.
Compare step response found in part 2 and as in part 4, what conclusion can be drawn.
________________________________________________________________________________________
________________________________________________________________________________________
________________________________________________________________________________________
________________________________________________________________________________________
100 | P a g e
Department of Electrical Engineering
Control Systems
101 | P a g e
12.1 Objectives
Estimate and validate nonlinear models from singleinput/singleoutput (SISO) data to find the one
that best represents your system dynamics. After completing this tutorial, you will be able to accomplish the
following tasks using the System Identification app:
1. Import data objects from the MATLAB workspace into the app.
2. Estimate and validate nonlinear models from the data.
3. Plot and analyze the behavior of the nonlinearities.
12.2 Data Description
This tutorial uses the data file twotankdata.mat, which contains SISO timedomain data for a
twotank system, shown in the following figure.
In the twotank system, water pours through a pipe into Tank 1, drains into Tank 2, and leaves the
system through a small hole at the bottom of Tank 2. The measured input u(t) to the system is the voltage
applied to the pump that feeds the water into Tank 1 (in volts). The measured output y(t) is the height of the
water in the lower tank (in meters).
Based on Bernoulli's law, which states that water flowing through a small hole at the bottom of a
tank depends nonlinearly on the level of the water in the tank, you expect the relationship between the
input and the output data to be nonlinear. twotankdata.mat includes 3000 samples with a sample time of
0.2 s.
12.3 What Are Nonlinear BlackBox Models?
12.3.1 Types of Nonlinear BlackBox Models
You can estimate nonlinear discretetime blackbox models for both singleoutput and multipleoutput time
domain data. You can choose from two types of nonlinear, blackbox model structures:
1. Nonlinear ARX models
2. HammersteinWiener models
12.4 Preparing Data
12.4.1 Loading Data into the MATLAB Workspace
Load sample data in twotankdata.mat by typing the following command in the MATLAB Command
Window:
load twotankdata
This command loads the following two variables into the MATLAB Workspace browser:
u is the input data, which is the voltage applied to the pump that feeds the water into Tank 1 (in volts).
y is the output data, which is the water height in Tank 2 (in meters).
12.4.2 Creating iddata Objects
System Identification Toolbox data objects encapsulate both data values and data properties into a
single entity. You can use the System Identification Toolbox commands to conveniently manipulate these
102 | P a g e
data objects as single entities. Use the following commands to create two iddata data objects, ze and zv,
where ze contains data for model estimation and zv contains data for model validation. Ts is the sample
time.
Ts = 0.2; % Sample time is 0.2 sec
z = iddata(y,u,Ts);
% First 1000 samples used for estimation
ze = z(1:1000);
% Remaining samples used for validation
zv = z(1001:3000);
To modify data properties, use dot notation. For example, to assign channel names and units that label plot
axes, type the following syntax in the MATLAB Command Window:
% Set time units to minutes
ze.TimeUnit = 'sec';
% Set names of input channels
ze.InputName = 'Voltage';
% Set units for input variables
ze.InputUnit = 'V';
% Set name of output channel
ze.OutputName = 'Height';
% Set unit of output channel
ze.OutputUnit = 'm';
% Set validation data properties
zv.TimeUnit = 'sec';
zv.InputName = 'Voltage';
zv.InputUnit = 'V';
zv.OutputName = 'Height';
zv.OutputUnit = 'm';
103 | P a g e
1. In the System Identification app, select Import data > Data object.
3. Enter ze in the Object field to import the estimation data. Press Enter.
4. This action enters the object information into the Import Data fields.
5. Click More to view additional information about this data, including channel names and units.
6. Click Import to add the icon named ze to the System Identification app.
7. In the Import Data dialog box, type zv in the Object field to import the validation data.
Press Enter.
8. Click Import to add the icon named zv to the System Identification app.
9. In the Import Data dialog box, click Close.
10. In the System Identification app, drag the validation data zv icon to the Validation
Data rectangle. The estimation data ze icon is already designated in the Working Data rectangle.
104 | P a g e
12.6 Estimating Nonlinear ARX Models
12.6.1 Estimating a Nonlinear ARX Model with Default Settings
In this portion of the tutorial, you estimate a nonlinear ARX model using default model structure and
estimation options.
1. In the System Identification app, select Estimate > Nonlinear models.
105 | P a g e
The Configure tab is already open and the default Model type is Nonlinear ARX.
1. Click Estimate. This action adds the model nlarx1 to the System Identification app, as shown in the
following figure.
The Nonlinear Models dialog box displays a summary of the estimation information in the Estimate tab.
The Fit (%) is the mean square error between the measured data and the simulated output of the model:
100% corresponds to a perfect fit (no error) and 0% to a model that is not capable of explaining any of the
variation of the output and only the mean level.
In the System Identification app, select the Model output check box. This action simulates the model using
the input validation data as input to the model and plots the simulated output on top of the output
validation data.
106 | P a g e
The Best Fits area of the Model Output plot shows that the agreement between the model output and the
validationdata output.
12.7 Estimating Transfer Function
To estimate transfer function
2. You will see following window. For instance set default setting i.e no. of poles 2 and no of zeros 1
and click estimate.
107 | P a g e
3. An additional icon with name tf will be generated in system identification window. As shown in
figure below:
5. You will see transfer function in the window that will satisfy the system.
108 | P a g e