Titular Curs: S.L. Dr. Ing. Nicoleta-Cristina GĂITAN

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 197

1

Titular curs: s.l. dr. ing. Nicoleta-Cristina GITAN


Partea a 2-a - Sisteme distribuite pentru conducerea
proceselor industriale bazate pe sisteme cu
microcontrolere
CAP VIII Instrumentaie, Control, PLC
2
CAP II Introducere n arhitectura
procesoarelor ARM
n acest capitol vom ncerca s:
Introducere n arhitectura sistemelor distribuite la
nivelul ntreprinderii,
Introducere n OPC,
Serverul OPC de date,
Serverul OPC de alarme i evenimente,
Serverul OPC de istorice,
. .
2. Instrumentation
and Control

Instrumentation - Sensors
and actors
Instrumentation -
4
2.1.1 Market
2.1 Instrumentation
2.1.1 Market
2.1.2 Binary instruments
2.1.3 Analog Instruments
2.1.4 Actors
2.1.5 Transducers
2.1.6 Instrumentation diagrams
2.1.7 Protection classes
2.2 Control
2.3 Programmable Logic Controllers
5
The instrumentation market
Emerson (Fisher-Rosemount): 27 %
Invensys: 4-5%
ABB: 4-5%
Honeywell: 3-4%


one dominant player a lot of small players
6
Concepts
instruments = sensors (capteurs, Messgeber) and actors (actionneurs, Stellglieder)

binary (on/off) and analog (continuous) instruments are distinguished.

industrial conditions:

temperature range commercial: (0C to +70C)
industry (-40C..+85C)
extended industrial(40C..+125C)

mechanical resilience (shocks and vibrations) EN 60068
protected against Electro-Magnetic (EM)-disturbances EN 55022, EN55024)
sometimes NEMP-protected (Nuclear EM Pulse) - water distribution, civil protection
protection against water and moisture (IP67=completely sealed, IP20 = normal)
easy mounting and replacement
robust connectors
DC-powered (24V= because of battery back-up, sometimes 48V=)
7
2.1.2 Binary Instruments
2.1 Instrumentation
2.1.1 Market
2.1.2 Binary instruments
2.1.3 Analog Instruments
2.1.4 Actors
2.1.5 Transducers
2.1.6 Instrumentation diagrams
2.1.7 Protection classes
2.2 Control
2.3 Programmable Logic Controllers
8
Binary position measurement
binary sensors (Geber, "Initiator", indicateur "tout ou rien"):

micro-switch (Endschalter, contact fin de course) +cheap, -wear, bouncing

optical sensor (Lichtschranke, barrire optique) +reliable, -dust or liquid sensitive

magnetic sensor (Nherungsschalter, dtecteur de proximit) +dust-insensitive, - magnetic

9
Binary Signal processing
Physical attachment
Level adaptation,
Galvanical separation
EMC barrier (against sparks, radio, disturbances)

Acquisition
Convert to standard levels
Relay contacts 24V (most frequent), 48V, 110V (electrical substations)
Electronic signals 24V >10V-60V,
Output: 0..24V@100mA
Counter inputs: Gray, BCD or binary

Processing
Filtering (e.g. 0..8 ms filter),
Plausibility (Antivalenz, Antivalence),
Bounce-free (Entprellen, Anti-rebond)


10
2.1.3 Analog Instruments
2.1 Instrumentation
2.1.1 Market
2.1.2 Binary instruments
2.1.3 Analog Instruments
2.1.3.1 Position and speed
2.1.3.2 Temperature
2.1.3.3 Hydraulic
2.1.4 Actors
2.1.5 Transducers
2.1.6 Instrumentation diagrams
2.1.7 Protection classes
2.2 Control
2.3 Programmable Logic Controllers
11
Repeatability and accuracy
Not repeatable
Not accurate
Not repeatable
Accurate
Repeatable
Not accurate
Repeatable
Accurate
12
2.1.3.1 Analog mechanical position
potentiometer
capacitive
balanced transformer (LVDT)
(linear or sin/cos encoder)
strain gauges
piezo-electric
+cheap, -wear, bad resolution
+cheap, -bad resolution
+reliable, robust - small displacements
+reliable, very small displacements
+extremely small displacements
13
Variable differential transformer
(LVTD)
The LVDT is a variable-reluctance device, where a primary center coil
establishes a magnetic flux that is coupled through a mobile armature to a
symmetrically-wound secondary coil on either side of the primary.
Two components comprise the LVDT: the mobile armature and the outer
transformer windings. The secondary coils are series-opposed; wound in
series but in opposite directions.
source: www.sensorland.com
When the moving armature is centered between the two series-opposed secondaries, equal
magnetic flux couples into both secondaries; the voltage induced in one half of the secondary
winding is 180 degrees out-of-phase with the voltage induced in the other half of the
secondary winding.
When the armature is moved out of that position, a voltage proportional to the displacement
appears
14
Capacitive angle or position
measurement
C =
A
d
o

o
fixed
movable
capacitance is evaluated
modifying the frequency
of an oscillator
15
Small position measurement: strain
gauges
R =
l
A
l
2
V
A
=
volume = constant, = constant
l"
temperature compensation
by dummy gauges
frequently used in buildings, bridges,
dams for detecting movements.
Principle: the resistance of a wire increases when this wire is stretched:
l'
Dehnungsmessstreifen (DMS), jauges de contrainte
l
2
R
1
measure
R
2
compensation
measurement in bridge
(if U
0
= 0: R
1
R
4
= R
2
R
3
)
U
U
o
R
4
R
3
16
Piezo-electrical effect
source: Kistler

Piezoelectric materials (crystals) change form when an electrical field is applied to them.
Conversely, piezoelectric materials produce an electrical field when deformed.
Quartz transducers exhibit remarkable properties that justify their
large scale use in research, development, production and testing.
They are extremely stable, rugged and compact.
Of the large number of piezoelectric materials available today,
quartz is employed preferentially in transducer designs because of
the following excellent properties:
high material stress limit, around 100 MPa (~ 14 km water
depth)
temperature resistance (up to 500C)
very high rigidity, high linearity and negligible hysteresis
almost constant sensitivity over a wide temperature range
ultra high insulation resistance (10+
14
ohms) allowing low
frequency measurements (<1 Hz)
17
Force measurement
Force / Torque / Weight / Pressure is measured by small displacements (F = k
x):

- piezo-electrical transducers
- strain gauges

Acceleration is measured by way of force / displacement measurement (F = M
)
18
Principle of optical encoding
courtesy Parker Motion & Control
Optical encoders operate by means of a grating that moves between a light source and a
detector. The detector registers when light passes through the transparent areas of the
grating.
For increased resolution, the light source is collimated and a mask is placed between the
grating and the detector. The grating and the mask produce a shuttering effect, so that
only when their transparent sections are in alignment is light allowed to pass to the
detector.
An incremental encoder generates a pulse for a given increment of shaft rotation (rotary
encoder), or a pulse for a given linear distance travelled (linear encoder). Total distance
travelled or shaft angular rotation is determined by counting the encoder output pulses.
An absolute encoder has a number of output channels, such that every shaft position may
be described by its own unique code. The higher the resolution the more output channels
are required.
19
courtesy Parker
Motion & Control
Absolute digital position: Grey encoder
1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 15
LSB
MSB
LSB
MSB
straight binary: if all bits were to change at about the same time: glitches
Grey: only one bit changes at a time: no glitch
Grey disk (8 bit)
20
Analog speed measurement:
tachometer
angular speed e
Ui ~ de / dt,
f ~ e
transducer
analog: 4..20 mA

digital: 010110110
this voltage is converted into an analog voltage or current, which can later be converted to a digital
value,

alternatively, the frequency can be measured to yield directly a digital value
a simple tachometer is a rotating permanent magnet that induces a voltage into a stator winding.
21
Temperature measurement
the most frequently measured value in industry
www.omega.com
Thermowell
Extension Assemblies
Protection and
head assembly
22
Temperature measurement
Spectrometer:
measures infrared radiation by photo-sensitive semiconductors
+ highest temperature, measures surfaces, no contact
- highest price
Thermistance (RTD - resistance temperature detector):
metal whose resistance depends on temperature:
+ cheap, robust, high temperature range ( -180C ..600C),
- require current source, needs linearization.
Thermistor (NTC - negative temperature coefficient):
semiconductor whose resistance depends on temperature:
+ very cheap, sensible,
- low temperature, imprecise, requires current source, strongly non-linear
Thermo-element (Thermoelement, thermocouple):
pair of dissimilar metals that generate a voltage proportional to the
temperature difference between warm and cold junction (Seebeck effect)
+ high precision, high temperature, punctual measurement
- low voltage, requires cold junction compensation, high amplification, linearization
Bimetal (Bimetall, bilame):
mechanical (yes/no) temperature indicator using the difference in the dilatation
coefficients of two metals, very cheap, widely used (toasters...)
23
Thermo-element and Thermo-resistance
Thermo-element
(Thermocouple)
Thermoresistance
(semiconductor or metal)
Platinum (Pt 100)
Fe-Const
also: Pt/Rh - Pt
u
2 u
1
Fe
Constantan
Cu
Cu
U (u
2
-u
1
)
U u
i = constant
u
3
u
4
2 or 4 wire connection (to compensate voltage drop)
2,3- or 4-wire connection
reference temperature
(cold junction)
4..20 mA
4..20 mA
u
measured temperature
(hot junction)
two dissimilar
electrical
conductors
one material
whose resistance
is temperature-
dependent
extensio
n wire
24
2.1.3.3 Hydraulic measurements
Flow,
Mass Flow,
Level,
Pressure,
Conductivity,
pH-Sensor,
Viscosity,
Humidity,
special requirements: intrinsic safety = explosive environment, sea floor = high
pressure
25
Level measurement
pulsed laser

load cell

pulsed microwave

nuclear

ultrasonic (40-60 kHz)

low power ultrasonic

detector
row
see Control Engineering, Aug 2003
F = mg
26
Flow velocity measurement: differential
pressure
occultatio
n
(Blende)

membran
e
the flow velocity is proportional to the square root of the pressure
difference
piezo-electric
sensor
p
2
- p
1
= v
2
1

