Vous êtes sur la page 1sur 113

LAB MANUAL

EEE325
Control Systems

COMSATS INSTITUTE OF INFORMATION TECHNOLOGY


(CIIT)
Department of Electrical Engineering
Islamabad (Park Road) Campus

Copyright 2012 by CIIT, Islamabad


All rights reserved

List of Contributors
Mr. Abdul Samad
Mr. Fahd Sikandar Khan
Mr. Raheel Ahmad
Mr. Mustafa Pasha
Mr. Waqar Saeed
Mr. Ahsan Malik
Dr. Jamshed Iqbal

ii

Preface
Infinite praise definitely goes to Allah Almighty, Who has given us motivation and strength
to compile this manual.

This manual supports the practical sessions of the course Control Systems for undergraduate engineering degrees. The manual comprises of sixteen experiments which cover
software as well as hardware aspects of control. The hardware experiments consists of
working with platforms like PLC (Exp. 1-3), Rectilinear plant (Exp. 5,13), COM3 lab (Exp.
11), Servo motor trainer (Exp. 12) and Robotic arm (Exp. 14). The software based
experiments mainly use Matlab and Simulink tools and implement the concrete concepts
being taught in theoretical lectures. The theme of the semester course project Robian is
listed at Exp. 16.

The third edition offers significant improvements from previous manual. In an attempt to
make the students capable of correlating theoretical concepts with physical systems, three
new experiments exploiting high-tech in-house facilities have been included in this edition.
While writing this manual, the two main focuses were systematic explanation and problem
solving methodology. Keeping in view these objectives, most of the experiments using
Matlab/Simulink have either been rewritten or updated to reflect better understanding and
illustration.

We hope and pray that you will find this manual useful to enhance your skills and expertise.
Enjoy learning by doing !

Dr. Jamshed Iqbal

iii

Contents
1

INTRODUCTION TO PLCS AND IMPLEMENTATION OF COMBINATIONAL LOGIC


THROUGH LADDER LOGIC .......................................................................................................... 1

IMPLEMENTATION OF TIMERS AND COUNTERS IN TRILOGY .......................................13

IMPLEMENTATION OF SEQUENCERS IN TRILOGY.............................................................22

INTRODUCTION

TO

MATLAB

AND

SIMULINK,

SOLUTION OF

DIFFERENTIAL

EQUATIONS USING MATLAB AND SIMULINK AND TRANSFER FUNCTION BASED


MODELLING .....................................................................................................................................27

MODELING OF TRANSLATIONAL MECHANICAL SYSTEM AND TO CALCULATE ITS


VARIOUS RESPONSES ...................................................................................................................33

INTRODUCTION TO LSIM AND TIME RESPONSE OF 1ST AND 2ND ORDER


SYSTEMS ...........................................................................................................................................43

BLOCK DIAGRAM REDUCTION AND ANALYSIS AND DESIGN OF FEEDBACK SYSTEMS


51

EFFECT OF ZEROS ON 2ND ORDER SYSTEMS RESPONSE, POLE ZERO CANCELLATION.


56

STEADY STATE ERROR ANALYSIS AND DESIGN ..................................................................58

10 STABILITY ANALYSIS VIA PHASE PORTRAIT, POLE ZERO MAP AND ROUTH HURWITZ
CRITERION. STABILITY DESIGN VIA ROUTH-HURWITZ CRITERION...........................62

11 INTRODUCTION TO CONTROL EXPERIMENTS ON COM3 LAB TRAINER ....................67


12 AUTOMATIC OPEN LOOP AND CLOSED LOOP SPEED CONTROL AND EFFECT OF THE
DIFFERENT COMPONENTS OF THE PID CONTROLLER .....................................................69

13 RIGID BODY PD & PID CONTROL USING RECTILINEAR PLANT .....................................76


14 CONTROL AND TASK ACCOMPLISHMENT USING 6-DOF ROBOTIC ARM ....................81
15 15-A) STATE SPACE MODELLING USING MATLAB AND SIMULINK ...............................89
16

15-B) SYSTEMS: TRANSFER FUNCTIONS, STATE SPACE, POLE-ZERO MAPS AND


RESPONSES, INTER-CONVERSION BETWEEN STATE SPACE AND TRANSFER FUNCTION
94

17

ROBIAN (THEME) ...........................................................................................................................98

iv

List of Tables
Table 1.1 NOR truth table ................................................................................................. 12
Table 1.2 NAND truth table .............................................................................................. 12
Table 3.5 Full stepping truth table .................................................................................... 25
Table 9.1 System types and errors .................................................................................... 59
Table 10.1 Higher Order Example .................................................................................... 63
Table 10.2 Fifth Order Example........................................................................................ 64
Table 10.3 Sixth Order System Example .......................................................................... 64
Table 12.1 Observation table (Open loop speed control).................................................. 71
Table 12.2 Observation table (Closed loop speed control) ............................................... 74
Table 14.1 ED7220C features .......................................................................................... 82
Table 14.2 Control commands .......................................................................................... 84

List of Figures
Figure 1.1 Parts of PLC ....................................................................................................... 2
Figure 1.2 PLC scan cycle................................................................................................... 3
Figure 1.3 Relay Structure .................................................................................................. 4
Figure 2.1 ON-delay timer operation ................................................................................ 13
Figure 2.2 OFF-delay timer operation............................................................................... 13
Figure 2.3 Retentive timer operation ................................................................................. 14
Figure 2.4 Control System ................................................................................................ 14
Figure 2.5 Water Tank System .......................................................................................... 17
Figure 2.6 Length measurement task ................................................................................ 18
Figure 2.7 PLC wiring diagram (Lab task 2) .................................................................... 19
Figure 2.8 Industrial control task ...................................................................................... 21
Figure 3.1 Flow Chart ....................................................................................................... 23
Figure 3.2 Inserting 1Sec. Clock ....................................................................................... 24
Figure 3.3 Inserting Sequencer.......................................................................................... 24
Figure 3.4 Inserting SeqN:x .............................................................................................. 24
Figure 3.5 Resultant Circuit .............................................................................................. 24
Figure 4.1 RLC circuit ...................................................................................................... 31
Figure 4.2 Simulink model of RLC circuit ....................................................................... 31
Figure 4.3 RLC circuit for Task 3 ..................................................................................... 32
Figure 5.1 Single Mass-Spring-Damper system ............................................................... 34
Figure 5.2 Test inputs used in control systems ................................................................. 35
Figure 5.3 Experimental control systems .......................................................................... 35
Figure 5.4 Electromechanical plant ................................................................................... 36
Figure 5.5 Rectilinear apparatus........................................................................................ 37
Figure 5.6 Mass-spring-damper system for the experiment .............................................. 37
Figure 5.7 Overall rectilinear system ............................................................................... 38
vi

Figure 5.8 Controller reset utility ...................................................................................... 38


