Introduction Industrial IT
Lecture 2 – part 1
Introduction to systematic PLC
programming
IEC 61131 standard
Assignment #1
Plant Model
Teaching Material By: I/O Signals
Process
Geir Hovland Host PC
or
I/O
Physical
Controller
MAS411 Industrial IT (Spring 2017) 1
Contents Industrial IT
International Control programming standard
IEC 61131-3 history and benefits
IEC 61131-3 software model hierarchy
IEC 61131-3 fundamentals and elements
IEC 61131-3 programming languages
Programmable Logic Controllers
Functional description using Flowcharts and State
machine
Functional description to IEC 61131-3 languages
IEC 61131-3 languages conversion methodology
Introduction of Assignment number 1
MAS411 Industrial IT (Spring 2017) 2
IEC standard Industrial IT
IEC 61131-3 Programming languages /
Industrial Control Programming
...with support for people
with different backgrounds
MAS411 Industrial IT (Spring 2017) 3
IEC standard Industrial IT
Users? Which Users?
Discrete Mnf
Process cntrl
System Integrator
YOU ??
Education
Programming
Maintenance Installation
MAS411 Industrial IT (Spring 2017) 4
IEC standard Industrial IT
Users? Which Users?
• Offshore drilling / pipe-handling equipment
• Renewable Energy (Wind-Turbines, Hydro Power, ...)
• Automobile production lines
• Water treatment plant
• Food processing and packaging machinery
• Cable manufacturing
• Semi-conductor clean room automation
• Theme-park roller coasters
• Nuclear waste treatment plant
This wide range encompass different skills
MAS411 Industrial IT (Spring 2017) 5
IEC standard Industrial IT
What is the Benefit of such a Standard?
• Reduced waste of human resources (in training,
debugging, maintenance and consultancy)
• Creating a focus to problem solving via
software re-usability (reduced application
investment and supplier dependency)
• Reduced misunderstandings and errors
• Programming techniques usable in more
• environments (general industrial control)
• Combining harmonously different components
from different locations, companies or
countries, or projects Software
•
Library
Increased connectivity (investment protection)
Function Block
"Heating"
Function
"LIMIT"
Function Block
"Feeding"
Function Function Block
"TEST" "Turning"
MAS411 Industrial IT (Spring 2017) 6
IEC standard Industrial IT
Key quality features of IEC 61131-3
• Structured software - through use of Configuration,
Resource and Program Organization Units (POUs)
• Strong Data Typing - through languages that restrict
operations to only apply to appropriate types of data
• Execution control - through use of tasks
• Complex sequential behaviour - through Sequential
Function Charts
• Software encapsulation - through use of POUs,
structures and complex data types.
7
MAS411 Industrial IT (Spring 2017) 7
IEC standard Industrial IT
International Language Standardization
NEMA Programmable Controllers Committee formed (USA)
GRAFCET (France)
DIN 40719, Function Charts (Germany)
NEMA ICS-3-304, Programmable Controllers (USA)
IEC SC65A/WG6 formed
DIN 19 239, Programmable Controller (Germany)
IEC 65A(Sec)38, Programmable Controllers
MIL-STD-1815 Ada (USA)
IEC SC65A(Sec)49, PC Languages
IEC SC65A(Sec)67
IEC 848, Function Charts
IEC 64A(Sec)90
IEC 1131-3
Type 3 report
recommendation
IEC 61131-3
name change
70 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
IEC: International Electrotechnical Commission.
The current (third) edition was published in February 2013, see http://en.wikipedia.org/wiki/IEC_61131-3
MAS411 Industrial IT (Spring 2017) 8
IEC standard Industrial IT
Advantages of IEC 61131-3
• Internationally accepted standard
• Step by step all suppliers will support it
• Uniform structures, languages, and the way of handling
• It saves you time
• Unique software model and data/ type concept
• You only have to learn it once for different controller types
• Reduced misunderstandings and errors
• Standard functions and function blocks
• Reusability of tested software
MAS411 Industrial IT (Spring 2017) 9
IEC standard Industrial IT
Advantages of IEC 61131-3
• Supports safety and quality programming
• Easy and comfortable structuring
• Data typing prohibits programming errors
• Provides the best language for each problem
• Consistent specifications of 5 languages
• Two textual and two graphical languages
• One structuring language, providing an overview
• Availability of high level language
• Possibility to mix different languages
MAS411 Industrial IT (Spring 2017) 10
Software hierarchy Industrial IT
IEC 61131-3 Software Model
Configuration A
Resource L Resource L
Task1 Task2 Task3 Task4
Program P1 Program P2 Program P3 Program P4
FB1 FB2 FB3 FB4
global and direct addressed variables
access paths
Task association
Access path association
MAS411 Industrial IT (Spring 2017) 11
Software hierarchy Industrial IT
FC FB
OB1
DB
FB FC
Operating System
OB - Organization Block
FC
FC - Function
FB - Function Block
DB – Data Block
FB
Memory
Other
OB’s like OB35 is timed interrupt
OB35 & OB100 Default period of 100 ms to be integrated
(IC’s block) with synchronized system’s
MAS411 Industrial IT (Spring 2017) 12
Software hierarchy Industrial IT
FC, FB and DB
• FC can be used for functions without memory
• FB can be used for «objects» consisting of both functions and
memory (DB). Data in the DB will be remembered after the
FB has finished.
• You can use the internal memory of the PLC (M0.0, M0.1,
M0.2, MD10, MW20, etc), but this space is limited.
• It is strongly recommended to use Data Blocks (DB). In this
way, one single PLC can run many programs created by
different people without memory conflicts.
MAS411 Industrial IT (Spring 2017) 13
Software hierarchy Industrial IT: Example of FC
MAS411 Industrial IT (Spring 2017) 14
Elements Industrial IT
IEC 61131-3: The Common Elements
• Character set (English.........)
• Data types (BOOL, WORD, INTEGER.................)
• Variables (VAR, VAR_input, VAR_output..........)
• POUs, Program Organisation Units (Function, Function Block...)
• SFC Elements (Steps, Transitions.................................)
• Configuration elements: (Tasks)
• Basis for software re-use
MAS411 Industrial IT (Spring 2017) 15
Elements Industrial IT
IEC 61131-3 Standard Data types
• Bit string types (BOOL, BYTE, WORD, DWORD, LWORD)
• Integer types (SINT, INT, DINT, LINT)
• Unsigned integer types (USINT, UINT, UDINT, ULINT)
• Real types (REAL, LREAL)
• Time types (TIME, DATE, TIME_OF_DAY, DATE_AND_TIME)
• Character types (STRING)
Vendor and user defined data types are possible
– Direct derived, sub range, enumeration
– Array, structure
MAS411 Industrial IT (Spring 2017) 16
Elements Industrial IT
Name Type Bits Range
BOOL boolean 1 0 to 1
SINT short integer 8 -128 to 127
IEC 61131-3 Elementary Data Types
INT integer 16 -32768 to 32767
DINT double integer 32 -2.1e-9 to 2.1e9
LINT long integer 64 -9.2e19 to 9.2e19
USINT unsigned short integer 8 0 to 255
UINT unsigned integer 16 0 to 65536
UDINT unsigned double integer 32 0 to 4.3e9
ULINT unsigned long integer 64 0 to 1.8e20
REAL real numbers 32
LREAL long reals 64
TIME duration not fixed not fixed
DATE date not fixed not fixed
TIME_OF_DAY, TOD time not fixed not fixed
DATE_AND_TIME, DT date and time not fixed not fixed
STRING string variable variable
BYTE 8 bits 8 NA
WORD 16 bits 16 NA
DWORD 32 bits 32 NA
LWORD 64 bits 64 NA
MAS411 Industrial IT (Spring 2017) 17
Elements Industrial IT
Example Boolean Operations:
A AND A OR
C C
B B
A XOR A B AND OR XOR
C 0 0 0 0 0
0 1 0 1 1
B
1 0 0 1 1
1 1 1 1 0
MAS411 Industrial IT (Spring 2017) 18
Elements Industrial IT
Bits and Bytes:
A BYTE X consists of 8 bits.
LSB MSB
0 1 2 3 4 5 6 7
LSB = Least Significant Bit
MSB = Most Significant Bit
Bit addresses = X.0, X.1, X.2, …, X.7
BYTE value = X.0 + 2*X.1 + 4*X.2 + 8*X.3 + 16*X.4 + 32*X.5 + 64*X.6 + 128*X.7
Range: 0 to 255
MAS411 Industrial IT (Spring 2017) 19
Elements Industrial IT
Example BIT and BYTE Operations:
X := 100; 1 2 4 8 16 32 64 128
0 0 1 0 0 1 1 0
X = 64 + 32 + 4 = 100
X.5
X.5 : = X.5 XOR 1;
1 2 4 8 16 32 64 128
0 0 1 0 0 0 1 0
X = 64 + 4 = 68;
X.5 : = X.5 XOR 1;
1 2 4 8 16 32 64 128
0 0 1 0 0 1 1 0
X = 64 + 32 + 4 = 100;
XOR with 1 often used to toggle bits from 0 to 1 to 0.
MAS411 Industrial IT (Spring 2017) 20
Elements Industrial IT
IEC 61131-3 Programming Languages
IL (Instruction List) - This is effectively mnemonic programming
ST (Structured Text) - A BASIC like programming language
LD (Ladder Diagram) - Relay logic diagram based programming
FBD (Function Block Diagram) - A graphical dataflow programming
method
SFC (Sequential Function Charts) - A graphical method for structuring
programs
PS: Siemens has in addition the language SCL (Structured Control
Language), which we will use in MAS411.
MAS411 Industrial IT (Spring 2017) 21
Elements Industrial IT
MAS411 Industrial IT (Spring 2017) 22
LD Industrial IT
Ladder Diagram (LD)
• Standardized, rationalized set of relay ladder programming
symbols
• Resembling electrical drawing standard
A B C
-| |--|/|----------------( )
MAS411 Industrial IT (Spring 2017) 23
LD Industrial IT
Ladder Diagram (LD)
• Ladder Diagram (LD) is a graphic representation of Boolean equations, combining
contacts (input arguments) with coils (output results).
• The LD language enables the description of tests and modifications of Boolean
data by placing graphic symbols into the program chart.
• LD graphic symbols are organized within the chart exactly as an electric contact
diagram.
• LD diagrams are connected on the left side and on the right side to vertical power
rails.
A and not B equals C
-| |--|/|----------------( )
MAS411 Industrial IT (Spring 2017) 24
IL Industrial IT
Instruction List (IL)
• Single Accumulator based execution model
• Based upon the German ‘Anweisungsliste’, AWL
• Only one operation such as storing a value in the
accumulator register, is allowed per line
LD A
ANDN B
ST C
MAS411 Industrial IT (Spring 2017) 25
ST Industrial IT
Structured Text (ST)
• High level language, block structured
• Syntax resembles PASCAL
• Complex statements and nested instructions possible
• Support for
– Iteration loops (REPEAT-UNTIL; WHILE-DO)
– Conditional execution (IF-THEN-ELSE; CASE)
– Functions (SQRT(), SIN())
C:= A AND NOT B
MAS411 Industrial IT (Spring 2017) 26
FBD Industrial IT
Function Block Diagram (FBD)
Graphical language, widely used in Europe
Allows program elements which appear as blocks to
be "wired" together in a form analogous to a circuit
diagram
Used in many applications that involve the flow of
information or data between control components
AND
A C
B
MAS411 Industrial IT (Spring 2017) 27
FBD Industrial IT
IEC 61131-3 Standard Function Blocks
• Bitable (SR, RS, SEMA)
• Edge detection (R_TRIG, F_TRIG)
• Counters (CTU, CTD, CTUD)
• Timers (TP, TON, TOF, RTC)
Vendor and user defined function blocks are possible
MAS411 Industrial IT (Spring 2017) 28
Functions Industrial IT
IEC 61131-3 Standard Functions
• Bit string functions (AND, OR, XOR, NOT, SHL, SHR, ROL, ROR)
• Numerical functions (ADD, SUB, MUL, DIV, MOD, EXPT, ABS,
SQRT, LN, LOG, EXP, SIN, COS, TAN, ASIN,
ACOS, ATAN)
• Type conversions (e.g. USINT_TO_DINT, BOOL_TO_BYTE)
• Selection functions (SEL, MIN, MAX, LIMIT, MUX)
• Comparison functions (GT, GE, EQ, LT, LE, NE)
• String functions (LEN, LEFT, RIGHT, MID, CONCAT,
INSERT, DELETE, REPLACE, FIND)
Vendor and user defined functions are possible
MAS411 Industrial IT (Spring 2017) 29
Step 7 Industrial IT
Statement Lists and Function Block Diagram
Conversion of analog input value
MAS411 Industrial IT (Spring 2017) 30
Step 7 Industrial IT
Monitoring: Tags table
MAS411 Industrial IT (Spring 2017) 31
SFC Industrial IT
Sequential Function Chart (SFC)
• Graphical language which provides a diagrammatic
representation of program sequences --> flowchart
• Based on the French Grafcet (IEC 848)
• Main structure and suitable for rapid diagnostics Step 1 N FILL
• The basic elements are steps with action blocks and
transitions
Transition 1
• Steps consist of a piece of program that is carried out
until a condition specified in the transition is met
• Programming of complex tasks by dividing in
Step 2 S Empty
smaller parts
• Each element can be programmed in any of the IEC- Transition 2
languages such as LD or ST or IL or FB mix or
match any of the languages
Step 3
MAS411 Industrial IT (Spring 2017) 32
SFC Industrial IT
Programming language for describing Step 1 Action 1
Sequential Controls Action 2
Structured program draft
Description of the process with steps Transition
and transitions
Clear, easy to understand by the process, production
and operations staff
Application examples Step 2 Action 1
Presses and Packaging technology
Production lines
Process technology (start up – shutdown)
OEM equipment machinery technology Transition
Rotating Machinery e.g. compressors, pumps
MAS411 Industrial IT (Spring 2017) 33
PLC What is a PLC ?
outputs
inputs actuators
sensors PLC motors, valves
• roots in the wiring logic
– originally hardware based: Relays
• increasingly software based
– more flexible, easier to modify
– more efficient, lower costs
• needs a programming device
– industrial PC = PLC + programming device
– On standard PLC’s programming device removed after
programming
• special requirements: rough environment
– no moving parts such as harddisks
– Designed to last for many years in industrial environments
MAS411 Industrial IT (Spring 2017) 34
PLC Industrial IT
A PLC program works in a cyclic manner
• Cyclic calculation of the
output pattern according to the
input pattern inputs
– it starts again when it’s finished
– no inputs during the cycle inputs
• cycle time depends on the program cycle time
application
• smart living technology: < min;
• drives: several ms
• particular programming
languages outputs
MAS411 Industrial IT (Spring 2017) 35
Functional
description Industrial IT
Why Flowchart or State-Machine ?
• PLC programs can become difficult for others
to read without documentation
• Flowchart or state-machine is a standard
approach to document a logic program flow
• Documentation required by ISO 9001
– PXXXX-DS011 Design Specification
– PXXXX-DS021 Functional Description
– PXXXX-DS024 Program Description
– PXXXX-DS025 Definition of Variables
MAS411 Industrial IT (Spring 2017) 36
Flowchart Industrial IT
MAS411 Industrial IT (Spring 2017) 37
Conversion Industrial IT
Ladder Logic for the Transitions
MAS411 Industrial IT (Spring 2017) 38
Conversion Industrial IT
Ladder Logic Functions
MAS411 Industrial IT (Spring 2017) 39
Coversion Industrial IT
Ladder Logic Functions and Outputs
MAS411 Industrial IT (Spring 2017) 40
State machine Industrial IT
State based design approach
• A State based system can be described with system
states, and the transitions between those states.
• If the system is in state 1 and A happens the system will
then go into state 2, otherwise it will remain in State 1.
• if the system is in state 2, and B happens the system
will return to state 1.
MAS411 Industrial IT (Spring 2017) 41
State machine Industrial IT
Case Study : traffic lights
Inputs: S1, S2 (walk button)
Outputs: L1, L2, …, L6 (2 sets of red, yellow, green lights)
Green NS – ST1
Yellow NS – ST2
Green EW – ST3
Yellow EW - ST4
4 seconds delay from
yellow to green
MAS411 Industrial IT (Spring 2017) 42
State machine Industrial IT
Inputs: S1, S2 (walk button)
Outputs: L1, L2, …, L6 (2 sets of red, yellow, green lights)
Green NS – ST1
Yellow NS – ST2
Green EW – ST3
Yellow EW - ST4
4 seconds delay from
yellow to green
MAS411 Industrial IT (Spring 2017) 43
State machine Industrial IT
1. Obtain the states System State:
2. Draw the state transition diagram L1,L2, .., L6
3. Derive state equations and transient State description:
equations ST1,ST2,ST3,ST4
4. Convert to ladder logic and First Scan: FS
Delay 4 s S2 Pressed
T2 ST3 T3
ST2 ST4
T1 ST1 T4
S1 pressed Delay 4 s
Transients: T1,T2,T3,T4,T5 T5
e.g. T1: transient from ST1 to ST2 FS
MAS411 Industrial IT (Spring 2017) 44
State machine Industrial IT
Delay 4 s S2 Pressed
Inputs: S1, S2 (walk button) T2 ST3 T3
Outputs: L1, L2, …, L6
ST2 ST4
3. Derive state equations and ST1
transient equations T1 T4
S1 pressed T5 Delay 4 s
FS
MAS411 Industrial IT (Spring 2017) 45
State machine Industrial IT
Convert to Ladder Logic
MAS411 Industrial IT (Spring 2017) 46
State machine Industrial IT
MAS411 Industrial IT (Spring 2017) 47
State machine Industrial IT
MAS411 Industrial IT (Spring 2017) 48
Standards
Conversion Industrial IT
Alternative
Implementation Equivalent
with SR Block
T4 ST1
S Q
T5
T1
R
MAS411 Industrial IT (Spring 2017) 49
Standards
Conversion Industrial IT
Statement List:
Example Equivalent
A(
O ST1
O T4
O T5
)
AN T1
= ST1
MAS411 Industrial IT (Spring 2017) 50
Standards
Conversion Industrial IT
STL to FBD Equivalent
ST1 >=1
T4 >=1
T5 &
ST1
T1
MAS411 Industrial IT (Spring 2017) 51
Standards
Conversion Industrial IT
FBD Arithmetic's: Example 1
Height_volt = 28200*(0.2 + 0.008825745*Height_ref)
MAS411 Industrial IT (Spring 2017) 52
Standards
Conversion Industrial IT
FBD Arithmetic's: Example 2
Height_out = (Sensor_real/28200 - 0.2)/0.008825745
MAS411 Industrial IT (Spring 2017) 53
Bibliography Industrial IT
• John, K.H. and Tiegelkamp, M., "IEC 61131-3: Programming Industrial Automation Systems: Concepts
and Programming Languages, Requirements for Programming Systems, Decision-Making Aids"; Springer
Verlag (2010)
• Tisserant, E. and Bessard, L. and De Sousa, M., “An open source IEC 61131-3 integrated development
environment"; IEEE (2007)
• De Sousa, M. and Carvalho, A., “Emerging Technologies and Factory Automation, 2003. Proceedings.
ETFA'03. IEEE Conference"; IEEE (2003)
• Industrial IT – MAS 400 Lecture notes by Geir Hovland (2010)
• Design of Control Systems – MAS217 lecture note’s by Yousef Iskandarani (2011)
• Berger, H., 2006, Automating with SIMATIC, 3rd edition, Publicis Corporate Publishing
• Olsson, G. og Piani, G., 1992, Computer Systems for Automation and Control, Prentice Hall
• http://www.automation.siemens.com/mcms/simatic-controller-software/en/step7/Pages/Default.aspx
• www.iec.ch
• www.PLCopen.org
MAS411 Industrial IT (Spring 2017) 54