2

(Bernoulli effect)
p
2
p
1
v

fluid of
viscosity
27
Flow measurement
Other means:

Magnetic-dynamic
Coriolis
Ultra-sound
28
Flow measurement in a plant
29
2.1.4 Actors
2.1 Instrumentation
2.1.1 Market
2.1.2 Binary instruments
2.1.3 Analog Instruments
2.1.4 Actors
2.1.5 Transducers
2.1.6 Instrumentation diagrams
2.1.7 Protection classes
2.2 Control
2.3 Programmable Logic Controllers
30
Actors (Actuators)
About 10% of the field elements are actors (that influence the process).
Actors can be binary (on/off) or analog (e.g. variable speed drive)

The most common are:
- electric contactors (relays)
- heating elements
- pneumatic and hydraulic movers (valve, pump)
- electric motors (rotating and linear)
Solenoids,
DC motor
Asynchronous Motors (Induction)
Synchronous motors
Step motors, reluctance motors

Actors are controlled by the same electrical signal levels as sensors use
(4..20mA, 0..10V, 0..24V, etc.) but at higher power levels (e.g. to directly move a
contactor (disjoncteur).
31
Drives (variateurs de vitesse, Stellantriebe)
Variable speed drives control speed and acceleration and protect the motor
(over-current, torque, temperature).
High-power drives can feed back energy to the grid when braking (inverters).
Drives is an own market (Automation & Drives)
simple motor control cabinet for power of > 10 kW
small drive control < 10 kW
(Rockwell)
Motors are a separate business
32
Linear Motors
source: LinMot (/www.linmot.com)
33
Hydraulics and fluidics
Pumps, valves, rods,
source: www.bachofen.ch
fluidic switches
switchboard ("Ventilinsel")
the most widespread actor in industry
(lightweight, reliable, cheap)
I/P or E/P = electro-pneumatic
transducers
34
2.1.5 Transducers
2.1 Instrumentation
2.1.1 Market
2.1.2 Binary instruments
2.1.3 Analog Instruments
2.1.4 Actors
2.1.5 Transducers
2.1.6 Instrumentation diagrams
2.1.7 Protection classes
2.2 Control
2.3 Programmable Logic Controllers
35
Transducer
A transducer converts the information supplied by a sensor (piezo, resistance,)
into a standardized signal which can be processed digitally.

Some transducers have directly a digital (field bus) output and are integrated
in the sensor.

Other are located at distances of several meters from the sensor.
36
Example of analog transducer
Emergency panel
PLC
Control Room
Current

Transformer
0..1A rms
Field house
Transducer
4..20 mA
E R = Load
High voltage
Protection
37
4-20 mA loop standard
The transducer acts as a current source which delivers a current between 4 and
20 mA, proportional to the measurand (Messgrsse, valeur mesure).
Information is conveyed by a current, the voltage drop along the cable induces
no error.
0 mA signals an error (wire disconnection)
The number of loads connected in series is limited by the operating voltage
(10..24 V).
e.g. if (R1 + R2+ R3) = 1.5 kO, i = 24 / 1.5 = 16 mA, which is < 20 mA: NOT
o.k.)
Simple devices are powered directly by the residual current (4mA) allowing to
transmit signal and power through a single pair of wires.








Transducer
instrument

1
instrument

2
instrument

3
0, 4..20 mA
R1
R2 R3
Object
i = f(v)
10..24V
voltage
source

measurand
38
Analog measurements processing in the
transducer
Acquisition (Erfassung/Saisie)
Correction of pressure and temperature measurement for moist gases,

correction of level in function of pressure,

power and energy computation, cumulative measurements
Range, Limit supervision, Wire integrity
Error report, diagnostic, disabling.

Combined measurement

Plausibility
Filtering against 50Hz/60Hz noise and its harmonics
Scaling,
Linearization of sensors (Pt100, Fe-Const), correction (square root for flow).
Averaging and Computation of Root Mean Square (Effektivwert, valeur efficace),
Analog-Digital Conversion

Shaping (Aufbereitung/conditionnement)
Normalized Signals: 0-10V, 2-10V, (0/4-20mA), 20mA,
Resistance thermometer (Pt100),

Thermo-element
39
2.1.6 Instrumentation diagrams: P&ID
2.1 Instrumentation
2.1.1 Market
2.1.2 Binary instruments
2.1.3 Analog Instruments
2.1.4 Actors
2.1.5 Transducers
2.1.6 Instrumentation diagrams
2.1.7 Protection classes
2.2 Control
2.3 Programmable Logic Controllers
40
Instrumentation Diagrams
Similarly to electrical schemas, the control industry (especially the chemical
and process industry) describes its plants and their instrumentation by a

P&ID (pronounce P.N.I.D.) (Piping and Instrumentation Diagram),
sometimes called P&WD (Piping and wiring diagrams)

The P&ID shows the flows in a plant (in the chemical or process industry) and
the corresponding sensors or actors.

At the same time, the P&ID gives a name ("tag") to each sensor and actor,
along with additional parameters.

This tag identifies a "point" not only on the screens and controllers, but also on
the
objects in the field.
41
P&ID example
4, Combustor C2
2, Air Heater C1
3, SOFC Outlet
3, SOFC Inlet
TA51B
TI
TE TE TE PT
TA51A
TI
TA51C
TI
Chimney
Emission
Analysis
PT22
PI
TA22B
TI
TE TE TE PT
TA22A
TI
TA22C
TI
Process Air Exhaust
Blow Off Valve
BE
10 x
TE
TC2M1 - M10
TI
FLAMDETC2
BS
Ingnitor
Box
BE
10 x
TE
TC1M1 - M10
TI
Fuel Supply
S
SVGAS3
IC
Atmosphere
PT21
PI
TA21B
TI
TE TE TE PT
TA21A
TI
TA21C
TI
Rotary block valve
V52
IC
TE
TA62
TI
7, Heat
exchanger
6, Recuperator
TE
Latchable
Check Valve
S
SVGAS2
IC
FLAMDETC1
BS
TA32B
TI
TE TE TE
TA32C
TI
TA32A
TI
PT32
PI
PT
TY
I
P
Regulator Valve
TY
I
P
SVGAS1
IC
S
S
EMICO
E
EMIUHC
E
EMICO2
E
EMIO2
E
EMINOX
E
AIT
AIT
AIT
AIT
AIT
PT51
PI
F
r
o
m

s
a
m
p
l
e

p
r
o
b
e

a
t
C
1

e
x
i
t
TBVCOOL
IC
TBVDEP
IC
PT
TE
PT12
PI
TA12
TI
IGNITC2
IC
TW72
TI
PT
PT52
PI
TE
TA52
TI
G
AC Grid
Modulatable
Load
PCS
1,
C
5,
T
LOP
PI
SPEED
SI
PT ST
0
,

A
i
r

I
n
l
e
t
PT
TE
PT02
PI
TA02
TI
S
V12
IC
R
Ingnitor
Box C1
IGNITC1
IC
Piping and Instrumentation Diagram for MTG100FC Engine Tests
S
VPPWMC2
IC
FO
VMPWMC2
IC
S
S
VMPWMC1
IC
S
S
S
VPPWMC1
IC
FO
Fuel flow C2 MFM
Fuel flow C1 MFM
42
P&ID
The P&ID mixes pneumatic / hydraulic elements, electrical elements
and instruments on the same diagram

It uses a set of symbols defined in the ISA S5.1 standard.

Examples of pneumatic / hydraulic symbols:
pipe
valve
binary (or solenoid) valve (on/off)
350 kW
heater
vessel / reactor
pump, also
heat exchanger
analog valve (continuous)
one-way valve (diode)
43
Instrumentation identification
V1528
FIC
S
tag name of the
corresponding
variable
function
(here: valve)
mover
(here: solenoid)
The first letter defines the measured or initiating variables such as Analysis (A), Flow (F),
Temperature (T), etc. with succeeding letters defining readout, passive, or output
functions such as Indicator (I), Record (R), Transmit (T), and so forth
44
ISA S5.1 General instrument or function
symbols


Primary location
accessible to
operator
Field mounted
Auxiliary
location
accessible to
operator
Discrete
instruments
Shared
display,
shared
control
Computer
function
Programmabl
e logic
control
1. Symbol size may vary according to the user's needs and the type of document.
2. Abbreviations of the user's choice may be used when necessary to specify location.
3. Inaccessible (behind the panel) devices may be depicted using the same symbol but with
a dashed horizontal bar.
Source: Control Engineering with data from ISA S5.1 standard
45
Example of P&ID
FT101 is a field-mounted
flow transmitter connected
via electrical signals (dotted
line) to flow indicating
controller FIC 101 located in
a shared control/display
device
Square root extraction of the
input signal is part of FIC
101s functionality.
The output of FIC 101 is an electrical signal to TY 101
located in an inaccessible or behind-the-panel-board location.
The output signal from TY
101 is a pneumatic signal
(line with double forward
slash marks)
making TY 101 an I/P
(current to pneumatic
transducer)
TT 101 and TIC 101 are
similar to FT 101 and FIC
101
but are measuring,
indicating, and controlling
temperature
TIC 101s output is
connected via an internal
software or data link (line
with bubbles) to the
setpoint (SP) of FIC 101 to
form a cascade control
strategy
46
The ISA code for instrument type


First letter


Measured or initiating variable Modifier
A Analysis


B Burner, combustion


C User's choice


D User's choice Differential
E Voltage


F Flow rate Ration (fraction)
G User's choice


H Hand


I Current (electrical)


J Power Scan
K Time, time schedule Time rate of change
L Level


M User's choice Momentary
N User's choice


O User's choice


P Pressure, vacuum


Q Quantity Integrate, totalizer
R Radiation


S Speed, frequency Safety
T Temperature


U Multivariable


V Vibration, mechanical analysis


W Weight, force


X Unclassified X axis
Y Event, state, or presence Y axis
Z Position, dimension Z axis
47
Common connecting lines
Connection to process, or
instrument supply
Pneumatic signal
Electric signal
Capillary tubing (filled
system)
Hydraulic signal
Electromagnetic or sonic
signal (guided)
Internal system link
(software or data link)
Source: Control Engineering with data from ISA S5.1 standard