Figure 5.9 Control algorithm setup ................................................................................... 39
Figure 5.10 Setting control parameters ............................................................................. 39
Figure 5.11 Input selection menu ...................................................................................... 40
Figure 5.12 Changing input parameters ............................................................................ 40
Figure 5.13 Executing trajectory ....................................................................................... 40
Figure 5.14 Data samples uploaded .................................................................................. 41
Figure 5.15 Plotting setup ................................................................................................. 41
Figure 5.16 Step response (Sample plot) .......................................................................... 42
Figure. 6.1 Simulink model of RLC circuit ...................................................................... 46
Figure. 6.2 Typical Response of 2nd Order System ........................................................... 48
Figure. 6.3 RLC circuit for Task 4 ................................................................................... 50
Figure. 7.1 Series Block Diagram Reduction .................................................................... 53
Figure. 7.2 Parallel Block Diagram Reduction ................................................................. 53
Figure. 7.3 Feedback Block Diagram Reduction .............................................................. 53
Figure. 7.4 Block Diagram Reduction Task2 .................................................................... 54
Figure. 7.5 Block Diagram Reduction Task2 .................................................................... 54
Figure. 7.6 System for Task3 ............................................................................................ 55
Figure 10.1: Phase Potrait ................................................................................................. 65
Figure 11.1 COM3 Lab ..................................................................................................... 67
Figure 12.1 DC servo motor trainer .................................................................................. 70
Figure 12.2 External motor unit: Front and side views ..................................................... 70
Figure 12..3 Open loop speed control ............................................................................... 71
Figure 12.4 Characteristics: Open loop speed control ...................................................... 72
Figure 12.5 Closed loop speed control .............................................................................. 72
Figure 12.6 Trainer configuration for closed loop speed control ...................................... 73
Figure 12.7 Characteristics: Closed loop speed control .................................................... 74
Figure 13.1 Rigid body PID control Control block diagram.......................................... 77
Figure 13.2 Mass/Spring/Damper ..................................................................................... 80
Figure 14.1 ED7220C robotic arm .................................................................................... 81
Figure 14.2 Robotic arm and the human arm .................................................................... 82
vii

Figure 14.3 Complete system ............................................................................................ 83


Figure 14.4 Robot controller (ED-MK4) .......................................................................... 84
Figure 14.5 Teaching loader.............................................................................................. 84
Figure 14.6 Pick and place task snapshots ........................................................................ 88
Figure 15.1 Example Parallel RLC circuit ........................................................................ 91
Figure 15.2 Series RLC for Lab Task 1 ............................................................................ 93
Figure 15.3 Mass spring damping system ......................................................................... 93
Figure 15.4 Example system response .............................................................................. 96
Figure 16.1 : Contest Arena .............................................................................................. 99

viii

Abbreviations
CPU

Central Processing Unit

DOF

Degree Of Freedom

EPROM

Erasable Programmable Read Only Memory

EEPROM

Electrically EPROM

FBD

Function Block Diagrams

FRD

Frequency Response Data

IEC

International Electrotechnical Commission

I/O

Input/Output

I/p

Input

LED

Light Emitting Diode

LS

Limit Switch

LTI

Linear Time Invariant

MATLAB

MATrix LABoratory

O/p

Output

ODE

Ordinary Differential Equation

OS

Over Shoot

PID

Proportional Integral Derivative

PLC

Programmable Logic Controller

PWM

Pulse Width Modulation

RLC

Resistance Inductance Capacitance

RPM

Revolution Per Minute

RT

RoboTalk

ix

Experiment 1

Introduction to PLCs 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.

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 611311 (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 useroriented 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 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

Computer

PLC

Inexpensive Inexpensive

Expensive

Inexpensive

Size

Large

Small

Moderate

Small

Noise

Good

Fair

Excellent

Fair

Speed

Slow

Very Fast

Very Fast

Fast

Difficult

Simple

Simple

Difficult

Simple

Simple

Supported

Supported

Supported

System Modification

Troubleshooting
Complex

Function

Support

Digital Design

Very
Difficult
Very
Difficult
None

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.

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 Electrotechnical 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).

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 lowpower 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.

LAB TASKS:
Task1: 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

Figure 1.4 Task 1: Wiring Diagram

2. Now open Trilogy as explained below


(Start->Programe-> Internet TRrLOGI 5.2 -> TRiLOGI Version 6.0

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.
5

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.

3. Now insert the first element by left-clicking on the icon


. At the same
time, an I/O 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.

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.

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.

iii.

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 Servers 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.

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.
i.
ii.

From PLC itself: By giving the input through switch and visually observing the
outputs from LEDs.
From Trilogy: From main menu bar, select
Controller -> On-Line Monitoring or simply press Ctrl + M.

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).

Task-2: Inserts a relay in program to make it more professional:

Lab Task-2

Instructor Signature

Task-3 Implement Logic Gates:


3 Inputs AND Gate:

Lab Task-3a

3 Inputs OR Gate:

Lab Task-3b

Single Input NOT Gate:

Lab Task-3c

2 Inputs XOR Gate

Lab Task-3d

Instructor Signature

10

Task-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.)

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

11

Home Tasks:
1.

Implement Flip-Flop using both NAND and NOR Gates.


Truth Table of NOR Gate
S
1
0
0
0
1

Table 1.1 NOR truth table


R
Q
Q
0
1
0
0
1
0
1
0
1
0
0
1
1
0
0

Truth Table of NAND Gate


S
1
1
0
1
0

Table 1.2 NAND truth table


R
Q
Q
0
0
1
1
0
1
1
1
0
1
1
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

Y
F1

12

Experiment 2

Implementation of Timers and Counters in Trilogy


Objective:
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.

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 reenergized, 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

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

13

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 preset 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 DOWNcounters.

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

Figure 2.4 Control System

14

Actuator

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

rage

Temperature, Magnetic

of

sensors

available

like

Light,

Motion,

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. PLCs 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.

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.

15

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.

o 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.

16

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.
(Note: This is a sequential logic Problem, Carefully implement the sensors
NO/NC states)

Sensor-1
Tank-1
Sensor-2

Motor

Tank-2
Sensor-3

Figure 2.5 Water Tank System

Lab Task No 1b:


Suppose the tank-1 is in vibrant environments that cause false signal
generation even the tank-1 isnt empty. To insure the signal is not false the Controller
should wait till 5 sec if the signal is true and than 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

17

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

(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.

18

Figure 2.7 PLC wiring diagram (Lab task 2)

19

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

Instructor Signature

Task-2 Length Measurement System:

Lab Task-2

Instructor Signature

20

Home Tasks:
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

21

Experiment 3

Implementation of Sequencers in Trilogy


Objective:
To understand the sequencers implementation through ladder logic.

Equipment/Tools required:
PLC(Triangular Research Inc.), PC with TRiLOGI software, connecting leads
etc.

Introduction:
Sequencers in Trilogi:
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-by-step 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.
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.

22

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.

LAB TASKS:
Task1: Using TRiLOGI software, control 4 LEDs in Sequence of 1 sec. i.e Each
LED glow for 1 Sec after one another.
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. Define Inputs, Outputs, Relay and Sequencer in TRiLOGI.


3. Write Seq1 in the counter table Row#1 and set its preset value to 4, for
4 LEDs.
4. Define I/P start and O/P LED_ 1, LED_2, LED_3, LED_4.
5. Define Relay as per Requirement. (System is ready to build.)
6. Insert Input Start and Append 1 second clock in series with start
from the special bits.

23

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.

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.


24

Lab Task No 2:
Create the following output pattern using sequencers.
Out1

Out2

Out3

Out4

Out5

Lab Task No 3:
Design Full Step Stepper Motor Controller for forward and reverse Drive.
Table 3.5 Full stepping truth table
Outputs
Step no. in
forward direction
1
2
3
1
1
1
0
2
0
1
1
3
0
0
1
4
1
0
0

4
0
0
1
1

Result Tables (Fill it and submit to instructor at the end of Lab)

Task-2: Running Pattern:

Lab Task-2

25

Task-3: Stepper Motor Controller:

Lab Task-3
Instructor Signature

Home Task:
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)
Right
Left

