Professional Documents
Culture Documents
IEC 61131-3
MEI-56206 Production Automation Exercises
16.1.2017
72
Agenda
PLC HW & Operational Principle (Recap)
PLC Programming
Standard IEC 61131-3
Structural components
(Use of) Instance of FB
Details of IEC 61131-3 Programming
languages
16.1.2017
73
Recap of PLC HW
16.1.2017
74
Power source
Input units
CPU
Output units
Special units
Prg Port
Counter inputs
Encoder inputs
Pulse outputs
Potentiometer,
temp. sens.
Barcode reader
Computer,
HMI
16.1.2017
75
16.1.2017
76
16.1.2017
77
Exe. Logic
W Outputs
R Inputs
Exe. Logic
W Outputs
Cycle Time = X ms
16.1.2017
78
PLC
R Inputs
R Inputs
Cycle Time = X ms
SoftPLC PC -Based
tOS
Logic time = Y ms
R Inputs
R Inputs
Exe. Logic
Disk UI tasks
Cycle Time = X ms
Config:
Cycle time
tOS max. % Y of X
16.1.2017
79
Systems Response
Target:
small deviation
(Determinism)
prev. slide t 0 s
AND
16.1.2017
80
PLC Programing
16.1.2017
81
PLC Programming
Program can be usually made offline without PLC HW
PLC HW is usually required for testing. PLC is connected to
development environment PC via serial/USB/ethernet port
Establishing connection between PLC and PC; downloading
application program to controller; and performing the testing
procedure.
Dev. Env. Usually offers means for monitoring states, memory,
and execution of PLC program and affecting on it.
Sometimes possible to test program directly on development
environment. However this requires modelling and simulation
of HW (SW in the loop).
Programming device
MEI-56206 Production Automation Exercises
16.1.2017
82
16.1.2017
83
16.1.2017
84
16.1.2017
85
tyyppi
koko (bitti)
alue
BOOL
boolean
01
SINT
short integer
-128 127
INT
integer
16
-32768 32767
DINT
double integer
32
-2.1e-9 2.1e9
LINT
long integer
64
-9.2e19 9.2e19
USINT
0 255
UINT
unsigned integer
16
0 65536
UDINT
32
0 4.3e9
ULINT
64
0 1.8e20
REAL
real number
32
LREAL
long real
64
TIME
kesto
DATE
pivys
TIME_OF_DAY
aika
DATE_AND_TIME
pivys ja aika
STRING
string
vaihtelee
vaihtelee
BYTE
8 bitti
WORD
16 bitti
16
DWORD
32 bitti
32
LWORD
64 bitti
64
16.1.2017
86
16.1.2017
87
Structure of PLC
Configuration / Program
16.1.2017
88
Visibility
Instances
PRG
FB
PRG
Global
FB
Local
0..N
Global
16.1.2017
89
OUTPUT
IN_OUT
By reference
VAR
Local variables
MEI-56206 Production Automation Exercises
16.1.2017
90
FB Implementation vs.
instance (ilmentym)
Cylinder (1 actuator, 1 control signal, 2 sensors)
FB implementation ~ class description (luokka)
Abstraction of cylinder
Top limit
Low limit
FUNCTION_BLOCK FB_Cylinder
FB instance (ilmentym)
Activity for single device
Created as variables in memory
Referring the
implementation by the
type of the variable
fbCylinder_A : FB_Cylinder;
fbCylinder_B : FB_Cylinder;
Benefits
Ylraja
Ylraja
Ylraja
Alaraja
Alaraja
Alaraja
Ease of maintenance
Clear interfaces
Calling an
instance
fbCylinder_A
Ctrl_Close
Limit_up
Limit_down
FB_Cylin
der
16.1.2017
bDone
OutToValve
91
Calling a FB
Calling INSTANCE of FB
= Executing its code
On each PLC cycle or when needed
Call can be partial. All ports (IF inputs/outputs) are
not defined or connections are missing
16.1.2017
92
Calling a FB
Changing / reading values of a single instance of
FB
Its code is NOT executed or evaluated
no state change occurs
E.g.:
Writing input:
fbDrive.wTarget:= GPOS_LOADING;
Reading output (e.g. in transition condition):
fbDrive.bMoveDone
Reading output and assigning it into another variable:
bMuttuja1 := fbDrive.bMoveDone;
State of input can be read with same method
MEI-56206 Production Automation Exercises
16.1.2017
93
Function
Global
Does not preserve its state between two
adjacent calls (e.g. values of variables) No
counters or timers!!
Can NOT have VAR_OUTPUT type of
variables, only one (1) return value
For math operations E.g. add, storeToQueue
16.1.2017
94
Programming Languages
16.1.2017
95
IEC 1131-3 :
Programming
languages
Textual
ANDN
ST
Step 1
Sequential Function
Chart (SFC)
[Sekvenssikaavio]
Structured Text (ST)
[Rakenteellinen teksti]
FILL
Transition 1
Step 2
Empty
Transition 2
Step 3
Graphical
C:= A AND NOT B;
Graphical
A
B
A B
-| |--|/|----------------( )
16.1.2017
96
Programming languages
(IEC 61131-3)
1.
2.
3.
4.
16.1.2017
97
16.1.2017
98
[Tikapuukaavio, Relekaavio]
LD looks like electrical circuit diagram (relay logic), used
commonly in industry.
Used long before standard was developed
Used a lot (still today)
User, who are familiar with electrical drawings
easy to read, smaller need for training
Input Instruction
Output Instruction
16.1.2017
99
16.1.2017
100
TempControl
Feed valve
Heat
Acidic reagent
Heat
Alkali reagent
Temp sensor
TempSensor
PV
pH sensor
Heater band
Cool
SetPoint
Cool
pHSensor
pHControl
AddAcid
MainSequence
Harvest valve
SetPoint AddAcid
Start
Stop
Duration
Start
Temp
Stop
pH
Duration
Agitation
PV
AddAlkali
AddAlkali
AgitateControl
MotorSpeed
FillState
SetPoint
MotorSpeed
PV
AgitateSpeed
ValveControl
Fill
Fill
State
ValvePositions
Harvest
Harvest
16.1.2017
101
16.1.2017
102
Example of ST
PROGRAM PRG_Jaa
VAR_INPUT
a : INT;
b : INT;
END_VAR
VAR_OUTPUT
c : INT;
END_VAR
IF b <> 0 THEN
c := a / b;
ELSE
c := 0;
END_IF;
END_PROGRAM
MEI-56206 Production Automation Exercises
16.1.2017
103
Step 1
FILL
Transition 1
Step 2
Empty
Transition 2
Step 3
16.1.2017
104
16.1.2017
106
1.L
2.L
4.L
3.O
5.O
7.L
6.O
8.O
2.L
L =
=
O=
=
9.L
16.1.2017
107
Proprietary solution
SFC Example
Be careful with S, N, P,
for Booleans
Program parts cannot modify
Use ONLY for flow control
Special case of
16.1.2017
108
16.1.2017
109
See:
http://engineeronadisk.com/book_plcs/plc_
sequa2.html#16763
16.1.2017
110
http://www.unitronics.com/KnowledgeBase/U90Ladder/Drum/dru
m_sequencer.htm
16.1.2017
111
16.1.2017
112