48
2.1.7 Protection Classes
2.1 Instrumentation
2.1.1 Market
2.1.2 Binary instruments
2.1.3 Analog Instruments
2.1.4 Actors
2.1.5 Transducers
2.1.6 Instrumentation diagrams
2.1.7 Protection classes
2.2 Control
2.3 Programmable Logic Controllers
49
German IP-Protection classes
2nd digit water

0 none

1 vertically falling

2 vertically dropping, 15 from vertical

3 spraying, 60 from vertical

4 spraying, any direction

5 jet, any direction

6 strong jet, any direction

protection against temporary
dipping
(30 mn, 1 m)
protection against permanent
dipping

9K water in high-pressure steam
washing
1st digit touching objects

0 none

1 large body object > 50 mm
surface
2 finger object >12.5 mm

3 tools, wires object > 2.5 mm

4 covered object >1 mm

5 dust

6 hermetical
for dust
e.g. IP 67 connector
50
Explosion protection
Instruments that operate in explosive environments
(e.g. petrochemical, pharmaceutical, coal mines,...) are subject to particular
restrictions.

e.g.
They may not contain anything that can produce sparks or high heat,
such as electrolytic capacitors or batteries without current limitation.
Their design or programming may not be altered after their acceptance.
Their price is higher than that of standard devices because they have to undergo
strict testing (Typentest, type test) by a qualified authority (TV in Germany)