lane

lane

26

Experiment 4

Introduction to Matlab and Simulink, Solution of


Differential Equations Using Matlab and Simulink
and Transfer Function Based Modelling
Objectives:
To evaluate and analyze transfer functions in MATLAB and to implement
control systems in MATLAB using Simulink.

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.

Linear Model Representations:


Normally four types of representations are used in MATLAB for representing linear
models. These are presented here with the examples:

27

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:
s = tf('s');

% Define the Laplace variable s

G = s/(s^2 + 2*s + 1);

% 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).
28

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:

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');
G = s/(s+1)^2;

% Define the Laplace variable s


% 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.
State space representation will be discussed further in experiments 14 & 15

29

Frequency Response Data (FRD) models


It consists of sampled measurements of a systems 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 =

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

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.
30

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
v(s)/U(s) =3 / s2+4s+3

The corresponding Simulink model is illustrated in Figure 4.2.

Figure 4.2 Simulink model of RLC circuit

31

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.

Lab Task No 2:
Find inverse laplace transform f(t) & hence find inverse from partial fraction
form (use MATLAB to compute the residues). Where

Solve the differential equation to compute x(t)


X + 2X + 10X = t2

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
than make its Simulink block diagram.

Figure 4.3 RLC circuit for Task 3

32

Experiment 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

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 Newtons law,

Spring is an element which opposes motion due to elasticity. According to


Hookes law,

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.*.

33

(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 DAlemberts 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

34

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.

Input / Output
Electronics

Electromechanical
Plant

DSP Based
Controller / Data
Acquisition Board

System Interface
Software
("Executive Program")

Real-time Controller & I/O

Figure 5.3 Experimental control systems

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
35

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

36

Travel Limit Stops

Brushless
Servo
Motor

Encoder #1

Encoder #2

Encoder #3

Scale Rule
Interchangeable Springs
Dashpot Extension Bracket

TOP VIEW

Spring Attachment Bracket


Adjustable Masses
Dashpot

Rack &
Pinion
Drive

Ball Bearing
Slides

Damping
Adjustment
Knob

Mass Carriages

SIDE VIEW

Figure 5.5 Rectilinear apparatus

Procedure:
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).
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.
37

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

12. Setup Control algorithm

38

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

Click OK and then finally click on Implement Algorithm followed by OK


13. Select appropriate input from the Command->Trajectory

39

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)

Figure 5.13 Executing trajectory

40

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)

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.

41

Figure 5.16 Step response (Sample plot)

42

Experiment 6

Introduction to lsim and Time Response


of 1st and 2nd Order Systems
a) Lsim and 1st order Systems
Objectives:
To implement transfer function and introduction to LSIM command and to
evaluate and analyze responses (impulse and step) of first order systems.

Introduction:
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:
H= 2 s^2 + 3 s + 2
----------------------5 s^3 + 4 s^2 + 7 s + 1
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.
43

X=LINSPACE(X1, X2, N) generates N points between X1 and X2.


N can be found as N=((Final value- Initial value)/ step_size) +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,
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)
44

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)
If only plot of impulse response is required then impulse function can be used
as:
>>impulse(sys)

Lab Tasks:
Lab Task No 1:
The standard form of a first order system is

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.

Lab Task No 2:
Consider the transfer function,

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.
45

Lab Task No 3:
Find the natural response of the following first order system. Assuming
v(0)=10.

Figure. 6.1 Simulink model of RLC circuit

Hint: The circuit equation for the circuit is RCdv/dt +v = 0

46

b) Time Response of 2nd Order System


Objectives:
To calculate and observe the responses of second order systems in time
domain and to identify systems from their step response.

Introduction:
A second order system can be represented generally as:
Md2y(t)/dt2 + B dy(t)/dt + Ky(t) = f(t)
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

Standard Performance measures:


Performance measures are usually defined in terms of the step response of a system as
shown in Figureure below.

47

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
Percentage overshoot can be found by:
P.O. = 100e /(1 2)^1/2

48

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
IMPULSE calculates the impulse response of the LTI model SYS (created
with either TF, ZPK, or SS).
>>[y, t] = impulse (sys)

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.

49

Lab Tasks:
Lab Task No 1:
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.

Lab Task No 2:
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.

Lab Task No 3:
Plot %OS vs. damping ratio and analyze the plot carefully.

Lab Task No 4:
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.

50

Experiment 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.

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.
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.
51

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).
Example:
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')

52

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

ii.

Figure. 7.2 Parallel block diagram reduction

iii.

Figure. 7.3 Feedback block diagram reduction

53

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

ii.

Figure. 7.5 Block diagram reduction Task 2

54

Lab Task 3:
For the following system consider: Plant=Motor=1/[s(s+6)] and controller=k,
design a closed loop system with poles at 33j. 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


set K =

55

j, we need to

Experiment 8

Effect of Zeros on 2nd Order Systems Response,


Pole Zero Cancellation.
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.

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 zeros associated gain vector.
PZMAP:
>> PZMAP(SYS)
where

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
as x's and the zeros are plotted as o's.
56

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

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

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)}

57

Experiment 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.

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):

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
58

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

Type 0 systems
Type 1 systems
Type 2 systems

Steady State Error


Formula
Static Error Constant
Error
Error
Error

Step

Input
Ramp

Parabolic

1/(1+Kp)

1/Kv

1/Ka

Kp = constant
1/(1+Kp)
0
0

Kv = 0
infinity
1/Kv
0

Ka = 0
infinity
infinity
1/Ka

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.

59

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.

60

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

61

Experiment 10

Stability Analysis via Phase Portrait, Pole Zero


Map and Routh Hurwitz Criterion. Stability Design
via Routh-Hurwitz Criterion
Objectives:
To design controller system gain for obtaining specific characteristics. Using
MATLAB, design controllers for stable systems response and plot the results. To plot
phase portrait characteristics of different systems and interpret them.

Introduction:
The RouthHurwitz 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.

RouthHurwitz 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
is stable) if all the coefficients satisfy

62

For a third-order polynomial

the coefficients must satisfy


For a fourth-order

, all
, and

polynomial
coefficients must satisfy

, all the

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 non-negative poles.
Consider a system with a characteristic polynomial

63

We have the following table:


Table 10.2 Fifth Order Example

0.75 1.5

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

20

16

12

16

12

16

64

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 imaginary axis. These two points on the imaginary axis are the
prime cause of marginal stability

Phase Portrait:
A phase portrait is a geometric representation of the trajectories of a dynamical
system in the phase plane. Each set of initial conditions is represented by a different
curve, or point. Phase portraits are an invaluable tool in studying dynamical systems.
They consist of a plot of typical trajectories in the state space. A phase portrait graph
of a dynamical system depicts the system's trajectories (with arrows) and stable steady
states (with dots) and unstable steady states (with circles) in a state space. The axes
are of state variables.

