Você está na página 1de 9

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.

FORMAT FOR STATEMENT LIST (STL)


OPERATION
AND Operation

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

EXAMPLES OF BASIC BINARY LOGIC OPERATIONS


OPERA
TION
3 Input
ANDing

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

OVERVIEW OF STEP 5 OPERATIONS


BOOLEAN / BINARY LOGIC OPERATIONS
STATEMENT
LIST
A

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.

LOADING AND TRANSFER OPERATIONS


L
L
L
L
L
L
L
L
L
L
L
L

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

LOAD (INTO ACCU 1) :


an input byte (from PII)
an input word (from PII)
an output byte (from PIO)
an output word (from PIO)
a flag byte
a flag word
data (right-hand byte)
data (left-hand byte)
data word
a time
a count
a peripheral byte of the digital inputs (bypassing the PIO)
a peripheral byte of the analog inputs
a peripheral byte of the digital inputs (bypassing the PIO)
a peripheral word of the analog inputs
times (BCD)
counts (BCD)
a constant, 1 byte
a constant, two ASCII symbols
a time (constant)
a count (constant)
a constant as bit pattern
a constant in hexadecimal code
a constant as fixed-point number
a constant, 2 bytes
TRANSFER (THE CONTENTS OF ACCU 1 ) TO :
an input byte (into the PII)
an input word (into the PII)
an output byte (into the PIO)
an output word (into the PIO)
a flag byte
a flag word
data (right-hand byte)
data (left-hand byte)
data word
a peripheral byte of the digital outputs (bypassing the PIO)
a peripheral byte of the analog outputs
a peripheral word of the outputs (bypassing the PIO)

128 to 254

a peripheral word of the analog outputs

TIMER AND COUNTER OPERATIONS


STATEMENT LIST
S T 0 to 127
SE T 0 to 127
SI T 0 to 127
SS T 0 to 127
SF T 0 to 127
R T 0 to 127
S C 0 to 127
R C 0 to 127
CU C 0 to 127
CD C 0 to 127

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

COMPARE FIXED-POINT NUMBERS in accu 1 and accu 2


(the first operand specified is compared with the operand following,
according to the comparison function)
for equal to : ACCU 2 = ACCU 1
for not equal to : ACCU 2 ACCU 1
for greater than : ACCU 2 > ACCU 1
for greater than or equal to : ACCU 2 ACCU 1
for less than : ACCU 2 < ACCU 1
for less than or equal to : ACCU 2 <= ACCU 1

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.

ORGANISATION BLOCKS (OB)


PROGRAM BLOCKS (PB)
FUNCTION BLOCKS (FB)
SEQUENCE BLOCKS (SB)

PROGRAM BLOCKS contain the user program structured according to technological or


functional criteria (e.g. program blocks for transport, monitoring). Further blcks, such as
program blocks or function blocks, can be referenced from a program block.
ORGANISATION BLOCKS contain block calls determining the sequence in which the
program blocks are to be processed. It is therefore possible to call program blocks
conditionally (depending on certain conditions). In additin, special organisatin blocks can be
programmed to enable the user to react to interruptions in cyclic program processing. Such an
interrupt can be triggered by monitoring function if one or several monitored events occur.
FUNCTION BLOCKS
Function blocks are blocks with programs for recurrent complex functions (e.g.
positioning, text output, motor drive control, valve drive control etc.)
The program in a function block is usually not written with absolute operands, but
symbolic (formal) operands. This permits a function block to be used several times
over with different operands.
A standard function block is designed in such a way that the programming unit
prompts the user when linking the block into his program.
The function block is called with a call statement.
It is then displayed with its block name and its parameter names.
Parameter names are mnemonics which represent the type and function of inputs and
outputs as well as the data required by the function block.
An actual parameter must be entered alongside each parameter name when the
corresponding block is called up.
The actual parameter is chosen by the user according to the requirements of the
control task at that particular point.

EXAMPLE OF FUNCTION BLOCK


STL
JU FB 37
NAME
: ADD
Z1
:
IW 3
SZ 2
:
I 1.2
Z2
:
IW 5
UE
:
I 2.5
UA
:
F 2.7
Z3=0
:
Q 2.3
SZ 3
:
Q 1.7
Z3
:
QW 12
: BE
CSF / FBD
FB 37
IW 3
I 1.2
IW 5
I 2.5

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.

TIME-CONTROLLED PROGRAM PROCESSING


Certain organisation blocks are processed at predetermined time intervals (e.g. every 100, 200
or 500 ms or 1, 2, or 5 seconds). For this purpose, cyclic program processing is interrupted at
a block boundary and resumed again at this point once the relevant organisation block has
been processed.
PROCESS IMAGE
After each cycle an image of the state of the process inputs and outputs is updated.
PROGRAM STRUCTURE
OB 1
JU PB 1

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

Você também pode gostar