Such devices are called Eex - or "intrinsic safety devices" (Eigensichere Gerte, "Ex-
Schutz", protection anti-dflagrante, "Ex" ) and are identified by the following logo:
51
European Explosion-Proof Code
Eex-devices are "safe" (certified) to be used in an explosive environment.
They must have passed a type test at TF (Germany), UL (USA),...
Swiss Norm: "Verordnung ber Gerte und Schutzsysteme in explosionsgefhrdeten Bereichen"
52
Control of continuos
processes
+
-
plant
measurement
controller
set point
controlled
variables
53
2.2 Control
2.1 Instrumentation
2.2 Control
2.2.1 Plant modeling
2.2.2 Controllers
2.2.2.1 On/Off (two-point) controller
2.2.2.2 PID controller
2.2.2.3 Nested Controllers
2.3 Programmable Logic Controllers
54
Motivation
This is an intuitive introduction to automatic control intended for
students who did not enjoy automatic control courses as a preparation for the
PLC programming.


First, modeling of plants is introduced.

Then, the two most popular controllers in industry are presented:

- the two-point controller

- the PID controller

Finally, nested controllers are introduced.
55
Open Loop control vs. Closed Loop control
1
2
3
4
5
temperature
open loop: temperature is imprecise,
depends on ambient temperature and
cooking quantity
but time of heating can be modulated.
120
140
180
200
220
closed loop:
temperature closely controlled,
requires measurement of the output
variable (temperature)
+
-
higher
/lower
temperature sensor
56
Open loop vs. closed loop
output
controller
+
-
plant
state
display
control variable
(analog)
set-point (solicited)
valeur de consigne
Sollwert,

plant
measurement
plant state
sequencer
on/off
plant
display
closed-loop control / regulation

(rgulation, Regelung)
keywords: feedback, analog variables,
continuous processes, "process control"
open-loop control / command

(commande / pilotage, steuern, )



keywords: sequential / combinatorial,
binary variables, discrete processes,
"batch control", "manufacturing"
output
error
(deviation)
binary
%
process value
(valeur mesure,
Istwert)
measurement
clock
57
2.2.1 Plant Modeling
2.1 Instrumentation
2.2 Control
2.2.1 Plant modeling
2.2.2 Controllers
2.2.2.1 On/Off (two-point) controller
2.2.2.2 PID controller
2.2.2.3 Nested Controllers
2.3 Programmable Logic Controllers
58
Modeling
The first step in analysis of control systems is to know the plant to be controlled.

Knowing means express the plants behavior in a mathematical way,
generally as a system of differential equations,

- by analyzing the physical principles (requires that all elements are precisely known)

- by identifying the plants parameters by analyzing its behavior (output) in response
to an input change.

The second step is define a controller that meets physical and economical requirements
59
Modeling: Continuous processes
Examples: drives, ovens, vehicles, chemical reactors
y = F (x, t)
y x
Continuous plants have states which can be described by continuous (analog)
variables (temperature, voltage, speed,...)
The relation between plant input and plant output
which can be described by a continuous model (transfer function).
Continuous plants are mostly reversible and monotone:
This is the condition necessary to control them.
The relation of output to input is called the transfer function.
The transfer function may be described by differential equations

When the system is linear, these differential equations may by transformed by
Laplace,
simplifying greatly notation and computations
60
Example: modeling a train
Train:
v
dt
dx
=
) ) sin( (
1
2
v C v C
radius
K
m mg F
m dt
dv
f x
c
tract
= o

o
F
tract
mg
mass of the train
plus contribution
of rotating parts
(wheels and rotors)
slope
F
frict
air friction
mechanical
friction
curve
friction
motor force
61
Resulting train model in Matlab
train
inertia
v
position
K
m
C
x
traction force
Fz
C
z
x

friction
air
resistance
v
2
1
M
mgsin(o)
i
C
c
curve friction
slope
radius
taken from
topography database
motor
current
motor

speed
|v|
r(x)
o(x)
a
acceleration
slope

62
Help in modeling: use an electrical
equivalent
water
ambient-water isolation R
1
water
temperature u
energy U
q
solicited
temperature u
2
ambient
temperatur
e u
a
R
1
R
2
C
C
heater-water
isolation
Heat
resistance R
2
U
a
(ambient temperature)
x ~ u
U
q
U
a
Ux
C R C R
x
dt
dx
2 2
1 1
+ =
heating

cooling

Ua
C R
U
C R C
R R
x
dt
dx
q
2 1
2 1
1 1
)
1 1
(
+ +
+
=
Electrical equivalent

u
a
~ u
a
C Bu Ax
dt
dx
+ + =
E Dx
dt
dx
+ =
controller
63
2.2.2 Controllers
2.1 Instrumentation
2.2 Control
2.2.1 Plant modeling
2.2.2 Controllers
2.2.2.1 On/Off (two-point) controller
2.2.2.2 PID controller
2.2.2.3 Nested Controllers
2.3 Programmable Logic Controllers
64
Controllers
Once the plant is known, a controller can be designed to control its output.

If the plant would be perfectly known, no regulation would be needed.

In practice, the plants parameters vary ( e.g. number of passengers in a train),
the plant is subject to disturbances (wind, slope)

The controller needs measuring through sensors the plants state and possibly
the disturbances. In a general model, the desired behaviour of the plant is just a
disturbance.

The controller follows certain quality laws, primarily to stabilize the output within
useful time, not overshoot, minimize energy consumption, etc..
65
Controller (rgulateur, Regler)
set-point
(solicited)
Sollwert
valeur de consigne
plant
Strecke
processus
command
Stellgre
valeur de commande
error
Regelabweichun
g
dviation
process value
Istwert
valeur mesure
regulator
Regler
rgulateur
measureme
nt
Messglied
mesure
e
u
y
the regulator (controller) can be implemented by mechanical elements, electrical elements,
computers,...
controller
x
K
p
power amplifier
Leistungsverstrker
amplificateur de puissance
m
state
Zustand
tat
66
Where is that controller located ?
in the sensor
or in the actuator
(analog PIDs)
as a separate device (analog PIDs)
(some times combined with a recorder)
as an algorithm in a computer
(that can handle numerous "loops").
actors sensors
set-points
67
2.2.2.1 On/Off (two-point) controller
2.1 Instrumentation
2.2 Control
2.2.1 Plant modeling
2.2.2 Controllers
2.2.2.1 On/Off (two-point) controller
2.2.2.2 PID controller
2.2.2.3 Nested Controllers
2.3 Programmable Logic Controllers
68
Two-point controller: principle
The two-point controller (or regulator, Zweipunktregler, Rgulateur tout ou rien)
has a binary output: on or off (example: air conditioning)
commercial controller with integrated
thermometer
room set-point
temperature
measured value
thermometer
heater
control
variable
energy
off on
69
Two-point controller: time response
0.00
0.20
0.40
0.60
0.80
1.00
1

9

1
7

2
5

3
3

4
1

4
9

5
7

6
5

7
3

8
1

8
9

9
7

Note the different time
constants for heating and
cooling:
this is a non-linear
system
If the process is not slow enough, hysteresis or switching period limit are included
to limit switching frequency and avoid wearing off the contactor.

(thermal processes are normally so inertial that no hysteresis is needed)
time
temperature
lower switch point
upper switch point
hysteresis
min period
70
Two-point controller: Input variable as ramp
0.00
0.20
0.40
0.60
0.80
1.00
1.20
0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00
time (s)
v
a
l
u
e

Solicited
Upper bound
Lower bound
Output
%
71
2.2.2.2 PID Controller
2.1 Instrumentation
2.2 Control
2.2.1 Plant modeling
2.2.2 Controllers
2.2.2.1 On/Off (two-point) controller
2.2.2.2 PID controller
2.2.2.3 Nested Controllers
2.3 Programmable Logic Controllers
72
A glance back in time...
ruins of a tin* mine in Cornwall (England), with the machine house for pumping,
where the first steam engines were installed (1790)
*Tin = Sn
tain, Zinn,
stannum

Zk, Zink, zinc
73
Birth of the steam machine (1780 - Thomas
Newcomen)
used for:

pump water
winches
ore crashing
Problem: keep the wheel speed constant.
74
The Watts "governor" (1791) - the first
industrial regulator
75
Flywheel governor
steam pipe
ancestor of automatic control...
e
o = f(e
2
)
valve
cylinder
76
Plant model for the following example
The following examples use a plant modeled by a 2
nd
order differential equation:
2
2
1
1
1
TT s sT m
y
+ +
=
Laplace transfer function
(since system is linear)
differential equation
This transfer function is typical of a plant with slow response, but without dead
time
0
0.2
0.4
0.6
0.8
1
1.2
1.4
0 1 2 3 4 5 6 7 8 9 10
time
delay time constant
gain
In the examples:
T
1
= 1 s
TT
2
= 0.25 s
2
step response
d ~ 0.2, T= 1.5s
plant m y
m TT y T y y = + +
2 1
" '
Temporal response
77
P-controller: simplest continuous regulator
m(t) = K
p
e(t) = K
p
(u(t) y(t))
the P-controller simply amplifies the error to obtain the command
variable
it works, but if the plant has a proportional behavior, an error always remains
set-point
plant
command
variable
e
process value
proportional factor
measurement
P
controlled
variable
K
p
x

u
y
error
m
78
-0.5
0
0.5
1
1.5
2
0 1 2 3 4 5 6 7 8 9 10
P-Controller: Step response
m
(
t
)
,

y
0
(
t
)

x large
large error
smaller asymptotic error
x small
Numerical:
K
p
= 5.0
set-point
The larger the set-point, the greater the error.
(The operator used to "reset" the control by increasing or decreasing the set-point)
command
79
P-Controller: Effect of Load change
-0.5
0
0.5
1
1.5
2
0 1 2 3 4 5 6 7 8 9 10
v
a
l
u
e

u
0
(Solicited)
Not only a set-point change, but a load change causes the error to increase or decrease.
(A load change, modeled by disturbance u
1
, is equivalent to a set-point change)
u
1
(load change)
command
u
0
= set-point plant
m = command
variable
e = error
y
0
= process value
proportional factor
measurement
P-regulator
controlled
variable
K
p
u1 =
disturbance
80
P-Controller: Increasing the proportional
factor
increasing the proportional factor reduces the error, but the system tends to oscillate
-0.2
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
0 1 2 3 4 5 6 7 8 9 10
time [s]
u
0
(
t
)
,

y
0
(
t
)

81
PI-Controller (Proportional Integral):
introducing the integrator
dt x y
y = level [m]
inflow [m
3
/s]
level (t) = (inflow(t)) dt
t
1
t
2
Example of an integration process
Time response of an integrator
input
output
older symbol
1
s
y x
}
=
t
t
d x y
0
) ( t t
82
PI (Proportional-Integral) Controller
set-point u
0 plant
command
variable
dt
PI
error e
process value y
0
integration
time constant
controller gain Kp
measurement
K
p
1

T
i
m
1
s
The integral factor produces a non-zero control variable even when the error is zero.
83
PI Regulator : Equations
) ) (
1
) ( (
0
}
+ =
t
t
i
p
d e
T
t e K m t t
T
i
= reset time, temps dintgration, Nachstellzeit
e
sT
K m
i
P
~
)
1
1 (
~
+ =
Laplace domain
Time domain
84
PI-Controller: response to set-point change
The integral factor reduced the asymptotical error to zero, but slows down the
response
(if K
p
is increased to make it faster, the system becomes unstable)
Kp = 2,0, T
i
=1,0 s
-0.2
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
2.2
0 1 2 3 4 5 6 7 8 9 10
time
v
a
l
u
e

Solicited
Output
Command
Integrator
85
PD controller
Basic idea of the PD regulator: take into account not only the value of the
error, but the rate at which the error changes.


Example: when parking a car in front of a wall, the driver not only looks at the
distance to the wall, but also at the speed at which the car approaches the
wall.
86
PD-Controller: Introducing the differentiator
Time response of a differentiator
input
output
dt
dx
y =

equation:
s y x
A perfect differentiator does not exist.
Differentiators increase noise.
Differentiators are approximated by
integrators (filtered differentiator):
1
s
T
d
Nf

1

Instead of differentiating, one can use an
already available variable:
e.g. the speed for a position control
x y
symbol:
87
PD - controller
K
p
u plant
command
variable
s
error
process value y
derivative
factor
proportional factor
measurement
T
d
PD
Adding the D-part allows to react vigorously to changes in set-point or perturbations.
m x
set-point
88
PD Controller: Equations
|
.
|

\
|
+ =
dt
t de
T t e K t m
d p
) (
) ( ) (
Laplace domain
( ) ) (
~
1 ) (
~
s e s T K s m
d p
+ =
Time domain
Td = derivative time, temps de dosage de drive, Vorhaltezeit Tv
89
PID-Controller (Proportional-Integral-
Differential)
The proportional factor K
p
generates an output proportional to the error, it requires a
non-zero error to produce the command variable.
Increasing the amplification K
p
decreases the error, but may lead to instability
The integral time constant T
i
produces a non-zero control variable even when the
error is zero, but makes the system instable (or slower).
The derivative time T
d
speeds up response by reacting to an error change with a
control variable proportional to the steepness of change.
PID
K
p
1

T
i
1
s
set-point plant
command
variable
s
error
process value
derivative
factor
proportional factor
measurement
T
d
90
PID controller: Equations
|
|
.
|

\
|
+ + =
}
dt
t de
T d e
T
t e K t m
d
t
t
i
p
) (
) ) (
1
) ( ) (
0
t t
|
|
|
|
.
|

\
|
+
+ + =
) 1 (
1
1
) (
~
) (
~
s
T
N
s T
sT
K
s e
s m
d
f
d
i
p
Real differentiators include this filtering
time domain
Laplace domain
K
p
= proportional factor, gain, Reglerverstrkung,
T
i
= reset time, temps de dosage dintgration (Nachhaltezeit, T
N
)
Td = derivative time, temps de dosage de drive, Vorhaltezeit Tv
alternate representation:
|
.
|

\
|
+
+ + =
t s
s T
sT
K
s e
s m
d
i
p
1
1 1
) (
~
) (
~
91
PID response summary
0
1
0 1 2 3 4 5 6 7 8 9 10
Solicited P
small
P
large
PI PID U
1
P
small
(K=5) asymptotic error
proportional only
P
large
(K
p
= 15) less error,
but unstable
PI: no remaining error,
but sluggish response
(or instable, if K
p
increased)
differential factor
increases responsiveness
load change (load decreases)
92
PID-Controller: empirical settings
Rise time Overshoot Settling time Steady-State
Error
increasing
Kp Decrease Increase Small Change Decrease
Ti Decrease Increase Increase Eliminate
Td Small Change Decrease Decrease Small Change

Empirical formula of Nichols (1942 !)
0
0.2
0.4
0.6
0.8
1
1.2
1.4
0 1 2 3 4 5 6 7 8 9 10
delay time constant
gain K
step response (open loop)
d ~ 0.2, T= 1.5s
1.2 T
K
V
K
p
= T
i
= 2.0 d T
d
= 0.5 d (N
f
= 10)
Caution: Nichols assumes the plant is
first order with time delay
93
Extract from a controllers manual
You can optimize the regulator yourself. This describes the optimization according to Ziegler-Nichols
Assuming that the process is stable at the operating temperature:
1. Set the Parameters ti und td OFF.
2. Set the Parameters Hcb und Lcb on Auto.
3. The actual value differs now from the solicited value by the Proportional factor.
4. As soon as the temperature stabilize, reduce the value of the proportional band Pb, until the
temperature starts to swing. Note the swinging period T. Increase the proportional band until the
temperature just stops swinging, do not haste. Note the value of the proportional band B.
5. Set the values of Pb, Ti and Td according to the following table in the controller.
But what do you do if this method does not work ?
How do you know that this plant can be controlled by a PID controller (many cannot)
How do you prevent overshoot ? (this method does not)
Trial-and-error cant replaces a serious analysis -> see for further reading.
94
2.2.2.3 Nested controllers
2.1 Instrumentation
2.2 Control
2.2.1 Plant modeling
2.2.2 Controllers
2.2.2.1 On/Off (two-point) controller
2.2.2.2 PID controller
2.2.2.3 Nested Controllers
2.3 Programmable Logic Controllers
95
Several controllers act together: Electricity
Generator
Generator
Active power
frequency (Pf)
controller
Turbine
3-phase Electrical Power Mechanical power
Steam
Valve
control
mechanism
Main
steam
valve
Controllable
excitation
source
Voltage
sensors
Frequency sensor
AQ
AV
AP
AP + j AQ
Af
Reactive power
voltage (QV)
controller
96
Nested control of a continuous plant -
example
Example: position control of a rotating shaft
Nesting regulators allow to maintain the output variable at a determined value
while not exceeding the current or speed limitations
Position
Speed
Torque
torque regulation
(protection)
PID
sol
is
cmd
PID
sol
is
cmd
PID
sol
is
cmd
M
Current
Position
Velocity
tacho
encoder
amplifier
97
Nested loops and time response
A control system consists often of nested loops, with the fastest loop at the inner
level
robot arm trajectory
speed control
torque control
position control
98
Programmable Logic Controllers
Automates Programmables
Speicherprogrammierbare Steuerungen
lim
TIT
TIT_REF_TAB
N_GT
POST_START_TIMER_MOD
100
0
FAULT_STATE[tit1_oor]
FAULT_STATE[tit2_oor]
OR
TIT_RATE_LIM_DN
TIT_RATE_LIM_UP
TIT_ERROR
TIT_REF_MAX_START
WFD_TIT
PID
K_TIT
P
TD_TIT
D
MAX_INT
I
17.3
99
2.3.1 PLCs: Definition and Market
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market
2.3.2 PLCs: Kinds
2.3.3 PLCs: Functions and construction
2.3.4 Continuous and Discrete Control
2.3.5 PLC Programming Languages
2.3.5.1 IEC 61131 Languages
2.3.5.2 Function blocks
2.3.5.3 Program Execution
2.3.5.4 Input / Output
2.3.5.5 Structured Text
2.3.5.6 Sequential Function Charts
2.3.5.7 Ladder Logic
2.3.5.8 Instruction Lists
2.3.5.9 Programming environment
100
Programmable Logic Controller:
Definition
Definition: small computers, dedicated to automation tasks in an industrial environment"


cabled relay control (hence 'logic'), analog (pneumatic, hydraulic) governors
specialized computer performing control and regulation


Function: Measure, Command, Control






AP = Automates Programmables industriels
SPS = Speicherprogrammierbare Steuerungen

Formerly:
Today:
Distinguish Instrumentation
flow meter, temperature, position,. but also actors (pump, )
Control
programmable logic controllers with digital peripherals & field bus
Visualization
HMI in PLCs (when it exists) is limited to control of operator displays
101
PLC: functions
Measure
Command
Regulation



Event Logging
Communication
Human interface
Protection
(Messen, Schtzen, Regeln = MSR)

PLC = PMC: Protection, Measurement and Control
102
PLC: Characteristics
large number of peripherals: 20..100 I/O per CPU, high density of wiring, easy assembly.
binary and analog Input/Output with standard levels
located near the plant (field level), require robust construction, protection against dirt,
water and mechanical threats, electro-magnetic noise, vibration, extreme temperature
range (-30C..85C)
programming: either very primitive with hand-help terminals on the target
machine itself, or with a lap-top able to down-load programs.
network connection is becoming common, allowing programming on workstations.
primitive Man-Machine interface, either through LCD-display or connection of a laptop
over serial lines (RS232).
economical - 1000.- .. 15'000.- for a full crate.
the value is in the application software (licenses 20'000 ..50'000)
field bus connection for remote I/Os
103
PLC: Location in the control
architecture
Enterprise Network

directly connected
I/O
Control Bus
(e.g. Ethernet)
Engineer
station
I
/
O

I
/
O

I
/
O

I
/
O

C
P
U

Sensor Bus (e.g. ASI)
Field Bus
gateway
Field Stations
Control Station
with Field Bus
direct I/O
I
/
O

Field Devices
FB
gateway
gateway
I
/
O

I
/
O

I
/
O

I
/
O

C
P
U

C
O
M

I
/
O

I
/
O

I
/
O

C
O
M

C
P
U

C
O
M

C
O
M

C
O
M

I
/
O

Field Bus
C
P
U

C
O
M

2

I
/
O

I
/
O

I
/
O

C
P
U

C
O
M
1

C
O
M

2

I
/
O

C
P
U

Operator
station
large
PLCs
small PLC
very simple PLCs
PLC
PLC
C
O
M
1

C
O
M
1

Supervisor
Station
104
PLC: manufacturers
Europe:
Siemens (60% market share) [Simatic],
ABB (includes Hartmann&Braun, Elsag-Bailey, SattControl,) [Industrial
IT
],
Groupe Schneider [Tlmcanique],
WAGO,
Phoenix Contact ...
World Market:
GE-Fanuc,
Honeywell,
Invensys (Foxboro)
Rockwell, (Allen-Bradley,)
Emerson (Fisher Control, Rosemount, Westinghouse)
Hitachi, Toshiba, Fujitsu, Yokogawa

SAIA, Weidmller
Switzerland
large number of bidders, fusions and acquisitions in the last years.
Distinguish PLCs for the open market (OEM) and proprietary PLCs
105
2.3.3 PLCs: Kinds
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market
2.3.2 PLCs: Kinds
2.3.3 PLCs: Functions and construction
2.3.4 Continuous and Discrete Control
2.3.5 PLC Programming Languages
2.3.5.1 IEC 61131 Languages
2.3.5.2 Function blocks
2.3.5.3 Program Execution
2.3.5.4 Input / Output
2.3.5.5 Structured Text
2.3.5.6 Sequential Function Charts
2.3.5.7 Ladder Logic
2.3.5.8 Instruction Lists
2.3.5.9 Programming environment
106
Kinds of PLC
Monolithic construction

Monoprocessor

Fieldbus connection
Fixed casing

Fixed number of I/O (most of them binary)

No process computer capabilities (no MMC)

Typical product: Mitsubishi MELSEC F, ABB AC31, SIMATIC S7
(1)
Modular construction (backplane)

One- or multiprocessor system

Fieldbus and LAN connection
3U or 6U rack, sometimes DIN-rail

Large variety of input/output boards

Connection to serial bus

Small MMC function possible

Typical products: SIMATIC S5-115, Hitachi H-Serie, ABB AC110
(2)


Compact
Modular PLC
(3) Soft-PLC
Windows NT or CE-based automation products
Direct use of CPU or co-processors
107
courtesy ABB
Modular PLC
RS232
CPU CPU Analog
I/O
Binary I/O
backplane
parallel bus
housed in a 19" (42 cm) rack
(height 6U ( = 233 mm) or 3U (=100mm)
concentration of a large number of I/O
Power Supply
high processing power (several CPU)
primitive or no HMI
cost effective if the rack can be filled
tailored to the needs of an application
supply 115-230V~ , 24V= or 48V= (redundant)
fieldbus
LAN
large choice of I/O boards
interface boards to field busses
requires marshalling of signals
fieldbus
developme
nt
environmen
t

cost ~ 10000 for a filled crate


108
Small modular PLC
mounted on DIN-rail, 24V supply
cheaper (5000)
not water-proof,
no ventilator
extensible by a parallel bus (flat cable or rail)
courtesy ABB
courtesy Backmann
109
Specific controller (railways)
data bus
special construction: no fans, large temperature range, vibrations
three PLCs networked by a data bus.
110
Compact or modular ?

# I/O modules
Limit of local
I/O
compact PLC
(fixed number of I/Os)
modular PLC (variable number of I/Os
field bus
extension
111
Industry- PC
Wintel architecture
(but also: Motorola, PowerPC),
MMI offered (LCD..)
Limited modularity through mezzanine boards
(PC104, PC-Cards, IndustryPack)
Backplane-mounted versions with PCI or Compact-PCI
Competes with modular PLC
no local I/O,
fieldbus connection instead,
courtesy INOVA courtesy MPI
costs: 2000.-
112
Soft-PLC (PC as PLC)
PC as engineering workstation
PC as human interface (Visual Basic, Intellution, Wonderware)

PC as real-time processor (Soft-PLC)

PC assisted by a Co-Processor (ISA- or PC104 board)

PC as field bus gateway to a distributed I/O system


2
12
2
3
3
23
4
I/O modules
113
Compact PLC
Monolithic (one-piece) construction
Fixed casing
Fixed number of I/O (most of them binary)
No process computer capabilities (no MMC)
Can be extended and networked by an extension (field) bus
Sometimes LAN connection (Ethernet, Arcnet)
Monoprocessor
Typical product: Mitsubishi MELSEC F, ABB AC31, SIMATIC S7
costs: 2000
courtesy ABB courtesy ABB courtesy ABB
114
Specific Controller (example: Turbine)
Thermocouple
inputs
binary I/Os,
CAN field bus
RS232 to HMI
Relays and
fuses
Programming
port
cost: 1000.-
tailored for a specific application, produced in large series
courtesy Turbec
115
Protection devices
Protection devices are highly specialized PLCs that measure the current and voltages in an
electrical
substation, along with other status (position of the switch) to detect situations that could
endanger the equipment (over-current, short circuit, overheat) and triggers the circuit breaker
(trip) to protect the substation.
In addition, it records disturbances and sends the reports to the substations SCADA.
Sampling: 4.8 kHz, reaction time: < 5 ms.
Human interface
for status
and
settings
measurement
transformers

I
r
I
s
I
t
U
r
U
s
U
T
Programming
interface
trip relay

communication to operator
costs: 5000
substation

116
Market share
Micro: 15 to 128 I/O points
Medium: 128 - 512 I/O points
Large: > 512 I/O points
Nano: < 15 I/O points
PC-based
Software PLC
Embedded control
32%
29%
20%
7%
6%
4%
2%
% installed PLCs
Source: Control Engineering, Reed Research, 2002-09
117
Global players
Total sales in 2004: 7000 Mio Source: ARC Research, 2005-10
118
Comparison Criteria Example
Siemens
Number of Points
Memory
Programming Language
Programming Tools
Download
Real estate per 250 I/O
Label surface
Network
Hitachi
640
16 KB
Ladder Logic
Instructions
Logic symbols
Basic
Hand-terminal
Graphic on PC
yes
1000 cm2
6 characters
6 mm2
19.2 kbit/s
1024
Ladder logic
Instructions
Logic symbols
Hand-terminal
Graphic on PC
no
2678 cm2
5.3 mm2
7 characters per line/point
10 Mbit/s
10 KB
Mounting cabinet DIN rail
Brand
119
2.3.3 PLCs: Function and
construction
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market
2.3.2 PLCs: Kinds
2.3.3 PLCs: Functions and construction
2.3.4 Continuous and Discrete Control
2.3.5 PLC Programming Languages
2.3.5.1 IEC 61131 Languages
2.3.5.2 Function blocks
2.3.5.3 Program Execution
2.3.5.4 Input / Output
2.3.5.5 Structured Text
2.3.5.6 Sequential Function Charts
2.3.5.7 Ladder Logic
2.3.5.8 Instruction Lists
2.3.5.9 Programming environment
120
The signal chain
analog
variable
(e.g. 4..20mA)
filtering
&
scaling
analog-
digital
converter
processing
digital-
analog
converter
analog
variable
e.g. -10V..10V
time
y
time
y(i)
sampling
binary
variable
(e.g. 0..24V)
filtering sampling
time
y
transistor
or
relay
binary
variable
amplifier
011011001111
counter
1
non-volatile
memory
0001111
time
y(i)
121
General PLC architecture
CPU
Real-Time
Clock
flash
EPROM
ROM
buffers
signal
conditioning
power
amplifiers
relays
signal
conditioning
serial port
controller
Ethernet
parallel bus
ethernet
controller
RS 232
analog-
digital
converters
digital-
analog
converters
Digital Output
Digital
Input
fieldbus
controller
external
I/Os
extension
bus
field bus
direct Inputs and Outputs
122
2.3.4 Continuous and discrete control
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market
2.3.2 PLCs: Kinds
2.3.3 PLCs: Functions and construction
2.3.4 Continuous and Discrete Control
2.3.5 PLC Programming Languages
2.3.5.1 IEC 61131 Languages
2.3.5.2 Function blocks
2.3.5.3 Program Execution
2.3.5.4 Input / Output
2.3.5.5 Structured Text
2.3.5.6 Sequential Function Charts
2.3.5.7 Ladder Logic
2.3.5.8 Instruction Lists
2.3.5.9 Programming environment
123
Matching the analog and binary world
discrete control analog regulation
124
PLC evolution
A
B
P2
P1
I1
Analog World
Binary World
C
continuous processes
Regulation, controllers
discrete processes
combinatorial sequential
relay controls,
Relay control
pneumatic sequencer
Pneumatic and electromechanical
controllers
Programmable Logic Controllers

(Speicherprogrammierbare Steuerungen, Automates Programmables)
125
Continuous Plant (reminder)
Example: traction motors, ovens, pressure vessel,...
The time constant of the control system must be at least one order of
magnitude smaller than the smallest time constant of the plant.
F(s) = y x
The state of continuous plants is described by continuous (analog) state
variables like temperature, voltage, speed, etc.
Continuous plants are normally reversible and monotone.
This is the condition to allow their regulation.
There exist a fixed relationship between input and output,described by a continuous
model in form of a transfer function F.
This transfer function can be expressed by a set of differential equations.
If equations are linear, the transfer function may expressed as Laplace or Z-
transform.
time
y
(1+Ts)
(1+T
1
s + T
2

s
2
)

the principal task of the control system for a continuous plant is its regulation.
126
Discrete Plant (reminder)
Examples: Elevators,
traffic signaling,
warehouses, etc.
The plant is described by variables which take well-defined, non-overlapping values.
The transition from one state to another is abrupt, it is caused by an external event.
Discrete plants are normally reversible, but not monotone, i.e. negating the
event which caused a transition will not revert the plant to the previous state.

Example: an elevator doesn't return to the previous floor when the button is released.

Discrete plants are described e.g. by finite state machines or Petri nets.
the main task of a control system with discrete plants is its sequential
control.
e
c + d
1
2 3
6 5
4
7
a
b
c + d
e
init
127
Continuous and Discrete Control
(comparison)
A B
Out = A B
B
NOT C
A
Out = (A + B) C
"sequential"
"combinatorial"
1)

ladder
logic
e.g. GRAFCET, Petri Nets
e.g. ladder logic, CMOS logic
P2
P1
I1
analog
building
blocs
1) not really combinatorial: blocs may have memory
128
2.3.5 Programming languages
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market
2.3.2 PLCs: Kinds
2.3.3 PLCs: Functions and construction
2.3.4 Continuous and Discrete Control
2.3.5 Programming languages
2.3.5.1 IEC 61131 Languages
2.3.5.2 Function blocks
2.3.5.3 Program Execution
2.3.5.4 Input / Output
2.3.5.5 Structured Text
2.3.5.6 Sequential Function Charts
2.3.5.7 Ladder Logic
2.3.5.8 Instruction Lists
2.3.5.9 Programming environment
129
"Real-Time" languages
Extend procedural languages to
express time
(introduce programming constructs to
influence scheduling and control flow)
languages developed for
cyclic
execution and real-time

("application-oriented languages")
ladder logic


function block language


instruction lists


GRAFCET


SDL


etc...














wide-spread in the control industry.
Now standardized as IEC 61131
ADA


Real-Time Java
MARS (TU Wien)


Forth


C with real-time features


etc
could not impose themselves
















130
The long march to IEC 61131
Source: Dr. J. Christensen
77 78 79 81 80 93 94 95 70 82 83 84 85 87 86 88 89 90 91 92
NEMA Programmable Controllers Committee formed (USA)
GRAFCET (France)
IEC 848, Function Charts
DIN 40719, Function Charts (Germany)
NEMA ICS-3-304, Programmable Controllers (USA)
IEC SC65A/WG6 formed
DIN 19 239, Programmable Controller (Germany)
MIL-STD-1815 Ada (USA)
IEC SC65A(Sec)67
Type 3 report
recommendation
96
IEC 65A(Sec)38, Programmable Controllers
IEC 1131-3
IEC SC65A(Sec)49, PC Languages
IEC 64A(Sec)90
IEC 61131-3
name change
131
The five IEC 61131-3 Programming languages
Structured Text (ST)
VAR CONSTANT X : REAL := 53.8 ;
Z : REAL; END_VAR
VAR aFB, bFB : FB_type; END_VAR
bFB(A:=1, B:=OK);
Z := X - INT_TO_REAL (bFB.OUT1);
IF Z>57.0 THEN aFB(A:=0, B:=ERR);
ELSE aFB(A:=1, B:=Z is OK);
END_IF
Ladder Diagram (LD)
OUT
PUMP
http://www.isagraf.com
Function Block Diagram (FBD)
PUMP
AUTO
MAN_ON
ACT
DO
V
Instruction List (IL)
A: LD %IX1 (* PUSH BUTTON *)
ANDN %MX5 (* NOT INHIBITED *)
ST %QX2 (* FAN ON *)
Sequential Flow Chart (SFC)
START STEP
T1
T2
D1_READY
D2_READY
STEP A
ACTION D1
N
D ACTION D2
STEP B
D3_READY
D4_READY
ACTION D3
N
D ACTION D4
T3
DI
V
CALC1
CALC
IN1
IN2
OUT
>=1
graphical languages
textual languages
AUTO
MAN_ON
ACT
CALC1
CALC
IN1
IN2
132
Importance of IEC 61131
IEC 61131-3 is the most important automation language in industry.

80% of all PLCs support it, all new developments base on it.

Depending on the country, some languages are more popular.


133
2.4.2.1 Function Blocks Language
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market
2.3.2 PLCs: Kinds
2.3.3 PLCs: Functions and construction
2.3.4 Continuous and Discrete Control
2.3.5 PLC Programming Languages
2.3.5.1 IEC 61131 Languages
2.3.5.2 Function blocks language
2.3.5.3 Program Execution
2.3.5.4 Input / Output
2.3.5.5 Structured Text
2.3.5.6 Sequential Function Charts
2.3.5.7 Ladder Logic
2.3.5.8 Instruction Lists
2.3.5.9 Programming environment
134
Function Block Languages
The function block languages express "combinatorial"
programs in a way similar to electronic circuits.
They draw on a large variety of predefined and custom functions

This language is similar to the Matlab / Simulink language used in simulations
(Funktionsblocksprache, langage de blocs de fonctions)
(Also called "Function Chart" or "Function Plan" - FuPla)
135
Function Block Examples
&
A
B
C
Trigger
T
&
Running
Reset
S
R
Spin
Function blocks is a graphical programming language, which is akin to the
electrical and block diagrams of the analog and digital technique.

It mostly expresses combinatorial logic, but its blocks may have a memory
(e.g. flip-flops).
Example 1:
Example 2:
external inputs
external outputs
136
Function Block Elements
"continuously"
executing block,
independent,
no side effects
set point
measurement motor
parameters
The block is defined by its:
Data flow interface (number and type of input/output signals)
Black-Box-Behavior (functional semantic, e.g. in textual form).
Connections that carry a pseudo-continuous data flow.
Connects the function blocks.
Signals
Function block
(set point)
(set point)
set point
Example
Example
PID
137
Function Block Example
138
Function Block Rules
There exist exactly two rules for connecting function blocks by signals
(this is the actual programming):
Each signal is connected to exactly one source.
This source can be the output of a function block or a plant signal.
The type of the output pin, the type of the input pin and the signal type
must be identical.


For convenience, the function plan should be drawn so the signals flow from left
to right and from top to bottom. Some editors impose additional rules.
Retroactions are exception to this rule. In this case, the signal direction is
identified by an arrow. (Some editors forbid retroactions - use duplicates instead).
a
b
y
x
z
c
139
Types of Programming Organisation
Units (POUs)
1) Functions
- are part of the base library.
- have no memory.
Example are: adder, multiplier, selector,....