Figure 10.1: Phase Potrait

65

Lab Tasks:
Lab Task 1:
For the following systems, find the range of K for stability using Routh
Hurwitz criterion. Verify using Simulink.
i.

ii.

iii.

Also find open loop stability, total response stability and natural response
stability. Also design K.

Lab Task 2:
Perform the phase portrait Analysis of the following systems:

i.

ii.

iii.

iv.

v.
vi.
66

Experiment 11

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

67

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
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

Lab Tasks on COM3Lab:


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)
68

Experiment 12

Automatic Open Loop and Closed Loop Speed


Control and Effect of the Different Components of
the PID Controller
Objectives:
To study, analyze and record data from various configurations (open loop,
closed loop) of the PID controller and to plot the recorded data.

Introduction:
Servo motor trainer (developed by Tidiers Pool, Islamabad) is designed for the
study of angular speed and position transducers and their automatic controls. It
consists of a front panel with test-points and silk screen-printed electrical circuit
diagram (Figure 12.1), divided into blocks forming the control chain. These building
blocks include:
1. Set point
2. Error amplifier (Qty:2)
3. Potentiometer conditioner
4. Tacho generator conditioner
5. Speed detector
6. Digital RPM meter
7. PID controller
8. Current limiter
9. PWM power amplifier
10. Speed and position process unit
On the right side of the module, there are two terminals (a red one and a black
one) for the connection between the trainer and transducers of the external unit. The
external motor unit consists of a permanent magnet showing transparent/opaque radial
sectors (Figure 12.2).

69

Figure 12.1 DC servo motor trainer

(a)

(b)

(c)

Figure 12.2 External motor unit: Front and side views

70

Lab Tasks:
Lab Task 1 (Automatic open loop speed control)
The step by step procedure of this task is mentioned below:
o Carry out the circuit of Figure 12.3.
o Jump terminals 26-27 to insert the clamp circuit.
o Set a null load value with the knob of the mechanical brake.
o Set a 0V voltage with the knob of the mechanical brake.
o Fill Table 12.1 with these data.
o Repeat measurement for all the voltage values on the table.
o Bring the set point voltage back to 0V.
o Apply a significant load by acting on the brake knob. Take care not to
block the motor with a too strong breaking action.
o Repeat measurement s with load.
o Report in Graph 12.4 the set point voltage / rotating speed diagrams with
no load and load different from zero.
o Repeat measurements with negative set point and voltage values.

Set Point

29 PWM & Power

Figure 12.3 Open loop speed control

Table 12.1 Observation table (Open loop speed control)

Voltage
0
1
2
3
4
5
6

RPM

71

Speed

350030002000-

1000-

Set Point
1

V Point

Figure 12.4 Characteristics: Open loop speed control

Lab Task 2 (Automatic closed loop speed control)


The closed loop speed control is shown in following block diagram.

Set

PID Controller

Amplifier

Signal

Motor

Transducer

Conditioner

Figure 12.5 Closed loop speed control

The main elements of speed control are:

Set Point: It is the block by which the desired input signal is given for the
whole circuit.

Comparison Block: It consists in the section of Error Amplifier and it


compares the obtained output variable with the set input one.

Controller: Controller type is PID which can be configured in different ways:


the three actions (proportional, integrative and derivative) can be controlled
and inserted separately.

Power Amplifier: It is an electric circuit which doses the input electric


power in order to give it to the actuator (electric motor).

72

Speed Transducer: Here Tacho Generator is used which is followed by the


signal conditioner which takes the signal supplied by the transducer back to
the same kind of signal used for the set point.

Position and Speed Process Unit: It contains DC Motor module, tachometer,


and circular rotation dial with graduated angular scale.

The step by step procedure of this task is mentioned below:


o Carry out the circuit of Figure 12.6.
o Set null load value with the knob of the mechanical brake.
o Set the PID Controller to the maximum with the Proportional knob and to
the minimum Integrative one.
o Set a 0V voltage with the set point and read the digital RPM meter speed
on the display.
o Fill the Table 12.2 with these data.
o Repeat measurement for the voltage values on the table.
o Bring the set point voltage back to 0V.
o Apply a significant load by acting on the brake knob.
o Repeat measurements with no load.
o Report in a graph like 12.7 the set point voltage/ rotating speed diagrams
with no load and load different from zero.
o Repeat measurements with negative set point values.
o Confront the obtained values with the open loop exercise ones.

Figure 12.6 Trainer configuration for closed loop speed control

73

Table 12.2 Observation table (Closed loop speed control)

Voltage
0
1
2
3
4
5
6
7
8
9

RPM

Speed

350030002000-

1000-

Set Point
1

V Point

Figure 12.7 Characteristics: Closed loop speed control

Lab Task 3 (Study the Effects of Different Components of PID


Controller
The step by step procedure of this task is mentioned below:
o Carry out the circuit of Figure 12.6.
o Set a null load value by acting on the mechanical break knob.
o Insert only the proportional action of the controller (connect only terminals
11 and 12) and take the proportional knob to the minimum value.
o With the set point apply a 4V and measure the voltage across terminal 6
(output of the error amplifier) which corresponds to the difference between
set point and obtained output variable.
74

o Take the proportional knob to the maximum value.


o Measure the output voltage of the error amplifier and measure the error
variations as the function of proportional action and take the integrative
potentiometer to the minimum value: measure the error.
o Set the integrative potentiometer to half stroke and the proportional
potentiometer to the minimum.
o Measure the error under these conditions and then remove the integrative
action by disconnecting the terminals 13 and 14 and measure the error
again.
o Note how the integrative action tends to zero the error.
o Connect terminals 13 to 14 again and take the integrative potentiometer to
the minimum value.
o Note how the integrative action diminishes the error but tends to make the
system ripple (unstable conditions).
o Introduce the derivative action and observe how this action takes the
system back to the stable conditions.

Home Task:

Write your comments and conclusion in the end of


your lab-report.

75

Experiment 13

Rigid Body PD & PID Control Using Rectilinear


Plant
Objectives:
To demonstrate key concepts associated with Proportional plus Derivative
(PD) control and subsequently the effects of adding integral action (PID).

Equipment/Tools required:
Rectilinear Plant with controller interfaced with PC

Introduction:
This control scheme, acting on plants modelled as rigid bodies finds broader
application in industry than any other.

It is employed in such diverse areas as

machine tools, automobiles (cruise control), and spacecraft (attitude and gimbal
control). The block diagram for forward path PID control of a rigid body is shown in
Figure 13.1a where friction is neglected. Figure 13.1b shows the case where the
derivative term is in the return path. Both implementations are found commonly in
application and, as the student should verify, both have the identical characteristic
roots. They therefore have identical stability properties and vary only in their
response to dynamic inputs.
The closed loop transfer functions for the respective cases are:

c(s) =

c(s) =

khw/m kds2 +kp s+ki


x(s)
=
r(s) s 3 + khw/m kds 2 +kp s+ki

(13.1a)

khw/m kp s+ki
x(s)
=
r(s)
s 3 + khw/m kds 2 +kp s+ki

(13.1b)

For the first portion of this exercise we shall consider PD control only (ki=0). For the
case of kd in the return path the transfer function reduces to:

c(s) =

khw/m kds+kp
s2 + khw/m kds+kp
76

(13.2)

By defining:

n =

kp khw
m

(13.3)

(13.4)

k k
kdkhw
kdkhw
kdkhw
=
= d hw =
2m n 2 mkp khw
2m n 2 mkp khw

Which can be expressed as:

c(s) =

2n
s2 +2n s + 2n

The effect of kp and kd on the roots of the denominator (damped second order
oscillator) of Eq (13.2) is studied in the work that follows.

r(s)
Reference Input
(E.g. Input
Trajectory)

k
kp + si + kds

khw

Hardware
Gain

PID Controller

1
ms2
Plant

x(s)
Output
(Mass position)

a) PID In Forward Path

