Linear Control Laboratory Manual
Linear Control Laboratory Manual
Faculty of Engineering
Electrical Engineering Department
June 2019
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Experiments 1
Introduction to MATLAB
Objectives:
- To become familiar with the MATLAB software by introducing you the basic
features, commands, and functions.
Introduction:
Note: The most important function for learning MATLAB on your own:
»help sin
»doc sin
Basic Operations:
Computations:
>> 2*3 >> 2+3 >> 2-3 >> 2/3
ans = 6 ans =5 ans = -1 ans = 0.6667
Suppress Display of Results:
>> 2*3; % A semi-colon (;) after an expression suppresses the output.
1|Page
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Commands:
Matrices:
All variables represent matrices.
A scalar is a 1x1 matrix and a vector is a matrix with only one row or column.
Generating Vectors :
1- By directly inputting the elements,
Row Vector Column vector
>> a=[1, 2, 3] >> a=[1; 2; 3]
a= a=1
123 2
3
2- By using the colon (:) operator.
>> a=[1:3]
a=
123
>> c=[2: 2: 10]
c=
2 4 6 8 10
Generating Matrices :
X=[1 2 3; 4 5 6]
X=
123
456
2|Page
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Matrix operation:
3|Page
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Complex number:
The symbol "i" identifies the imaginary part and has to be typed immediately after the
numerical value of the imaginary part: (you can use j instead of i.)
It is also important to point out that termination with the character i only works with
simple numbers, not expressions.
If you want to multiply a complex expression by i, you have to use the multiplication
operation symbol (*).(Like this: (1 - 2i)*i)
Some complex building function
4|Page
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
3- Branching (if):
if relation
true alternative
else
false alternative
end
5|Page
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
4- Switch
switch variable
case value 1
statement group 1
case value 2
statement group 2
…
otherwise
last statement group
end
Note:
A ‘while’ loop is useful when, in contrast to a ‘for’ loop, the calculations are to be
repeated an undetermined number of times.
The ‘break’ command causes the enclosed loop – either a ‘for’ or ‘while’ loop to
terminate.
The ‘return’ command causes the currently executing function M-file to terminate.
Plotting:
1- Basic Two-Dimensional Plot:
t=0:0.01:2;
Temp=exp(-t);
plot(t,Temp)
xlabel('Time')
ylabel('Temp')
title('Transient Temperatures')
6|Page
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
7|Page
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
You can change colors, symbols, markets and line types as demonstrated below:
MATLAB Functions:
1- Scalar Functions:
8|Page
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
2- Vector Functions:
Certain MATLAB functions operate essentially on scalars, but operate element wise when
applied to a matrix. Some of these functions are:
9|Page
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
M-Files:
Such files are called M-files because they must have the file type ‘.m’.
There are two types of M-files:
1- Script files.
2- Function files.
The name of an M-file must begin with an alphabetic character.
Script files are simply pieces of code that are organized inside a file (i.e. they could be
run line-by-line inside the MATLAB workspace) so they can add to workspace
variables.
Function files cannot be run separately but they have to be called inside other
scripts/functions and their variables are local.
You must save the m-file as the name of the function to be able to fetch it at write it in
command window.
The problem can be rewritten in matrix-vector notation. We introduce a matrix A and a vector b
by :
10 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
2- Laplace Transformation:
MATLAB has a function called (Laplace) which transfer a function from time domain to
S-Domain.
Before you use this function you must declare the variable by syms function.
To get the Laplace inverse, only use (ilaplace) after declare the variable.
Simulink:
Simulink is an environment for simulation and model-based design for dynamic and
embedded systems.
Simulink is integrated with MATLAB, providing immediate access to an extensive
range of tools that let you develop algorithms, and provides a graphical user interface for
constructing block diagram models using “drag-and-drop” operations.
You start Simulink by open MATLAB and select the Simulink icon in the Toolbar as
shown in the figure or type “Simulink” in the Command window
Figure 5 Simulink
11 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Simulink Library:
The Simulink Library Browser is the library where you find all the blocks you may use
in Simulink. Simulink software includes an extensive library of functions commonly
used in modeling a system. These include:
1- Continuous and discrete dynamics blocks, such as Integration, Transfer
functions, Transport Delay, etc.
2- Math blocks, such as Sum, Product, Add, etc
3- Sources, such as Ramp, Random Generator, Step, etc
12 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Experiments 2
Introduction to LabVIEW
Objectives:
- To study introduction to labview program.
- To apply some basic examples on labview.
Introduction:
LabVIEW programs are called virtual instruments, or VIs, because their appearance and
operation imitate physical instruments, such as oscilloscopes and millimeters. LabVIEW
contains a comprehensive set of tools for acquiring, analyzing, displaying, and storing data,
as well as tools to help you troubleshoot code you write.
LabVIEW is a graphical programming language that uses icons instead of lines of text to
create applications. In contrast to text-based programming languages, where instructions
determine program execution, LabVIEW uses dataflow programming, where the flow of data
determines execution.
In LabVIEW, you build a user interface, or front panel, with controls and indicators. Controls
are knobs, push buttons, dials, and other input mechanisms. Indicators are graphs, LEDs, and
other output displays. After you build the front panel, you add code using VIs and structures
to control the front panel objects. The block diagram contains this code.
If no template is available for the VI you want to build, you can start with a blank VI and add
Express VIs to accomplish a specific task.
Complete the following steps to open a blank VI.
1. Launch LabVIEW program.
2. Select Blank VI to create new VI program from the list display on started window.
3. A blank front panel window and block diagram window appear.
4. If the Functions palette is not visible, right-click any blank space on the block
diagram to display a temporary version of the Functions palette. Click the thumbtack,
shown below, in the upper left corner of the Functions palette to pin the palette so it is
no longer temporary.
Figure 1: Thumbtack
13 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
In LabVIEW, you build a user interface by using a set of tools and objects. The user interface is
known as the front panel. You then add code using graphical representations of functions to control
the front panel objects. The block diagram contains this code. In some ways, the block diagram
resembles a flowchart. Users interact with the Front Panel when the program is running. Users can
control the program, change inputs, and see data updated in real time. Controls are used for inputs
such as, adjusting a slide control to set an alarm value, turning a switch on or off, or to stop a
program. Indicators are used as outputs. Thermometers, lights, and other indicators display output
values from the program. These may include data, program states, and other information.
Every front panel control or indicator has a corresponding terminal on the block diagram. When a
VI is run, values from controls flow through the block diagram, where they are used in the
functions on the diagram, and the results are passed into other functions or indicators through
wires.
1- Front Panel:
The front panel is the user interface of a VI. You build the front panel by using controls and
indicators, which are the interactive input and output terminals of the VI, respectively. Controls
and indicators are located on the Controls palette.
Controls are knobs, push buttons, dials, and other input mechanisms. Controls simulate instrument
input mechanisms and supply data to the block diagram of the VI.
Indicators are graphs, LEDs, and other displays. Indicators simulate instrument output
mechanisms and display data the block diagram acquires or generates.
14 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
2- Block Diagram:
The block diagram contains the graphical source code, also known as G code or block diagram
code, for how the VI runs.
The block diagram code uses graphical representations of functions to control the front panel
objects. Front panel objects appear as icon terminals on the block diagram. Wires connect control
and indicator terminals to Express VIs, VIs, and functions. Data flows through the wires in the
following ways: from controls to VIs and functions, from VIs and functions to indicators, and from
VIs and functions to other VIs and functions. The movement of data through the nodes on the
block diagram determines the execution order of the VIs and functions. This movement of data is
known as dataflow programming.
15 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Graphical Environment:
The LabVIEW palettes give you the options you need to create and edit the front panel and block
diagram.
1- Tools Palette:
The Tools palette is available on the front panel and the block diagram.
A tool is a special operating mode of the mouse cursor, when you select a tool, the cursor icon
changes to the tool icon, we use the tools to operate and modify front panel and block diagram
objects.
Select view → Tools Palette to display the Tools palette. You can place the Tools palette anywhere
on the screen. If automatic tool selection is enabled and you move the cursor over objects on the
front panel or block diagram, LabVIEW automatically selects the corresponding tool from the
Tools palette.
16 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
2- Control Palette:
The Controls palette is available only on the front panel, it contains the controls and indicators
you use to create the front panel.
Select view → Controls Palette or right-click the front panel workspace to display the Controls
palette, you can place it at anywhere on the screen.
3- Function Palette:
The Functions palette is available only on the block diagram, it contains the VIs and functions
you use to build the block diagram.
Select view → Functions Palette or right-click the block diagram workspace to display the
Functions palette. You can place it at anywhere on the screen.
17 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Lab work:
Example1: Make a LabVIEW program that ask the user to enter(x,y) two numbers and the
program find :
x+y
x-y
x*y
x/y if y equal zero (answer equal infinity) a led should light to warn the user.
Solution:
Solution:
18 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Note:
Formula tool can be found at arithmetic and comparison and is used to enter a
formula in an easy way for the user.
If the formula is correct then this led is green.
Example3: Create a LabVIEW program that allows the user to enter the student marks in five
subjects and then calculate the average. The program contain six leds as following.
Solution:
19 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Example4: Make a LabVIEW program that plots a sine signal or a square according to a toggle
switch control by the user. If the switch is on then the plotted signal is sine if the switch is off
then the plotted signal is square.
Solution:
Note:
Simulated signal can be found on the function palette then input.
The select operator can be found in arithmetic and comparison then comparison, it
work as a multiplexer with a selector to choose the output.
You can change Amplitude, Frequency and phase for any type of signal.
20 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Example5: Modified previous example by adding noise to each signal and control the amplitude,
frequency and amplitude of noise, the following must also be implemented:
1- When amplitude noise greater than amplitude signal the led will light on.
2- Display amplitude signal and amplitude noise by using gauge.
Solution:
Note:
For controlling the parameter manually for any signal, you can use Knob. (Knob as
input).
Adding gauge by two needle to display amplitude signal and amplitude noise
21 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
22 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Experiments 3
Execution Structures in LabVIEW
Objectives:
- To study how can we use While Loops, For Loops and Case Structures in LabVIEW and
apply many examples for them.
Introduction:
In this lab we will explains the basic concepts of Loops and Structures in LabVIEW, Loops are
used to run a specific part of a code iteratively. If you are a user of any programming language you
must be familiar with loops. Some of the most commonly used loops in every programming
language are for loop, while loop and do….while loops.
Loops are mostly used in the programs where we need the result of a function at various data
points. We can update the value of variable, store values in arrays (we will discuss them in
upcoming tutorials) and also plot graphs (we will discuss plotting in upcoming tutorials) and many
more things iteratively. In programming language, a loop is defined as sequence of commands
which are required to be repeated until a certain condition provided by the programmer is satisfied.
After the condition is satisfied the control flow leaves the loop and stop executing the program
over and over again.
Typically, for loop is used when the number of iterations are known and while loop allows the
code to be executed repeatedly depending upon a Boolean condition. If the condition is true the
code inside the loop is executed and if it is false the loop is skipped. While working with loops,
one must remember that the condition given to the loop must converge to satisfaction, i.e. the if
the condition is never going to be satisfied ever, your loop will run infinitely, and ultimately you
program will never stop, which is not a good programming skill.
The topics are as follows:
- While Loop
- For Loop
- Case Structure
The different Loops and Structures available are located in the “Structures” sub palette in the
Functions palette on the Block Diagram.
23 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
The While Loop is located on the Structures palette. Select the While Loop from the palette then
use the cursor to drag a selection rectangle around the section of the program you want to repeat.
When you release the mouse button, a While Loop boundary encloses the section you selected.
Below we see an empty While loop:
The While Loop executes the code it contains until the conditional terminal, which is an input
terminal, receives a specific Boolean value.
The iteration terminal is an output terminal that contains the number of completed iterations.
The iteration count for the While Loop always starts at zero.
Note:
The While Loop always executes at least once.
Example (1):
Create a LabVIEW program with three leds with the following specification:
- The first led lights red when the iteration is less than 15.
- The second led lights yellow when the iteration is more than 15 and less than 20.
- The third led lights green when the iteration is more than 20.
- The system should reset (iteration=0) when the iteration reaches 40.
Note: Control the loop delay so the led can go faster or slower
24 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Solution:
1. First create the front panel design which consist of three leds as
shown in figure below.
2. The main idea depends on the iteration value so we need to use
the comparison function in order to meet the system
specification, for example the first led should light when the
iteration is less than or equals to 15 so we use the function as for
the second led it should light when two conditions are true so we
use comparison function in addition to an AND gate and final the
same for the third led. Figure 3 Front Panel
3. To reset the system at 40 we use the equal function as shown
in figure below.
4. When a loop finishes executing an iteration, it immediately begins executing the next
iteration, unless it reaches a stop condition. Most often, you need to control the iteration
frequency or timing. For example, if you are acquiring data, and you want to acquire the
data once every 10 seconds, you need a way to time the loop iterations so they occur once
every 10 seconds. Even if you do not need the execution to occur at a certain frequency,
you need to provide the processor with time to complete other tasks, such as responding to
the user interface (Time Delay).
25 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
2- The iteration terminal is an output terminal that contains the number of completed
iterations.
The for loop iteration always starts from zero.
Example (2):
Use the for loop structure to make a flashing ring of seven leds with the following specification.
The first led light then the second led light and the first led remains light then the third led light
and the first and second led remains light and so on until the seventh led light, then all the leds are
tuned off and repeated the previous repetition.
Solution:
1. Design the front panel with seven leds and a Knob which is used to control the speed as
shown in figure.
26 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
2. Since we have seven led flasher we need the loop to run eight time because in the final
loop all leds off so we put the counter terminal to 8 as shown in figure below, put delay
equal 0.5sec.
27 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
The case selector label at the top of the Case structure contains the name of the selector value that
corresponds to the case in the center and decrement and increment arrows on each side. Click the
decrement and increment arrows to scroll through the available cases. You also can click the down
arrow next to the case name and select a case from the pull down menu.
Wire an input value, or selector, to the selector terminal to determine which case executes. You
must wire an integer, Boolean value, string, or enumerated type value to the selector terminal. You
can position the selector terminal anywhere on the left border of the Case structure. If the data type
of the selector terminal is Boolean, the structure has a True case and a false case. If the selector
terminal is an integer, string, or enumerated type value, the structure can have any number of cases.
Right-click the Case structure border to add, duplicate, remove, or rearrange cases, and to select a
default case.
28 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Example3:
Design a LabVIEW program to calculate the area of a circle, and circumference of a circle using
case structure.
Solution:
Example4:
Built a simple function generator that generates sin, square, and triangular waves. The user
should control the amplitude, frequency, and phase (delay) using case structure.
Solution:
29 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Experiment 4
System Modeling By MATLAB & LabVIEW
Objectives:
- Find a mathematical model, called a state-space representation, for a linear, time
invariant system using MATLAB and LabVIEW.
- Convert a transfer function to state space.
- Convert a state-space representation to a transfer function.
- Reduce a block diagram of multiple subsystems to a single block representing the transfer
function.
Introduction:
The first step in the control design process is to develop appropriate mathematical models of
the system to be controlled. These models may be derived either from physical laws or
experimental data. In this section, we introduce the state-space and transfer function
representations of dynamic systems. We then review some basic approaches to modeling
mechanical and electrical systems and show how to generate these models in MATLAB for
further analysis.
Modeling is the translator that represents a physical device by its equivalent equations.
In modeling we need some standard physical laws that relate our variables.
30 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
31 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
With the NI LabVIEW Control Design and Simulation Module, you can analyze open-loop
model behavior, design closed-loop controllers, simulate online and offline systems, and conduct
physical implementations.
Create models from first principles using transfer function, state-space, or zero-pole-gain
representation. With time and frequency analysis tools, such as time step response or Bode plot,
you can interactively analyze open- and closed-loop behavior. Use built-in tools for both
multiple input, multiple output (MIMO) and single input, single output (SISO) systems and take
advantage of simulation capabilities to verify linear and nonlinear system dynamics.
32 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
𝑠+2
G(s) =
𝑠 2 +𝑠+10
By MATLAB:
By LabVIEW
33 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
By MATLAB:
Figure 5 Series TF
By MATLAB(Another method):
BY LabVIEW:
34 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
By MATLAB :
Figure 9 Parallel TF
BY LabVIEW:
35 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
By MATLAB:
Figure 12 Feedback TF
By LabVIEW:
36 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
By MATLAB:
By LabVIEW:
37 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Figure 17 Convert TF to SS
By LabVIEW:
38 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
By MATLAB:
By LabVIEW:
39 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
8- Reduce a block diagram of multiple subsystems to a single block representing the transfer
function.
By MATLAB:
Figure 23 Reducing to TF
By LabVIEW:
40 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
41 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Experiments 5
Time Response Analysis
Objectives:
- To study the transient response of first-order systems and second-order systems.
- To study how can be Find the settling time, peak time, percent overshoot, and rise
time for an underdamped second-order system.
- To draw the time response from transfer function and state-space representation by
MATLAB and LabVIEW.
Introduction:
What is Time Response?
If the output of control system for an input varies with respect to time, then it is called the time
response of the control system. The time response consists of two parts:
Transient response.
Steady state response.
The response of control system in time domain is shown in the following figure.
Here, both the transient and the steady states are indicated in the figure. The responses
corresponding to these states are known as transient and steady state responses.
Mathematically, we can write the time response c(t) as:
𝒚(𝒕) = 𝒚𝒕 (𝒕) + 𝒚𝒔𝒔 (𝒕)
42 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Transient Response
After applying input to the control system, output takes certain time to reach steady state. So, the
output will be in transient state till it goes to a steady state. Therefore, the response of the control
system during the transient state is known as transient response.
Note: If the input is step function the output or the response is called step time response and
if the input is ramp, the response is called ramp time response.
43 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
2. Underdamped responses
Poles: Two complex at −𝜎𝑑 ± 𝑗𝜔𝑑
complex poles
3. Undamped responses
Poles: Two imaginary at ±𝑗𝜔1
imaginary poles
4. Critically damped responses
Poles: Two real at −𝜎1
real & repeated poles
44 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
The first order system has no overshooting but can be stable or not depending on the
location of its pole.
The first order system has a single pole at -a. If the pole is on the negative real axis (LHP),
then the system is stable. If the pole is on the positive real axis (RHP), then the system is
not stable. The zeros of a first order system are the values of s which makes the numerator
of the transfer function equal to zero.
45 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
How can be draw the step response by Matlab code, Simulink and LabVIEW for
transfer function and state space representation.
For Example,
10
Transfe1r function: G(s) =
𝑠2 +2𝑠+10
𝟎 𝟏 𝟎
State space: A= [ ] , B = [ ],
−𝟗 −𝟐 𝟏
C = [𝟗 𝟎] , D =0
Firstly// MATLAB Code:
- Transfer Function:
- State Space:
46 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Secondly // Simulink.
We can do the same work by Simulink in MATLAB.
Components :
For most of the systems we will encounter, we only need to be concerned with a small
fraction of Simulink’s Component library. In particular, the components you should be
familiar with are:
1. ”Continuous” library:
Integrator–integrates a signal.
State-Space–used to add a system block in state-space form.
Transfer Function–used to add a system block in transfer function form.
3. ”Sinks” library:
Scope–used for viewing system output.
To workspace–used to transfer a signal to MATLAB.
4. ”Sources” library:
Ramp–generates a ramp signal.
Sine Wave–generates a sinusoid.
Step–generates a unit step signal.
- Transfer Function:
47 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
- State Space:
Thirdly // LabVIEW.
Open Blank VI in LabVIEW then go to the block diagram window and open the function
palette then select control design and simulation library.
Add control and simulation loop as area for your simulation then add the function generator
and linear control system then display the output on the Sim-time waveform.
48 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
- Transfer Function:
- State Space:
49 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
50 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Experiments 6
Root-Locus
Objectives:
- To study what is root-locus technique.
- To study how can be plot root-locus using MATLAB and LabVIEW.
- Deign of system using root-locus technique.
Introduction:
Root locus, a graphical presentation of the closed-loop poles as a system parameter is varied,
is a powerful method of analysis and design for stability and transient response. Feedback
control systems are difficult to comprehend from a qualitative point of view, and hence they
rely heavily upon mathematics. The root locus covered in this Lab is a graphical technique that
gives us the qualitative description of a control system’s performance that we are looking for
and also serves as a powerful quantitative tool that yields more information than the methods
already discussed.
The root locus can be used to describe qualitatively the performance of a system as various
parameters are changed. For example, the effect of varying gain upon percent overshoot,
settling time, and peak time can be vividly displayed. The qualitative description can then be
verified with quantitative analysis.
• Consider a feedback system that has one parameter (gain) K > 0 to be designed.
• Root locus graphically shows how poles of CL system varies as K varies from 0 to
infinity.
Root-Locus Technique:
As system parameter k varies over a continuous range of values, the root locus diagram
shows the trajectories of the closed-loop poles of the feedback system. Typically, the root
locus method is used to tune the loop gain of a SISO control system by specifying a designed
set of closed-loop pole locations.
Then, Root Locus technique produces a plot that shows the locations of poles of a closed
loop system on the S-Plane as K varies and from this plot we can choose the suitable K that
meet our specification conditions.
51 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
For example: Below we see two plots of root locus. The lines are represent the locations of
the poles as K vary.
As we note in the root locus graph, implemented by Mat lab, the plot tell us that when the gain
K = 3.78 the response will have overshooting 1.34% and damping ratio 0.8 and when K = 9.36
the response will have no overshooting. Also the locus say that all values of K will not make
the system unstable and will remain in the stable region.
52 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
When the gain K = 9.44 the system will be unstable because the poles become in RHP , so
we can conclude that the proportional controller may drive the system from the unstable
mode to a stable one and vice versa.
𝑆+5
L(s) = 𝑆2 +5𝑆+6
num=[1 5]
den=[1 5 6]
sys=tf(num,den)
rlocus(sys)
53 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
We knew that root locus plot the poles for an closed loop transfer function that will be
controlled by Proportional controller and the system must have unity feedback path as in
figure below.
54 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
But if the system does not has unity feedback as in figure below, so we should convert it to
another has unity feedback by the solution below.
Example 1: Using Mat lab plot the root locus for the T.F and design K controller to get 5% O.S
55 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
MATLAB Code:
num=[3]
den=[1 8 0]
sys=tf(num,den)
rlocus(sys)
From the plot of root locus we find that if K = 11.2 then the O.S will be 5 %
To verify draw the step response when K = 11.2:
MATLAB Code:
num=[3]
den=[1 8 0]
sys=tf(num,den)
k=11.2
sysf=feedback(k*sys,1)
step (sysf)
56 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
57 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Experiments 7
𝒚(𝒕)=𝒚𝒕(𝒕)+𝒚𝒔𝒔(𝒕)
58 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
For example of the open loop system, an electric clothes dryer. Depending upon the amount of
clothes or how wet they are, a user or operator would set a timer (controller) to say 30 minutes and
at the end of the 30 minutes the drier will automatically stop and turn-off even if the clothes where
still wet or damp.
In this case, the control action is the manual operator assessing the wetness of the clothes and
setting the process (the drier) accordingly.
So in this example, the clothes dryer would be an open-loop system as it does not monitor or
measure the condition of the output signal, which is the dryness of the clothes. Then the accuracy
of the drying process, or success of drying the clothes will depend on the experience of the user
(operator).
59 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Where (𝒔) = 𝑳 {𝒆(𝒕)} : the error signal between the input and output.
𝑌(𝑠)
𝐺(𝑠) =
𝑋(𝑠)
𝐸(𝑠) = 𝑋(𝑠) − 𝑌(𝑠)
𝑌(𝑠) 𝐺(𝑠)
𝐻(𝑠) = =
𝑋(𝑠) 1 + 𝐺(𝑠)
60 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
Proportional Controller:
The closed loop system overcomes the disadvantage that existed in the open loop systems.
Where (𝒔) = 𝑳 {𝒆(𝒕)} : the error signal between the input and output.
𝑌(𝑠)
𝐺(𝑠) =
𝑋(𝑠)
𝐸(𝑠) = 𝑋(𝑠) − 𝑌(𝑠)
𝑌(𝑠) 𝐾 𝐺(𝑠)
𝐻(𝑠) = =
𝑋(𝑠) 1 + 𝐾 𝐺(𝑠)
In this case K is called Proportional Gain or Proportional Controller.
num = 1.5;
den = [1 14 40.02];
G = tf(num,den);
K = input('K = ')
sys = feedback(K*G,1);
step(sys)
stepinfo(sys)
61 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
At K = 0.1
At K = 1
62 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
At K = 10
At K = 100
63 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
At K = 1000
Conclusion:
The previous results say that the proportional controller has an effect on overshooting and
settling time such that increasing the K gain will increase the overshooting and decrease the
settling time and rise time. In the other hand decreasing the K gain will decrease the
overshooting and increase the settling time and rise time.
64 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
65 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
- Change parameter source of the gain (K) from configuration dialog box to terminal as
shown in figure.
Figure 12 Specification
66 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
- Now we will varying in the value of proportional gain and observe the effect of increasing it
on the step response of the system G(s).
At K = 0.1
At K = 1
67 | P a g e
Eng. Nael Sofyan Dokhan Linear Control System LAB Eng. Haya Ashraf Swedan
At K = 10
K = 100
K = 1000
68 | P a g e