2) Elementary Function Blocks (EFB)
- are part of the base library
- have an individual memory ("static" data).
- may access global variables (side-effects!)
Examples: counter, filter, integrator,.....

3) Programs (Compound blocks)
- user-defined or application-specific blocks
- may have a memory
- may be configurable (control flow not visible in the FBD
Examples: PID controller, Overcurrent protection, Motor sequence
(a library of compound blocks may be found in IEC 61804-1)

140
Function Block library
The programmer chooses the blocks in a block library, similarly to the
hardware engineer who chooses integrated circuits out of the catalogue.
This library indicates the pinning of each block, its semantics and the execution time.
The programmer may extend the library by defining function block macros out of
library elements.
If some blocks are often used, they will be programmed in an external language
(e.g. C, micro-code) following strict rules.
141
IEC 61131-3 library (extract)
binary elements
ADD
analog elements
SUB
MUL
DIV
adder
INT
PV
selector
timer on
delay
AND
OR
XOR
S1
SR
Q0
S1
R_TRIG
Q0
R
subtractor
multiplier
divider
integrator
greater than
less than
up counter
(CTD counter down)
GT
LT
LE less equal
and
or
exclusive-or
flip-flop
positive
edge
GT
SEL
IN
TON
Q
PT ET
CTU
CU
RESET
PV
Q
ET
The number of inputs or outputs and their type is restricted.

The execution time of each block depends on the number of inputs and on the processor.

Init
142
Exercise: Tooth saw generator
exercise: build a tooth-saw (asymmetric) generator with
the IEC 61131 elements of the preceding page
75%
0%
-25%
5s
12s
143
Library functions for discrete plants
logical combinations (AND, OR, NOT, EXOR)
Flip-flop
Selector m-out-of-n
Multiplexer m-to-n
Timer
Counter
Memory
Sequencing
Basic blocks
Display
Manual input, touch-screen
Safety blocks (interlocking)
Logging
Compound blocks
Alarm signaling
144
Analog function blocks for continuous
control
Basic blocks
Summator / Subtractor
Multiplier / Divider
Integrator / Differentiator
Filter
Minimal value, Maximum value
Radix
Function generator
Regulation Functions
P, PI, PID, PDT2 controller
Fixed set-point
Ratio and multi-component regulation
Parameter variation / setting
2-point regulation
3-point regulation
Output value limitation
Ramp generator
Adaptive regulation
Drive Control
145
Function Block library for specialized
applications
MoveAbsolute
AXIS_REF
Axis Axis
AXIS_REF
BOOL
Execute
Done BOOL
REAL Position BOOL
REAL Velocity
CommandAborted
WORD REAL
Acceleration
BOOL
REAL Deceleration
REAL Jerk
MC_Direction Direction
Erro
r
ErrorID
Example: FB for motion control
146
Specifying the behaviour of Function Block
Time Diagram:
0 T
T
x
y
y
x
S
R
x1
0
0
1
1
x2
0
1
0
1
y
previous state
0
1
1
Truth Table:
Mathematical Formula:
x1
x2
Textual Description:

y x
}
+ +
t
i d p xd K
dt
dx
K x K
0
t
Calculates the root mean square of the input with a filtering constant
Equal
147
Function Block specification in
Structured Text
148
Function Block decomposition
A function block describes a data flow interface.
Its body can be implemented differently:
The body is implemented in an external language
(micro-code, assembler, java, IEC 61131 ST):
Elementary block
The body is realized as a function block program
Each input (output) pin of the interface is implemented
as
exactly one input (output) of the function block.
All signals must appear at the interface to guarantee
freedom from side effects.


