Date post: | 03-Jun-2018 |
Category: |
Documents |
Upload: | bilal-shahid |
View: | 225 times |
Download: | 0 times |
of 113
8/12/2019 PLC for electrical engineers
1/113
Industrial AutomationAutomation Industrielle
Industrielle Automation
2.3 Programmable Logic Controllers (PLCs)
Autmatas programablesAutomates Programmables
Speicherprogrammierbare Steuerungen (SPS)
lim
TIT
TIT_REF_TABN_GT
POST_START_TIMER_MOD
1000
FAULT_STATE[tit1_oor]
FAULT_STATE[tit2_oor]OR
TIT_RATE_LIM_DN
TIT_RATE_LIM_UP
TI
T_ERROR
TIT_REF_MAX_START
WFD_TITPID
K_TIT
P
TD_TIT
D
MAX_INT
I
17.3
8/12/2019 PLC for electrical engineers
2/113
Programmable Logic Controllers 2.3 - 2Industrial Automation2013
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 Languages2.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 Logic2.3.5.8 Instruction Lists
2.3.5.9 Programming environment
8/12/2019 PLC for electrical engineers
3/113
Programmable Logic Controllers 2.3 - 3Industrial Automation2013
PLC = Programmable Logic Controller: Definition
Definition: small computers, dedicated to automation tasks in an industrial environment"
cabled relay control (hence 'logic'), analog (pneumatic, hydraulic) governors
real-time (embedded) computer with extensive input/output
Function: Measure, Control, Protect
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
Human Machine Interface (HMI) in PLCs (when it exists) is limitedto service help and control of operator displays
8/12/2019 PLC for electrical engineers
4/113
Programmable Logic Controllers 2.3 - 4Industrial Automation2013
Simple PLC
networkdigital inputs
digital outputs
analog inputs / outputs
8/12/2019 PLC for electrical engineers
5/113Programmable Logic Controllers 2.3 - 5Industrial Automation2013
PLC in a cabinet
CPU1
redundant field
bus connection
CPU2
inputs/outputs
serial connections
8/12/2019 PLC for electrical engineers
6/113Programmable Logic Controllers 2.3 - 6Industrial Automation2013
example: turbine control (in the test lab)
8/12/2019 PLC for electrical engineers
7/113Programmable Logic Controllers 2.3 - 7Industrial Automation2013
PLC: functions
Measure
Control (Command and Regulation)
Event LoggingCommunicationHuman interface
Protection
(Messen, Schtzen, Regeln = MSR)
PLC = PMC: Protection, Measurement and Control
8/12/2019 PLC for electrical engineers
8/113Programmable Logic Controllers 2.3 - 8Industrial Automation2013
PLC: Characteristics
large number of peripherals: 20..100 I/O per CPU, high density of wiring, easy assembly.
digital and analog Input/Output with standard levels
operate under harsh conditions, require robust construction, protection against dirt,
water and mechanical threats, electro-magnetic noise, vibration, extreme temperaturerange (-30C..85C), sometimes directly located in the field.
programming: either very primitive with hand-help terminals on the target machine
itself, or with a laptop network connection for programming on workstations and connection to SCADA
primitive Human-Machine-Interface for maintenance, either through LCD-display orconnection of a laptop over serial lines (RS232) or wireless.
economical -1000.- ..15'000.- for a full crate.
the value is in the application software (licenses20'000 ..50'000)
field bus connection for remote I/Os
8/12/2019 PLC for electrical engineers
9/113Programmable Logic Controllers 2.3 - 9Industrial Automation2013
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
CPU
Sensor Bus (e.g. ASI)
Field Bus
gateway
Field Stations
Control Stationwith Field Bus
direct I/O
I/O
Field DevicesFB
gateway
gateway
I/O
I/O
I/O
I/O
CPU
COM
I/O
I/O
I/O
COM
CPU
COM
COM
COM
I/O
Field Bus
CPU
COM
2
I/O
I/O
I/O
CPU
COM
1
COM2
I/O
CP
U
Operator
station
large
PLCs
small PLC
PLC
PLC
CO
M1
COM
1
Supervisor
Station
data concentrators,
not programmable,
but configurable
8/12/2019 PLC for electrical engineers
10/113
Programmable Logic Controllers 2.3 - 10Industrial Automation2013
Why 24V / 48 V supply ?
After the plant lostelectric power, operators
could read instruments only
by plugging in temporary
batteries
[IEEE Spectrum Nov 2011
about Fukushima]
Photo TEPCO
8/12/2019 PLC for electrical engineers
11/113
Programmable Logic Controllers 2.3 - 11Industrial Automation2013
Global players
Total sales in 2004: 7000 Mio
Source: ARC Research, 2005-10
8/12/2019 PLC for electrical engineers
12/113
Programmable Logic Controllers 2.3 - 12Industrial Automation2013
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 Languages2.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 Logic2.3.5.8 Instruction Lists
2.3.5.9 Programming environment
8/12/2019 PLC for electrical engineers
13/113
Programmable Logic Controllers 2.3 - 13Industrial Automation2013
Kinds of PLC
Monolithic constructionMonoprocessorFieldbus connection
(1)
Modular construction (backplane)
One- or multiprocessor systemFieldbus and LAN connectionSmall Micro Memory Card (MMC) function possible
(2)
Compact
Modular PLC
(3) Soft-PLCWindows NT or CE-based automation productsDirect use of CPU or co-processors
8/12/2019 PLC for electrical engineers
14/113
Programmable Logic Controllers 2.3 - 14Industrial Automation2013
Compact PLC
Monolithic (one-piece) constructionFixed casingFixed number of I/O (most of them binary)No process computer capabilities (no MMC)Can be extended and networked by an extension (field) busSometimes LAN connection (Ethernet, Arcnet)Monoprocessor
Typical product: Mitsubishi MELSEC F, ABB AC31, SIMATIC S7
costs:2000
courtesy ABBcourtesy ABB courtesy ABB
8/12/2019 PLC for electrical engineers
15/113
Programmable Logic Controllers 2.3 - 15Industrial Automation2013
Specific Controller (example: Turbine)
Thermocouple
inputs
binary I/Os,
CAN field bus
RS232 to HMI
Relays and fusesProgramming port
cost:1000.-
tailored for a specific application, produced in large series
courtesy Turbec
8/12/2019 PLC for electrical engineers
16/113
Programmable Logic Controllers 2.3 - 16Industrial Automation2013
courtesy ABB
Modular PLC
RS232
CPU CPU Analog I/O Binary I/O
backplaneparallel 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 CPUs)
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
development
environment
cost ~10000 for a filled crate
Typical products: SIMATIC S5-115, Hitachi H-Serie, ABB AC110
S ll d l PLC
8/12/2019 PLC for electrical engineers
17/113
Programmable Logic Controllers 2.3 - 17Industrial Automation2013
Small modular PLC
mounted on DIN-rail, 24V supplycheaper (5000)not water-proof,
no ventilatorextensible by a parallel bus (flat cable or rail)
courtesy ABBcourtesy Backmann
S ifi t ll ( il )
8/12/2019 PLC for electrical engineers
18/113
Programmable Logic Controllers 2.3 - 18Industrial Automation2013
Specific controller (railways)
data bus
special construction: no fans, large temperature range, vibrations
three PLCs networked by a data bus.
C t d l ?
8/12/2019 PLC for electrical engineers
19/113
Programmable Logic Controllers 2.3 - 19Industrial Automation2013
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
Industry PC
8/12/2019 PLC for electrical engineers
20/113
Programmable Logic Controllers 2.3 - 20Industrial Automation2013
Industry- PC
Wintel architecture(but also: Motorola, PowerPC),
HMI (LCD..)Limited modularity through mezzanine boards(PC104, PC-Cards, IndustryPack)Backplane-mounted versions with PCI or Compact-PCI
Competes with modular PLCno local I/O,
fieldbus connection instead,
courtesy INOVA courtesy MPI
costs: 2000.-
Soft PLC (PC as PLC)
8/12/2019 PLC for electrical engineers
21/113
Programmable Logic Controllers 2.3 - 21Industrial Automation2013
Soft-PLC (PC as PLC)
PC as engineering workstation PC as human interface (Visual Basic, Intellution, Wonderware) PC as real-time processor PC assisted by a Co-Processor (ISA- or PC104 board) PC as field bus gateway to a distributed I/O system
212
2
3
3
23
4
I/O modules
Protection devices
8/12/2019 PLC for electrical engineers
22/113
Programmable Logic Controllers 2.3 - 22Industrial Automation2013
Protection devices
Protection devices are highly specialized PLCs that measure the current and voltages in an electrical
substation, along with other statuses (position of the switches,) to detect situations that could
endanger the equipment (over-current, short circuit, overheat) and trigger the circuit breaker (trip) toprotect the substation.
In addition, they record disturbances and send the reports to the substations SCADA.
Sampling: 4.8 kHz, reaction time: < 5 ms.
Human interface
for status
and
settings
measurement
transformers
IrIsIt
UrUsUT
Programming
interface
trip relay
communication to operator
costs:5000
substation
Comparison Criteria what matters
8/12/2019 PLC for electrical engineers
23/113
Programmable Logic Controllers 2.3 - 23Industrial Automation2013
Comparison Criteria what matters
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
Graphical (on PC)
yes
1000 cm2
6 characters6 mm2
19.2 kbit/s
1024
Ladder logic
Instructions
Logic symbols
Hand-terminal
Graphical (on PC)
no
2678 cm2
5.3 mm27 charactersper line/point
10 Mbit/s
10 KB
Mounting cabinetDIN rail
Brand
2 3 3 PLCs: Function and construction
8/12/2019 PLC for electrical engineers
24/113
Programmable Logic Controllers 2.3 - 24Industrial Automation2013
2.3.3 PLCs: Function and construction
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market2.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 Logic2.3.5.8 Instruction Lists
2.3.5.9 Programming environment
General PLC architecture
8/12/2019 PLC for electrical engineers
25/113
Programmable Logic Controllers 2.3 - 25Industrial Automation2013
General PLC architecture
CPUReal-Time
Clock
flash
EPROM
ROM
buffers
signal
conditioning
power
amplifiersrelays
signal
conditioning
serial port
controller
Ethernet
parallel bus
ethernet
controller
RS 232
analog-
digital
converters
digital-
analog
converters
Digital Output DigitalInput
fieldbuscontroller externalI/Os
extensionbus
field bus direct Inputs and Outputs
The signal chain within a PLC
8/12/2019 PLC for electrical engineers
26/113
Programmable Logic Controllers 2.3 - 26Industrial Automation2013
The signal chain within a PLC
analog
variable(e.g. 4..20mA)
filtering
&
scaling
analog-
digital
converter
processing
digital-
analog
converter
analog
variablee.g. -10V..10V
time
y
time
y(i)
sampling
binary
variable(e.g. 0..24V)
filtering sampling
time
y
transistor
or
relay
binary
variable
amplifier011011001111
counter
1
non-volatile
memory
0001111
time
y(i)
Internals of a protection device
8/12/2019 PLC for electrical engineers
27/113
Programmable Logic Controllers 2.3 - 27Industrial Automation2013
p
Signal flow in an IED
8/12/2019 PLC for electrical engineers
28/113
Programmable Logic Controllers 2.3 - 28Industrial Automation2013
g
2.3.4 Continuous and discrete control
8/12/2019 PLC for electrical engineers
29/113
Programmable Logic Controllers 2.3 - 29Industrial Automation2013
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers2.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 Charts2.3.5.7 Ladder Logic
2.3.5.8 Instruction Lists
2.3.5.9 Programming environment
Matching the analog and binary world
8/12/2019 PLC for electrical engineers
30/113
Programmable Logic Controllers 2.3 - 30Industrial Automation2013
discrete control analog regulation
PLC evolution
8/12/2019 PLC for electrical engineers
31/113
Programmable Logic Controllers 2.3 - 31Industrial Automation2013
A
B
P2
P1
I1
Analog WorldBinary World
C
continuous processes
Regulation, controllers
discrete processes
combinatorial sequential
Relay control, pneumatic
sequencer
Pneumatic and electromechanicalcontrollers
Programmable Logic Controllers
(Speicherprogrammierbare Steuerungen, Automates Programmables)
Continuous Plant (reminder)
8/12/2019 PLC for electrical engineers
32/113
Programmable Logic Controllers 2.3 - 32Industrial Automation2013
Example: traction motors, ovens, pressure vessel,...
The time constant of the control system must be at least one order ofmagnitude smaller than the smallest time constant of the plant.
F(s) = yx
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 inform 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+T1s + T2s2)
the principal task of the control system for a continuous plant is its regulation.
Discrete Plant (reminder)
8/12/2019 PLC for electrical engineers
33/113
Programmable Logic Controllers 2.3 - 33Industrial Automation2013
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 theevent 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
bc + d
e
init
Continuous and Discrete Control (comparison)
8/12/2019 PLC for electrical engineers
34/113
Programmable Logic Controllers 2.3 - 34Industrial Automation2013
A B
Out = A B
B
NOT CA
Out = (A + B) C
"sequential""combinatorial"1)
ladderlogic
e.g. GRAFCET, Petri Netse.g. ladder logic, CMOS logic
P2
P1
I1
analog
building
blocs
1) not really combinatorial: blocs may have memory
2.3.5 Programming languages
8/12/2019 PLC for electrical engineers
35/113
Programmable Logic Controllers 2.3 - 35Industrial Automation2013
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market2.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 Logic2.3.5.8 Instruction Lists
2.3.5.9 Programming environment
"Real-Time" languages
8/12/2019 PLC for electrical engineers
36/113
Programmable Logic Controllers 2.3 - 36Industrial Automation2013
Extend procedural languages to
express time
(introduce programming constructs toinfluence 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
The long march to IEC 61131
8/12/2019 PLC for electrical engineers
37/113
Programmable Logic Controllers 2.3 - 37Industrial Automation2013
Source: Dr. J. Christensen
77 78 79 8180 93 94 9570 82 83 84 85 8786 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
it took 20 years to make that standard
The five IEC 61131-3 Programming languageshttp://www.isagraf.com
8/12/2019 PLC for electrical engineers
38/113
Programmable Logic Controllers 2.3 - 38Industrial Automation2013
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
Function Block Diagram (FBD)
PUMP
AUTOMAN_ON
ACT
DOV
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 AACTION D1N
D ACTION D2
STEP B D3_READY
D4_READY
ACTION D3N
D ACTION D4
T3
CALC1
CALC
IN1
IN2
OUT >=1
graphical languages
textual languages
AUTO
MAN_ON
ACT
CALC1
CALC
IN1
IN2
OUT
Importance of IEC 61131
8/12/2019 PLC for electrical engineers
39/113
Programmable Logic Controllers 2.3 - 39Industrial Automation2013
IEC 61131-3 is the most important automation language in industry.
80% of all PLCs support it, all new developments are based on it.
Depending on the country, some languages are more popular than others.
http://docs.google.com/forms/d/1m4dQkDF89aGj5B
aL0Rzj9Xl7XprDvyU8pB4J0vd4sWo/viewform
Exercise
2.4.2.1 Function Blocks Language
http://docs.google.com/forms/d/1m4dQkDF89aGj5BaL0Rzj9Xl7XprDvyU8pB4J0vd4sWo/viewformhttp://docs.google.com/forms/d/1m4dQkDF89aGj5BaL0Rzj9Xl7XprDvyU8pB4J0vd4sWo/viewformhttp://docs.google.com/forms/d/1m4dQkDF89aGj5BaL0Rzj9Xl7XprDvyU8pB4J0vd4sWo/viewformhttp://docs.google.com/forms/d/1m4dQkDF89aGj5BaL0Rzj9Xl7XprDvyU8pB4J0vd4sWo/viewform8/12/2019 PLC for electrical engineers
40/113
Programmable Logic Controllers 2.3 - 40Industrial Automation2013
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market2.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 language2.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
Function Block Languages
8/12/2019 PLC for electrical engineers
41/113
Programmable Logic Controllers 2.3 - 41Industrial Automation2013
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 for simulations
(Funktionsblocksprache, langage de blocs de fonctions)
(Also called "Function Chart" or "Function Plan" - FuPla)
Function Block Examples
8/12/2019 PLC for electrical engineers
42/113
Programmable Logic Controllers 2.3 - 42Industrial Automation2013
&
A
B C
TriggerTempo &
Running
Reset
S
R
Spin
Graphical programming language, similar to electrical and block
diagrams. Mostly expresses combinatorial logic, but blocks may havememory (e.g. RS-flip-flopsbut no D-flip-flops: no edge-triggered logic).
Example 1:
Example 2:external inputs external outputs
Q
Function Block Elements
8/12/2019 PLC for electrical engineers
43/113
Programmable Logic Controllers 2.3 - 43Industrial Automation2013
"continuously"
executing block,independent,no side effects
set pointmeasurement
command
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).
Typed connections that carry a pseudo-continuous data flow.
Connects the function blocks.
Signals
Function block
(set point)
(set point)
set point
Example
Example
PID
input signals output signals
overflow
Function Block Example
8/12/2019 PLC for electrical engineers
44/113
Programmable Logic Controllers 2.3 - 44Industrial Automation2013
Function Block Rules
8/12/2019 PLC for electrical engineers
45/113
Programmable Logic Controllers 2.3 - 45Industrial Automation2013
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 typemust be identical.
The function plan should be drawn so the signals flow from leftto right and from top to bottom. Some editors impose additional rules.
Retroactions are an exception to this rule. In this case, the signal direction isidentified by an arrow (forbidden in some editorsuse global variables instead).
ab
y
x
z
c
Types of Programming Organisation Units (POUs)
8/12/2019 PLC for electrical engineers
46/113
Programmable Logic Controllers 2.3 - 46Industrial Automation2013
1) Functions
- are part of the base library.
- have no memory.Examples: and gate, adder, multiplier, selector,....
2) Elementary Function Blocks (EFB)
- are part of the base library
- have a 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)
Function Block library
8/12/2019 PLC for electrical engineers
47/113
Programmable Logic Controllers 2.3 - 47Industrial Automation2013
The programmer chooses the blocks in a block library, similarly to the
hardware engineer who chooses integrated circuits in a catalogue.
The library describes the pinning of each block, its semantics and theexecution time.
The programmer may extend the library by defining function block macroscomposed of library elements.
If some blocks are used often, they will be programmed in an externallanguage (e.g. C, micro-code) following strict rules.
Library functions for discrete plants
8/12/2019 PLC for electrical engineers
48/113
Programmable Logic Controllers 2.3 - 48Industrial Automation2013
logical combinations (AND, OR, NOT, EXOR)
Flip-flop
Selector m-out-of-nMultiplexer m-to-n
Timer
Counter
Memory
Sequencing
Basic blocks
Display
Manual input, touch-screen
Safety blocks (interlocking)
Logging
Compound blocks
Alarm signaling
Analog function blocks for continuous control
8/12/2019 PLC for electrical engineers
49/113
Programmable Logic Controllers 2.3 - 49Industrial Automation2013
Basic blocks
Summator / Subtractor
Multiplier / Divider
Integrator / DifferentiatorFilter
Minimal value, Maximum value
Radix
Function generator
Regulation Functions
P, PI, PID, PDT2 controllerFixed set-point
Ratio and multi-component regulation
Parameter variation / setting
2-point regulation
3-point regulation
Output value limitationRamp generator
Adaptive regulation
Drive Control
Function Block library for specialized applications
8/12/2019 PLC for electrical engineers
50/113
Programmable Logic Controllers 2.3 - 50Industrial Automation2013
MoveAbsolute
AXIS_REFAxis Axis
AXIS_REFBOOL Execute Done BOOL
REAL Position BOOL
REAL Velocity
CommandAborted
WORDREAL Acceleration
BOOL
REAL Deceleration
REAL Jerk
MC_Direction Direction
Error
ErrorID
standardized blocks are defined in libraries, e.g. Motion Control or Robot
IEC 61131-3 library (extract)
binary elements
8/12/2019 PLC for electrical engineers
51/113
Programmable Logic Controllers 2.3 - 51Industrial Automation2013
binary elements
ADD
analog elements
SUB
MUL
DIV
adder
INT
PVselector
(1:2)
AND
OR
XOR
SRS
Q
S
R_TRIG
Q
R1
subtractor
multiplier
divider
integrator
greater than
less than
Up counter(CTD counter down)
GT
LT
LE less equal
and
or
exclusive-or
flip-flop
dominant reset
Q:=!R1&(Q|S)
positive
edge
GT
SEL
IN
TP/TON/TOF
QPT ET
CTUCURESETPV
QCV
In
Reset
greater equalGE
(if reset) { Out := PV,
else Out:=t *In + Out}multiplexer
(1:N)
MUX
bool
int
IN pos.edge: start
PT duration of delay
Q TP: 1, while PT
TON: 1, at PT
TOF: 0, at PT
ET actual delay
S1SR
QR
flip-flop
dominant set
Q:=S1|(Q&!R)
bool
More details: http://www.zpss.aei.polsl.pl/content/dydaktyka/PC/PLC_IEC61131-3.pdf
Exercise: What do the following blocks do ?
8/12/2019 PLC for electrical engineers
52/113
Programmable Logic Controllers 2.3 - 52Industrial Automation2013
CTUCURESETPV
QCV
https://docs.google.com/forms/d/1ynmoXf3JTcRn2yv
2_4bKhcK0HJNDYpiTnQQm13lDSso/viewform
ADD OutIn
(e.g.10)(initially 2)
1.
DIV
INT
PresetValIn
Reset Out
In1
(initially 2)
(initially 0)
2.
(e.g. 1024)
In2
3.
4.S
R
Q
Flipflop: dominant set or reset?
t1 t2 t3 t4 t5 t6 t7 t8
CUReset = 0, PV = 3 Q = (CV >= PV) ?
ftp://advantechdownloads.com/Trai
ng/KW%20training/
SRS
QR1
dominant reset
Q:=!R1&(Q|S)
S1SR
QR
dominant set
Q:=S1|(Q&!R)
(if reset) { Out := PV,
else Out:=t *In + Out}
Exercise: What do the following blocks do ?
https://docs.google.com/forms/d/1ynmoXf3JTcRn2yv2_4bKhcK0HJNDYpiTnQQm13lDSso/viewformhttps://docs.google.com/forms/d/1ynmoXf3JTcRn2yv2_4bKhcK0HJNDYpiTnQQm13lDSso/viewformhttps://docs.google.com/forms/d/1ynmoXf3JTcRn2yv2_4bKhcK0HJNDYpiTnQQm13lDSso/viewformhttps://docs.google.com/forms/d/1ynmoXf3JTcRn2yv2_4bKhcK0HJNDYpiTnQQm13lDSso/viewform8/12/2019 PLC for electrical engineers
53/113
Programmable Logic Controllers 2.3 - 53Industrial Automation2013
https://docs.google.com/forms/d/1ynmoXf3JTcRn2yv
2_4bKhcK0HJNDYpiTnQQm13lDSso/viewform
3.
CV = 1, 1, 2, 2, 3, 3, 4, 4
Q = 0, 0, 0, 0, 1, 1, 1, 1
4.S
R
Q
ftp://advantechdownloads.com/Trai
ng/KW%20training/
S1SR
QR
dominant set
Q:=S1|(Q&!R)
1.
2, 10, 22, 31, 42
2.
If out is initially 0: 0, 0, 0, 0, 0
If out is initially 1024: 1024, 1536, 2304,
3456, 5184
Exercise: Which Behavior belongs to which Timer?
5.
https://docs.google.com/forms/d/1ynmoXf3JTcRn2yv2_4bKhcK0HJNDYpiTnQQm13lDSso/viewformhttps://docs.google.com/forms/d/1ynmoXf3JTcRn2yv2_4bKhcK0HJNDYpiTnQQm13lDSso/viewformhttps://docs.google.com/forms/d/1ynmoXf3JTcRn2yv2_4bKhcK0HJNDYpiTnQQm13lDSso/viewformhttps://docs.google.com/forms/d/1ynmoXf3JTcRn2yv2_4bKhcK0HJNDYpiTnQQm13lDSso/viewform8/12/2019 PLC for electrical engineers
54/113
Programmable Logic Controllers 2.3 - 54Industrial Automation2013
IN
TP/TON/TOF
QPT ET
IN pos.edge: start
PT duration of delay
Q Timer Pulse: 1, while PT Timer ON delay: 1, at PT Timer OFF delay: 0, at PT
ET actual delay
https://docs.google.com/forms/d/1ynmoXf3JTcRn2yv2_4bKhcK0HJNDYpiTnQQm13lDSso/viewform
a)
b)
c)
ftp://advantechdownloads.com/
Training/KW%20training/
Exercise: Which Behavior belongs to which Timer?
5.
https://docs.google.com/forms/d/1ynmoXf3JTcRn2yv2_4bKhcK0HJNDYpiTnQQm13lDSso/viewformhttps://docs.google.com/forms/d/1ynmoXf3JTcRn2yv2_4bKhcK0HJNDYpiTnQQm13lDSso/viewform8/12/2019 PLC for electrical engineers
55/113
Programmable Logic Controllers 2.3 - 55Industrial Automation2013
IN
TP/TON/TOF
QPT ET
IN pos.edge: start
PT duration of delay
Q Timer Pulse: 1, while PT Timer ON delay: 1, at PT Timer OFF delay: 0, at PT
ET actual delay
https://docs.google.com/forms/d/1ynmoXf3JTcRn2yv2_4bKhcK0HJNDYpiTnQQm13lDSso/viewform
a)
Timer ON delay
b)
Timer OFF delay
c)
Pulse
ftp://advantechdownloads.com/
Training/KW%20training/
Exercise: Asymmetric Sawtooth Wave
https://docs.google.com/forms/d/1ynmoXf3JTcRn2yv2_4bKhcK0HJNDYpiTnQQm13lDSso/viewformhttps://docs.google.com/forms/d/1ynmoXf3JTcRn2yv2_4bKhcK0HJNDYpiTnQQm13lDSso/viewform8/12/2019 PLC for electrical engineers
56/113
Programmable Logic Controllers 2.3 - 56Industrial Automation2013
Build an asymmetric sawtooth wave generator with
the IEC 61131 elements of Slide 51
75
0
-25
5s 12s
Exercise: Saw-tooth FBD
8/12/2019 PLC for electrical engineers
57/113
Programmable Logic Controllers 2.3 - 57Industrial Automation2013
+ 8.3
-20.0
75.0
-25.0
Specifying the behaviour of Function Block
Time Diagram:
8/12/2019 PLC for electrical engineers
58/113
Programmable Logic Controllers 2.3 - 58Industrial Automation2013
g
0 T
T
x
y
yx
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:
yx
t
idp xdK
dt
dxKxK
0
Calculates the root mean square of the input with a filtering constant
defined in parameter FilterDelay
Function Block specification in Structured Text
8/12/2019 PLC for electrical engineers
59/113
Programmable Logic Controllers 2.3 - 59Industrial Automation2013
Function Block decomposition
A function block describes a data flow interface
8/12/2019 PLC for electrical engineers
60/113
Programmable Logic Controllers 2.3 - 60Industrial Automation2013
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, IEC 61131 ST):
Elementary block
The body is realized as a function block program
Each input (output) pin of the interface is implemented asexactly 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;=
=
Function Block segmentation
An application program (task) is decomposed into segments ("Programs")
8/12/2019 PLC for electrical engineers
61/113
Programmable Logic Controllers 2.3 - 61Industrial Automation2013
An application program (task) 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
2.3.5.3 Program execution
2 1 Instrumentation
8/12/2019 PLC for electrical engineers
62/113
Programmable Logic Controllers 2.3 - 62Industrial Automation2013
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market2.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 blocks2.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
Execution of Function Blocks
A X01 XSegment or POU
8/12/2019 PLC for electrical engineers
63/113
Programmable Logic Controllers 2.3 - 63Industrial Automation2013
F1ABX01
F2X01XF3BCX02
F4XX02Y
Machine Code:functioninput1input2output
AF1 F2
BF4
YX02
F3
C
XSegment or POU(program organization unit)
The function blocks aretranslated to machine language(intermediate code, IL),that is either interpreted orcompiled to assembly language
Blocks are executed in sequence,
normally from upper left to lower right
The sequence is repeated every tms.
Input-Output of Function Blocks
R ti
8/12/2019 PLC for electrical engineers
64/113
Programmable Logic Controllers 2.3 - 64Industrial Automation2013
execute individual period
I OX I OX I OX
readinputs
writeoutputs
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
Program configuration
The programmer divides the program into tasks (sometimes called pages or
8/12/2019 PLC for electrical engineers
65/113
Programmable Logic Controllers 2.3 - 65Industrial Automation2013
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 operations take more than one period,
they are executed in background.
The periodic execution always has the highest priority.
IEC 61131 - Execution engine
configuration
8/12/2019 PLC for electrical engineers
66/113
Programmable Logic Controllers 2.3 - 66Industrial Automation2013
configuration
resource
task task
program program
FB FB
task
execution control path
variable access paths
FB function block
variable
represented variables
communication function
Legend:
program
FB FB
resource
task
program
global and directly
access paths
Parallel execution
F ti bl k ti l l ll it d f t lti i ( ll l
8/12/2019 PLC for electrical engineers
67/113
Programmable Logic Controllers 2.3 - 67Industrial Automation2013
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 ashared 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
2.3.5.4 Input and Output
2.1 Instrumentation
8/12/2019 PLC for electrical engineers
68/113
Programmable Logic Controllers 2.3 - 68Industrial Automation2013
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market2.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 blocks2.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
Connecting to Input/Output, Method 1: dedicated I/O blocks
Th I t d O t t f th PLC t b t d t (t d) i bl
8/12/2019 PLC for electrical engineers
69/113
Programmable Logic Controllers 2.3 - 69Industrial Automation2013
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
Connecting to Input / Output, Method 2: Variables configuration
All program variables must be declared with name and type initial value and volatility
8/12/2019 PLC for electrical engineers
70/113
Programmable Logic Controllers 2.3 - 70Industrial Automation2013
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
2.3.5.5 Structured Text
2.1 Instrumentation
2 2 C t l
8/12/2019 PLC for electrical engineers
71/113
Programmable Logic Controllers 2.3 - 71Industrial Automation2013
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 blocks2.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
Structured Text
(Strukturierte Textsprache, langage littral structur)
8/12/2019 PLC for electrical engineers
72/113
Programmable Logic Controllers 2.3 - 72Industrial Automation2013
( p , g g )
Structured Text is a 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 blocks
Caution: writing programs in structured text can breach the real-time rules !
Data Types
Function Blocks are typed: the types of connection, input and output must match.
8/12/2019 PLC for electrical engineers
73/113
Programmable Logic Controllers 2.3 - 73Industrial Automation2013
binary types: analog types:
Derived Types are user-defined and must be declared in Structur ed Text
subrange,
enumerated,
arrays,
structured types
(e.g. AntivalentBoolean2)
Variables can receive initial values and be declared as non-volatile (RETAIN), so
after restart they contain the last value before power-down or reset.
BOOLBYTEWORDDWORD
181632
REAL (Real32)LREAL (Real64)
Elementary Types are defined either in Structured Text or in the FB configuration.
61131 Elementary Data Types
1 BOOL Boolean 1
No. Keyword Data Type Bits
8/12/2019 PLC for electrical engineers
74/113
Programmable Logic Controllers 2.3 - 74Industrial Automation2013
1 BOOL Boolean 1
2 SINT Short integer 8
3 INT Integer 16
4 DINT Double integer 325 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 variable
13 DATE Date (only) variable
14 TIME_OF_DAY or TOD Time of day (only) variable
15 DATE_AND_TIME or DT Date and time of day variable
16 STRING Character string variable
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
Example of Derived Types
8/12/2019 PLC for electrical engineers
75/113
Programmable Logic Controllers 2.3 - 75Industrial Automation2013
TYPE
ANALOG_CHANNEL_CONFIGURATIONSTRUCT
RANGE: ANALOG_SIGNAL_RANGE;
MIN_SCALE : ANALOG_DATA ;
MAX_SCALE : ANALOG_DATA ;
END_STRUCT;
ANALOG_16_INPUT_CONFIGURATION :
STRUCTSIGNAL_TYPE : ANALOG_SIGNAL_TYPE;
FILTER_CHARACTERISTIC : SINT (0.99)
CHANNEL: ARRAY [1..16] OF ANALOG_CHANNEL_CONFIGURATION;
END_STRUCT ;
END_TYPE
2.3.5.6 Sequential Function Charts
2.1 Instrumentation
8/12/2019 PLC for electrical engineers
76/113
Programmable Logic Controllers 2.3 - 76Industrial Automation2013
2.2 Control
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market2.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 blocks2.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
SFC (Sequential Flow Chart)
(Ablaufdiagramme, diagrammes de flux en squence - grafcet)
8/12/2019 PLC for electrical engineers
77/113
Programmable Logic Controllers 2.3 - 77Industrial Automation2013
SFC describes sequences of operations and interactions between parallel processes.
It is derived from the languages Grafcet and SDL (Specification and DescriptionLanguage, used for communication protocols), mathematical foundation lies in Petri Nets.
START STEP
ACTION D1N D1_READY
D ACTION D2 D2_READY
T1
T2
STEP BSTEP A
SFC: Elements
"1"event condition
S0
8/12/2019 PLC for electrical engineers
78/113
Programmable Logic Controllers 2.3 - 78Industrial Automation2013
The sequential program consists of states connected by transitions.
A state is activatedby 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
(task to which this program is attached)
Ec = ((varX & varY) | varZ)
token
Sa
Sb
"1"
Ea
Sc
Eb
transitions
states
eventcondition
("1" = always true)
example transition condition
Rule: there is always a transition between two states,there is always a state between two transitions
SFC: Initial state
8/12/2019 PLC for electrical engineers
79/113
Programmable Logic Controllers 2.3 - 79Industrial Automation2013
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).
SFC: Switch and parallel execution
"1" E0
8/12/2019 PLC for electrical engineers
80/113
Programmable Logic Controllers 2.3 - 80Industrial Automation2013
Sa
Sb
Se
token switch : the token crosses the first active
transition (at random if both Ea and Eb are true)
Note: transitions are after the alternance
token forking : when the transition Ee is true, the token
is replicated to all connected statesNote: transition is before the fork
Ed
token join: when all connected states have tokens
and transition Eg is true, one single token is forwarded.
Note: transition is after the join
Ee
Sc
Sd
SfSg
Eg
Ea Eb
Ec
Ef
SFC: P1, N and P0 actions
P1 State1 P1: do at enterSt t 1
8/12/2019 PLC for electrical engineers
81/113
Programmable Logic Controllers 2.3 - 81Industrial Automation2013
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 enteredP0 (pulse fall) action is executed once when the state is leftN (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.
Special action: the timer
rather than define a P0 action reset timer there is an implicit variable defined as
8/12/2019 PLC for electrical engineers
82/113
Programmable Logic Controllers 2.3 - 82Industrial Automation2013
rather than define a P0 action reset timer., there is an implicit variable defined as
.t that express the time spent in that state.
Sf
S.t > t#5s
S
SFC: graphic rules
The input and output flow of a state are always in the same vertical line (simplifies structure)
8/12/2019 PLC for electrical engineers
83/113
Programmable Logic Controllers 2.3 - 83Industrial Automation2013
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.
SFC: Exercise
VariablesInput:I0, I1, I2, I3;
Output:
8/12/2019 PLC for electrical engineers
84/113
Programmable Logic Controllers 2.3 - 84Industrial Automation2013
initially: move vehicle at reduced speed until it touches I0 and open the trap for 5s(empty the vehicle). Speed = 5 cm/s between I0 and I1 or between I2 and I3,speed = 1 m/s between I1 and I2.
1 - Let the vehicle move from I0 to I32 - Stop the vehicle when it reaches I3.
3 - Open the tank during 5s.
4 - Go back to I05 - Open the trap and wait 5s.
repeat above steps indefinitely
I2 I3Inputs generate 1 as long as
the tag of the vehicle (1cm) is
over the sensor.
Register = {0: closed; 1: open}
I0 I1
trap+speed
Speed = {+20: +1 m/s; +1: +5 cm/s; 0: 0m/s}
negative values: opposite direction
Output:
Trap = {0: closed; 1: open}
Register = {0: closed; 1: open}
Exercise: Wagon SFC
8/12/2019 PLC for electrical engineers
85/113
Programmable Logic Controllers 2.3 - 85Industrial Automation2013
Right2Left
SFC: Building subprograms
T-element
8/12/2019 PLC for electrical engineers
86/113
Programmable Logic Controllers 2.3 - 86Industrial Automation2013
::=
::=
OR: OR:
OR: OR:
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 appearas elements in the flow chart.
A flow chart may only contain the terminal symbols: state and transition
SFC: Structuring
Every flow chart without a token generator may be redrawn as astructured flow chart (by possibly duplicating program parts)
8/12/2019 PLC for electrical engineers
87/113
Programmable Logic Controllers 2.3 - 87Industrial Automation2013
A
B
C
a
b
d
c
Not structured
A
B
C
a
b
a
bB'
A'
d
c
d
structured
SFC: Complex structures
These general rules serve to build networks, termed by DIN and IEC as flow charts
8/12/2019 PLC for electrical engineers
88/113
Programmable Logic Controllers 2.3 - 88Industrial Automation2013
Problems with general networks:
Deadlocks, uncontrolled
token multiplication
Solution:
assistance through the flow chart editor.
Function Blocks And Flow Chart
8/12/2019 PLC for electrical engineers
89/113
Programmable Logic Controllers 2.3 - 89Industrial Automation2013
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 functionblock with binary inputs (transitions) and binary outputs (states).
Executing Flow Charts As blocks
A function block may be implemented in three different ways:
8/12/2019 PLC for electrical engineers
90/113
Programmable Logic Controllers 2.3 - 90Industrial Automation2013
procedure
xy(...);begin...
end xy;
extern (ST) function blocks flow chart
Function blocks and flow chart communicate over binary signals.
Flow Charts or Function Blocs ?
A task can sometimes be written indifferently as function blocs or as flow chart.
Th li ti m d id hi h t ti i m i t
8/12/2019 PLC for electrical engineers
91/113
Programmable Logic Controllers 2.3 - 91Industrial Automation2013
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
Flow Charts Or Blocks ? (2)
Flow Chart Function Blocks
8/12/2019 PLC for electrical engineers
92/113
Programmable Logic Controllers 2.3 - 92Industrial Automation2013
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
Function Blocks
2.3.5.7 Ladder Logic
2.1 Instrumentation
2.2 Control
8/12/2019 PLC for electrical engineers
93/113
Programmable Logic Controllers 2.3 - 93Industrial Automation2013
2.3 Programmable Logic Controllers
2.3.1 PLCs: Definition and Market2.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 blocks2.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
Ladder logic (1)
(Kontaktplansprache, langage contacts)
8/12/2019 PLC for electrical engineers
94/113
Programmable Logic Controllers 2.3 - 94Industrial Automation2013
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.
Ladder Logic (2)
make contact
8/12/2019 PLC for electrical engineers
95/113
Programmable Logic Controllers 2.3 - 95Industrial Automation2013
01 02
50
01
02
03 50
03
relay coil(bobine)
break contact
(contact repos)
make contact
(contact travail)
corresponding
ladder diagram
origin:
electricalcircuit
50 05
44
rung
"coil" 50 is used to move
other contact(s)
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.
8/12/2019 PLC for electrical engineers
96/113
Programmable Logic Controllers 2.3 - 96Industrial Automation2013
y g g p g g y
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
contact travail
contact repos
bobine
Arbeitskontakt
Ruhekontakt
Spule
Ladder logic (4)
Binary combinations are expressed by series and parallel relay contact:
ladder logic representation l i " i l t
8/12/2019 PLC for electrical engineers
97/113
Programmable Logic Controllers 2.3 - 97Industrial Automation2013
+ 01 02
50
Coil 50 is active (current flows) when 01 is active and 02 is not.
01
0250
Series
+ 01
40
02
Coil 40 is active (current flows) when 01 is active or 02 is not.
Parallel
ladder logic representation logic" equivalent
01
0240
Ladder logic (5)
The ladder logic is more intuitive for complex binary expressions than literal languages
textual expression
8/12/2019 PLC for electrical engineers
98/113
Programmable Logic Controllers 2.3 - 98Industrial Automation2013
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 72 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
p
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 morein relay terms
8/12/2019 PLC for electrical engineers
99/113
Programmable Logic Controllers 2.3 - 99Industrial Automation2013
in relay terms.
The contact plan language was extended to express functions:
literal expression:
!00 & 01 FUN 02 = 200200FUN 02
0100
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 thefreedom of side effects and makes programs difficult to read.
Ladder logic (7)
Ladder logic provides neither: sub-programs (blocks) nor
8/12/2019 PLC for electrical engineers
100/113
Programmable Logic Controllers 2.3 - 100Industrial Automation2013
sub-programs (blocks), nordata encapsulation nor
structured data types.
It is not suited to make reusable modules.
IEC 61131 does not prescribe the minimum requirements for a compiler / interpretersuch 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
2.3.6 Instruction Lists
2.1 Instrumentation
2.2 Control
2 3 Programmable Logic Controllers
8/12/2019 PLC for electrical engineers
101/113
Programmable Logic Controllers 2.3 - 101Industrial Automation2013
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 blocks2.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 Lists2.3.5.9 Programming environment
Instruction Lists (1)
Instruction lists is the machinelanguage of PLC programming
(Instruktionsliste, liste d'instructions)
8/12/2019 PLC for electrical engineers
102/113
Programmable Logic Controllers 2.3 - 102Industrial Automation2013
language of PLC programmingIt 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 resultregister (RR) or accumulator.
Instruction Lists Example (2)
8/12/2019 PLC for electrical engineers
103/113
Programmable Logic Controllers 2.3 - 103Industrial Automation2013
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 structuringhas weak semanticsis machine dependent
End: ST temp3 (* result *)
Exercise IEC 61131 Languages
Function Block Diagram
C
Ladder Diagram
8/12/2019 PLC for electrical engineers
104/113
Programmable Logic Controllers 2.3 - 104Industrial Automation2013
https://docs.google.com/forms/d/1lGkFXQrlwlnoKc8g
Ug-_ESAdtVy-RgIOLnFbkIOGNa8/viewform
Instruction List
? ?
? ?
? ?
A C
B
?
C:= ?
Structured Text
A B C
-| |--|/|----------------( )?
?
Exercise IEC 61131 Languages
Function Block Diagram
A B C
Ladder Diagram
https://docs.google.com/forms/d/1lGkFXQrlwlnoKc8gUg-_ESAdtVy-RgIOLnFbkIOGNa8/viewformhttps://docs.google.com/forms/d/1lGkFXQrlwlnoKc8gUg-_ESAdtVy-RgIOLnFbkIOGNa8/viewformhttps://docs.google.com/forms/d/1lGkFXQrlwlnoKc8gUg-_ESAdtVy-RgIOLnFbkIOGNa8/viewformhttps://docs.google.com/forms/d/1lGkFXQrlwlnoKc8gUg-_ESAdtVy-RgIOLnFbkIOGNa8/viewformhttps://docs.google.com/forms/d/1lGkFXQrlwlnoKc8gUg-_ESAdtVy-RgIOLnFbkIOGNa8/viewformhttps://docs.google.com/forms/d/1lGkFXQrlwlnoKc8gUg-_ESAdtVy-RgIOLnFbkIOGNa8/viewformhttps://docs.google.com/forms/d/1lGkFXQrlwlnoKc8gUg-_ESAdtVy-RgIOLnFbkIOGNa8/viewformhttps://docs.google.com/forms/d/1lGkFXQrlwlnoKc8gUg-_ESAdtVy-RgIOLnFbkIOGNa8/viewform8/12/2019 PLC for electrical engineers
105/113
Programmable Logic Controllers 2.3 - 105Industrial Automation2013
https://docs.google.com/forms/d/1lGkFXQrlwlnoKc8g
Ug-_ESAdtVy-RgIOLnFbkIOGNa8/viewform
Instruction List
LD A
ANDN B
ST C
A C
B
AND
C:= AAND NOTB
Structured Text
A B C
-| |--|/|----------------( )
2.3.5.9 Programming environment
2.1 Instrumentation
2.2 Control
2.3 Programmable Logic Controllers
https://docs.google.com/forms/d/1lGkFXQrlwlnoKc8gUg-_ESAdtVy-RgIOLnFbkIOGNa8/viewformhttps://docs.google.com/forms/d/1lGkFXQrlwlnoKc8gUg-_ESAdtVy-RgIOLnFbkIOGNa8/viewformhttps://docs.google.com/forms/d/1lGkFXQrlwlnoKc8gUg-_ESAdtVy-RgIOLnFbkIOGNa8/viewformhttps://docs.google.com/forms/d/1lGkFXQrlwlnoKc8gUg-_ESAdtVy-RgIOLnFbkIOGNa8/viewformhttps://docs.google.com/forms/d/1lGkFXQrlwlnoKc8gUg-_ESAdtVy-RgIOLnFbkIOGNa8/viewformhttps://docs.google.com/forms/d/1lGkFXQrlwlnoKc8gUg-_ESAdtVy-RgIOLnFbkIOGNa8/viewformhttps://docs.google.com/forms/d/1lGkFXQrlwlnoKc8gUg-_ESAdtVy-RgIOLnFbkIOGNa8/viewformhttps://docs.google.com/forms/d/1lGkFXQrlwlnoKc8gUg-_ESAdtVy-RgIOLnFbkIOGNa8/viewform8/12/2019 PLC for electrical engineers
106/113
Programmable Logic Controllers 2.3 - 106Industrial Automation2013
2.3.1 PLCs: Definition and Market
2.3.2 PLCs: Kinds2.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 Lists2.3.5.9 Programming environment
Programming environment capabilities
A PLC programming environment (e.g. ABB ControlBuilder,
Siemens Step 7, CoDeSys,...) allows the programmer to
8/12/2019 PLC for electrical engineers
107/113
Programmable Logic Controllers 2.3 - 107Industrial Automation2013
- program the PLC in one of the IEC 61131 languages
- define the variables (name and type)
- bind the variables to the input/output (binary, analog)
- run simulations
- download programs and firmware to the PLC
- upload from the PLC (seldom provided)
- monitor the PLC
- document and print
61131 Programming environment
configuration, editor,compiler, library
8/12/2019 PLC for electrical engineers
108/113
Programmable Logic Controllers 2.3 - 108Industrial Automation2013
laptop
download
symbols
code
variablemonitoring
and
forcingfor debugging
firmware
network
PLC
Program maintenance
The source of the PLC program is generally on the laptop of the technician.
8/12/2019 PLC for electrical engineers
109/113
Programmable Logic Controllers 2.3 - 109Industrial Automation2013
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.
Is IEC 61131 FB an object-oriented language ?
Not really: it does not support inheritance
8/12/2019 PLC for electrical engineers
110/113
Programmable Logic Controllers 2.3 - 110Industrial Automation2013
Not really: it does not support inheritance.
Blocks are not recursive.
But it supports interface definition (typed signals), instantiation, encapsulation,
some form of polymorphism.
Some programming environments offer control modules for better object-
orientation
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)
8/12/2019 PLC for electrical engineers
111/113
Programmable Logic Controllers 2.3 - 111Industrial Automation2013
(but this is good so).
- if structured text increases in importance, better constructs are required (object-oriented)
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 ?
8/12/2019 PLC for electrical engineers
112/113
Programmable Logic Controllers 2.3 - 112Industrial Automation2013
g g p g g
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)
Exercise: write the SFC for this task
open V1 until tanks L1 indicates upper level
8/12/2019 PLC for electrical engineers
113/113
Programmable Logic Controllers 2.3 - 113Industrial Automation2013
L1
T
V1 V2
ope u t ta s d cates uppe e e
open V2 during 25 seconds
open V3 until the tanks L1 indicate it reached the lower level
while stirring.
heat mixture during 50 minutes while stirring
empty the reactor while the drying bed is moving
MSV3
MD
temperature
(sensor)
H1
upper
lower
V4
heater
(actor)