r(s)
Reference Input
(E.g. Input
Trajectory)

k
kp + si

khw

PID Controller

Hardware
Gain

1
ms2
Plant

kd s

b) PI In Forward Path, D In Return Path

Figure 13.1 Rigid body PID control Control block diagram

77

x(s)
Output
(Mass position)

Procedure:
Proportional & Derivative (PD) Control Actions:
1. Construct a model of the plant with four 500g mass pieces on the
first mass carriage with no springs or damper attached. You may
neglect friction.
2. Set-up the plant in the configuration described in Step 1. There
should be no springs or damper connected to the first carriage
and the other carriages should be secured away from the range of
motion of the first carriage.
3. From Eq (13.3) determine the value of kp (kd=0) so that the
system behaves like a 2 Hz spring-mass oscillator.
4. Set-up to collect Encoder #1 and Commanded Position
information via the Set-up Data Acquisition box in the Data
menu. Set up a closed-loop step of 0 (zero) counts, dwell time =
3000 ms, and 1 (one) rep (via Trajectory in the Command menu).
5. Enter the Control Algorithm box under Set-up and set
Ts=0.0042s and select Continuous Time Control. Select PID and
Set-up Algorithm. Enter the kp value determined above for 2
Hz oscillation (kd & ki = 0, do not input values greater than kp =
0.08) and select OK.
Place the first mass carriage at approximately the -0.5 cm
(negative is toward the motor) mark.
In this and all future work, be sure to stay clear of the mechanism
before doing the next step. Selecting Implement Algorithm
immediately implements the specified controller; if there is an
instability or large control signal, the plant may react violently.
If the system appears stable after implementing the controller,
first displace it with a light, non sharp object (e.g. a plastic ruler)
to verify stability prior to touching plant.
Select Implement Algorithm, then OK.
6. Enter Execute under Command. Prepare to manually displace
the mass carriage roughly 2 cm. Select Run, displace the mass
approximately 3 cm and release it. Do not hold the mass position
for longer than about 1 second as this may cause the motor drive
thermal protection to open the control loop.
7. Plot encoder #1 output. Determine the frequency of oscillation.
What will happen when proportional gain, kp, is doubled?
Repeat Steps 5 & 6 and verify your prediction. (Again, for
system stability, do not input values greater than kp = 0.06).
8. Determine the value of the derivative gain, kd, to achieve kdkhw=
50 N/(m/s). Repeat Step 5, except input the above value for kd
and set kp & ki = 0. (Do not input values greater than kd = 0.04).
78

9. After checking the system for stability by displacing it with a


ruler, manually move the mass back and forth to feel the effect of
viscous damping provided by kd. Do not excessively coerce the
mass as this will again cause the motor drive thermal protection
to open the control loop.
10. Repeat Steps 8 & 9 for a value of kd five times as large (again,
kd < 0.04). Can you feel the increased damping?

PD Control Design:
11. From Eq's (13.3 and 13.4) design controllers (i.e. find kp & kd)
for a system natural frequencies n = 4Hz, and three damping
cases: (1) = 0.2 (under-damped), (2) = 1.0 (critically
damped), (3) = 2.0 (over-damped).

Step Response:
12. Implement the underdamped controller (via PI + Velocity
Feedback) and set up a trajectory for a 2500 count closed-loop
Step with 1000 ms dwell time and 1 rep.
13. Execute this trajectory and plot the commanded position and
encoder position (Plot them both on the same vertical axis so that
there is no graphical bias.)
14. Repeat Steps 12 & 13 for the critically damped and over-damped
cases. Save your plots for later comparison.

Frequency Response:
15. Implement the underdamped controller from Step 11. Set up a
trajectory for a 600 count closed-loop Sine Sweep from 0.1 Hz to
20 Hz of 60 seconds duration with Logarithmic Sweep checked.
(You may wish to specify Encoder #1 data only via Set-up Data
Acquisition. This will reduce the acquired data size.)
16. Execute the trajectory and plot the Encoder 1 frequency response
using Linear Time and Linear amplitude for the horizontal and
vertical axes. The data will reflect the system motion seen as the
sine sweep was performed. Now plot the same data using
Logarithmic Frequency and Db amplitude. By considering the
amplitude (the upper most portion of the data curve) you will see
the data in the format commonly found in the literature for Bode
magnitude plots. Can you easily identify the resonance frequency
and the high frequency (>5 Hz) and low frequency (< 0.8 Hz)
gain slopes? (i.e. in Db/decade).
17. Repeat Step 16 for the critically damped and overdamped cases.

79

Adding Integral Action:


18. Now compute ki such that kikhw = 7500 N/(m-sec). Implement a
controller with this value of ki and the critically damped kp & kd
parameters from Step 11. (Do not input ki >3). Be certain that
the following error seen in the background window is within 20
counts prior to implementing.). Execute a 2500 count closedloop step of 2000 ms duration (1 rep). Plot the encoder #1
response and commanded position.
19. Increase ki by a factor of two, implement your controller (do not
input ki >3.0) and plot its step response. Manually displace the
mass by roughly 5 mm. Can you feel the integral action
increasing the restoring control force with time? (Do not hold for
more than about 2 seconds to avoid excessive force build-up and
hence triggering the motor thermal protection.) What happens
when you let go?

Questions:
I.

What is the effect of the system hardware gain, khw, the mass, m, and
the control gains, kp and kd, on the natural frequency and damping
ratio? Derive the transfer function for the mass/spring/damper system
shown in Figure 13.2. How do the viscous damping constant, c, and
the spring constant k correspond to the control gains kd and kp in the
PD controlled rigid body of Figure 13.1b?

II.

Describe the effects of natural frequency and damping ratio on the


characteristic roots of Eqs 13.1. Use an S-plane diagram in your
answer to show the effect of changing from 0 to for a given n.

III.

Compare the step response and frequency response plots for the under, critical, and overdamped cases (ki = 0). Discuss how the resonance
(if present), and bandwidth
seen in the frequency response data
correlate with features of the step responses.

x(t)
k
F(t)
m
c
Figure 13.2 Mass/Spring/Damper

80

Experiment 14

Control and Task Accomplishment Using 6-DOF


Robotic Arm
Objectives:
To investigate the control of robots by providing a series of motion
instructions to the motors of a robotic arm. To understand and visually inspect the
robots functionality, a simple but very common industrial task of pick and place
objects using the robotic arm will be demonstrated.

