Uploaded by Psyonic S3

EEE325 Control Systems V3 LAB MANUAL

advertisement
EEE325 Control Systems
Control Systems
EEE325
Lab Manual
Name
Registration Number
Class
Instructor’s Name
COMSATS University Islamabad
Page 1
EEE325 Control Systems
Introduction
This manual supports the practical sessions of the course “Control Systems EEE325” for under-graduate engineering degrees. The manual comprises of
experiments which cover software as well as hardware aspects of control. The
hardware experiments consists of working with platforms like PLC and rectilinear
plant. The software based experiments mainly use MATLAB and Simulink tools
and implement the concrete concepts being taught in theoretical lectures.
During the labs the students usually work in groups (no more than three students
per group). They are required to complete the “Pre-Lab” section of the lab before
coming to the lab. The students are evaluated against their “Pre-Lab” and “InLab” tasks. The “Post-Lab” section is given as an assignment, which needs to be
completed before next lab.
The students are not allowed to wander in the lab or consult other groups when
performing experiments. Similarly the lab reports must contain original efforts as
the CUI has a zero tolerance anti-plagiarism policy.
Apart from these weekly labs students are given a project as a final lab exam. The
grading policy is already discussed in the Course Description File.
We hope and pray that you will find this manual useful to enhance your skills and
expertise. Enjoy ‘learning by doing’!
COMSATS University Islamabad
Page 2
EEE325 Control Systems
Acknowledgement
The labs for EEE-325 Control System were designed by Dr. Adeel Mehmood. The
manuals were prepared by Mr. Syed Ali Ajwad, Mr. Rizwan Azam and Mr. Saqib
Irfan. This manual is modified according to OBE requirements
The typesetting and formatting of this version was carried out under the supervision of Dr.
Omar Ahmad and was carried out by Mr. Abdul Rehman, Mr Suleman and Mr Baqir Hussain .
History of Revision
Version
and Date
of Issue
Team
Comments
Version 1.
July 2016
Dr. Adeel Mehmood
Mr. Syed Ali Ajwad
Mr. Rizwan Azam
Mr. Saqib Irfan
The
manual
was
remodeled
according to the new OBE format.
Some of the labs were improved.
Version 2.
July 2018
Shaharyar Mahmood
Dr. Mahmood Pervaiz
Revised, edited and appended with
more examples to make it more
student friendly and enhance the
aspect of learning.
COMSATS University Islamabad
Page 3
EEE325 Control Systems
Safety Precautions
•
Be calm and relaxed, while working in lab.
•
First check your measuring equipment.
•
When working with voltages over 40 V or current over 10 A , there must be at least two
people in the lab at all time.
•
Keep the work area neat and clean.
•
Be sure about the locations of fire extinguishers and first aid kit.
•
No loose wires or metals pieces should be lying on the table or neat the circuit.
•
Avoid using long wires, that may get in your way while making adjustments or
changing leads.
•
Be aware of bracelets, rings, and metal watch bands (if you are wearing any of them).
Do not wear them near an energized circuit.
•
When working with energize circuit use only one hand while keeping rest of your body
away from conducting surfaces.
•
Always check your circuit connections before power it ON.
•
Always connect connection from load to power supply.
•
Never use any faulty or damage equipment and tools.
•
If an individual comes in contact with a live electrical conductor.
o Do not touch the equipment, the cord, the person.
o Disconnect the power source from the circuit breaker and pull out the plug using
insulated material.
COMSATS University Islamabad
Page 4
EEE325 Control Systems
Table of Contents
Introduction .................................................................................................................................. 2
Acknowledgement ........................................................................................................................ 3
History of Revision ...................................................................................................................... 3
Safety Precautions ........................................................................................................................ 4
Lab # 1 Introduction to PLC’s and Implementation of Combinational Logic through Ladder
Logic............................................................................................................................................. 8
Objectives ................................................................................................................................. 8
Pre Lab ..................................................................................................................................... 8
In-Lab: .................................................................................................................................... 12
Post-Lab: ................................................................................................................................ 21
Critical Analysis / Conclusion.................................................................................................. 22
Lab # 2 Implementation of Timers and Counters in Trilogy ..................................................... 23
Objectives ............................................................................................................................... 23
Pre Lab ................................................................................................................................... 23
In-Lab: .................................................................................................................................... 27
Post-Lab ................................................................................................................................. 31
Critical Analysis / Conclusion.................................................................................................. 32
Lab # 3 Implementation of Sequencers in Trilogy..................................................................... 33
Objectives ............................................................................................................................... 33
Pre Lab ................................................................................................................................... 33
In-Lab ..................................................................................................................................... 34
Post-Lab: ................................................................................................................................ 38
Critical Analysis / Conclusion.................................................................................................. 39
Lab # 4 Introduction to MATLAB and Simulink, Solution of Differential Equations Using
MATLAB and Simulink and Transfer Function Based Modelling............................................ 40
Objectives ............................................................................................................................... 40
Pre Lab ................................................................................................................................... 40
Pre Lab Tasks ......................................................................................................................... 46
Lab Tasks ............................................................................................................................... 48
Post Lab Tasks ....................................................................................................................... 53
Critical Analysis / Conclusion.................................................................................................. 54
COMSATS University Islamabad
Page 5
EEE325 Control Systems
Lab # 5 Modeling of Translational Mechanical System and to Calculate Its Various Responses
.................................................................................................................................................... 55
Objectives ............................................................................................................................... 55
Pre Lab ................................................................................................................................... 55
Lab Tasks ............................................................................................................................... 59
Post Lab Tasks ....................................................................................................................... 64
Critical Analysis / Conclusion.................................................................................................. 67
Lab # 6 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems .................. 68
Objectives ............................................................................................................................... 68
Pre Lab ................................................................................................................................... 68
Lab Tasks ............................................................................................................................... 75
Post Lab Tasks ....................................................................................................................... 81
Critical Analysis / Conclusion.................................................................................................. 84
Lab # 7 Block Diagram Reduction and Analysis and Design of Feedback Systems ................. 85
Objectives ............................................................................................................................... 85
Pre Lab ................................................................................................................................... 85
Pre Lab Tasks ......................................................................................................................... 87
Lab Tasks ............................................................................................................................... 88
Post Lab Tasks ....................................................................................................................... 95
Critical Analysis / Conclusion.................................................................................................. 97
Lab # 8 Effect of Zeros on 2nd Order Systems Response, Pole Zero Cancellation and Stability
Analysis via Routh Hurwitz Criterion........................................................................................ 98
Objectives ............................................................................................................................... 98
Pre Lab ................................................................................................................................... 98
Pre Lab Tasks ....................................................................................................................... 102
Lab Tasks ............................................................................................................................. 104
Post Lab Tasks ..................................................................................................................... 111
Critical Analysis / Conclusion................................................................................................ 113
Lab # 9 Steady State Error Analysis and Design ..................................................................... 114
Objectives ............................................................................................................................. 114
Pre Lab ................................................................................................................................. 114
Lab Tasks ............................................................................................................................. 116
Post Lab Tasks ..................................................................................................................... 121
COMSATS University Islamabad
Page 6
EEE325 Control Systems
Critical Analysis / Conclusion................................................................................................ 123
Lab # 10 Analysis of Systems using Root Locus Method. ...................................................... 124
Objectives ............................................................................................................................. 124
Pre-Lab Task. ....................................................................................................................... 124
Post-Lab ............................................................................................................................... 127
Critical Analysis / Conclusion................................................................................................ 129
Lab#11 PID Controller Design. ............................................................................................... 130
Objectives: ............................................................................................................................ 130
Pre-LAB ............................................................................................................................... 130
PID Overview ....................................................................................................................... 130
The Characteristics of the P, I, and D Terms ....................................................................... 132
LAB TASK-1 ....................................................................................................................... 133
Example Problem ................................................................................................................. 133
Open-Loop Step Response ................................................................................................... 134
Proportional Control............................................................................................................. 135
Proportional-Derivative Control .......................................................................................... 137
Proportional-Integral Control ............................................................................................... 139
Proportional-Integral-Derivative Control ............................................................................. 140
General Tips for Designing a PID Controller ...................................................................... 142
Post-Lab ............................................................................................................................... 143
Automatic PID Tuning ......................................................................................................... 143
Critical Analysis / Conclusion................................................................................................ 146
Lab # 12 Introduction to control experiments on COM3 Lab Trainer ..................................... 147
Critical Analysis / Conclusion................................................................................................ 149
Lab # 13 State Space Representation ....................................................................................... 150
Critical Analysis / Conclusion................................................................................................ 156
COMSATS University Islamabad
Page 7
LAB # 01 Introduction to PLC’s and Implementation of Combinational Logic through Ladder Logic
Lab # 1 Introduction to PLC’s and Implementation
of Combinational Logic through Ladder Logic
Objectives
To understand the basics of PLCs and their programming using ladder logic.
Equipment/Tools required:
PLC(Triangular Research Inc.), PC with TRiLOGI software, connecting leads etc.
Pre Lab
Part I- Introduction
A Programmable Logic Controller (PLC) is a specialized computer used to control machines
and processes. It uses a programmable memory to store instructions and execute specific
functions that include on/off control, timing, counting, sequencing, Arithmetic and data
handling. The design of most PLCs is similar to that of other computers. Basically, the PLC is
an assembly of solid-state digital logic elements designed to make logical decisions and
provide outputs. Programmable logic controllers are used for the control and operation of
manufacturing process equipment and machinery.
PLC Definition:
The term ’programmable logic controller’ is defined as follows by EN 61131-1 (IEC 61131-1).
“A digitally operating electronic system, designed for use in an industrial Environment, which
uses a programmable memory for the internal storage of user-oriented instructions for
implementing specific functions Such as logic, sequencing, timing, counting and arithmetic, to
control, through digital or analogue inputs and outputs, various types of machines or
processes”.
History:




In the start of 19th century more and more industries were tend to converted as
Automated. At that time it was done using Relays and Switches.
In the late 1960's PLCs were first introduced by Bedford Associates “MODICON 084”.
The primary reason was to eliminating complicated relay based machine control systems.
In the mid70's As conventional microprocessors evolved, larger and larger PLCs were
being based upon them. Communications abilities began to appear in approximately
1973.
The 80's saw an attempt to standardize communications with General Motor's
manufacturing automation protocol (MAP). It was also a time for reducing the size of the
COMSATS University Islamabad
Page 8
LAB # 01 Introduction to PLC’s and Implementation of Combinational Logic through Ladder Logic
PLC and making them software programmable through symbolic programming on
personal computers
The 90's have seen a gradual reduction in the introduction of new protocols, and the
modernization of the physical layers of some of the more popular protocols that survived
the 1980's. The latest standard (IEC 1131-3) has tried to merge plc programming
languages under one international standard.

Characteristics of PLC:
Category
Relay
Price
Digital Design
Computer
PLC
Inexpensive Inexpensive
Expensive
Inexpensive
Size
Large
Small
Moderate
Small
Noise
Good
Fair
Excellent
Fair
Speed
Slow
Very Fast
Very Fast
Fast
System Modification
Very
Difficult
Difficult
Simple
Simple
Troubleshooting
Very
Difficult
Difficult
Simple
Simple
Complex Function
Support
None
Supported
Supported
Supported
Parts of PLC:
A typical PLC can be divided into following parts: (Figure 1.1)





Central processing unit (CPU).
Input/Output (l/O) section.
Power supply.
Programming device.
Communication Port.
COMSATS University Islamabad
Page 9
LAB # 01 Introduction to PLC’s and Implementation of Combinational Logic through Ladder Logic
Figure 1.1 Parts of PLC
Extending PLC:
Every PLC controller has a limited number of input/output lines,



If needed this number can be increased through certain additional modules by system
extension through extension lines.
Each module can contain extension both of input and output lines.
Also, extension modules can have inputs and outputs of a different nature from those on
the PLC controller (ex. in case relay outputs are on a controller, transistor outputs can
be on an extension module).
PLC Scan Cycle:
During each operating cycle, the processor reads all the inputs, takes these values and
energizes or de-energizes the outputs according to the user program. This process is known as
a scan. A typical PLC scan is shown in Figure 1.2 in which PLC scan I/O and program. Since
inputs may change continuously so PLC must carry on this process continuously. The PLC
scan time specification indicates how fast the controller can react to changes in inputs. Scan
time varies with program content and length. The time required to make a single scan can vary
from about 1ms to 20ms.
Read Input
Adjust Output
Run Program
Figure 1.2 PLC scan cycle
PLC Programming:
According to International Electro technical Commission (IEC) 61131-3/EN 6131 standard,
PLC can be programmed using following five different languages:





Ladder diagram (Graphical, Electrical Design base).
Function Block Diagrams (Graphical, Function Block base).
Statement lists (Text, Assembly base, use in Europe).
Structured text languages (Text, Pascal and C base).
Sequential function charts.(Text, Sequentially describes the flow and conditions of
manufacturing process).
COMSATS University Islamabad
Page 10
LAB # 01 Introduction to PLC’s and Implementation of Combinational Logic through Ladder Logic
Relay:
A relay is a simple electromechanical switch made up of an electromagnet and a set of
contacts. Relays are used where it is necessary to control a circuit by a low-power signal (with
complete electrical isolation between control and controlled circuits), or where several circuits
must be controlled by one signal.
Basic design and operation of Relay:
A simple electromagnetic relay consists of a coil of wire a movable iron armature, and one or
more sets of contacts.
The coil part is an operating part and contacting part is the switching part of relay (see
figure 1.3). When an electric current is passed through the coil it generates magnetic that
activates the armature and the consequent movement of the movable contact either makes or
breaks (depending upon construction) a connection with a fixed contact.
Figure 1.3 Relay Structure
Ladder Diagrams:
Ladder Diagram is graphical depiction of a process with rungs of logic, similar to the relay
ladder logic schemes that were replaced by PLCs. The main function of the ladder logic
diagram program is to control outputs based on input conditions. This control is accomplished
through the use of what is referred to as a ladder rung. In general, a rung consists of a set of
input conditions, represented by contact instructions, and an output instruction at the end of the
rung is represented by the coil symbol.
COMSATS University Islamabad
Page 11
LAB # 01 Introduction to PLC’s and Implementation of Combinational Logic through Ladder Logic
In-Lab:
LAB TASKS:
Lab Task 1:
Using TRiLOGI software, design a circuit to control single bulb with single switch
STEPS:
1. First define Inputs, Outputs and Relay labels on paper. Draw a sketch of wiring
diagram. This diagram may look as shown below
Switch
Bulb
220V AC
1.4 Task 1: Wiring Diagram
Figure
2. Now open Trilogy as explained below
(Start->Programe-> Internet TRrLOGI 5.2 -> TRiLOGI Version 6.0
COMSATS University Islamabad
Page 12
LAB # 01 Introduction to PLC’s and Implementation of Combinational Logic through Ladder Logic
3. Open pull-down "File" menu and select "New". Save the file as ‘Lab1_Task1’.
4. Open up the I/O label editing Window by pressing <F2>.
5. Scroll to the "Inputs" window by using the left/right cursor keys or by clicking
on the red color left/right arrow.
6. Move the deep blue color highlight bar to Input #1 position by clicking on it.
Click again to open up a text field for entering the name for Input #1.
7. Enter the name "Switch" for Input #1. Press <Enter> key to accept the name.
8. Press <Enter> key again and the highlight bar will be moved to Input #2.
9. Repeat above steps for Outputs, Relay, Timer and Counters as per requirement.
Now you are ready to Design your first ladder logic Circuit (Rung).
(Design fallowing ladder diagram and simulate).
1. With the circuit pointer (red color triangle) at Circuit #1, press the <Spacebar> to enter
the "Ladder Edit" mode
2. Once you enter the "Ladder Edit" mode, a row of ladder icons appear along the top of the
main TRiLOGI window just below the pull down menu. The following is a description of
each item. A yellow color highlight bar, which you can move to select an element in the
ladder circuit, will appear.
COMSATS University Islamabad
Page 13
LAB # 01 Introduction to PLC’s and Implementation of Combinational Logic through Ladder Logic
. At the same time, an I/O
3. Now insert the first element by left-clicking on the icon
table should appear on the screen with a light beige-color background instead of the normal
light blue background.
4. Select the first switch i.e. “Start”.
5. Now insert the second element Output labeled as Bulb by left-clicking on the icon
6. Compile the Result by pressing <F8>
7. Simulate the program by pressing Ctrl+F9.
8. Fill up Task-1 Table at the Result Table Page.
COMSATS University Islamabad
Page 14
LAB # 01 Introduction to PLC’s and Implementation of Combinational Logic through Ladder Logic
Transferring the Program to PLC:
Once you successfully simulated your logic, how much interesting it will be to see your logic
working on a PLC. This is also pretty straight-forward. Before transferring your program,
make sure two things:
i.
The PLC server is on. If it is not, go to
Start -> Programs -> Internet Trilogy 5.2 -> TL Server ver 2.0
ii.
iii.
PLC does not know itself which switch you want to use for the input Start and which
LEDs will be used for the outputs Y1 and Y2. We have to map the input and outputs by
connecting simple jumper wires.
Now from the main menu, select ‘Controller’ -> ‘Program transfer to PLC’ or simply
press Ctrl + T as shown below.
You will get following dialog window prompting for Server’s details.
You do not have to enter any password. Just click on “Detect ID”. It will automatically scan
the device and give its ID in hexadecimal format.
COMSATS University Islamabad
Page 15
LAB # 01 Introduction to PLC’s and Implementation of Combinational Logic through Ladder Logic
Pressing OK will prompt you for transferring your program on PLC.
Pressing OK will automatically result in compilation of your program. The compilation should
give you an encouraging success message mentioning the details about your circuit as well as
code.
Pressing OK will automatically result in saving the program in EEPROM.
You are almost done. But wait, do not go before monitoring the behavior/performance of your
program. There are two ways of doing this. You should try both ways.
From PLC itself: By giving the input through switch and visually observing the outputs
from LEDs.
ii. From Trilogy: From main menu bar, select
Controller -> On-Line Monitoring or simply press Ctrl + M.
i.
COMSATS University Islamabad
Page 16
LAB # 01 Introduction to PLC’s and Implementation of Combinational Logic through Ladder Logic
Result Tables (Fill it and submit to instructor at the end of Lab)
Lab Task-1
Problem: what if the Load (Bulb) we are using is of 200watt (220V, 1A Approximate).
Lab Task-2: Inserts a relay in program to make it more professional:
Lab Task-2
Instructor Signature
Lab Task-3 Implement Logic Gates:
3 Inputs AND Gate:
COMSATS University Islamabad
Page 17
LAB # 01 Introduction to PLC’s and Implementation of Combinational Logic through Ladder Logic
Lab Task-3a
3 Inputs OR Gate:
Lab Task-3b
Single Input NOT Gate:
Lab Task-3c
2 Inputs XOR Gate
COMSATS University Islamabad
Page 18
LAB # 01 Introduction to PLC’s and Implementation of Combinational Logic through Ladder Logic
Lab Task-3d
Instructor Signature
COMSATS University Islamabad
Page 19
LAB # 01 Introduction to PLC’s and Implementation of Combinational Logic through Ladder Logic
LabTask-4 Design a 3 to 8 Line Decoder:
(Procedure: 1st Design Truth Table, Then Boolean Equation, Then Logic Gates Circuit
Diagram (if necessary) and at last design Ladder Logic Program.)
A
B
C
0
0
0
0
0
1
0
1
0
0
1
1
1
0
0
1
0
1
1
1
0
1
1
1
D0
D1
D2
D3
D4
D5
D6
D7
(Hint: D0 = A’.B’.C’, D1 = A’.B’.C, D2 = A’.B.C’, D3 = A’.B.C, D4 = A.B’.C’, D5 = A.B’.C,
D6 = A.B.C’, D7 = A.B.C)
Lab Task-4
Instructor Signature
COMSATS University Islamabad
Page 20
LAB # 01 Introduction to PLC’s and Implementation of Combinational Logic through Ladder Logic
Post-Lab:
1.
Implement Flip-Flop using both NAND and NOR Gates.
Truth Table of NOR Gate
S
Table 1.1 NOR truth table
R
Q
Q’
1
0
1
0
0
0
1
0
0
1
0
1
0
0
0
1
1
1
0
0
Truth Table of NAND Gate
S
Table 1.2 NAND truth table
R
Q
Q’
1
0
0
1
1
1
0
1
0
1
1
0
1
1
1
0
0
0
1
1
2. Implement half bit adder Circuit in LD.
3. Design your home TV Lounge Electrical Circuit diagram on Paper.
4. Implement fallowing control cct. In LD
X
Y
Z
COMSATS University Islamabad
F1
Page 21
LAB # 01 Introduction to PLC’s and Implementation of Combinational Logic through Ladder Logic
Performance
Viva
(10 Marks)
(5 Marks )
Performance
/6
Results
/3
Critical Analysis
/1
Total/15
Comments
Critical Analysis / Conclusion
(By Student about Learning from the Lab)
COMSATS University Islamabad
Page 22
LAB # 02 Implementation of Timers and Counters in Trilogy
Lab # 2 Implementation of Timers and Counters in
Trilogy
Objectives
To understand the implementation of fundamental building blocks (timers and counters)
through ladder logic.
Equipment/Tools required:
PLC (Triangular Research Inc.), PC with TRiLOGI software, connecting leads etc.
Pre Lab
Introduction:
Timers:
A timer is a special kind of relay that, when its coil is energized, must wait for a fixed length of
time before closing its contact. The waiting time is dependent on the "Set Value" (SV)of the
timer (1 S.V unit = 100mSec). Once the delay time is up, the timer's N.O. contacts will be
closed for as long as its coil remains energized. When the coil is de-energized (i.e. turned
OFF), all the timer's N.O. contacts will be opened immediately.
However, if the coil is de-energized before the delay time is up, the timer will be reset and its
contact will never be closed. When a last aborted timer is re-energized, the delay timing will
restart afresh using the SV of the timer and not continue from the last aborted timing operation.
In general, there are three different timers - the ON-delay timer, OFF-delay timer and retentive
timer.
ON-delay timer:
The on-delay timer operates such that when the rung containing the timer is true, the timer
time-out period commences. At the end of the timer time-out period, an output is made active.
Input
Output
Figure 2.1 ON-delay timer operation
COMSATS University Islamabad
Page 23
LAB # 02 Implementation of Timers and Counters in Trilogy
OFF-delay timer:
The off-delay timer operation will keep the output energized for a time period after the rung
containing the timer has gone false.
Input
Output
Figure 2.2 OFF-delay timer operation
Retentive Timer:
A retentive timer accumulates time whenever the device receives power, and it maintains the
current time should power be removed from the device. Once the device accumulates time
equal to its pre-set value the contacts of the device change state.
Input
Output
Figure 2.3 Retentive timer operation
We will use on-delay timer in fallowing lab.
Counters:
A counter is also a special kind of relay that has a programmable Set Value (SV). When a
counter coil is energized for the first time after a reset, it will load the value of SV-1 into its
count register. From there on, every time the counter coil is energized from OFF to ON, the
counter decrement its count register value by 1. Note that the coil must go through OFF to ON
cycle in order to decrement the counter. If the coil remain energized all the time, the counter
will not decrement. Hence counter is suitable for counting the number of cycles an operation
has gone through.
When the count register hits zero, all the counter's N.O. contacts will be turned ON. These
counter contacts will remain ON regardless of whether the counter's coil is energized or not. To
turn OFF these contacts, you have to reset the counter using a special counter reset function
[RSctr]. In general, there are two different counters – UP-counters and DOWN- counters.
COMSATS University Islamabad
Page 24
LAB # 02 Implementation of Timers and Counters in Trilogy
UP-counters:
The up-counter is incremented by 1 each time the rung containing the counter is energized.
DOWN-counters:
The down-counter decrements by 1 each time the rung containing the counter is energized.
Sensor
PLC
Actuator
Figure 2.4 Control System
Sensors
A sensor (also called detectors) is a device that measures a measurable attribute and converts it
into a (Electrical or Mechanical) signal which can be read by an observer or by an instrument.
There are wide range of sensors available like Light, Motion, Temperature, Magnetic
Fields, Gravity, Humidity, Moisture, Vibration, Pressure, Electrical Fields, Sound, And Other
Physical Aspects Of The External Environment.
Digital Sensor is a modified form of switch, as a switch contain two states i.e. “0” for OFF and
“1” for ON. Same as Digital Sensors how sense a signals of different forms and send signals
accordingly.
Actuators
An actuator is a type of motor for moving or controlling a mechanism or system. It is operated
by a source of energy, usually in the form of an electric current, hydraulic fluid pressure
or pneumatic pressure, and converts that energy into some kind of motion.
There are different types of Actuators available like Solenoids, Wheel and axle and Screw type
Power Supply
A power supply is a device that supplies electrical energy to one or more electric loads. PLC’s
are available in market to work on wide range off power supplies from 5V DC to 220V AC as
per requirement of industry operations. There are two types of Digital I/O exist in PLC.
1. Sinking
2. Sourcing.
COMSATS University Islamabad
Page 25
LAB # 02 Implementation of Timers and Counters in Trilogy
Sinking
At “0” state the I/P pin provides ground as common and make it to state “1” connects the pin to
the +ve terminal of supply. As same for O/P, the pin provides GND as common and when it
switches-on it provides +ve voltage to the output.
Sourcing
Sourcing is inverse to sinking, at “0” state, I/P pin provides +ve as common and to convert it to
state “1” connects it to the GND terminal of supply. For O/P, the pin provides +ve at OFF and
when it switch-on it provides GND as a signal.
(Triangle Research TD100MD PLC is designed on Sourcing Principle)
Tips and Ticks:
Latch Circuit:
Latch circuits use when you need to ON an output from one input and off from the other.
Push-ON/Push-OFF
To control an output in toggle switch manner, using a single push batten to ON and OFF an
output.
DIFU
Differential-up (DIFU) is one of the belt in special function in PLC. When the execution
condition for [DIFU] goes from OFF to ON, the designated output or relay will be turned ON
for one scan time only. After that it will be turned OFF.
COMSATS University Islamabad
Page 26
LAB # 02 Implementation of Timers and Counters in Trilogy
In-Lab:
Lab Tasks
Lab Task No 1a:
Fallowing is the diagram of home water tank filling system. Design the solution for the
system using TD-100MD PLC.
The motor should start filling the tank-1 when the water level of tank-1 goes down to
lower level and stops if the tank-1 file up or tank-2 goes out of water.
states)
(Note: This is a sequential logic Problem, Carefully implement the sensors NO/NC
Sensor-1
Tank-1
Sensor-2
Motor
Tank-2
Sensor-3
Figure 2.5 Water Tank System
COMSATS University Islamabad
Page 27
LAB # 02 Implementation of Timers and Counters in Trilogy
Lab Task No 1b:
Suppose the tank-1 is in vibrant environments that cause false signal generation even the tank1 isn’t empty. To insure the signal is not false the Controller should wait till 5 sec if the signal
is true and then turn the motor ON.
(Note: implementation of timer is same as relay except a Set Value (S.V) should also be given
at time of initialization and 1 S.V unit = 100mSec.)
Lab Task No 2 (Length measurement)
The length measurement system mainly consists of a moving conveyor belt and two types of
sensors. Pieces of bars (shown as green rectangles in Figure 2.8) placed above moving
conveyor belt move from one end to the other. Two types of sensors include Magnetic Sensor
(MAG_SENS) and Photoelectric Sensor (PE_SENS).
Using counters, the system accumulates the total length of bar pieces. The operation of the
program can be summarized as follows:
The magnetic sensor generates the count inputs pulses. These pulses detect passing teeth
(‘dandanay’ in Urdu) on a conveyor drive sprocket. If 10 teeth per foot of conveyor motion
pass the sensor, the accumulated count of the counter would indicate feet in tenths.
The photoelectric sensor monitors a reference point on the conveyor. Light collected at the
reflector gives a hint of presence/absence of the pieces of bar below the reference point. Since
the task is to measure the length of bar pieces, (and not the empty space between bar pieces),
so it means the counter should not count when there is no bar pieces under reference point
(photoelectric sensor-reflector pair is activated). The counter is reset by closing the reset
button.
START
STOP
RESET
Figure 2.6 Length measurement task
COMSATS University Islamabad
Page 28
LAB # 02 Implementation of Timers and Counters in Trilogy
(Note: START, RESET: NO contacts, STOP: NC contacts, photoelectric sensor, Magnetic
sensor: NO contacts)
Hint, the counter should be enabled for counting based on readings of magnetic sensor AND
photoelectric sensor. The PLC wiring diagram for this task is presented in Figure 2.9.
START
X1
STOP
RESET
X2
X3
Y1
PE_SENS LED
MAG_SENS PE_SENS
X4
Y2
X5
Y3
MAG_SENS LED MOTOR_DRV
Figure 2.7 PLC wiring diagram (Lab task 2)
COMSATS University Islamabad
Page 29
LAB # 02 Implementation of Timers and Counters in Trilogy
Result Tables (Fill it and submit to instructor at the end of Lab)
Task-1a: Water level Control System:
Lab Task-1a
Task-1b Water level Control System with delay:
Lab Task-1b
Task-2-Length Measurement System:
Lab Task-2
COMSATS University Islamabad
Page 30
LAB # 02 Implementation of Timers and Counters in Trilogy
Post-Lab



Design water level Sensor
Design Milk Packing System.
Design ladder logic program that will correctly execute the industrial control process in.
The sequence of operation is as follows:
Product in position (limit switch LS1 contacts close).
The start button is pressed and the conveyor motor starts to move the product forward
toward position A (limit switch LS1 contacts open when the actuating arm returns to its normal
position).
The conveyor moves the product forward to position A and stops (position counted by
8pulses of an up-counter).
A time delay of 10s occurs, after which the conveyor starts to move the product to limit
switch LS2 and stops (LS2 contacts close when the actuating arm is hit by the product).
An emergency stop button is used to stop the process at any time.
MOTOR
START
STOP
Figure 2.8 Industrial control task
COMSATS University Islamabad
Page 31
LAB # 02 Implementation of Timers and Counters in Trilogy
Performance
Viva
(10 Marks)
(5 Marks )
Performance
/6
Results
/3
Critical Analysis
/1
Total/15
Comments
Critical Analysis / Conclusion
(By Student about Learning from the Lab)
COMSATS University Islamabad
Page 32
LAB # 03 Implementation of Sequencers in Trilogy
Lab # 3 Implementation of Sequencers in Trilogy
Objectives
To understand the sequencers implementation through ladder logic.
Equipment/Tools required:
PLC(Triangular Research Inc.), PC with TRiLOGI software, connecting leads etc.
Pre Lab
Introduction:
Sequencers in Trilogy:
A sequencer is a highly convenient feature for programming machines or processes which
operate in fixed sequences. These machines operate in fixed, clearly distinguishable step-bystep order, starting from an initial step and progressing to the final step and then restart from
the initial step again. At any moment, there must be a "step counter" to keep track of the
current step number. Every step of the sequence must be accessible and can be used to trigger
some action, such as turning on a motor or solenoid valve, etc.
i-TRiLOGI Version 5 supports up to eight sequencers of 32 steps each. Each sequencer uses
one of the first eight counters (Counter #1 to Counter #8) as its step counter. Any one or all of
the first eight counters can be used as sequencers "Seq1" to "Seq8".No. of Sequencer supported
by PLC Hardware depends upon its Model.
PLC Special Functions:
 Reversible Counter Functions: [DNctr], [Upctr] and [RSctr].
The [DNctr], [UPctr] and [RSctr] functions work together to implement reversible counter
functions on any of the 128 counters supported by i-TRiLOGI.
o Decrement Counter [DNctr]
Each time when the execution condition of a [DNctr] function changes from OFF to ON,
the present value of the designated counter is changed as follow:
o Increment Counter [Upctr]
Each time when the execution condition of an [Upctr] function changes from OFF to ON,
the present value of the designated counter is affected as follow:
o Reset Counter [RSctr]
When the execution condition of this function changes from OFF to ON, the counter will
reset to inactive state. This function is used to reset both a reversible counter and an ordinary
down-counter coil.
COMSATS University Islamabad
Page 33
LAB # 03 Implementation of Sequencers in Trilogy
 Latch Relay Function [Latch].
Latching relay is convenient for keeping the status of an execution condition even if the
condition is subsequently removed. The program elements that are assigned as Latching Relays
will remain ON once they are energized. Only Relays and Outputs may be assigned as
Latching Relays.
 Clear Relay Function [Clear]
To de-energize a program element that has been latched by the [Latch] function, it is
necessary to use [Clear] function.
 Interlock [ILock].
The "Interlock" [ILock] and "Interlock Off" [ILoff] functions work together to control an
entire section of ladder circuits. If the execution condition of an [ILock] function is ON, the
program will be executed as normal. If the execution condition of [ILock] is OFF, the program
elements between the [ILock] and [ILoff] will behave as follow:
a. all output coils are turned OFF.
b. all timers are reset to inactive.
c. all counters retain their present values.
d. Latched relays by [Latch] function are not affected.
e. [dDIFU] and [dDIFD] functions are not executed.all other functions are not executed.
 Master Reset.
An ON condition to this function clears all mailbox inputs, outputs, relays, timers and
counter bits to OFF, resets all timers counters/sequencers to inactive state, and clears all
latched relay bits. All integer variables will be cleared to zeros and all string variables will be
assigned to empty string.
In-Lab
Lab Tasks
Lab Task 1:
Using TRiLOGI software, control 4 LEDs in Sequence of 1 sec. i.e Each LED glow for 1 Sec
after one another.
COMSATS University Islamabad
Page 34
LAB # 03 Implementation of Sequencers in Trilogy
STEPS:
1. First define Inputs, Outputs and Relay labels on paper and sketch flow chart. This
diagram may look as shown below.
Start
Puls
LED
LED
LED
LED
Figure 3.1 Flow Chart
2.
3.
4.
5.
6.
Define Inputs, Outputs, Relay and Sequencer in TRiLOGI.
Write “Seq1” in the counter table Row#1 and set its preset value to 4, for 4 LEDs.
Define I/P “start” and O/P “LED_ 1, LED_2, LED_3, LED_4”.
Define Relay as per Requirement. (System is ready to build.)
Insert Input “Start” and Append “1 second clock” in series with “start” from the
special bits.
Figure 3.2 Inserting 1Sec. Clock
7. To insert Seqnecer1, Press [Fn]g or Press 9.
8. Select [AVseq] from list and then Select Sequencer 1.
Figure 3.3 Inserting Sequencer
9. In Next Rung (Circuit #2) Select input then Special Bits and then SeqN:x. know
select sequencer number and specify the step number.
COMSATS University Islamabad
Page 35
LAB # 03 Implementation of Sequencers in Trilogy
Figure 3.4 Inserting SeqN:x
10. Insert Output i.e. LED_1
11. Repeat Step 9 and 10 for rest of 3 outputs. The program may look like as figure
3.5
Figure 3.5 Resultant Circuit
12. Compile Simulate and burn on PLC.
Lab Task No 2:
Create the following output pattern using sequencers.
Out1
Out2
COMSATS University Islamabad
Out3
Out4
Out5
Page 36
LAB # 03 Implementation of Sequencers in Trilogy
Lab Task No 3:
Design Full Step Stepper Motor Controller for forward and reverse Drive.
Table 3.5 Full stepping truth table
Step
no.
in
forward direction
Outputs
1
2
3
4
1
1
1
0
0
2
0
1
1
0
3
0
0
1
1
4
1
0
0
1
Result Tables (Fill it and submit to instructor at the end of Lab)
Task-2: Running Pattern:
Lab Task-2
COMSATS University Islamabad
Page 37
LAB # 03 Implementation of Sequencers in Trilogy
Task-3: Stepper Motor Controller:
Post-Lab:
Task 01:


Implement 3 bit ring counter which counts from 000, 001, ……. 111 using sequencers.
Implement two way traffic signal (Red-30s, Green-30s, Yellow-5s)
(Red2)
(Red1)
(Yellow2)
(Yellow1)
(Green2)
(Green1)
Left
lane
COMSATS University Islamabad
Right
lane
Page 38
LAB # 03 Implementation of Sequencers in Trilogy
Performance
Viva
(10 Marks)
(5 Marks )
Performance
/6
Results
/3
Critical Analysis
/1
Total/15
Comments
Critical Analysis / Conclusion
(By Student about Learning from the Lab)
COMSATS University Islamabad
Page 39
LAB # 04 Introduction to MATLAB and Simulink, Solution of Differential Equations Using MATLAB and
Simulink and Transfer Function Based Modelling
Lab # 4 Introduction to MATLAB and Simulink,
Solution of Differential Equations Using MATLAB
and Simulink and Transfer Function Based
Modelling
Objectives
To evaluate and analyse transfer functions in MATLAB and to implement control systems in
MATLAB using Simulink.
Pre Lab
Introduction:
Typically, control engineers begin by developing a mathematical description of the dynamic
system that they want to control. The system to be controlled is called a plant. This plant is
normally represented in some form for controlling it.
MATLAB Functions:
Important MATLAB functions used for building linear models include:
sys = tf(num,den) % Transfer function
sys = zpk(z,p,k) % Zero/pole/gain
sys = ss(a,b,c,d) % State-space
sys = frd(response,frequencies) % Frequency response data
% is used to write comments in MATLAB.
Explore these functions from help of the MATLAB and construct your models.
COMSATS University Islamabad
Page 40
LAB # 04 Introduction to MATLAB and Simulink, Solution of Differential Equations Using MATLAB and
Simulink and Transfer Function Based Modelling
Linear Model Representations:
Normally four types of representations are used in MATLAB for representing linear models.
These are presented here with the examples:
Transfer function representation
A continuous-time Single Input Single Output (SISO) transfer function in polynomial form is
given by:
where s is the Laplace variable, N(s) is the numerator polynomial, and D(s) is
the denominator polynomial.
Create a SISO transfer function model in polynomial form using:
G = tf(num,den)
where num and den are row vectors of coefficients of the polynomials N(s)
and D(s), respectively. These row vectors are ordered in descending powers
of s. G is a tf model object.
For example, create the transfer function G(s) = s/(s2 + 2s + 1), using:
G = tf([1 0],[1 2 1]);
Alternatively, you can specify the same tf model as a rational expression in
the Laplace variable s:
COMSATS University Islamabad
Page 41
LAB # 04 Introduction to MATLAB and Simulink, Solution of Differential Equations Using MATLAB and
Simulink and Transfer Function Based Modelling
s = tf('s');
G = s/(s^2 + 2*s + 1);
% Define the Laplace variable s
% Specify rational expression in s
Zero Pole gain models
A continuous-time SISO transfer function in factorized (zero-pole-gain) form
is given by:
where:
,
• k is a real- or complex-valued scalar gain.
• z1 ,..., zm are the real or complex conjugate pairs of zeros of the transfer
function G(s) — roots of the numerator polynomial N(s).
• p1 ,..., pn are the real or complex conjugate pairs of poles of the transfer
function G(s) — roots of the denominator polynomial D(s).
Create transfer functions in factorized (zpk) form using:
G = zpk(z, p, k)
where z, p, and k are row vectors of zeroes z1 ,..., zm, poles p1 ,..., pn, and gain k
respectively.
For example, the transfer function G(s) = s/(s2 + 2s + 1) in factorized form
is given by:
COMSATS University Islamabad
Page 42
LAB # 04 Introduction to MATLAB and Simulink, Solution of Differential Equations Using MATLAB and
Simulink and Transfer Function Based Modelling
This transfer function has a zero at s = 0, two poles at s = –1, and a gain of 1.
Create a zpk model of this transfer function using:
G = zpk([0],[-1 -1],[1]);
Alternatively, you can specify the same zpk model as a rational expression in
the Laplace variable s:
s = zpk('s');
% Define the Laplace variable s
G = s/(s+1)^2;
% Specify the rational expression
State Space representation
𝑑𝑑𝑑𝑑
= 𝐴𝐴𝐴𝐴 + 𝐵𝐵𝐵𝐵
𝑑𝑑𝑑𝑑
𝑦𝑦 = 𝐶𝐶𝐶𝐶 + 𝐷𝐷𝐷𝐷
Where
A, B, C, and D are matrices of appropriate dimensions,
x is the state vector ,
u and y are the input and output vectors respectively.
Note: State space representation will be discussed further in experiments 13.
COMSATS University Islamabad
Page 43
LAB # 04 Introduction to MATLAB and Simulink, Solution of Differential Equations Using MATLAB and
Simulink and Transfer Function Based Modelling
Frequency Response Data (FRD) models
It consists of sampled measurements of a system’s frequency response. e.g you can
store experimentally collected frequency response data in an FRD model.
Other helpful commands
Basic computational unit is the matrix:
>> t = [1 2 3; 4 5 6; 7 8 9]
MATLAB uses a colon notation to generate a row vector:
>> t = 0: 0.1:1
Convolution is being used for the multiplication of two polynomials:
>> conv([1 0],[1 1])
,
ans =
1
1
0
Convertion between partial fraction expansion and polynomial coefficients:
>>[r,p,k]=residue(num,den)
Laplace and Inverse Laplace transforms:
>>syms t
>>f = t^4 % As an example
>>laplace(f) % Laplace
>>syms s
>>f = 1/s^2
>>ilaplace(f) % Inverse laplace
COMSATS University Islamabad
Page 44
LAB # 04 Introduction to MATLAB and Simulink, Solution of Differential Equations Using MATLAB and
Simulink and Transfer Function Based Modelling
Introduction to Simulink:
Modelling in Simulink is based on a six steps mentioned below:
1. Defining the system.
2. Identifying system components.
3. Modeling the system with equations.
4. Building the Simulink block diagram.
5. Running the simulation.
6. Validating the simulation results.
The first three steps are performed outside the
Simulink prior to
building the model. To let you grasp the concept well, an example is stated
below.
Example
Figure 4.1 RLC circuit
The corresponding mathematical equation is
or in s domain
𝑑𝑑 2 𝑉𝑉𝑉𝑉
𝑑𝑑𝑑𝑑𝑑𝑑
= −4
− 3𝑉𝑉𝑉𝑉 + 3𝑢𝑢(𝑡𝑡)
2
𝑑𝑑𝑡𝑡
𝑑𝑑𝑑𝑑
v(s)/U(s) =3 / s2+4s+3
The corresponding Simulink model is illustrated in Figure 4.2.
COMSATS University Islamabad
Page 45
LAB # 04 Introduction to MATLAB and Simulink, Solution of Differential Equations Using MATLAB and
Simulink and Transfer Function Based Modelling
Figure 4.2 Simulink model of RLC circuit
Pre Lab Tasks
(Attach extra A4 White page if needed)
1. Implement above example in SIMULINK
2. Find Response of the system for following Inputs;
a. Unit Step
b. Unit Impulse
c. Ramp
d. Sinusoidal
SIMULINK Model
COMSATS University Islamabad
Page 46
LAB # 04 Introduction to MATLAB and Simulink, Solution of Differential Equations Using MATLAB and
Simulink and Transfer Function Based Modelling
Responses
COMSATS University Islamabad
Page 47
LAB # 04 Introduction to MATLAB and Simulink, Solution of Differential Equations Using MATLAB and
Simulink and Transfer Function Based Modelling
Lab Tasks
Lab Task No 1:
𝐆𝐆(𝐬𝐬) =
𝒔𝒔 + 𝟎𝟎. 𝟐𝟐𝟐𝟐
𝒔𝒔(𝒔𝒔 + 𝟏𝟏)(𝒔𝒔 + 𝟐𝟐)(𝒔𝒔 + 𝟑𝟑)
Considering G(s), prove that tf2zp() and zp2tf() are inverse of each other. Also, prove that
laplace() and illaplace() exhibits the same property.
Solution
MATLAB Code
COMSATS University Islamabad
Page 48
LAB # 04 Introduction to MATLAB and Simulink, Solution of Differential Equations Using MATLAB and
Simulink and Transfer Function Based Modelling
Results
COMSATS University Islamabad
Page 49
LAB # 04 Introduction to MATLAB and Simulink, Solution of Differential Equations Using MATLAB and
Simulink and Transfer Function Based Modelling
Lab Task No 2:
Find inverse Laplace transform f(t) & hence find inverse from partial fraction form (use
MATLAB to compute the residues). Where
F(s) =
Solution
𝑠𝑠 5 + 8𝑠𝑠 4 + 23𝑠𝑠 3 + 35𝑠𝑠 2 + 28𝑠𝑠 + 3
s 3 + 6s 2 + 8s
MATLAB Code
COMSATS University Islamabad
Page 50
LAB # 04 Introduction to MATLAB and Simulink, Solution of Differential Equations Using MATLAB and
Simulink and Transfer Function Based Modelling
Results
Lab Task No 3:
Consider the following RLC circuit (Fig 4.3) and take values of your choice. Make a
mathematical equation of this circuit (taking your own defined values) and then make its
SIMULINK block diagram.
Figure 4.3 RLC circuit for Task 3
COMSATS University Islamabad
Page 51
LAB # 04 Introduction to MATLAB and Simulink, Solution of Differential Equations Using MATLAB and
Simulink and Transfer Function Based Modelling
Solution
Mathematical Model
SIMULINK Diagram
COMSATS University Islamabad
Page 52
LAB # 04 Introduction to MATLAB and Simulink, Solution of Differential Equations Using MATLAB and
Simulink and Transfer Function Based Modelling
Post Lab Tasks
Task 01
Solve the differential equation to compute x(t)
X’’ + 2X’ + 10X = t2
Task 02
Use the mathematical model , computed in In-lab task 02, and find its state space
representation using MATLAB.
MATLAB Code
MATLAB Results
COMSATS University Islamabad
Page 53
LAB # 04 Introduction to MATLAB and Simulink, Solution of Differential Equations Using MATLAB and
Simulink and Transfer Function Based Modelling
Performance
Viva
(10 Marks)
(5 Marks )
Performance
/6
Results
/3
Critical Analysis
/1
Total/15
Comments
Critical Analysis / Conclusion
(By Student about Learning from the Lab)
COMSATS University Islamabad
Page 54
LAB # 05 Modeling of Translational Mechanical System and to Calculate Its Various Responses
Lab # 5 Modeling of Translational Mechanical
System and to Calculate Its Various Responses
Objectives
To demonstrate the key components of a translational mechanical system, model the system
and finally to obtain various responses using computation and observe it on Rectilinear plant.
Equipment/Tools required:
Rectilinear Plant with controller interfaced with PC
Pre Lab
Introduction:
The modelling elements of a translational mechanical system include mass, spring and
damper. Mass is an element which resists the motion due to inertia. According to Newton’s
law,
law,
Spring is an element which opposes motion due to elasticity. According to Hooke’s
Where K is Spring constant or stiffness of spring.
Damping is an element which opposes motion due to friction. If the friction is viscous
friction, then the frictional force is proportional to velocity, i.e.
Where B is damping coefficient.
These three modelling elements are symbolized in Figure 5.*.
COMSATS University Islamabad
Page 55
LAB # 05 Modeling of Translational Mechanical System and to Calculate Its Various Responses
(a)
(b)
(c)
Figure 5.* Modelling elements (a)Mass (b)Spring (b)Damper
Considering a single mass-spring-damper system (Figure 5.1) where an external force
‘f’ is applied on the mass ‘M’.
Figure 5.1 Single Mass-Spring-Damper system
The resistive forces aroused from mass, spring and damper are given be equations
mentioned above. According to D‘Alembert‘s principle, for any body, the algebraic sum of
externally applied forces and the forces opposing the motion in any given direction is zero.
Thus,
External force = Resistive forces
Taking Laplace Transformation on both sides and then re-arranging
If velocity is chosen as output variable instead of position variable
COMSATS University Islamabad
Page 56
LAB # 05 Modeling of Translational Mechanical System and to Calculate Its Various Responses
Figure 5.2 Test inputs used in control systems
This experiment is intended to demonstrate the modelling and response observation of
the rectilinear plant actuated with various inputs (Figure 5.2). The experimental rectilinear
control system is comprised of the three subsystems shown in Figure 5.3.
Figure 5.3 Experimental control systems
COMSATS University Islamabad
Page 57
LAB # 05 Modeling of Translational Mechanical System and to Calculate Its Various Responses
The first of these is the electromechanical plant (Figure 5.4) which consists of the
spring/mass mechanism, its actuator and sensors. The design features a brushless DC servo
motor, high resolution encoders, adjustable masses, and reconfigurable plant type.
Figure 5.4 Electromechanical plant
The second subsystem is the real-time controller unit which contains the Digital Signal
Processor (DSP) based real-time controller, servo/actuator interfaces, servo amplifier, and
auxiliary power supplies. The DSP is capable of executing control laws at high sampling rates
allowing the implementation to be modelled as being continuous or discrete in time. The
controller also interprets trajectory commands and supports such functions as data acquisition,
trajectory generation, and system health and safety checks. A logic gate array performs motor
commutation and encoder pulse decoding. Two optional auxiliary Digital-to-Analog
Converters (DAC's) provide for real-time analog signal measurement. This controller is
representative of modern industrial control implementation.
The third subsystem is the executive program which runs on a PC under the DOS or
Windows™ operating system. This menu-driven program is the user's interface to the system
and supports controller specification, trajectory definition, data acquisition, plotting, system
execution commands, and more. Controllers may assume a broad range of selectable block
diagram topologies and dynamic order. The interface supports an assortment of features which
provide a friendly yet powerful experimental environment.
The top and side views of the rectilinear plant are illustrated in Figure 5.5
COMSATS University Islamabad
Page 58
LAB # 05 Modeling of Translational Mechanical System and to Calculate Its Various Responses
Figure 5.5 Rectilinear apparatus
Lab Tasks
Calculations:
1. Express the system shown in Figure 5.5 using modelling symbols. Your schematics
should look like as shown in Figure 5.6.
Figure 5.6 Mass-spring-damper system for the experiment
2. Make mathematical model of the system using laws of Electronics, Mechanics and
Physics (Single Mass-Spring-Damper system has been modelled as an example).
3. Calculate the transfer functions X1(s)/F(s), X2(s)/F(s) and X3(s)/F(s).
4. Calculate impulse, step, ramp, parabolic and sinusoidal responses by taking relevant
values of F(s).
COMSATS University Islamabad
Page 59
LAB # 05 Modeling of Translational Mechanical System and to Calculate Its Various Responses
5. Using Inverse Laplace, compute time domain equivalents of the responses of Step 4.
You can also use MATLAB.
6. Plot the time domain results obtained in Step 5.
Hardware:
7. Make sure that the equipment is connected as shown in Figure 5.7.
Figure 5.7 Overall rectilinear system
8. Secure two 500g masses each on the first, second and third mass carriages.
9. Make sure that the locking screws do not constrain the linear motion of the mechanism.
10. From PC, open the “ECP” software.
11. Reset the controller using ‘Utility’ tab. You will see Encoder data as zero now.
Figure 5.8 Controller reset utility
COMSATS University Islamabad
Page 60
LAB # 05 Modeling of Translational Mechanical System and to Calculate Its Various Responses
12. Setup Control algorithm
Figure 5.9 Control algorithm setup
You can change controller gains by clicking on “Setup Algorithm” (Figure 5.10)
Figure 5.10 Setting control parameters
COMSATS University Islamabad
Page 61
LAB # 05 Modeling of Translational Mechanical System and to Calculate Its Various Responses
Click OK and then finally click on “Implement Algorithm” followed by OK
13. Select appropriate input from the Command->Trajectory
Figure 5.11 Input selection menu
Select an input and then click on “Setup” to set values of various parameters of the
input (Figure 5.12)
Figure 5.12 Changing input parameters
14. Execute the selected trajectory by Command tab -> Execute (Figure 5.13)
COMSATS University Islamabad
Page 62
LAB # 05 Modeling of Translational Mechanical System and to Calculate Its Various Responses
Figure 5.13 Executing trajectory
15. After clicking on Run, the trajectory is executed and the data samples are collected
(Figure 5.14)
Figure 5.14 Data samples uploaded
16. For plot, Plotting tab->Setup plot (Figure 5.15)
COMSATS University Islamabad
Page 63
LAB # 05 Modeling of Translational Mechanical System and to Calculate Its Various Responses
Figure 5.15 Plotting setup
17. Selecting Encoder 3 (for example) and then clicking on “Plot Data”, you should see
plot similar to that of Figureure 5.16.
Figure 5.16 Step response (Sample plot)
Post Lab Tasks
Task 01
Figure 1: 3 DOF Plant
COMSATS University Islamabad
Page 64
LAB # 05 Modeling of Translational Mechanical System and to Calculate Its Various Responses
i)
Consider k1 = 200, k2 = 400, k3 = 400, k4 = 0 and C1 = C2 = 0, c3=0.5. Find
following Transfer Functions;
ii)
Find Step response;
Calculations
COMSATS University Islamabad
Page 65
LAB # 05 Modeling of Translational Mechanical System and to Calculate Its Various Responses
MATLAB Results
COMSATS University Islamabad
Page 66
LAB # 05 Modeling of Translational Mechanical System and to Calculate Its Various Responses
Performance
Viva
(10 Marks)
(5 Marks )
Performance
/6
Results
/3
Critical Analysis
/1
Total/15
Comments
Critical Analysis / Conclusion
(By Student about Learning from the Lab)
COMSATS University Islamabad
Page 67
LAB # 06 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems
Lab # 6 Introduction to “lsim” and Time Response of
1st and 2nd Order Systems
Objectives
•
•
•
To implement transfer function,
Introduction to LSIM command,
To evaluate and analyse responses of first and second order systems.
Pre Lab
First Order System:
First order systems are those which, when modelled by differential equation have only
first order derivative i.e no higher order derivatives. In this lab, a number of MATLAB
functions are used to analyze these systems and plot their responses. The basic functions and
their representation are mentioned below:
For transfer function:
To represent a system in MATLAB by its transfer function we can use the function
TF(num,den). In num we define the coefficients of the numerator terms of transfer function.
In den we define the coefficients of the denominator terms of transfer function.
>>sys_tf = TF (num, den); % where num and den are numerator and
% denominator matrices respectively and
% ‘tf’ calculates transfer function.
For example consider a transfer function given by:
2 s^2 + 3 s + 2
H = ----------------------5 s^3 + 4 s^2 + 7 s + 1
COMSATS University Islamabad
Page 68
LAB # 06 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems
The above transfer function can be implemented in MATLAB as
sys_tf= TF([2 3 2],[5 4 7 1);
For creating time matrix:
The function LINSPACE can be used for creating a linearly spaced vector. The general format
of this function is given below.
X=LINSPACE(X1, X2, N) generates N points between X1 and X2.
Where, N can be found as
𝑁𝑁 = ((𝐹𝐹𝐹𝐹𝐹𝐹𝐹𝐹𝐹𝐹 𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣 − 𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼 𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣)/ 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠_𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠) + 1
This function can be used for declaring time axis. For example if you want to plot some result
over the time range of 0 to 10 seconds and you want step size to be 0.1 second then you could
declare time axis as.
>>t = linspace (0, 10,101)
Gives t=0 0.1 0.2 ….. 9.9 10
LSIM command:
Simulate time response of LTI models to arbitrary inputs. The general syntax is
>>[y, t] = lsim (sys, u, t)
Where
sys can be transfer function or state space representation of system,
u is the input signal which is a function of time,
COMSATS University Islamabad
Page 69
LAB # 06 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems
t is the time axis that can be defined using linspace. It contains the values of
time at which output is to be calculated.
The function gives two outputs (y and t) where y is the output matrix with time t. You
can use plot(y,t) to plot the response.
Another variant of lsim command is
>>[y, t, x] = lsim (sys_ss, u, t, x0)
This has another input, initial condition (x0) and an additional output (x) having states. It is
applicable for state space representation only.
Step response:
To find the step response of a system, step function can be used. The general syntax is:
>>[y, t] = step (sys)
Where sys is transfer function.
returns the step response y and the time vector t used for simulation.
The response can then be plotted using plot command as:
>> plot(y,t)
If only plot of step response is required then step function can be used as:
>>step(sys)
Natural response:
The impulse response of a system can be found using impulse function. The general syntax is:
>>[y, t] = impulse (sys)
Where sys is transfer function.
returns the impulse response y and the time vector t used for simulation.
The response can then be plotted using plot command as:
>> plot(y,t)
COMSATS University Islamabad
Page 70
LAB # 06 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems
If only plot of impulse response is required, then impulse function can be used as:
>>impulse(sys)
Second Order System:
A second order system can be represented generally as:
𝑴𝑴𝒅𝒅𝟐𝟐 𝒚𝒚(𝒕𝒕)/ 𝒅𝒅𝒕𝒕𝟐𝟐 + 𝑩𝑩 𝒅𝒅𝒅𝒅(𝒕𝒕)/𝒅𝒅𝒅𝒅 + 𝑲𝑲𝑲𝑲(𝒕𝒕) = 𝒇𝒇(𝒕𝒕)
If we define ωn = (K/M)1/2 and ϛ = B/2(KM)1/2
Then the general expression for the transfer function of a second order system(assuming initial
conditions to be zero) is:
The time domain expression for the response of second order system to a step input is:
For impulse response the time domain expression is.
ς = dimensionless damping ratio
ωn = the natural frequency
COMSATS University Islamabad
Page 71
LAB # 06 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems
Standard Performance measures:
Performance measures are usually defined in terms of the step response of a system as shown
in Figurer below.
Figure. 6.2 Typical response of 2nd Order System
The key characteristics of the second order response are:
•
•
•
•
Swiftness of the response is measured by rise time Tr , and peak time Tp.
Steady-state error: ess
Percentage overshoot %OS.(maximum rise over steady state value)
Settling time: Ts. (time required for response to settle within 2% of final value)
All the above mentioned parameters can be determined from the damping ratio and natural
frequency as can be seen from the mathematical expressions given below.
For second order system, we seek T s for which the response remains within 2% of the final
value. This occurs approximately when:
e −ζω nTs < 0.02 or ζω nTs ≅ 4
Therefore :
Ts ≅ 4τ = 4/ζωn
The expression for peak time( the time at which the response is maximum) is:
Tp = π/ ωn(1− ς2)1/2
COMSATS University Islamabad
Page 72
LAB # 06 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems
Percentage overshoot can be found by:
P.O. = 100e −ζπ /(1−ς 2)^1/2
In this lab, a number of MATLAB functions are used to analyze systems and
plot their responses.
The basic functions and their representation are mentioned below:
POLE
POLE computes the poles of LTI models.
>> pole (sys)
Where sys can be transfer function or state space. This command gives poles in a vector form.
STEP
STEP computes the step response of an LTI system and returns time and magnitudes in y and t
respectively.
>>[y, t] = step (sys)
Where sys can be transfer function or state space.
IMPULSE
the impulse response of the LTI model SYS (created
with either TF, ZPK, or SS).
IMPULSE calculates
>>[y, t] = impulse (sys)
COMSATS University Islamabad
Page 73
LAB # 06 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems
DAMP
For calculating natural frequency and damping of LTI model
[Wn, Z, P] = DAMP (SYS)
Returns vectors Wn ,Z and P containing the natural frequencies and damping factors of the
LTI model SYS.
COMSATS University Islamabad
Page 74
LAB # 06 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems
Lab Tasks
Lab Task No 1:
The standard form of a first order system is
𝐺𝐺(𝑠𝑠) =
1
𝑇𝑇𝑇𝑇 + 1
Where T is the time constant of the system. For this transfer function,
a) Plot step response using step function for T=1, 2 and 3 seconds.
b) Comment the effect of time constant on the speed of the system response.
c) Use ‘lsim’ for generating step response and compare the results with the ones
calculated in part a.
MATLAB Code
COMSATS University Islamabad
Page 75
LAB # 06 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems
Results and Plots
Lab Task No 2:
Consider the transfer function,
𝐺𝐺(𝑠𝑠) =
1
𝑠𝑠 + 1
For this transfer function,
a) Simulate and give response using ‘lsim’ function with input u=sin(t) and
u=exp(-t).
b) Plot impulse and step response using MATLAB and SIMULINK and compare
results of the two.
COMSATS University Islamabad
Page 76
LAB # 06 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems
MATLAB Code
Results and Plots
COMSATS University Islamabad
Page 77
LAB # 06 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems
Lab Task No 3:
For wn =10rads/sec, plot the step response for general second order system for zeta=0, 0.7, 1,
1.5, and compare the four systems.
MATLAB Code
Results and Plots
COMSATS University Islamabad
Page 78
LAB # 06 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems
Lab Task No 4:
For the four systems given in task 1 plot their poles and identify the effect of pole locations on
the settling time of the system.
MATLAB Code
Comments
COMSATS University Islamabad
Page 79
LAB # 06 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems
Lab Task No 5:
Plot %OS vs. damping ratio and analyze the plot carefully.
MATLAB Code
Results and Plots
COMSATS University Islamabad
Page 80
LAB # 06 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems
Post Lab Tasks
Lab Task No 1:
Find the natural response of the following first order system. Assuming v(0)=10.
Figure. 6.1 Schematic diagram of RC circuit
Hint: The circuit equation for the circuit is RC dv/dt +v = 0
MATLAB Code / SIMULINK Diagram
COMSATS University Islamabad
Page 81
LAB # 06 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems
Lab Task No 2:
For the system given below, find its unit step response and impulse response.
Figure 6.3 RLC circuit for Task 4
Assuming R= 1 Ohm, L= 1mH and C=1uF
Find the values of %OS, Settling Time and peak time by calculations and from the plot of step
response and verify that the two are same.
MATLAB Code
COMSATS University Islamabad
Page 82
LAB # 06 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems
Results and Plots
COMSATS University Islamabad
Page 83
LAB # 06 Introduction to “lsim” and Time Response of 1st and 2nd Order Systems
Performance
Viva
(10 Marks)
(5 Marks )
Performance
/6
Results
/3
Critical Analysis
/1
Total/15
Comments
Critical Analysis / Conclusion
(By Student about Learning from the Lab)
COMSATS University Islamabad
Page 84
LAB # 07 Block Diagram Reduction and Analysis and Design of Feedback Systems
Lab # 7 Block Diagram Reduction and Analysis and
Design of Feedback Systems
Objectives
To reduce block diagrams using MATLAB functions and plot the results. Verification of the
results using Simulink. To design controller system gain for obtaining specified poles.
Pre Lab
Introduction:
Given below is brief description of new MATLAB functions used in this lab.
SERIES:
>>sys = SERIES(sys1,sys2)
Series connects two LTI models in series. This function accepts any type of LTI model.
The two systems must be either both continuous or both discrete with identical sample time.
Static gains are neutral and can be specified as regular matrices.
PARALLEL:
>>sys = parallel(sys1,sys2)
Parallel connects two LTI models in parallel. This function accepts any type of LTI
model. The two systems must be either both continuous or both discrete with identical sample
time. Static gains are neutral and can be specified as regular matrices.
COMSATS University Islamabad
Page 85
LAB # 07 Block Diagram Reduction and Analysis and Design of Feedback Systems
FEEDBACK:
>>sys = FEEDBACK(sys1,sys2,±1)
Feedback connects two systems in feedback order, where sys1 is the forward path gain,
sys2 is the feedback path gain and ±1 specifies positive and negative feedback respectively.
CONNECT:
Used for block-diagram interconnections of LTI models.
CONNECT constructs the aggregate model for a given block diagram interconnection of LTI
models. You can specify the block diagram connectivity in two ways. We will consider one
approach i.e. Name-based.
Name-based interconnection
In this approach, you name the input and output signals of all LTI blocks SYS1, SYS2,... in
the block diagram, including the summation blocks. The aggregate model SYS is then built by
SYS = CONNECT(SYS1,SYS2,...,INPUTS,OUTPUTS)
Where
INPUTS and OUTPUTS are the names of the block diagram external I/Os
(specified as strings or cell arrays of strings).
COMSATS University Islamabad
Page 86
LAB # 07 Block Diagram Reduction and Analysis and Design of Feedback Systems
Pre Lab Tasks
Task 1
Implement the following example in MATLAB
Given SISO LTI models C and G, you can construct the closed-loop transfer T from r to y
using CONNECT function.
e
u
r --->O-->[ C ]---[ G ]-+---> y
- |
|
+<--------------------+
+
C.InputName = 'e'; C.OutputName = 'u';
G.InputName = 'u'; G.OutputName = 'y';
Sum = sumblk('e','r','y','+-');
T = CONNECT (G,C,Sum,'r','y')
MATLAB Code
Results
COMSATS University Islamabad
Page 87
LAB # 07 Block Diagram Reduction and Analysis and Design of Feedback Systems
Lab Tasks
Lab Task 1:
For the following Figures find the transfer function (C/R) using series, parallel and feedback
functions and plot unit step response for the system. Verify the results using Simulink.
i.
Figure. 7.1 Series block diagram reduction
MATLAB Code
COMSATS University Islamabad
Page 88
LAB # 07 Block Diagram Reduction and Analysis and Design of Feedback Systems
Results
ii.
Figure. 7.2 Parallel block diagram reduction
MATLAB Code
COMSATS University Islamabad
Page 89
LAB # 07 Block Diagram Reduction and Analysis and Design of Feedback Systems
Results
iii.
Figure. 7.3 Feedback block diagram reduction
COMSATS University Islamabad
Page 90
LAB # 07 Block Diagram Reduction and Analysis and Design of Feedback Systems
MATLAB Code
Results
COMSATS University Islamabad
Page 91
LAB # 07 Block Diagram Reduction and Analysis and Design of Feedback Systems
Lab Task 2:
Using connect functions find the equivalent transfer function for block diagram in Figure 7.4
and Figure 7.5. Plot the unit step response and verify using Simulink.
Gi(s)=1/(s+1)
i.
Figure. 7.4 Block diagram reduction Task 2
MATLAB Code
COMSATS University Islamabad
Page 92
LAB # 07 Block Diagram Reduction and Analysis and Design of Feedback Systems
Results
COMSATS University Islamabad
Page 93
LAB # 07 Block Diagram Reduction and Analysis and Design of Feedback Systems
ii.
Figure. 7.5 Block diagram reduction Task 2
MATLAB Code
COMSATS University Islamabad
Page 94
LAB # 07 Block Diagram Reduction and Analysis and Design of Feedback Systems
Results and Plots
Post Lab Tasks
Lab Task No 1:
For the following system consider: Plant=Motor=1/[s(s+6)] and controller=k, design a closed
loop system with poles at –3±3j. Compare the motor system response before and after
implementation of controller
Figure. 7.6 System for Task 3
Hint: According to the feedback analysis, to get poles at
COMSATS University Islamabad
–𝑎𝑎
2
±
−𝑎𝑎
2
𝑎𝑎2
j, we need to set K =
2
Page 95
LAB # 07 Block Diagram Reduction and Analysis and Design of Feedback Systems
Calculation and MATLAB Code
Results and Plots
COMSATS University Islamabad
Page 96
LAB # 07 Block Diagram Reduction and Analysis and Design of Feedback Systems
Performance
Viva
(10 Marks)
(5 Marks )
Performance
/6
Results
/3
Critical Analysis
/1
Total/15
Comments
Critical Analysis / Conclusion
(By Student about Learning from the Lab)
COMSATS University Islamabad
Page 97
LAB # 08 Effect of Zeros on 2nd Order Systems Response, Pole Zero Cancellation and Stability Analysis
via Routh Hurwitz Criterion.
Lab # 8 Effect of Zeros on 2nd Order Systems
Response, Pole Zero Cancellation and Stability
Analysis via Routh Hurwitz Criterion.
Objectives
•
•
To observe the effect of zeros on responses of second order systems in time domain and
to analyze situations in which pole-zero cancellation is possible.
To design controller system gain for obtaining specific characteristics. Using
MATLAB, design controllers for stable systems response and plot the results.
Pre Lab
Introduction:
Stable systems without dead time, which are described by the transfer function
and do not have zeros in the right half plane, are called minimum phase systems.
If a transfer function has poles and/or zeros in the right half plane then this system shows
non-minimum phase behaviour.
Given below is brief description of new MATLAB functions used in this lab.
ZERO:
>>[z, k]= ZERO (sys)
Where
sys can be transfer function or state space,
‘z’ output has zeros vector,
‘k’ has zero’s associated gain vector.
COMSATS University Islamabad
Page 98
LAB # 08 Effect of Zeros on 2nd Order Systems Response, Pole Zero Cancellation and Stability Analysis
via Routh Hurwitz Criterion.
PZMAP:
where
>> PZMAP(SYS)
SYS can be transfer function or state space,
PZMAP(SYS) computes the poles and (transmission) zeros of the
LTI model SYS and plots them in the complex plane. The poles are plotted
zeros are plotted as o's.
as x's and the
Routh–Hurwitz:
The Routh–Hurwitz stability criterion is a necessary and sufficient method to
establish the stability of a single-input, single-output (SISO), linear time invariant (LTI)
control system. More generally, given a polynomial, some calculations using only the
coefficients of that polynomial can lead to the conclusion that it is not stable. The criterion
establishes a systematic way to show that the linearized equations of motion of a system have
only stable solutions exp (pt), that is where all p have negative real parts. It can be performed
using either polynomial divisions or determinant calculus.
Routh–Hurwitz criterion for second, third, and fourth-order polynomials:
In the following, we assume the coefficient of the highest order (e.g. a_2 in a second order
polynomial) to be positive. If necessary, this can always be achieved by multiplication of the
polynomial with ‘-1’.
•
For a second-order polynomial,
, all the roots are
in the left half plane (and the system with characteristic equation
the coefficients satisfy
•
•
.
For a third-order polynomial
coefficients must satisfy
For a fourth-order polynomial
all the coefficients must satisfy :
COMSATS University Islamabad
is stable) if all
, all the
, and
,
Page 99
LAB # 08 Effect of Zeros on 2nd Order Systems Response, Pole Zero Cancellation and Stability Analysis
via Routh Hurwitz Criterion.
Higher-order example
A tabular method can be used to determine the stability when the roots of a higher order
characteristic polynomial are difficult to obtain. For an nth-degree polynomial
the table has n + 1 rows and the following structure:
Table 10.1 Higher Order Example
When completed, the number of sign changes in the first column will be the number of nonnegative poles.
Consider a system with a characteristic polynomial
We have the following table:
Table 10.2 Fifth Order Example
1
2
3
0
4
5
6
0
0
0
0.75 1.5
COMSATS University Islamabad
Page 100
LAB # 08 Effect of Zeros on 2nd Order Systems Response, Pole Zero Cancellation and Stability Analysis
via Routh Hurwitz Criterion.
−3
6
3
0
6
0
0
In the first column, there are two sign changes (0.75 → −3, and −3 → 3), thus there are two
non-negative roots where the system is unstable. Sometimes the presence of poles on the
imaginary axis creates a situation of marginal stability. In that case the coefficients of the
"Routh Array" become zero and thus further solution of the polynomial for finding changes in
sign is not possible. Then another approach comes into play. The row of polynomial which is
just above the row containing the zeroes is called "Auxiliary Polynomial".
Consider a system with a characteristic polynomial
We have the following table:
Table 10.3 Sixth Order System Example
1
8
20
16
2
12
16
0
2
12
16
0
0
0
0
0
In such a case the Auxiliary polynomial is
which is again equal
to zero. The next step is to differentiate the above equation which yields the following
polynomial.
. The coefficients of the row containing zero now become "8" and
"24". The process of Routh array is proceeded using these values which yield two points on the
COMSATS University Islamabad
Page 101
LAB # 08 Effect of Zeros on 2nd Order Systems Response, Pole Zero Cancellation and Stability Analysis
via Routh Hurwitz Criterion.
imaginary axis. These two points on the imaginary axis are the prime cause of marginal
stability.
Pre Lab Tasks
Task 1
For the following systems, find the range of K for stability using Routh Hurwitz criterion.
i.
𝐾𝐾 (𝑠𝑠) =
𝐾𝐾 (𝑠𝑠+0.01)(𝑠𝑠+6)
𝐾𝐾 (𝑠𝑠) =
𝐾𝐾 (𝑠𝑠+0.8)(𝑠𝑠+103)
𝑠𝑠(𝑠𝑠+20)(𝑠𝑠+100)
𝐺𝐺 (𝑠𝑠) =
10
𝑠𝑠2 + 10𝑠𝑠+29
ii.
iii.
𝑠𝑠
𝐾𝐾(𝑠𝑠) = 𝐾𝐾
COMSATS University Islamabad
𝐺𝐺 (𝑠𝑠) =
𝐺𝐺 (𝑠𝑠) =
Calculations
7570
(𝑠𝑠+62.61)(𝑠𝑠−62.61)
63∗ 106
(𝑠𝑠+30)(𝑠𝑠+140)(𝑠𝑠+2.5)
Page 102
LAB # 08 Effect of Zeros on 2nd Order Systems Response, Pole Zero Cancellation and Stability Analysis
via Routh Hurwitz Criterion.
COMSATS University Islamabad
Page 103
LAB # 08 Effect of Zeros on 2nd Order Systems Response, Pole Zero Cancellation and Stability Analysis
via Routh Hurwitz Criterion.
Lab Tasks
Lab Task 1:
For the following transfer function study the effect of additional zeros on the response of
second order system, note down the change in Ts, Tr, %OS, damping ratio, un-damped natural
frequency and poles of the system, let
D=s^2+2s+9
i.
G1(s)=9/D
ii.
G2(s)=((s+3)*9/3)/D
iii.
G3(s)=((s+5)*9/5)/D
iv.
G4(s)=((s+10)*9/10)/D
MATLAB Code
COMSATS University Islamabad
Page 104
LAB # 08 Effect of Zeros on 2nd Order Systems Response, Pole Zero Cancellation and Stability Analysis
via Routh Hurwitz Criterion.
Results
COMSATS University Islamabad
Page 105
LAB # 08 Effect of Zeros on 2nd Order Systems Response, Pole Zero Cancellation and Stability Analysis
via Routh Hurwitz Criterion.
Lab Task 2:
Consider the following systems with D=s^2+2s+4, from the step response determine which are
minimum phase and which are non-minimum phase systems. Compare the response of G1 and
G2 (find Ts, Tr and Tp) for both, which system is fast and why? Also compare systems G2 and
G3, find pole and zero for both systems and determine why both systems have different
responses?
i.
G1(s)=(s+4)/D
ii.
G2(s)=(-s+4)/D
iii.
G3(s)=(s-4)/D
MATLAB Code
COMSATS University Islamabad
Page 106
LAB # 08 Effect of Zeros on 2nd Order Systems Response, Pole Zero Cancellation and Stability Analysis
via Routh Hurwitz Criterion.
Results
COMSATS University Islamabad
Page 107
LAB # 08 Effect of Zeros on 2nd Order Systems Response, Pole Zero Cancellation and Stability Analysis
via Routh Hurwitz Criterion.
Lab Task 3:
Verify the value of “K” for all the systems, calculated in pre-lab task, using Simulink. Also
find open loop stability, total response stability and natural response stability. Also design “K”.
i.
Simulink Diagram
Results
COMSATS University Islamabad
Page 108
LAB # 08 Effect of Zeros on 2nd Order Systems Response, Pole Zero Cancellation and Stability Analysis
via Routh Hurwitz Criterion.
ii.
Simulink Diagram
Results
COMSATS University Islamabad
Page 109
LAB # 08 Effect of Zeros on 2nd Order Systems Response, Pole Zero Cancellation and Stability Analysis
via Routh Hurwitz Criterion.
Simulink Diagram
Results
COMSATS University Islamabad
Page 110
LAB # 08 Effect of Zeros on 2nd Order Systems Response, Pole Zero Cancellation and Stability Analysis
via Routh Hurwitz Criterion.
Post Lab Tasks
Lab Task 3:
Consider the following systems and check whether pole zero cancellation possible or not,
justify your answer by some solid arguments.
i.
G1(s)=-(s-5)/{(s-4.99)(s+6)}
ii.
G2(s)=(s+5)/{(s+4.99)(s+6)}
MATLAB Code
COMSATS University Islamabad
Page 111
LAB # 08 Effect of Zeros on 2nd Order Systems Response, Pole Zero Cancellation and Stability Analysis
via Routh Hurwitz Criterion.
Results and Plots
Comments
COMSATS University Islamabad
Page 112
LAB # 08 Effect of Zeros on 2nd Order Systems Response, Pole Zero Cancellation and Stability Analysis
via Routh Hurwitz Criterion.
Performance
Viva
(10 Marks)
(5 Marks )
Performance
/6
Results
/3
Critical Analysis
/1
Total/15
Comments
Critical Analysis / Conclusion
(By Student about Learning from the Lab)
COMSATS University Islamabad
Page 113
Lab # 10 Analysis of Systems using Root Locus Method.
Lab # 9 Steady State Error Analysis and Design
Objectives
To find steady state errors and static error constants and verify the results using MATLAB. To
design controller system gain for obtaining specified characteristics.
Pre Lab
Introduction:
Steady-state error is defined as the difference between the input and output of a system
in the limit as time goes to infinity (i.e. when the response has reached the steady state). The
steady-state error depends on the type of input (step, ramp, etc) as well as the system type (0, I,
or II).
Note: Steady-state error analysis is only useful for stable systems
Equations to calculate steady-state errors from open-loop transfer functions given
different inputs:

Step Input (R(s) = 1/s):

Ramp Input (R(s) = 1/s^2):

Parabolic Input (R(s) = 1/s^3):
COMSATS University Islamabad
Page 114
Lab # 10 Analysis of Systems using Root Locus Method.
When we design a controller, we usually want to compensate for disturbances to a system. We
find the steady-state error for a step disturbance input with the following equation. Gc(s) in the
equation is the transfer function of controller.
System types and errors:
The system type is defined as the number of pure integrators in a system. Steady state
error relates to system types as:
Table 9.1 System types and errors
System
Error
Input
Step
Ramp
Parabolic
Steady State Error
Formula
1/(1+Kp)
1/Kv
1/Ka
Static Error Constant
Kp = constant
Kv = 0
Ka = 0
Error
1/(1+Kp)
infinity
infinity
Type 1 systems
Error
0
1/Kv
infinity
Type 2 systems
Error
0
0
1/Ka
Type 0 systems
COMSATS University Islamabad
Page 115
Lab # 10 Analysis of Systems using Root Locus Method.
Lab Tasks
Lab Task 1:
For the following systems find the static error constants, and then steady state error for the
following inputs:
i.
ii.
iii.
r(t) = u(t), unit step
r(t) = 20*t*u(t)
r(t) = 5*t^2*u(t)
Also verify the results using MATLAB. Find the steady state error for unit step input by
creating E/R transfer function in MATLAB. Find steady state error for other two inputs using
MATLAB.
Calculations
COMSATS University Islamabad
Page 116
Lab # 10 Analysis of Systems using Root Locus Method.
MATLAB Code
COMSATS University Islamabad
Page 117
Lab # 10 Analysis of Systems using Root Locus Method.
Results
COMSATS University Islamabad
Page 118
Lab # 10 Analysis of Systems using Root Locus Method.
Lab Task 2:
For the following systems (i) and (ii), do the following tasks:
a) Find the value of k for which system yields e(t=infinity)=10%, verify using
MATLAB. Is the system stable at that gain?
b) From the MATLAB estimate the value of k for which the system yields
minimum e(t=infinity) (system should stay stable)?
c) Mention the advantages and disadvantages of increasing k (compare steady state
response with transient response and stability)?
i.
ii.
Calculations
COMSATS University Islamabad
Page 119
Lab # 10 Analysis of Systems using Root Locus Method.
MATLAB Code
Results and Comments
COMSATS University Islamabad
Page 120
Lab # 10 Analysis of Systems using Root Locus Method.
Post Lab Tasks
Lab Task 3:
For the following figure, do the following tasks:
a) Find e(t=infinity) for reference input only.
b) Find e(t=infinity) for disturbance input only.
c) Find e(t=infinity) for reference input+ disturbance input.
d) How can e(t=infinity) for disturbance input can be decreased (with reference to
k).
e) Can e(t=infinity) for disturbance input be made zero? If yes then how?
Note: G(s) is not correct; place zero in G(s) so that closed loop transfer function
becomes stable
MATLAB Code
COMSATS University Islamabad
Page 121
Lab # 10 Analysis of Systems using Root Locus Method.
Results
COMSATS University Islamabad
Page 122
Lab # 10 Analysis of Systems using Root Locus Method.
Performance
Viva
(10 Marks)
(5 Marks )
Performance
/6
Results
/3
Critical Analysis
/1
Total/15
Comments
Critical Analysis / Conclusion
(By Student about Learning from the Lab)
COMSATS University Islamabad
Page 123
Lab # 10 Analysis of Systems using Root Locus Method.
Lab # 10 Analysis of Systems using Root Locus
Method.
Objectives
To understand construction of Root Locus using MATLAB and compare the results with
Analytical Methods.
Pre-Lab Task.
PROBLEM: Sketch the root locus for the system shown in Figure 8.19(a) and find
the following:
a. The exact point and gain where the locus crosses the 0.45 damping ratio line
b. The exact point and gain where the locus crosses the jv-axis
c. The breakaway point on the real axis
d. The range of K within which the system is stable
COMSATS University Islamabad
Page 124
Lab # 10 Analysis of Systems using Root Locus Method.
1. Solve the problem Analytically and then compare the results with the plot given above.
2. Students should now run the following program. You will learn how to use MATLAB
to plot and title a root locus, overlay constant zeta and wn curves, zoom into and zoom
out from a root locus, and interact with the root locus to find critical points as well as
gains at those points. This exercise solves the above example using MATLAB.
clf
numgh=[1-4 20];
dengh=poly([-2 -4]);
’G(s)H(s)’
GH=tf(numgh,dengh)
rlocus(GH)
z=0.2:0.05:0.5;
wn=0:1:10;
sgrid(z,wn)
title (’Root Locus ’)
pause
rlocus(GH)
axis([-3 1-4 4])
title(’Close-up’)
z=0.45;
wn=0;
sgrid(z,wn)
for k=1: 3
[K,p]=rlocfind(GH)
end
Pause
COMSATS University Islamabad
% Clear graph on screen.
% Define numerator of G (s) H (s).
% Define denominator of G (s) H (s).
% Display label.
% Create G(s)H(s) and display.
% Draw root locus.
% Define damping ratio values : 0.2
% to 0.5 in steps of 0.05.
% Define natural frequency values:
% 0 to 10 in steps of 1.
% Generate damping ratio and
% natural frequency grid lines for
% root locus.
% Define title for root locus.
% Draw close-up root locus.
% Define range on axes for root
% locus close-up view.
% Define title for close-up root locus.
% Define damping ratio line for
% overlay on close-up root locus.
% Suppress natural frequency
% overlay curves.
% Overlay damping ratio curve on
% close-up root locus.
% Loop allows 3 points to be
% selected as per Example 8.7,
%(z=0.45 , jwcrossing,breakaway).
% Generate gain, K, and closed-loop
% poles, p, for point selected
% interactively on the root locus.
% End loop.
Page 125
Lab # 10 Analysis of Systems using Root Locus Method.
Lab Task-1:
•
The characteristic polynomial of a feedback control system, which is the denominator
of the closed-loop transfer function, is given by 𝑠𝑠 3 + 2𝑠𝑠 2 + (20𝐾𝐾 + 7)𝑠𝑠 + 100𝐾𝐾.
Sketch the root locus for this system Analytically and using MATLAB.
Lab Task-2:
For the unity feedback system shown in figure below where:
Do the following:
a. Sketch the root locus
b. Find the value of K that will yield a 10% overshoot.
c. Locate all nondominant poles. What can you say about the second-order approximation
that led to your answer in Part b?
d. Find the range of K that yields a stable system.
Repeat the above problem using MATLAB. Use one program to do the following:
a. Display a root locus and pause.
b. Draw a close-up of the root locus where the axes go from -2 to 0 on the real axis and -2
to 2 on the imaginary axis.
c. Overlay the 10% overshoot line on the close-up root locus.
COMSATS University Islamabad
Page 126
Lab # 10 Analysis of Systems using Root Locus Method.
Post-Lab
COMSATS University Islamabad
Page 127
Lab # 10 Analysis of Systems using Root Locus Method.
Repeat the problem using MATLAB. The program will do the following in one
program:
Program:
numg=1;
deng=poly([0 -3 -7 -8]);
numh=[1 30];
denh=[1 20 200];
G=tf(numg,deng)
Gzpk=zpk(G)
H=tf(numh,denh)
rlocus(G*H)
pause
K=0:10:1e4;
rlocus(G*H,K)
sgrid(0.707,0)
axis([-2,2,-5,5]);
pause
for i=1:1:3;
[K,P]=rlocfind(G*H)
end
T=feedback(K*G,H)
step(T)
COMSATS University Islamabad
Page 128
Lab # 10 Analysis of Systems using Root Locus Method.
Performance
Viva
(10 Marks)
(5 Marks )
Performance
/6
Results
/3
Critical Analysis
/1
Total/15
Comments
Critical Analysis / Conclusion
(By Student about Learning from the Lab)
COMSATS University Islamabad
Page 129
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
Lab#11 PID Controller Design.
Objectives:
In this Lab we will introduce a simple, yet versatile, feedback compensator structure: the
Proportional-Integral-Derivative (PID) controller.
The PID controller is widely employed because it is very understandable and because it is quite
effective. One attraction of the PID controller is that all engineers understand conceptually
differentiation and integration, so they can implement the control system even without a deep
understanding of control theory. Further, even though the compensator is simple, it is quite
sophisticated in that it captures the history of the system (through integration) and anticipates
the future behavior of the system (through differentiation). We will discuss the effect of each
of the PID parameters on the dynamics of a closed-loop system and will demonstrate how to
use a PID controller to improve a system's performance.
Key MATLAB commands used in this tutorial are: tf , step , pid , feedback , pidtune
Pre-LAB
PID Overview
In this tutorial, we will consider the following unity-feedback system:
The output of a PID controller, which is equal to the control input to the plant, is calculated in the time domain from
the feedback error as follows:
COMSATS University Islamabad
Page 130
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
(1)
First, let's take a look at how the PID controller works in a closed-loop system using the schematic shown above.
The variable ( ) represents the tracking error, the difference between the desired output ( ) and the actual output (
). This error signal ( ) is fed to the PID controller, and the controller computes both the derivative and the integral
of this error signal with respect to time. The control signal ( ) to the plant is equal to the proportional gain (
times the magnitude of the error plus the integral gain (
)
) times the integral of the error plus the derivative gain (
) times the derivative of the error.
This control signal ( ) is fed to the plant and the new output ( ) is obtained. The new output ( ) is then fed back
and compared to the reference to find the new error signal ( ). The controller takes this new error signal and
computes an update of the control input. This process continues while the controller is in effect.
The transfer function of a PID controller is found by taking the Laplace transform of Equation (1).
(2)
where
= proportional gain,
= integral gain, and
= derivative gain.
We can define a PID controller in MATLAB using a transfer function model directly, for example:
Kp = 1;
Ki = 1;
Kd = 1;
s = tf('s');
C = Kp + Ki/s + Kd*s
C =
s^2 + s + 1
----------s
Continuous-time transfer function.
Alternatively, we may use MATLAB's pid object to generate an equivalent continuous-time controller as follows:
C = pid(Kp,Ki,Kd)
COMSATS University Islamabad
Page 131
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
C =
1
Kp + Ki * --- + Kd * s
s
with Kp = 1, Ki = 1, Kd = 1
Continuous-time PID controller in parallel form.
Let's convert the pid object to a transfer function to verify that it yields the same result as above:
tf(C)
ans =
s^2 + s + 1
----------s
Continuous-time transfer function.
The Characteristics of the P, I, and D Terms
Increasing the proportional gain (
) has the effect of proportionally increasing the control signal for the same level
of error. The fact that the controller will "push" harder for a given level of error tends to cause the closed-loop
system to react more quickly, but also to overshoot more. Another effect of increasing
is that it tends to reduce,
but not eliminate, the steady-state error.
The addition of a derivative term to the controller (
simple proportional control, if
) adds the ability of the controller to "anticipate" error. With
is fixed, the only way that the control will increase is if the error increases. With
derivative control, the control signal can become large if the error begins sloping upward, even while the magnitude
of the error is still relatively small. This anticipation tends to add damping to the system, thereby decreasing
overshoot. The addition of a derivative term, however, has no effect on the steady-state error.
The addition of an integral term to the controller (
) tends to help reduce steady-state error. If there is a
persistent, steady error, the integrator builds and builds, thereby increasing the control signal and driving the error
COMSATS University Islamabad
Page 132
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
down. A drawback of the integral term, however, is that it can make the system more sluggish (and oscillatory)
since when the error signal changes sign, it may take a while for the integrator to "unwind."
The general effects of each controller parameter (
,
,
) on a closed-loop system are summarized in the
table below. Note, these guidelines hold in many cases, but not all. If you truly want to know the effect of tuning the
individual gains, you will have to do more analysis, or will have to perform testing on the actual system.
CL RESPONSE
RISE TIME
OVERSHOOT
SETTLING TIME
S-S ERROR
Kp
Decrease
Increase
Small Change
Decrease
Ki
Decrease
Increase
Increase
Decrease
Kd
Small Change
Decrease
Decrease
No Change
LAB TASK-1
Example Problem
Suppose we have a simple mass-spring-damper system.
The governing equation of this system is
(3)
Taking the Laplace transform of the governing equation, we get
(4)
The transfer function between the input force
and the output displacement
then becomes
(5)
COMSATS University Islamabad
Page 133
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
Let
m = 1 kg
b = 10 N s/m
k = 20 N/m
F = 1 N
Substituting these values into the above transfer function
(6)
The goal of this problem is to show how each of the terms,
,
, and
, contributes to obtaining the common
goals of:



Fast rise time
Minimal overshoot
Zero steady-state error
Open-Loop Step Response
Let's first view the open-loop step response. Create a new m-file and run the following code:
s = tf('s');
P = 1/(s^2 + 10*s + 20);
step(P)
COMSATS University Islamabad
Page 134
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
The DC gain of the plant transfer function is 1/20, so 0.05 is the final value of the output to a unit step input. This
corresponds to a steady-state error of 0.95, which is quite large. Furthermore, the rise time is about one second,
and the settling time is about 1.5 seconds. Let's design a controller that will reduce the rise time, reduce the settling
time, and eliminate the steady-state error.
Proportional Control
From the table shown above, we see that the proportional controller (
) reduces the rise time, increases the
overshoot, and reduces the steady-state error.
The closed-loop transfer function of our unity-feedback system with a proportional controller is the following,
where
is our output (equals
) and our reference
is the input:
(7)
Let the proportional gain (
) equal 300 and change the m-file to the following:
Kp = 300;
C = pid(Kp)
T = feedback(C*P,1)
COMSATS University Islamabad
Page 135
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
t = 0:0.01:2;
step(T,t)
C =
Kp = 300
P-only controller.
T =
300
---------------s^2 + 10 s + 320
Continuous-time transfer function.
COMSATS University Islamabad
Page 136
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
The above plot shows that the proportional controller reduced both the rise time and the steady-state error,
increased the overshoot, and decreased the settling time by a small amount.
Proportional-Derivative Control
Now, let's take a look at PD control. From the table shown above, we see that the addition of derivative control (
) tends to reduce both the overshoot and the settling time. The closed-loop transfer function of the given system
with a PD controller is:
(8)
Let
equal 300 as before and let
equal 10. Enter the following commands into an m-file and run it in the
MATLAB command window.
Kp = 300;
Kd = 10;
C = pid(Kp,0,Kd)
T = feedback(C*P,1)
t = 0:0.01:2;
COMSATS University Islamabad
Page 137
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
step(T,t)
C =
Kp + Kd * s
with Kp = 300, Kd = 10
Continuous-time PD controller in parallel form.
T =
10 s + 300
---------------s^2 + 20 s + 320
Continuous-time transfer function.
This plot shows that the addition of the derivative term reduced both the overshoot and the settling time, and had a
negligible effect on the rise time and the steady-state error.
COMSATS University Islamabad
Page 138
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
Proportional-Integral Control
Before proceeding to PID control, let's investigate PI control. From the table, we see that the addition of integral
control (
) tends to decrease the rise time, increase both the overshoot and the settling time, and reduces the
steady-state error. For the given system, the closed-loop transfer function with a PI controller is:
(9)
Let's reduce
to 30, and let
equal 70. Create a new m-file and enter the following commands.
Kp = 30;
Ki = 70;
C = pid(Kp,Ki)
T = feedback(C*P,1)
t = 0:0.01:2;
step(T,t)
C =
1
Kp + Ki * --s
with Kp = 30, Ki = 70
Continuous-time PI controller in parallel form.
T =
30 s + 70
COMSATS University Islamabad
Page 139
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
-----------------------s^3 + 10 s^2 + 50 s + 70
Continuous-time transfer function.
Run this m-file in the MATLAB command window and you should generate the above plot. We have reduced the
proportional gain (
) because the integral controller also reduces the rise time and increases the overshoot as
the proportional controller does (double effect). The above response shows that the integral controller eliminated
the steady-state error in this case.
Proportional-Integral-Derivative Control
Now, let's examine PID control. The closed-loop transfer function of the given system with a PID controller is:
(10)
After several iterations of tuning, the gains
= 350,
= 300, and
= 50 provided the desired response. To
confirm, enter the following commands to an m-file and run it in the command window. You should obtain the
following step response.
COMSATS University Islamabad
Page 140
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
Kp = 350;
Ki = 300;
Kd = 50;
C = pid(Kp,Ki,Kd)
T = feedback(C*P,1);
t = 0:0.01:2;
step(T,t)
C =
1
Kp + Ki * --- + Kd * s
s
with Kp = 350, Ki = 300, Kd = 50
Continuous-time PID controller in parallel form.
COMSATS University Islamabad
Page 141
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
Now, we have designed a closed-loop system with no overshoot, fast rise time, and no steady-state error.
General Tips for Designing a PID Controller
When you are designing a PID controller for a given system, follow the steps shown below to obtain a desired
response.
1.
Obtain an open-loop response and determine what needs to be improved
2.
Add a proportional control to improve the rise time
3.
Add a derivative control to reduce the overshoot
4.
Add an integral control to reduce the steady-state error
5.
Adjust each of the gains
,
, and
until you obtain a desired overall response. You can always refer to
the table shown in this "PID Tutorial" page to find out which controller controls which characteristics.
Lastly, please keep in mind that you do not need to implement all three controllers (proportional, derivative, and
integral) into a single system, if not necessary. For example, if a PI controller meets the given requirements (like
the above example), then you don't need to implement a derivative controller on the system. Keep the controller as
simple as possible.
COMSATS University Islamabad
Page 142
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
Post-Lab
Automatic PID Tuning
MATLAB provides tools for automatically choosing optimal PID gains which makes the trial and error process
described above unnecessary. You can access the tuning algorithm directly using pidtune or through a nice
graphical user interface (GUI) using pidTuner.
The MATLAB automated tuning algorithm chooses PID gains to balance performance (response time, bandwidth)
and robustness (stability margins). By default, the algorithm designs for a 60-degree phase margin.
Let's explore these automated tools by first generating a proportional controller for the mass-spring-damper system
by entering the command shown below. In the shown syntax, P is the previously generated plant model,
and 'p' specifies that the tuner employ a proportional controller.
pidTuner(P,'p')
The pidTuner GUI window, like that shown below, should appear.
Notice that the step response shown is slower than the proportional controller we designed by hand. Now click on
the Show Parameters button on the top right. As expected, the proportional gain,
employed,
, is smaller than the one we
= 94.86 < 300.
We can now interactively tune the controller parameters and immediately see the resulting response in the GUI
window. Try dragging the Response Time slider to the right to 0.14 s, as shown in the figure below. This causes
the response to indeed speed up, and we can see
is now closer to the manually chosen value. We can also
see other performance and robustness parameters for the system. Note that before we adjusted the slider, the
target phase margin was 60 degrees. This is the default for the pidTuner and generally provides a good balance
between robustness and performance.
COMSATS University Islamabad
Page 143
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
Now let's try designing a PID controller for our system. By specifying the previously designed or (baseline)
controller, C, as the second parameter, pidTuner will design another PID controller (instead of P or PI) and will
compare the response of the system with the automated controller with that of the baseline.
pidTuner(P,C)
We see in the output window that the automated controller responds slower and exhibits more overshoot than the
baseline. Now choose the Domain: Frequency option from the toolstrip, which reveals frequency domain tuning
parameters.
COMSATS University Islamabad
Page 144
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
Now type in 32 rad/s for Bandwidth and 90 deg for Phase Margin, to generate a controller similar in
performance to the baseline. Keep in mind that a higher closed-loop bandwidth results in a faster rise time, and a
larger phase margin reduces the overshoot and improves the system stability.
Finally, we note that we can generate the same controller using the command line tool pidtune instead of
the pidTuner GUI employing the following syntax.
opts = pidtuneOptions('CrossoverFrequency',32,'PhaseMargin',90);
[C, info] = pidtune(P, 'pid', opts)
C =
1
Kp + Ki * --- + Kd * s
s
with Kp = 320, Ki = 796, Kd = 32.2
Continuous-time PID controller in parallel form.
info =
struct with fields:
Stable: 1
CrossoverFrequency: 32
PhaseMargin: 90
COMSATS University Islamabad
Page 145
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
Performance
Viva
(10 Marks)
(5 Marks )
Performance
/6
Results
/3
Critical Analysis
/1
Total/15
Comments
Critical Analysis / Conclusion
(By Student about Learning from the Lab)
COMSATS University Islamabad
Page 146
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
Lab # 12 Introduction to control experiments on
COM3 Lab Trainer
Objectives:
To study and analyze the behavior of different control system concepts and various
controller types using interactive software and hardware.
Introduction:
COM3LAB (developed by Ld-Didactic Germany) is an interactive, multimedia,
teaching and learning environment covering the theory and practice of electrical engineering
and electronics. It is intended for students as well as for teachers to learn/teach the basic as
well as advanced concepts in Control engineering. Link at the end of this page gives a useful
learning resource to get familiar with COM3.
COM3LAB consists of a master unit and a number of different courses. The courses
consist of an experiment board (Figure 11.1) and the necessary software. Here we only focus
on Control Technology I board which is specifically targeted for Control systems course.
Figure 11.1 COM3 Lab
Link: http://www.ld-didactic.de/pdf/COM3LAB_EN.pdf
The Control Technology I offers following potential benefits:

Theory and practice are conveyed with great clarity.

Responsibility and self-reliance are promoted.

Students become highly motivated
COMSATS University Islamabad
Page 147
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.

Suitable for use with mixed-ability students.

Test equipment is easy and quick to set up

Measuring produces real-world values

Learning takes place at the right place and at the right time

Teaching costs are reduced
In-Lab Tasks:
COM3Lab is divided into 12 experiments or case studies which have been planned to span
over the whole semester. The class will be divided into 7 groups (as 7 kits are available). At the
end of each lab session, after performing normal lab experiment, 30 minutes will be given for
COM3 experiment. Students will open the interactive software i.e Control Technology I and
will start working on their own after listening to audio and instructions on screen and perform
practically on attached hardware and answering question appearing on the screen and
visualizing results on analysis tools like characteristic plotter, multi-meter, oscilloscope,
function generator etc. During each experiment, the software poses different questions and
quizzes which is quite self accountable for students to grasp the adequate concepts of the
subject.
Following experiments (or case studies) have been planned:
1. Introduction (8 slides)
2. Open loop control (10 slides)
3. Closed loop control (10 slides)
4. Analysis of controlled systems (9 slides)
5. Controlled system with compensation (9 slides)
6. Controlled system with time delay of higher order (4 slides)
7. Controlled system without compensation (7 slides)
8. Controller types (3 slides)
9. Proportional action control (5 slides)
10. Integral action control (3 slides)
11. PI control (6 slides)
12. PID and PD control (9 slides)
COMSATS University Islamabad
Page 148
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
Performance
Viva
(10 Marks)
(5 Marks )
Performance
/6
Results
/3
Critical Analysis
/1
Total/15
Comments
Critical Analysis / Conclusion
(By Student about Learning from the Lab)
COMSATS University Islamabad
Page 149
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
Lab # 13 State Space Representation
Lab Task-1
Converting a Transfer Function to State Space
PROBLEM 1:
Find the state-space representation in phase-variable form for
the transfer function shown in Figure below.
Step 1
Find the associated differential equation. Since
Cross-multiplying yields
The corresponding differential equation is found by taking inverse Laplace
transform, assuming zero initial conditions:
Step 2 Select the state variables.
Choosing the state variables as successive derivatives, we get
COMSATS University Islamabad
Page 150
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
Differentiating both sides and making use of above equations we obtain the state
equations. Since the output is c=x1, the combines state and output equations are:
In vector-matrix form,
At this point, we can create an equivalent block diagram of the system to help
visualize the state variables. We draw three integral blocks as shown in Figure
below and label each output as one of the state variables, xi(t), as shown. Since
the input to each integrator is xi(t), use above equations to determine the
combination of input signals to each integrator. Form and label each input.
Finally label the output, y(t)=c(t). The final result is shown in the form of figure
below.
COMSATS University Islamabad
Page 151
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
Now run the programs below to learn State Space representation and finally solve
the above example using MATLAB.
Program 1:
Program 2:
COMSATS University Islamabad
Page 152
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
Program 3:
Problem-1 solved using MATLAB:
COMSATS University Islamabad
Page 153
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
Lab Task-2
Converting from State Space to a Transfer Function:
Remember that:
(1)
Example:
Given the system defined by the equations below, find the transfer function, T(s)=Y(s)/U(s),
where U(s) is the input and Y(s) is the output.
SOLUTION:
The solution revolves around finding the term (sI-A)-1.
Substituting the inverse, B, C, and D in equation (1), where
COMSATS University Islamabad
Page 154
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
We obtain the final result for the transfer function:
Now run the program below to learn how to convert state-space representation to a transfer
function.
COMSATS University Islamabad
Page 155
Lab # 12 Introduction to control experiments on COM3 Lab Trainer.
Post-LAB:
Solve Lab Task-2 using MATLAB.
Performance
Viva
(10 Marks)
(5 Marks )
Performance
/6
Results
/3
Critical Analysis
/1
Total/15
Comments
Critical Analysis / Conclusion
(By Student about Learning from the Lab)
COMSATS University Islamabad
Page 156
Download