.
Compound block
procedure xy(a,b:BOOLEAN; VAR b,c: BOOLEAN);
begin
......
....
end xy;
=
=
149
Function Block segmentation
An application program is decomposed into segments ("Programs")
for easier reading, each segment being represented on one (A4) printed page.


Within a segment, the connections are represented graphically .

Between the segments, the connections are expressed by signal names .


Segment A
Segment B
X1
M2 M1
Y1
Y2
M2
X2
M1
X3
150
2.3.5.3 Program execution
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market
2.3.2 PLCs: Kinds
2.3.3 PLCs: Functions and construction
2.3.4 Continuous and Discrete Control
2.3.5 PLC Programming Languages
2.3.5.1 IEC 61131 Languages
2.3.5.2 Function blocks
2.3.5.3 Program Execution
2.3.5.4 Input / Output
2.3.5.5 Structured Text
2.3.5.6 Sequential Function Charts
2.3.5.7 Ladder Logic
2.3.5.8 Instruction Lists
2.3.5.9 Programming environment
151
Execution of Function Blocks
F1
A
B
X01
F2
X01
X
F3
B
C
X02
F4
X
X02
Y
Machine Code:
function
input1
input2
output
A
F1
F2
B
F4
Y
X01
X02
F3
C
X
Segment or POU
(program organization unit)
The function blocks are
translated to machine language
(intermediate code, IL),
that is either interpreted or
compiled to assembly language