Introduction:
The robotic arm 7220C (developed by ED laboratory, Korea) is a vertical
articulated, 5 joint, 6 Degree Of Freedom (DOF) system which is actuated by six DC
servo motors. Such kinds of arms are common and popular in industry. Therefore, the
experience gained through the experiments can be directly mapped in the real
business needs. The ED-7220C is designed such that the main driving mechanism,
including the timing belt, is exposed to the user to offer the visual observation. The
arm is shown in Figure 14.1.

Figure 14.1 ED7220C robotic arm

81

Inspired from human arm, the robotic arm has 5 joints; (Figure 14.2); waist,
shoulder, elbow, wrist and hand. All of the joints except wrist have 1 DOF. The wrist
has 2 DOFs. Corresponding to 6 DOF, the arm is equipped with six motors (A-F)
A
B
C
D
E
F

Hand closing & opening (Gripper)


Hand rotation (Wrist)
Hand azimuthal motion (Wrist)
Elbow rotation
Shoulder rotation
Waist rotation

Figure 14.2 Robotic arm and the human arm

Table 14.1 summarizes important features of the robotic arm.


Table 14.1 ED7220C features

Feature
Position precision
Movement speed
Load capacity

Description
0.5mm (approx.)
100mm/s (max.)
1 Kg
DC servo motor
Actuator
(with optical encoder)
Gripper opening
55mm
Weight
25/33 Kg
Wrist rot: 360
Elbow: 130
Range Of Motion (ROM)
Shoulder: +130/-35
Body: 310
82

The overall system consists of robotic arm, robot controller (ED-MK4) and
teaching loader as shown in Figure 14.3. The robot can be controlled either with a PC
or with a teaching loader (limited control). Major electronics (except encoders) reside
inside the controller. The PC communicates with the system through RS232 interface
using application software RoboTalk (RT) or sending robotic arm commands using
a programming language (e.g. BASIC, C etc).

Figure 14.3 Complete system

The controller generates motion commands for the motors which are directed
to the arm through data cables (see A-F cables in Figure 14.4). The motor moves
either in joint coordinate system (encoder ticks) or in Cartesian coordinate system
(x,y,z,two wrist angles). On the way back, the encoder (position sensor) data is sent
from the robotic arm to the controller (and ultimately accessible in PC) thus
completing a closed loop feedback control system.
The controller has a 16 bit microprocessor (80188) and a motor controller
(8751). With a variety of memory storage (RAM, EPROM, EEPROM), the controller
offers flexibility. To interface user-designed circuits/systems with the controller, I/Os
have been provided. The inputs can be given either through eight I/p terminals or
through eight toggle switches. While available eight O/p terminals can be used to
drive external circuit.

83

Figure 14.4 Robot controller (ED-MK4)

More than 100 kernel commands are provided to communicate and control the
robotic arm. Table 14.2 lists some of the control commands to read or set various
motor parameters. Commands to read/set the Proportional (P), Integral (I) and
Derivative (D) gains permit the robotic arm to be used in a wide range of educational
and research applications.
Table 14.2 Control commands

Category

Motor

Gains

Commands
Read/Set PWM level & direction
Read/Set destination position
Read actual position
Read/Set rotation angle
Read/Set motor/system velocity
Read/Set system acceleration
Read/Set P/I/D gains
Store/Restore user gains to/from EEPROM

A Teaching loader is available as a remote control


device. It is an ideal tool for a rapid, hand-on introduction to
the robotic arm. They use a readily understood pictorial
language that can be mastered within a short time. With a teach
pendant, an operator can control the robot without having any
knowledge of a formal programming language. Moreover they
provide an easy and quick way of maintenance and repair bu
conducting extensive tests of robot motion. The teaching
loader is shown in Figure 14.5.

Figure 14.5 Teaching loader

84

Lab Tasks:
Lab Task 1 (Object Placement)
Pick and drop of objects is a universal task in many robotic applications.
Domains like packaging, manufacturing, construction, inspection, spot welding,
production, household etc employ this task in one form or the other. This lab task is
intended to examine this task using ED robotic arm.
Prior to the start of experiment, make sure that the setup is according to Figure
14.3. Place an object (e.g. a car key with a chain) at any location (say point P0) within
the reachable workspace of the robot.

STEP-I: Coding
Create and open a new text file in any editor (e.g. a notepad file named
code.txt). Using robotic arm kernel commands, write a simple program to instruct the
robot to perform pick and place. The sequence can be
i.

Move to Home

ii.

Open gripper

iii.

Move to a temporary point (P01) immediately above P0. This is defined for a
reason. Imagine if the robot moves and directly goes to P0, because of the
orientation of the object (key in this case), the robot (gripper) will collide with
the key and force it to fall down (change the orientation). By defining
temporary point P01, the robot goes immediately above the object and finally
to P0 (next step) thereby having the key in the middle of the gripper.

iv.

Move from P01 to P0.

v.

After reaching P0, close the gripper. This will let the current object picked up.

vi.

The next step is to drop the object at destination point (P02). Move to P02.
While moving, you may need to define temporary points to avoid the collision
between the robot and environment objects (obstacles) to ensure safe
operation.

vii.

After reaching at P02, open gripper resulting in dropping the object.

viii.

Now if you command the robot to move to its Home position, the robot will
do so however colliding and changing the orientation of key (object). So better

85

way is first to move up little bit at another temporary point (P03) and then
going toward home.
Note: The code will be explained during the lab session.

STEP-II: Running RoboTalk & Loading Code


Open DOS based RoboTalk by double clicking RT.exe. Once RoboTalk
begins execution, your computers screen will clear and you will see display of
information about RoboTalk. Press any key to continue. The screen will again clear
and you will see update information about RoboTalk including the version number.
To continue, press any key. The screen will clear again and you will see the prompt:
Initialize Robot? (Y/N/RETURN=N):
Answering YES to this question will cause RoboTalk to automatically move the robot
to its hardhome position. You generally answer YES to this question (first time)
unless the robot is already at its hardhome position. In order for the programs that you
write to work consistently each time they are run, it is necessary for the robot to be in
known starting position. This is why RoboTalk has the automatic hardhome proceed
built into it.

Once the robot has been initialized you will see the main system menu and prompt. It
is:
RoboTalk:Edit, Run, Load, Save, Do, Teach, Files, Config, Quit
enter command:
This is the top level menu in the RoboTalk system and will be referred to as
the RoboTalk menu. Only the stated options are valid at this point. You may type
either the first letter of the command or the entire word. Edit invokes the text editor.
Run will execute the current program. Load will load a program from a disk file.
Save will save a program to a disk file. Do invokes direct execution mode where you
may directly execute most RoboTalk language commands one at a time. Teach
allows the assigning of variable names to robot location points for later use in a
program. Files will list the disk files on your current diskette. Config configures
86

RoboTalk to your system environment. Quit exits to the operation system of the
computer.

After running RoboTalk, load the file containing the code (place.txt) by
pressing L or writing Load at RoboTalk menu. It will prompt for file name.
Entering the file name will load the code typed in an editor. Any problem in loading
will result in an error displayed on the screen.

STEP-III: Teaching Points


