Programming in Siemens Plcs
Programming in Siemens Plcs
The STEP 5 programming language is used for writing user programs for programmablle
controllers of the SIMATIC S5 system. STEP 7 language is used for SIMATIC S7 system
PLCs.
THIS PROGRAM CAN BE REPRESENTED IN 3 WAYS
LADDER DIAGRAM (LAD)
STATEMENT LIST (STL)
CONTROL SYSTEM FLOW CHART (CSF) /
FUNCTIONAL BLOCK DIAGRAM (FBD)
The LADDER DIAGRAM (LAD) uses graphic circuit diagram symbols (american
representation) to represent the automation task.
The STATEMENT LIST (STL) describes the automation task by means of mnemonic
function designations.
The CONTROL SYSTEM FLOWCHART (CSF) is a graphic representation of the
automation task, using symbols.
The type of representation to be used for programming depends on the relevant programming
unit and the type of representation selected for that particular programming unit.
The Programming Unit converts the control system flowchart or ladder diagram into a
statement list. In the memory of the programmable controller the program is stored in MC5
machine code.
ADDRESSING IN SIEMENS PLCs
Each I/O address will have a "Byte No.", "." & "Bit No."
Byte No.
: 0 to 7 / 15 / 63 / 127 depending on the PLC Model & capacity
Bit No.
: 0 to 7
Inputs are denoted by
: "I"
Outputs are denoted by
: "Q"
Internal Flags are denoted by : "F"
Examples of addresses
: I 0.0, I 5.6, I 63.7, I 127.7
Q 0.4, Q 10.3, Q 100.1
F 0.0 to F 255.7
HOW ADDRESSING IS DONE PHYSICALLY IN I/O MODULES
FIXED LOCATION ADDRESS : In some PLC models, each I/O module
location / plug-in slot will have a fixed address as specified in the Manufacturer's
manual.
JUMPERS IN MODULE : In these PLCs, the jumpers provided in each I/O
module will decide the address of that module. The jumper combination table will
be given in the manufacturer's manual.
DIP SWITCHES ON INTERFACE MODULE : In these PLCs DIP switches will
be provided for each location. By setting these switches as given the
manufacturer's table, the address of each I/O module can be set.
OR Operation
ASSIGNMENT
OPERAND
I
Q
F
I
Q
F
Q
F
ADDRESS
0.0 to 127.7
0.0 to 127.7
0.0 TO 127.7
CSF / FBD
I 1.1
I 2.2
F 3.3
3 Input I 1.1
ORing
I 2.2
F 3.3
&
LAD
I 1.1 I 2.2
Q 4.4
I 1.1
I 3.3
STL
Q 4.4
( )
Q 4.4
( )
Q 4.4
I 2.2
A
A
A
=
I 1.1
I 2.2
F 3.3
Q 4.4
O
O
O
=
I 1.1
I 2.2
I 3.3
Q 4.4
I 3.3
NEGATI
ON
I 1.1
I 1.1
&
Q 4.4
Q 4.4
( )
AN I 1.1
= Q 4.4
F 5.5
SET
I 1.1
I 1.1
F 5.5
(S)
A I 1.1
S F 5.5
F 5.5
I 1.1
RESET
I 1.1
F 5.5
(R)
A I 1.1
R F 5.5
LADDER DIAGRAM
AN
O
ON
S
(S)
R
=
O
A(
O(
)
NOP 0
NOP 0
NOP 1
NOP 1
BE
BE
BEC
BEC
DESCRIPTION
Normally open contact in series,
scanning for "1"
Normally closed contact in series,
scanning for "0"
Normally open contact in parallel,
scanning for "1"
Normally closed contact in
parallel, scanning for "0"
Latch if RLO = "1",
No action if RLO = "0"
Unlatch if RLO = "1",
No action if RLO = "0"
Assignment (Latch if RLO = "1",
unlatch if RLO= "0")
ORing of AND functions
(Return path for connecting two
circuits in parallel)
ANDing of bracketed expressions
(Start of a branch)
ORing of bracketed expressions
(Return path and start of a branch)
Right paranthesis
(Termination of a bracketed
expression)
No
operation.
Overwriting
erroneously
programmed
statements
No operation. Keeping memory
locations free.
Unconditional block end; Return
to beginning of program
Conditional block end; if RLO =
"1", return to beginning of
program.
If RLO = "0", no operation is
executed.
STATEMENT LIST
IB 0 to 127
IW 0 to 126
QB 0 to 127
QW 0 to 126
FB 0 to 256
FW 0 to 254
DR 0 to 255
DL 0 to 255
DW 0 to 255
T
0 to 127
C 0 to 127
PB 0 to 127
L PW 0 to 127
LC T
LC C
L KB
L KS
L KT
L KC
L KM
L KH
L KF
L KY
T
T
T
T
T
T
T
T
T
T
0 to 127
0 to 127
0 to 255
0 to 127
0.0 to 999.3
0 to 999
0 to 127
0 to 127
0 to 127
0 to 127
IB 0 to 127
IW 0 to 126
QB 0 to 127
QW 0 to 126
FB 0 to 256
FW 0 to 254
DR 0 to 255
DL 0 to 255
DW 0 to 255
PB 0 to 127
128 to 255
T PW 0 to 127
128 to 254
FUNCTION
Start Timer as PULSE
Start Timer as EXTENDED PULSE
Start Timer as "ON" DELAY
Start Timer as STORED "ON" DELAY
Start Timer as "OFF" DELAY
Reset Timer
Set Counter
Reset Counter
Increment counter (Count Up)
Decrement counter (Count Down)
COMPARISON OPERATIONS
STATEMENT
LIST
!= F
><F
> F
>=F
< F
<=F
ARITHMETIC OPERATIONS
STL
+ F
-
DESCRIPTION
Addition of fixed-point numbers
ACCU 1 + ACCU 2
Subtraction of fixed-point numbers
ACCU 2 ACCU 1
BLOCK CALLS
STATEMENT LIST
JU PB
JU FB
JU SB
JC PB
JC FB
JC SB
C DB 0 to 255
BE
BEC
BEU
Unconditional Jump :
to a Program Block
to a Function Block
to a Sequence Block
Conditional Jump (if RLO = "1")
to a Program Block
to a Function Block
to a Sequence Block
Calling a Data Block
Block End
Block End, conditional (if RLO = "1")
Block End, uncondition (Not in OBs)
USER PROGRAMS
STRUCTURED PROGRAMMING
The user program is clear and simple to program if it is divided into technology-oriented
program sections.
For programming the user program, various types of SOFTWARE BLOCKs are available.
1.
2.
3.
4.
Z1
SZ2
Z2
UE
UA
Z3=0
SZ 3
Z3
F 2.7
Q 2.3
Q 1.7
QW 12
: BE
SEQUENCE BLOCKS contain the step-enabling conditin, monitoring times and output
conditions for the current step in a sequence cascade. Sequence blocks are employed, for
example to organize the sequence cascade in conjuction with a standard function block.
DATA BLOCKS contain all fixed or variable data of the user program.
PROGRAM PROCESSING
Cyclic, interrupt driven and time controlled processing of the user program is
possible.
CYCLIC PROGRAM PROCESSING
The program blocks are processed in the order in which they are specified in the organisation
block.
INTERRUPT-DRIVEN PROGRAM PROCESSING
When certain input signal changes occur, cyclic processing is interrupted at the next block
boundary and an organisation block assigned to this event is started. The user can formulate
his response program to this interrupt in the organisation block. Cyclic programming is then
resumed at the point at which it was interrupted.
PB 100
FB108
JU FB 108
DB 10
CONTRO
LLER
START
FB 80
JU FB 80
ANALOG
INPUT
FB 97
JU FB 89
JU FB 97
SMOOT
HING
Parameter
assignment
of function
blocks
FB 82
CONTRO
LLER
JU FB 82
FB 98
JU FB 98
ARITHM
ETIC
BLOCK
FB 89
Generat
ion of
setting
Pulse
SEQU
ENCE
AND
TEST
DATA