Blocks are executed in sequence,
normally from upper left to lower right

The sequence is repeated every x ms.
152
Input-Output of Function Blocks
execute
individual period
I O X I O X I O X
read
inputs
write

outputs
Run-time:
The function blocks are executed cyclically.
all inputs are read from memory or from the plant (possibly cached)
the segment is executed
the results are written into memory or to the plant (possibly to a cache)
The order of execution of the blocks generally does not matter.
To speed up algorithms and avoid cascading, it is helpful to impose an
execution order to the blocks.

The different segments may be assigned a different individual period.
time
153
Parallel execution
Function blocks are particularly well suited for true multiprocessing (parallel
processors).

The performance limit is given by the needed exchange of signals by means of a
shared memories.

Semaphores are not used since they could block an execution and make the
concerned processes non-deterministic.
processor
1
processor
2
processor
3
shared
memory
shared
memory
shared
memory
shared
memory
input/
output
154
Program configuration
The programmer divides the program into tasks (sometimes called pages or segments),
which may be executed each with a different period.
The programmer assigns each task (each page) an execution period.
Since the execution time of each block in a task is fixed, the execution time is fixed.
Event-driven operations are encapsulated into blocks, e.g. for transmitting messages.

If the execution time of these tasks cannot be bound, they are executed in background.

The periodic execution always has the highest priority.
155
IEC 61131 - Execution engine
configuration
resource
task task
program program
FB FB
task
execution control path
variable access paths
FB
function block
variable
or
represented variables
communication function
legend:
program
FB FB
resource
task
program
global and directly
access paths
156
2.3.5.4 Input and Output
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market
2.3.2 PLCs: Kinds
2.3.3 PLCs: Functions and construction
2.3.4 Continuous and Discrete Control
2.3.5 PLC Programming Languages
2.3.5.1 IEC 61131 Languages
2.3.5.2 Function blocks
2.3.5.3 Program Execution
2.3.5.4 Input & Output
2.3.5.5 Structured Text
2.3.5.6 Sequential Function Charts
2.3.5.7 Ladder Logic
2.3.5.8 Instruction Lists
2.3.5.9 Programming environment
157
Connecting to Input/Output, Method
1: dedicated I/O blocks
The Inputs and Outputs of the PLC must be connected to (typed) variables
OUT_1
The I/O blocks are configured to be attached to the corresponding I/O groups.
IN_1
158
Connecting to Input / Output, Method
2: Variables configuration
All program variables must be declared with name and type, initial value and volatility.
A variable may be connected to an input or an output, giving it an I/O address.
Several properties can be set: default value, fall-back value, store at power fail,
These variables may not be connected as input, resp. output to a function block.
predefined addresses
159
2.3.5.5 Structured Text
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market
2.3.2 PLCs: Kinds
2.3.3 PLCs: Functions and construction
2.3.4 Continuous and Discrete Control
2.3.5 PLC Programming Languages
2.3.5.1 IEC 61131 Languages
2.3.5.2 Function blocks
2.3.5.3 Program Execution
2.3.5.4 Input / Output
2.3.5.5 Structured Text
2.3.5.6 Sequential Function Charts
2.3.5.7 Ladder Logic
2.3.5.8 Programming environment
160
Structured Text
(Strukturierte Textsprache, langage littral structur)
language similar to Pascal (If, While, etc..)

The variables defined in ST can be used in other languages.

It is used to do complex data manipulation and write blocs

Caution: writing programs in structured text can breach the real-time rules !
161
Data Types
binary types: analog types:

Derived Types are user-defined and must be declared in Structured Text
subrange,
enumerated,
arrays,
structured types
(e.g. AntivalentBoolean2)

variable can receive initial values and be declared as non-volatile (RETAIN)
BOOL
BYTE
WORD
DWORD
1
8
16
32
REAL (Real32)
LREAL (Real64)
Since Function Blocks are typed, the types of connection, input and output must
match.

Elementary Types are defined either in Structured Text or in the FB configuration.
162
61131 Elementary Data Types



No. Keyword Data Type Bits
1 BOOL Boolean 1
2 SINT Short integer 8
3 INT Integer 16
4 DINT Double integer 32
5 LINT Long integer 64
6 USINT Unsigned short integer 8
7 UINT Unsigned integer 16
8 UDINT Unsigned double integer 32
9 ULINT Unsigned long integer 64
10 REAL Real numbers 32
11 LREAL Long reals 64
12 TIME Duration
depends
13 DATE Date (only)
depends
14 TIME_OF_DAY or TOD Time of day (only)
depends
15 DATE_AND_TIME or DT Date and time of day
depends
16 STRING Character string
17 BYTE Bit string of length 8 8
18 WORD Bit string of length 16 16
19 DWORD Bit string of length 32 32
20 LWORD Bit string of length 64 64
21 variable length double-byte string
163
Example of Derived Types
TYPE
ANALOG_CHANNEL_CONFIGURATION
STRUCT
RANGE: ANALOG_SIGNAL_RANGE;
MIN_SCALE : ANALOG_DATA ;
MAX_SCALE : ANALOG_DATA ;
END_STRUCT;
ANALOG_16_INPUT_CONFIGURATION :
STRUCT
SIGNAL_TYPE : ANALOG_SIGNAL_TYPE;
FILTER_CHARACTERISTIC : SINT (0.99)
CHANNEL: ARRAY [1..16] OF ANALOG_CHANNEL_CONFIGURATION;
END_STRUCT ;
END_TYPE
164
2.3.5.6 Sequential Function Charts
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market
2.3.2 PLCs: Kinds
2.3.3 PLCs: Functions and construction
2.3.4 Continuous and Discrete Control
2.3.5 PLC Programming Languages
2.3.5.1 IEC 61131 Languages
2.3.5.2 Function blocks
2.3.5.3 Program Execution
2.3.5.4 Input / Output
2.3.5.5 Structured Text
2.3.5.6 Sequential Function Charts
2.3.5.7 Ladder Logic
2.3.5.8 Programming environment
165
SFC (Sequential Flow Chart)
START STEP
ACTION D1
N
D1_READY
D ACTION D2 D2_READY
(Ablaufdiagramme, diagrammes de flux en squence - grafcet)
SFC describes sequences of operations and interactions between parallel
processes.
It is derived from the languages Grafcet and SDL (used for communication
protocols),
its mathematical foundation lies in Petri Nets.
T1
T2
STEP B STEP A
SDL - Specification and Description Language
166
SFC: Elements
Ec = ((varX & varY) | varZ)
The sequential program consists of states connected by transitions.
A state is activated by the presence of a token (the corresponding variable becomes TRUE).

The token leaves the state when the transition condition (event) on the state output is true.

Only one transition takes place at a time, the execution period is a configuration parameter
token
Sa
Sb
"1"
Ea
Sc
Eb
transitions
states
event condition

("1" = always true)
example transition condition
example: Sc is true, S0, Sa, Sb are false
S0
167
SFC: Initial state
State which come into existence with a token are called initial states.
All initial states receive exactly one token, the other states receive none.
Initialization takes place explicitly at start-up.
In some systems, initialization may be triggered in a user program
(initialization pin in a function block).
168
SFC: Switch and parallel execution
Eb
Sa
Sb
"1"
Ea
Se
token switch : the token crosses the first active
transition (at random if both Ea and Eb are true)
Ec
token forking : when the transition Ee is true, the token
is replicated to all connected states



Ed
token join : when all tokens are present,

and the transition Ef is true, one single token is forwarded.
Ee
Sc
Sd
Sf Sg
Ef
169
SFC: P1, N and P0 actions
P1 State1_P1: do at enter
N State1_N: do while
P0 State1_P0: do at
leaving
State1
P1 (pulse raise) action is executed once when the state is entered
P0 (pulse fall) action is executed once when the state is left
N (non-stored) action is executed continuously while the token is in the state