The robotic arm is not really an intelligent system, nor is equipped with
sophisticated sensory interfaces. It needs to be manually taught the coordinates of all
the points (P0, P01, P02 and P03). Fortunately the remote shipped with robotic arm
acts as a Teaching Loader and supports the operator through a simple and quick
interface to teach the robot about different locations. Motors B to F can be moved by
pressing the respective keys on the teaching loader. (Remember motor A has just two
states, open and close gripper)
From the RoboTalk menu, press T or write Teach. The robot will enter into
teaching mode. Using teaching loader, move motors B-F in such a way that the robot
reaches P0. Then press Enter from the loader. This location is recorded and learnt by
the robot. Similarly teach the robot other points P01, P02 and P03 by moving
respective motors (B-F).

STEP-IV: Running Program


Now the program is already loaded and the robot knows all the points during
its trajectory, it is essentially time to run the program. From the RobotTalk menu,
write Run or simply press R. The program execution will start immediately.

The overall sequence in pictorial form is presented in Figure 14.6 for further
clarity.

87

Home Task:
For optimized placement of multiple objects from one point to the other,
various control algorithms have been proposed. Search the literature and mention at
least two such control algorithms

Figure 14.6 Pick and place task snapshots

88

Experiment 15

15-A) State Space Modelling Using Matlab and


Simulink
Objectives:
To evaluate and analyze systems by implementing state space models in
MATLAB and using Simulink, analyze control systems based on (i) State space block
(ii) Explicit state space implementation (iii) Implicit state space implementation.

Introduction:
In control engineering, a state space representation is a mathematical model
of a physical system as a set of input, output and state variables related by first-order
differential equations. To abstract from the number of inputs, outputs and states, the
variables are expressed as vectors, and the differential and algebraic equations are
written in matrix form. "State space" refers to the space whose axes are the state
variables. The state of the system can be represented as a vector within that space.

Advantages:
There are several advantages to using the state space representation compared with
other methods. Some of there are:

the ability to easily handle systems with multiple inputs and outputs;
the system model includes the internal state variables as well as the
output variable;
the model directly provides a time-domain solution, which ultimately
is the thing of interest;
the form of the solution is the same as for a single 1st-order differential
equation;
the effect of initial conditions can be easily incorporated in the
solution;
the matrix/vector modeling is very efficient from a computational
standpoint for computer implementation

89

Linear Systems representation:


The general state-space representation of a linear system with p inputs, m
outputs and n state variables is written in the following form:

Where
is the "state vector", y is the "output vector"
u is the "input (or control) vector"
A is the "state matrix",
B is the "input matrix",
C is the "output matrix",
D is the feed forward matrix,
Canonical realizations:
Any given transfer function which is strictly proper can easily be transferred
into state-space. Given a general transfer function:

.
The coefficients are inserted directly into the state-space model as:

This state-space realization is called controllable canonical form because the


resulting model is guaranteed to be controllable (i.e., because the control enters a
chain of integrators, it has the ability to move every state).
The transfer function coefficients can also be used to construct another type of
canonical form:
90

This state-space realization is called observer canonical form because the


resulting model is guaranteed to be observable (i.e., because the output exits from a
chain of integrators, every state has an effect on the output).

Parallel RLC circuit:


Here is a sample of the state space for the following RLC circuit:

Figure 15.1 Example Parallel RLC circuit

91

92

Lab Tasks:
Lab Task 1:
Construct state space for following electrical system:
a) In MATLAB where v(t)=sin(t).
b) In Simulink with:

State space block, explicit state space

implementation, implicit state space implementation.

Figure 15.2 Series RLC for Lab Task 1

Lab Task 2:
Considering the following mass-spring-damper system where x1 and x2
denote the outputs while u1 and u2 represent the inputs.

Construct state space in MATLAB and Simulink using all three methods.

Figure 15.3 Mass spring damping system

Lab Task 3:
Solve using observer and controller canonical form, where f(t)=10N is the
input and x1,x2 and x3 are the outputs.
93

15-B) Systems: Transfer Functions, State Space,


Pole-Zero Maps and Responses, Inter-conversion
between State Space and Transfer Function
Objectives:
To evaluate and analyze systems in MATLAB and Simulink and do
conversion from transfer functions to state space and vice versa. To plot pole-zero
maps of systems and system responses (impulse and step).

Introduction:
In this lab, a number of MATLAB functions are used to analyze systems and
plot their responses. Given below is brief description of few:
Transfer function:
>>sys_tf = tf (num, den);

Where num and den are numerator and denominator matrices


respectively and tf calculates transfer function.
State space:
>>sys_ss = ss (a, b, c, d)

Where a, b, c, d are system state-space representation matrices and ss


gives state-space model.
Time matrix:
>>t = linspace (start time, end time, no. of samples)

lsim:
Used for linear simulation.
>>[y, t] = lsim (sys, u, t)
Here, sys can be sys_tf or sys_ss, u is the input matrix and t is the time matrix.
The function gives two outputs, y and t, where y is the output matrix with time t. The
function simulates for both state space and transfer function.
>>[y, t, x] = lsim (sys_ss, u, t, x0)
94

This has another input, initial condition x0. It also gives additional output x
which has states.
Pole-zero map:
>>pzmap (sys)
where sys can be transfer function or state space.
Step response:
>>[y, t] = step (sys)
where sys can be transfer function or state space.
Natural response:
>>[y, t] = impulse (sys)
where sys can be transfer function or state space.
Conversion between transfer function & state space (MIMO and SISO):
a) ss2tf (state space to transfer function)
>>sys_ss = ss (a, b, c, d)
>>sys_tf = ss2tf (sys_ss)
or
>>[num, den] = ss2tf (a, b, c, d)
>>sys_tf = tf (num, den)
b) tf2ss (transfer function to state space)
>>sys_ss = tf2ss (sys_tf)

95

Example:
Plot the response of the state-space model

to the initial condition

a = [-0.5572 -0.7814;0.7814 0];


c = [1.9691 6.4493];
x0 = [1 ; 0]

sys = ss(a,[ ],c,[ ]); % the values of matrix B and D have to be placed into the
equation
initial(sys,x0)
% initial function calculates the unforced response of a state- space (ss)
model sys with an initial condition on the states specified by the vector x0

Figure 15.4 Example system response

96

Lab Tasks:
Lab Task 1:
For the system represented below:

a) Convert to transfer function


- using tf function
- using ss2tf function
b) Use lsim for generating step response
- with no initial condition
- with x0= [-1; -2] (also plot the states)
c) Create step response with step function and compare the results with
the ones calculated in part b.
d) Plot the pole-zero map of the system.

Lab Task 2:
For the transfer function G(s):

a) Obtain state space by


- using tf function and then ss function
- obtaining a, b, c, d matrices from num, den using tf2ss and
then ss function
b) Plot pole-zero map.
c) Simulate and give response using lsim function with input u=sin(t)
d) Plot impulse response using MATLAB and Simulink and compare

results of the two.


97

Experiment 16