P1 and P0 actions could be replaced by additional states.

The actions are described by a code block written e.g. in Structured Text.
170
SFC: graphic rules
The input and output flow of a state are always in the same vertical line (simplifies structure)
Alternative paths are drawn such that no path is placed in the vertical flow
(otherwise would mean this is a preferential path)
intentional displacement to
avoid optical preference of a
path.
Priority:
The alternative path most to the left has the
highest priority, priority decreases towards the right.
Loop: exit has a higher priority than loopback.
171
SFC: Exercise
initially: let vehicle until it touches I0 at reduced speed and open the trap for 5s (empty the vehicle).
1 - Let the vehicle move from I0 to I3
Speed = 5 cm/s between I0 and I1 or between I2 and I3, speed = 1 m/s between I1 and I2.
2 - Stop the vehicle when it reaches I3.
3 - Open the tank during 5s.
4- Go back to I0
5 - Open the trap and wait 5s.
repeat above steps indefinitely
In2 In3
Speed = {+20: +1 m/s; +1: +5 cm/s}
negative values: opposite direction
Generates 1 as long as the tag of the vehicle (1cm) is over the sensor.
Register = {0: closed; 1: open}
In0 In1
Variables:
Input: In0, In1, In2, In3;
Output:
+speed
Trap = {0: closed; 1: open}
Register = {0: closed; 1: open}
172
SFC: Building subprograms
: : =
: : =
OR:
OR:
OR: OR:
T-element
S-element
state S-sequence parallel paths
transition T-sequence alternative paths
loop
OR:
The meta-symbols T and S define structures - they may not appear
as elements in the flow chart.
A flow chart may only contain the terminal symbols: state and transition
173
SFC: Structuring
Every flow chart without a token generator may be redrawn as a
structured flow chart (by possibly duplicating program parts)
A
B
C
a
b
d
c
Not structured
A
B
C
a
b
a
b
B'
A'
d
c
d
structured
174
SFC: Complex structures
Problems with general networks:

deadlocks

uncontrolled token multiplication
These general rules serve to build networks, termed by DIN and IEC as flow charts
Solution:

assistance through the flow chart editor.
175
Function blocks And Flow Chart
Function Blocks:
Continuous (time) control
Sequential Flow Charts:
Discrete (time) Control
Many PLC applications mix continuous and discrete control.
A PLC may execute alternatively function blocks and flow charts.
A communication between these program parts must be possible.
Principle:
The flow chart taken as a whole can be considered a function
block with binary inputs (transitions) and binary outputs (states).
176
Executing Flow Charts As blocks
A function block may be implemented in three different ways:
procedure
xy(...);
begin
...
end xy;
extern (ST) function blocks flow chart
Function blocks and flow chart communicate over binary signals.
177
Flow Charts Or Function blocks ?
A task can sometimes be written indifferently as function blocks or as flow chart.
The application may decide which representation is more appropriate:
c
d
"1"
b
a
a
b c
d
Flow Chart Function Block
NOT
S
R
178
Flow Charts Or Blocks ? (2)
In this example, flow chart seems to be more appropriate:
A
B
C
"1"
a
b
c
S
R

&
S
R
&
S
R
&
init
a
b
c
A
B
C
Flow Chart
Function Blocks
179
2.3.5.7 Ladder Logic
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market
2.3.2 PLCs: Kinds
2.3.3 PLCs: Functions and construction
2.3.4 Continuous and Discrete Control
2.3.5 PLC Programming Languages
2.3.5.1 IEC 61131 Languages
2.3.5.2 Function blocks
2.3.5.3 Program Execution
2.3.5.4 Input / Output
2.3.5.5 Structured Text
2.3.5.6 Sequential Function Charts
2.3.5.7 Ladder Logic
2.3.5.8 Programming environment
180
Ladder logic (1)
The ladder logic is the oldest programming language for PLC
it bases directly on the relay intuition of the electricians.
it is widely in use outside Europe.
It is described here but not recommended for new projects.
(Kontaktplansprache, langage contacts)
181
Ladder Logic (2)
01
02
50
01
02
03 50
03
relay coil
(bobine)
break contact
(contact repos)
make contact
(contact travail)
corresponding
ladder diagram
origin:
electrical
circuit
50 05
44
rung
"coil" 50 is used to move
other contact(s)
182
Ladder logic (3)
The contact plan or "ladder logic" language allows an easy transition from the
traditional relay logic diagrams to the programming of binary functions.
It is well suited to express combinational logic
It is not suited for process control programming (there are no analog
elements).
The main ladder logic symbols represent the elements:

make contact
break contact
relay coil
183
Ladder logic (4)
Binary combinations are expressed by series and parallel relay contact:
+
01
02
50
Coil 50 is active (current flows) when 01 is active and 02 is not.
01
02
50
Series
+
01
40
02
Coil 40 is active (current flows) when 01 is active or 02 is not.
Parallel
ladder logic representation
"CMOS" equivalent
01
02
40
184
Ladder logic (5)
The ladder logic is more intuitive for complex binary expressions than literal languages
50
1 2 3 4
5 6
!N 1 & 2 STR 3 & N 4 STR N 5
& 6 / STR & STR = 50
50
0 1 4 5
6 7 2 3
10 11
12
!0 & 1 STR 2 & 3 / STR STR 4
& 5 STR N 6 & 7

/ STR & STR STR 10
& 11 / STR & 12 = 50
textual expression
185
Ladder logic (6)
Ladder logic stems from the time of the relay technology.
As PLCs replaced relays, their new possibilities could not be expressed any
more in relay terms.

The contact plan language was extended to express functions:
literal expression:
!00 & 01 FUN 02 = 200
200 FUN 02
01 00
The intuition of contacts and coil gets lost.
The introduction of functions that influence the control flow itself, is problematic.
The contact plan is - mathematically - a functional representation.
The introduction of a more or less hidden control of the flow destroys the
freedom of side effects and makes programs difficult to read.
186
Ladder logic (7)
Ladder logic provides neither:
sub-programs (blocks), nor
data encapsulation nor
structured data types.

It is not suited to make reusable modules.

IEC 61131 does not prescribe the minimum requirements for a compiler /
interpreter such as number of rungs per page nor does it specifies the minimum
subset to be implemented.

Therefore, it should not be used for large programs made by different persons

It is very limited when considering analog values (it has only counters)

used in manufacturing, not process control
187
2.3.6 Instruction Lists
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market
2.3.2 PLCs: Kinds
2.3.3 PLCs: Functions and construction
2.3.4 Continuous and Discrete Control
2.3.5 PLC Programming Languages
2.3.5.1 IEC 61131 Languages
2.3.5.2 Function blocks
2.3.5.3 Program Execution
2.3.5.4 Input / Output
2.3.5.5 Structured Text
2.3.5.6 Sequential Function Charts
2.3.5.7 Ladder Logic
2.3.5.8 Instructions Lists
2.3.5.9 Programming environment
188
Instruction Lists (1)
Instruction lists is the machine
language of PLC programming
It has 21 instructions (see table)


Three modifiers are defined:
"N" negates the result
"C" makes it conditional and
"(" delays it.

All operations relate to one
result register (RR) or
accumulator.


(Instruktionsliste, liste d'instructions)
189
Instruction Lists Example (2)
Instructions Lists is the most efficient way to write code, but only for
specialists.

Otherwise, IL should not be used, because this language:
provides no code structuring
has weak semantics
is machine dependent


190
2.3.5.9 Programming environment
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market
2.3.2 PLCs: Kinds
2.3.3 PLCs: Functions and construction
2.3.4 Continuous and Discrete Control
2.3.5 PLC Programming Languages
2.3.5.1 IEC 61131 Languages
2.3.5.2 Function blocks
2.3.5.3 Program Execution
2.3.5.4 Input / Output
2.3.5.5 Structured Text
2.3.5.6 Sequential Function Charts
2.3.5.7 Ladder Logic
2.3.5.8 Instructions Lists
2.3.5.9 Programming environment
191
Programming environment
capabilities
A PLC programming environment (ABB, Siemens, CoDeSys,...) allows:

- programming of the PLC in one of the IEC 61131 languages

- defining the variables (name and type)

- binding of the variables to the input/output (binary, analog)

- simulating

- downloading to the PLC of programs and firmware

- uploading of the PLC (seldom provided)

- monitoring of the PLC

- documenting and printing.

192
61131 Programming environment
laptop
download
symbols
code
variable
monitoring
and
forcing
for
debugging
firmware
network
configuration,
editor, compiler,
library
PLC
193
Program maintenance
The source of the PLC program is generally on the laptop of the technician.

This copy is frequently modified, it is difficult to track the original in a process database,
especially if several persons work on the same machine.

Therefore, it would be convenient to be able to reconstruct the source programs
out of the PLC's memory (called back-tracking, Rckdokumentation, reconstitution).

This supposes that the instruction lists in the PLC can be mapped directly to graphic
representations -> set of rules how to display the information.

Names of variables, blocks and comments must be kept in clear text, otherwise the code,
although correct, would not be readable.

For cost reasons, this is seldom implemented.
194
Is IEC 61131 FB an object-oriented
language ?
Not really: it does not support inheritance.

Blocks are not recursive.

But it supports interface definition (typed signals), instantiation, encapsulation, some form of
polymorphism.
195
Assessment
Which are programming languages defined in IEC 61131 and for what are they used ?
In a function block language, which are the two elements of programming ?
How is a PLC program executed and why is it that way ?
Draw a ladder diagram and the corresponding function chart.
Draw a sequential chart implementing a 2-bit counter
Program a saw tooth waveform generator with function blocks
How are inputs and outputs to the process treated in a function chart language ?
Program a sequencer for a simple chewing-gum coin machine
Program a ramp generator for a ventilator speed control (soft start and stop in 5s)


196
Limitations of IEC 61131
- it is not foreseen to distribute execution of programs over several devices

- event-driven execution is not foreseen. Blocks may be triggered by a Boolean
variable,
(but this is good so).


197

You might also like