Robian (Theme)
INTRODUCTION
The world of robotics has always fascinated students and engineers.
Historically, ROBIANS were considered a robotic nation with no will
and thinking power. After death of Dr. IVO ROBOTNIK who used to
reprogram them to have the capability of free thinking, CIIT is adopting
ROBIANS and its your responsibility now to make use of them.
How interesting it would be to have your own ROBIAN? . COMSATS
Islamabad is organizing ROBIAN12: the second ever robotic contest
in the history of COMSATS. The main objectives are to unleash talent in
students and to provide an opportunity for them to develop expertise in
various fields of robotics and mechatronics. Not less importantly, this
competition is aimed at preparing the students to face and accomplish
challenges in their future career life and to develop sense of sportsman
spirit.
OBJECTIVES

To work together as a team to solve challenging problems with spirit of C3


(Cooperation, Coordination and Collaboration).
To enable students to develop logical and systematic thinking during their
design and implementation of developed algorithms to program robots
intended for accomplishment of a challenging task. .
To enhance students creativity by developing problem solving skills and by
raising their awareness of the multiple possibilities to achieve a desired goal.
To promote competition in robotics.

Competition Date: Thursday, 24th May 2012


Competition Venue: Seminar Hall, Department of Electrical Engineering, CIIT
Islamabad.

98

THE CONTEST ARENA


The theme for the 2nd ROBIAN is a complicated line following
scenario. The corresponding arena provides best compromise among
various considerable parameters including interest level, complexity
depth and timeframe of three months for robot development. The
arena is shown in Figure 16.1.

Figure 16.1 Contest Arena

FLOOR DIMENSIONS
i. The Contest Arena is made by Waterproof Floor Mat sheets of size 400 X
250 cm.
ii. Fixed Lines are marked on the arena. The Lines are made from 3 cm wide
White Reflector Tape.
iii. Starting and ending points are marked on the floor.
iv. The three square shaped disaster sites have dimensions of 30.48cm X 30.48
cm
v. The fourth disaster side is a semi-circle with radius 30.48 cm

99

THEME OF CONTEST
Initial starting point of robot is fixed i.e. mentioned in the Figure 16.1 Each
robot will act as an emergency response vehicle that will have to reach the
four disaster sites in the least possible time. All disaster sites have been
highlighted with red color. Initially, each robot will first reach the Checkpost,
which is 1 feet away from the starting point. Valuable marks will be awarded.
(See points table).
Than after entering the arena through the Checkpost, the autonomous
Unmanned Ground Vehicle (UGV) will have to reach the disaster sites and
intelligently track through the possible paths provided by the white line. The
closest disaster site is FIRE highlighted by red in Figure 16.1. It is easily
assessable and so contains the least marks. In order to gain those points, the
robot will have to track any one of the four sides of the 1-square-feet box. The
points will be awarded if the UGV fully traverses any one side of the foursided disaster site. Similarly, the next disaster side is the CAR ACCIDENT
which has only two routes available. The third site BANK ROBBERY has a
more difficult approach. The last site TERRORIST ATTACK is the farthest and
the toughest of the emergency locations because in order to gain the points
for this site, robots will have to track a curved line between any two of the
three points (A, B, C) marked, as shown on Figure 16.1.

100

ROBOT SIZE AND WEIGHT


i. Maximum size of robot can be 1ft * 1ft (30.48 cm * 30.48 cm)
ii. Maximum weight of participating robot can be 5Kg.
All sensors mounted on the robot will be counted as part of the robots total
dimensions. Adding of any non-functional material like flag or logo is allowed
after-measurement.
Note: See penalties section for oversized / overweight robots.

SENSORS
There is no restriction on the type of sensors that can be used. However,
contestants are not allowed to place any markers, beacons or reflectors in the
contest area to aid in the robots navigation.

POWER SUPPLY
Robot should have on-board power source and maximum supply voltage
allowed is 18 Volts.

TEAMS
A team can only be composed of maximum 4 members. The names and
registration numbers of the team members should be communicated within 1
week (till 1st March 2012) to front office EE Department.

DURATION OF MATCH
i. Each team will be given maximum 9 minutes to complete their task.
However, team may be asked to stop the robot earlier if the referees decide
that the task cannot be completed due to mechanical problems or for safety
reason.
ii. Each team will be given 1 minute for setting up the robot at the start point.
iii. Robot can start at the instant when the start signal is given. It is highly
recommended that your robot must be constructed in a way that it can be
started in minimum possible operation(s).
101

iv. Once the robot started moving, team members will not be allowed to
touch the robot or enter in the contest arena.
v. The robot timing will start immediately after the contestant releases the
robot in arena.

POINTS
i. Successful approach to the CheckPost

5 marks

ii. Tracking any one side of the disaster site FIRE

10 marks

iii. Tracking any one side of the disaster site CAR ACCIDENT

20 marks

iv. Tracking any one side of the disaster site BANK ROBBERY

30 marks

v. Tracking any of the two points on the curved disaster site

40 marks

TERRORIST ATTACK
vi. Successful exit through Ending Point

45 marks

vii. Line Tracking (Atleast 8 feet)

50 marks

DEDUCTION OF POINTS
i. Retry number 1

5 marks

ii. Retry number 2

10 marks

iii. Oversize robot (Exceeding 30.48 cm * 30.48 cm)

20 marks

iv. Oversize robot (Exceeding 32.48 cm * 32.48 cm)


Disqualified

v. Overweight robot (Exceeding 5Kg)

40 marks

vi. Overweight robot (Exceeding 6Kg)


Disqualified

102

RULES
i. The Contest judges may stop any robot at any time if they feel that it is
performing, or is about to perform, any action that is dangerous or hazardous
to people or equipment.
Robot should have Emergency Stop button (probably implemented by
giving an interrupt of highest priority to the controller to stop the motors
immediately or even more simply emergency stop through turning off the
Power supply).
ii. All electronic circuitry must be designed and fabricated by the contestants
themselves. No Off-the-Shelf boards will be allowed.
iii. Total cost incurred on robot must not exceed Rs. 15,000/iv. Maximum efforts in the design and fabrication of the robot should be put
in by contestants themselves.
v. In all matters of interpreting the rules before and during the contest and in
any issues not covered by these rules, the decisions of the contest judging
committee will be final. However the committee will be bound to enforce the
rules homogeneously to ensure justice and equality.

TEST RUN
Contestants will be given time for trial run a day before the contest to
calibrate their robot/sensors on the actual arena/game field.
PRIZES
Winner
1st Runner Up
2nd Runner Up
Best Engineering Design
Additionally all those teams whose robots manage to traverse at least 2
disaster sites (out of 4) will be awarded with Certificate of successful
participation by ROBIAN12 organizers.

103

ORGANIZERS
Dr. JAMSHED IQBAL
Mr. AHSAN MALIK (& IDEA Student Society)
Mr. MUSTAFA PASHA
Mr. WAQAR SAEED
Mr. SOHAIL KHAN
Mr. IRFANULLAH
Mr. NOMAN JALIL
Mr. SHEHRYAR
Mr. RAHEEL AHMAD
Mr. ABDUS SAMAD
Mr. MUMTAZ ALI
Mr. KHURRAM NAVEED
Mr. ANUM ALI
Mr. FAHD SIKANDAR KHAN

Under the patronage and supervision of:


Dr. HAROON
Dr. SHAHID A. KHAN
Dr. SHAHZAD MALIK
Dr. SHAFAYAT ABRAR

104

Vous aimerez peut-être aussi