Vous êtes sur la page 1sur 20

Binary Operations

I 0.0

I 0.1

Q 8.0
I 1.0

Q 8.1

I 1.1

&

M1.0

M8.0

T4
I 0.7

S5T#35s

S_ODT

Q8.5

TV

BI

MW0

BCD

QW12

I 0.5

SIMATIC S7
Siemens AG 2005. All rights reserved.

Date:
File:

14.10.2005
PRO1_07E.1

Contents

SITRAIN Training for


Automation and Industrial Solutions

Page

Objectives ........................................................................................................................................
Basic terms such as RLO, Status etc. ..............................................................................................
Binary Logic Operations: AND, OR ...................................................................................................
Binary Logic Operations: Exclusive OR (XOR) .................................................................................
Sensors and Symbols ......................................................................................................................
Exercise 0: Sensors and Symbols ....................................................................................................
Assignment, Setting, Resetting .........................................................................................................
Setting / Resetting a Flip Flop ...........................................................................................................
Midline Output Coil ...........................................................................................................................
Instructions that Affect the RLO ........................................................................................................
Exercise 1: Mode Section of the Distribution Conveyor (FC15) .........................................................
Exercise 2: Programming the Conveyor for AUTO Mode (FC16) ......................................................
RLO - Edge Detection ......................................................................................................................
Signal - Edge Detection ....................................................................................................................
Exercise 3: Edge Detection ..............................................................................................................
If You Want to Know More ................................................................................................................
Unconditional Jump (Regardless of the RLO) ...................................................................................
Conditional Jump (Dependent on RLO) ............................................................................................
Additional Exercise 4: Optimizing the Mode Section FC 15...............................................................

SITRAIN Training for


Automation and Industrial Solutions

Page 1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

ST-PRO1
Binary Operations

Objectives
Upon completion of the chapter the participant will
...

understand the difference between real connected NC contacts


and NO contacts, and programmed symbols

...

be able to explain the terms Result of Logic Operation (RLO),


Status (STAT) and First Check

...

be able to program basic binary logic operations

SIMATIC S7
Siemens AG 2005. All rights reserved.

SITRAIN Training for


Automation and Industrial Solutions

Date:
File:

14.10.2005
PRO1_07E.2

Page 2

SITRAIN Training for


Automation and Industrial Solutions

ST-PRO1
Binary Operations

Basic terms such as RLO, Status etc.


Input Module
1
CPU
Address
Check
2
Binary Logic Operation

Status = Signal state of the address

Result of check

Result of logic operation RLO

3
Examples

RLO Memory

A I 10.0
Input 10.0: Check for signal state 1
and logic operation after AND
Memory Function

ON M 50.0
Bit Memory 50.0: Check for signal state 0
and logic operation after OR

Output Module

SIMATIC S7

Date:
File:

Siemens AG 2005. All rights reserved.

Basically

14.10.2005
PRO1_07E.3

SITRAIN Training for


Automation and Industrial Solutions

The CPU checks the signal state of the selected sensor (status) and gates the
result of the check (result of check) with the stored result of logic operation
(RLO) from the previous logic operation. The result of this logic operation is
stored as the new result of logic operation.
After that, the CPU processes the next instruction in the program, for example,
save the RLO in an address. After the old RLO has been saved, a new logic
operation begins with the first check, in which the result of check is made equal
with the result of logic operation.

Status

The status of an address is identical to the signal state that the address has. It
can be either 0 or 1. A check instruction checks the address status. At the
same time, it contains the operation with which the checked signal state is to be
gated with the RLO in the processor (Example: see slide).

RLO

The result of logic operation (RLO) is the signal state in the CPU that you use
for further binary signal processing. The RLO is formed and changed through
check instructions. With the RLO, binary operands are set or reset.

First Check

The first processed check operation after a conditional operation is called a first
check. What is particular, is that the CPU takes over the result of check of this
instruction directly as a result of logic operation (RLO).
The old RLO is thus lost. The first check always represents the beginning of a
logic operation. The operation (AND, OR, XOR) that comes with the first check
is of no importance.

SITRAIN Training for


Automation and Industrial Solutions

Page 3

ST-PRO1
Binary Operations

Binary Logic Operations: AND, OR


Circuit Diagram

LAD

FBD

STL

S1 (I 0.0)
I 0.0

I 0.1

Q 8.0

&

I 0.1

S2 (I 0.1)

AND

I 0.0

Q 8.1
=

Q 8.1

L1
(Q 8.0)

A
A
=
=

I 0.0
I 0.1
Q 8.0
Q 8.1

O
O
=

I 0.2
I 0.3
Q 8.2

L2
(Q 8.1)

S3
(I 0.2)

I 0.2
S4
(I 0.3)

OR

Q 8.0
=

Q 8.2
I 0.2
I 0.3

I 0.3

>=1

Q 8.2
=

L3 (Q 8.2)

SIMATIC S7

Date:
File:

Siemens AG 2005. All rights reserved.

14.10.2005
PRO1_07E.4

SITRAIN Training for


Automation and Industrial Solutions

Logic Tables
AND

OR

SITRAIN Training for


Automation and Industrial Solutions

I 0.0

I 0.1

I 0.2

I 0.3

Q 8.0

Q 8.2

Page 4

ST-PRO1
Binary Operations

Binary Logic Operations: Exclusive OR (XOR)

LAD

FBD

I 0.4
I 0.4

I 0.5

Q 8.0

&

I 0.5

>=1

I 0.4
I 0.4

I 0.5

STL

Q 8.0
=

&

I 0.5

I 0.4

XOR

I 0.5

SIMATIC S7

Date:
File:

Siemens AG 2005. All rights reserved.

14.10.2005
PRO1_07E.5

Q 8.0
=

A
AN
O
AN
A
=

I 0.4
I 0.5

X
X
=

I 0.4
I 0.5
Q8.0

I 0.4
I 0.5
Q8.0

SITRAIN Training for


Automation and Industrial Solutions

Logic Table
XOR

I 0.4

I 0.5

Q 8.0

Rule

The following rule is valid for the logic operation of two addresses after
XOR: the output has signal state "1", when one and only one of the two
checks is fulfilled.

Careful!

This rule cannot be generalized to "one and only one of n" ! for the logic
operation of several addresses after XOR !!
As of the third XOR instruction, the old RLO is gated with the new result of
check after XOR.

SITRAIN Training for


Automation and Industrial Solutions

Page 5

ST-PRO1
Binary Operations

Sensors and Symbols


Process

The
sensor
is a ...

NO
contact

The sensor
is ...

Interpretation in the PLC Program

Voltage
present
at input?

Signal
state
at
input

Check
for signal state 1

Check
for signal state 0

Symbol /
Instruction

Result of
check

Symbol /
Instruction

LAD:

Yes
1

LAD:

activated
1

yes

NO contact
not
activated

no

0
FBD:

NC
contact

not
activated

no

yes

No
0

A I x.y

SIMATIC S7

Date:
File:

Siemens AG 2005. All rights reserved.

14.10.2005
PRO1_07E.6

FBD:

Yes
1

&
No
0

STL:

No
0

NC contact

&

activated

Result of
check

Yes
1

Yes
1

STL:
AN I x.y

No
0

SITRAIN Training for


Automation and Industrial Solutions

Process

The use of normally open or normally closed contacts for the sensors in a
controlled process depends on the safety regulations for that process.
Normally closed contacts are always used for limit switches and safety switches,
so that dangerous conditions do not arise if a wire break occurs in the sensor
circuit.
Normally closed contacts are also used for switching off machinery for the same
reason.

Symbols

In LAD, a symbol with the name "NO contact" is used for checking for signal
state "1" and a symbol with the name "NC contact" to check for signal state "0".
It makes no difference whether the process signal "1" is supplied by an activated
NO contact or a non-activated NC contact.

Example

If an NC contact in the machine is not activated, the signal in the process image
table will be "1". You use the NO contact symbol in LAD to check for a signal
state of "1".
General:
The "NC contact" symbol delivers the result of check "1" when the checked
address state or status is "0".

SITRAIN Training for


Automation and Industrial Solutions

Page 6

ST-PRO1
Binary Operations

Exercise 0: Sensors and Symbols


Task: In all three examples, the light should be on when S1 is activated and S2 is not activated!
Hardware
S1

S2

S1

EI1.1
1.1

E
1.0
I1.0

E 1.1
I1.1

EI1.0
1.0

Programmable controller

Programmable controller

Q 4.0

I 1.1

I 1.0

Q 4.0

I 1.1

E I1.1
1.1

Programmable controller

Q 4.0

Light

Software

S2

EI1.0
1.0

Q 4.0

Light

I 1.0

S1

S2

Light

Q 4.0

I 1.0

I 1.1

Q 4.0

LAD

&

I 1.0

FBD

Q 4.0

I 1.1

STL

....... I 1.0
....... I 1.1
....... Q 4.0

Date:
File:

Siemens AG 2005. All rights reserved.

I 1.0
Q 4.0

I 1.1

....... I 1.0
....... I 1.1
....... Q 4.0

SIMATIC S7

&

I 1.0

14.10.2005
PRO1_07E.7

&
Q 4.0

I 1.1
....... I 1.0
....... I 1.1
....... Q 4.0

SITRAIN Training for


Automation and Industrial Solutions

Exercise

Complete the programs above to obtain the following functionality: When switch
S1 is activated and switch S2 is not activated, the light should be ON in all three
cases.

Note !

The terms "NO contact" and "NC contact" have different meanings depending
on whether they are used in the process hardware context or as symbols in the
software.

SITRAIN Training for


Automation and Industrial Solutions

Page 7

ST-PRO1
Binary Operations

Assignment, Setting, Resetting


LAD

I 1.0

I 1.1

FBD

Q 8.0

( )

Assignment

I 1.0

&

I 1.3

Q 8.1

(S)

Set

I 1.2

&

I 1.5

SIMATIC S7

I 1.4
I 1.5

Date:
File:

Siemens AG 2005. All rights reserved.

A I 1.0
A I 1.1
= Q 8.0

A I 1.2
A I 1.3
S Q 8.1

Q 8.1

(R)
Reset

Q 8.1
S

I 1.3

I 1.4

Q 8.0
=

I 1.1

I 1.2

STL

14.10.2005
PRO1_07E.8

>=1

Q 8.1
R

O I 1.4
O I 1.5
R Q 8.1

SITRAIN Training for


Automation and Industrial Solutions

Assignment

An assignment passes the RLO on to the specified address (Q, M, D). When the
RLO changes, the signal state of that address also changes.

Set

If RLO= "1", the specified address is set to signal state "1" and remains set until
another instruction resets the address.

Reset

If RLO= "1", the specified address is reset to signal state "0" and remains in this
state until another instruction sets the address again.

SITRAIN Training for


Automation and Industrial Solutions

Page 8

ST-PRO1
Binary Operations

Setting / Resetting a Flip Flop

LAD
M 5.7

I1.2
Dominant
Reset

FBD

SR

STL

M 5.7
Q 9.3
Q

I1.2

SR
Q9.3

I1.3
I1.3

M 5.7

I1.3
Dominant
Set

RS

M 5.7
Q 9.3
I1.3

RS
Q9.3

I1.2
I1.2

SIMATIC S7

Date:
File:

Siemens AG 2005. All rights reserved.

Flip Flop

14.10.2005
PRO1_07E.9

A
S
A
R
A
=

I 1.2
M 5.7
I 1.3
M 5.7
M 5.7
Q 9.3

A
R
A
S
A
=

I 1.3
M 5.7
I 1.2
M 5.7
M 5.7
Q 9.3

SITRAIN Training for


Automation and Industrial Solutions

A flip flop has a Set input and a Reset input. The memory bit is set or reset,
depending on which input has an RLO=1.
If there is an RLO=1 at both inputs at the same time, the priority must be
determined.

Priority

In LAD and FBD there are different symbols for Dominant Set and Dominant
Reset memory functions. In STL, the instruction that was programmed last has
priority.

Note

If an output is set with a set instruction, the output is reset on a warm restart of
the CPU.
If M 5.7 in the example above has been declared retentive, it will remain in the
set state after a warm restart of the CPU, and the reset output Q 9.3 will be
assigned the set state again.

SITRAIN Training for


Automation and Industrial Solutions

Page 9

ST-PRO1
Binary Operations

Midline Output Coil

LAD

I 1.0

I 1.1

STL

M 20.7

I 2.0

I 2.1

Q 4.0

( )

( )

FBD

I 1.0

A
A
=
A
A
A
=

I
I
M
M
I
I
Q

1.0
1.1
20.7
20.7
2.0
2.1
4.0

&
M 20.7
&

I 1.1

SIMATIC S7

Q 4.0

I 2.1

Date:
File:

Siemens AG 2005. All rights reserved.

Midline Output Coil

I 2.0

14.10.2005
PRO1_07E.10

SITRAIN Training for


Automation and Industrial Solutions

The midline output coil exists only in the LAD and FBD graphic languages. It is
an intermediate assignment element with assignment function that assigns the
current RLO at a specified address (M20.7 in the slide). The midline output coil
provides this same address in the same network for subsequent gating.
In the STL language, this is equivalent to
= M 20.7
A M 20.7
In the LAD language, when connected in series with other elements, the
"midline output coil" instruction is inserted in the same way as a contact.

SITRAIN Training for


Automation and Industrial Solutions

Page 10

ST-PRO1
Binary Operations

Instructions that Affect the RLO


LAD

NOT

I 0.0

FBD

I0.1
NOT

Q 8.0

I 0.0

( )

I 0.1

&

STL

Q 8.0
=

A I 0.0
A I 0.1
NOT
= Q 8.0

Examples:
STAT 0 Bit memory

CLR

not available

not available

CLR
= M 0.0

STAT 1 Bit memory


not available

SET

SIMATIC S7

not available

Date:
File:

Siemens AG 2005. All rights reserved.

14.10.2005
PRO1_07E.11

SET
= M 0.1

SITRAIN Training for


Automation and Industrial Solutions

NOT

The NOT instruction inverts the RLO.

CLR

The CLEAR instruction sets the RLO to "0" without pre-conditions (available
only in STL).

SET

The SET instruction sets the RLO to "1" without pre-conditions (available only in
STL).

Note

The CLR and SET instructions limit the result of logic operation, that is, the next
programmed scan becomes a first check.

First Check

The first processed check operation after a conditional operation is called a first
check. It has a particular meaning since the CPU takes over the result of check
directly as a result of logic operation (RLO). The old RLO is thus lost. The first
check always represents the beginning of a logic operation. The operation
(AND, OR, XOR) that comes with the first check is of no importance.

SITRAIN Training for


Automation and Industrial Solutions

Page 11

ST-PRO1
Binary Operations

Exercise 1: Mode Section of the Distribution Conveyor (FC15)


DI

DO Q 4....

I 0.0

System_ON

I 0.1

System_OFF

.0

I 0.2
I 0.3

Jog_RIGHT

I 0.4

AUTO / MANUAL

.4

I 0.5

Accept

.5

System

.1

MANUAL

.2
.3

AUTO

Jog_LEFT

I 0.6

-15V...+15V

.6

AI2

AO1

I 0.7

-15V...+15V
AO2

AI1

.7

AI1

Weight

0 8 1 5

SIMATIC S7

Date:
File:

Siemens AG 2005. All rights reserved.

Task

14.10.2005
PRO1_07E.12

AI1

AI2

AI2

AO1

AO2

SITRAIN Training for


Automation and Industrial Solutions

You are to program a "mode" section in FC 15 (symbolic name "FC_Modes") for


the distribution conveyor and integrate the message MANUAL mode (Q 4.2) as
a lock-out in the FC 16 block.
Function of the mode section in the FC 15 :

The system (LED Q4.1) is turned "on" using I 0.0, the simulator pushbutton.
It is turned "off" using I 0.1 (NC contact), the simulator pushbutton.
You can preselect "MANUAL" mode (LED Q 4.2) or "AUTO" mode
(LED Q 4.3) through switch I 0.4 as follows:
- I 0.4 switched off (= 0):
"MANUAL" mode preselected,
- I 0.4 switched on (= 1):
"AUTO" mode preselected.
The operating mode that you preselect through switch I 0.4 is
acknowledged or switched on through pushbutton I 0.5
The operating modes are switched off when you change the preselection of
the operating mode (I 0.4) or when the system is switched off (Q 4.1 = 0).

Integrating the MANUAL mode (Q 4.2):

What to Do

The "Jog Conveyor Motor" programmed in FC 16 is now only to be possible


when the "MANUAL" mode is switched on. Program the relevant lock-out in
FC 16.

1. Create an FC 15 block in your S7 program called "My Program" and


program Networks 1 to 3 according to the task.
2. Also call the FC 15 blick in OB 1.
3. Program the required lock-out in FC 16.
4. Download all blocks into the CPU and test your program.

SITRAIN Training for


Automation and Industrial Solutions

Page 12

ST-PRO1
Binary Operations

Exercise 2: Programming the Conveyor for AUTO Mode (FC16)


Transport Phase

Conv. Start

Conv. Stop

Prox.Sens.Bay 1
I 8.5
Pushbutton Bay 1
I 8.1
Prox.Sens.Bay 2
I 8.6
Pushbutton Bay 2
I 8.2
Light Barrier
I 8.0
Run Conveyor
RIGHT
Q8.5

SIMATIC S7

Date:
File:

Siemens AG 2005. All rights reserved.

Function

14.10.2005
PRO1_07E.13

SITRAIN Training for


Automation and Industrial Solutions

In AUTO mode, parts are to be transported from Bay 1 or Bay 2 to the Final
Control (light barrier).
Run Conveyor RIGHT starts when
Bay 1 proximity sensor is activated
AND NOT Bay 2 proximity sensor AND Bay 1 pushbutton is activated
OR

Bay 2 proximity sensor is activated


AND NOT Bay 1 proximity sensor AND Bay 2 pushbutton is activated

Run Conveyor RIGHT is stopped when


the part has reached the Final Control or the light barrier
OR
AUTO mode is switched off
What to Do

1. Check whether your program in FC16 fulfills the desired function!


2. Modify your program in such a way that the conveyor stops when AUTO
mode is switched off.
3. Test the function "Jog left" and "Jog right" in manual mode (Mode_Manual).

Note

To prevent double assignments, you should program a bit memory for each of
the two conditions:
- Bit memory M16.0: Bit memory for "Jog right" in manual mode
- Bit memory M16.1: Bit memory for "Run conveyor right" in auto mode
Both bit memories are then assigned to the output "Run conveyor right" in an
additional network using an OR function.

SITRAIN Training for


Automation and Industrial Solutions

Page 13

ST-PRO1
Binary Operations

RLO - Edge Detection


LAD
I 1.0

I 1.1

FBD

M1.0

M8.0

P
I 1.0

I 1.1

M1.1

I 1.0

&

I 1.1
M8.1

I 1.0

&

I 1.1

STL

M1.0

M8.0

M1.1

M8.1

A
A
FP
=

I 1.0
I 1.1
M1.0
M8.0

A
A
FN
=

I 1.0
I 1.1
M1.1
M8.1

OB1 Cycle

I 1.0
I 1.1
RLO
Example

M1.0
M1.1
M8.0
M8.1

SIMATIC S7

Date:
File:

Siemens AG 2005. All rights reserved.

14.10.2005
PRO1_07E.14

SITRAIN Training for


Automation and Industrial Solutions

RLO Edge Detection An "RLO edge" detection is when the result of a logic operation changes from
"0" to "1" or from "1" to "0".
Positive Edge

(Positive RLO Edge Detection) detects a signal change in the address from "0"
to "1", and displays it as RLO = "1" after the instruction (such as at M 8.0) for
one cycle.
To enable the system to detect the edge change, the RLO must be saved in an
FP bit memory (such as M 1.0), or a data bit.

Negative Edge

(Negative RLO Edge Detection) detects a signal change in the address from "1"
to "0" and displays it as RLO = "1" after the instruction (such as at M 8.1) for one
cycle.
To enable the system to detect the edge change, the RLO must be saved in an
FN bit memory (such as M 1.1), or a data bit.

SITRAIN Training for


Automation and Industrial Solutions

Page 14

ST-PRO1
Binary Operations

Signal - Edge Detection


LAD
I 1.1

I 1.0

POS
M1.0

M_BIT

I 1.0

I 1.1
NEG

M1.1

FBD

I 1.1
POS
M_BIT

M8.0
Q
M1.0

M8.1

I 1.1
NEG
M_BIT

M_BIT

M1.1

I 1.0

STL
&
M8.0

=
I 1.0

&
M8.1

A
A
A
FP
)
=
A
A
A
FN
)
=

I 1.0
(
I 1.1
M1.0
M8.0
I 1.0
(
I 1.1
M1.1
M8.1

I 1.0
I 1.1
Example

M1.0
M1.1
OB1 Cycle

M8.0
M8.1

SIMATIC S7

Date:
File:

Siemens AG 2005. All rights reserved.

14.10.2005
PRO1_07E.15

SITRAIN Training for


Automation and Industrial Solutions

Signal Edge

A "signal edge" is when a signal changes its state.

Example

Input I 1.0 acts as a static enable. Input I 1.1 is to be monitored dynamically and
every signal change is to be detected.

Positive Edge

When the signal state at I 1.1 changes from "0" to "1", the "POS" check
instruction results in signal state "1" at output Q for one cycle, provided input
I 1.0 also has signal state "1" (as in the example above).
To enable the system to detect the edge change, the signal state of I 1.1 must
also be saved in an M_BIT (bit memory or data bit) (such as M 1.0).

Negative Edge

When the signal state at I 1.1 changes from "1" to "0", the "NEG" check
instruction results in signal state "1" at output Q for one cycle, provided input
I 1.0 has signal state "1" (as in the example above).
To enable the system to detect the edge change, the signal state of I 1.1 must
also be saved in an M_BIT (bit memory or data bit) (such as M 1.1).

SITRAIN Training for


Automation and Industrial Solutions

Page 15

ST-PRO1
Binary Operations

Exercise 3: Edge Detection

Transport Phase

Conv. Start

Conv. Stop

Part at
Light barrier
Start condition
in AUTO mode

Light Barrier
(I 8.0)

Run Conveyor
RIGHT
(Q8.5)

SIMATIC S7

Date:
File:

Siemens AG 2005. All rights reserved.

FC 16 Up Till Now

14.10.2005
PRO1_07E.16

SITRAIN Training for


Automation and Industrial Solutions

In MANUAL mode (Q 4.2 = 1), you can jog the conveyor motor direction to the
RIGHT and LEFT using the pushbuttons I 0.2 and I 0.3.
In AUTO mode (Q 4.3 = 1), the Run Conveyor RIGHT is switched on when a
part is laid on the conveyor exactly in front of a proximity sensor at Bay 1 or 2,
(EXOR -logic operation) and the occupied Bays pushbutton is activated.
The conveyor motor is stopped when the part has reached the Final Control
(the light barrier) OR the AUTO mode is switched off.

Task

The function of the FC 16 to control the conveyor motor in AUTO mode is to


remain fundamentally unchanged. However, the conveyor motor is to be
stopped as soon as the part has passed through the light barrier ( edge
detection necessary, see slide).

What to Do

1. Program the necessary changes in FC 16, by changing the reset condition of


M 16.1 (bit memory for Run conveyor RIGHT in AUTO mode) from the light
barrier signal itself (I 8.0 ) to its positive edge.
For the necessary edge detection of the light barrier signal use the bit
memory M 16.2 as an edge memory bit.
2. Save the modified FC 16 block and download it into the CPU
3. Check whether your program fulfills the desired function !

SITRAIN Training for


Automation and Industrial Solutions

Page 16

ST-PRO1
Binary Operations

If You Want to Know More

SIMATIC S7

Date:
File:

Siemens AG 2005. All rights reserved.

Note

14.10.2005
PRO1_07E.17

SITRAIN Training for


Automation and Industrial Solutions

The following pages contain either further information or are for reference to
complete a topic.

SITRAIN Training for


Automation and Industrial Solutions

Page 17

ST-PRO1
Binary Operations

Unconditional Jump (Regardless of the RLO)

LAD

Network 1

FBD

NEW1

( JMP )
Network 2
:
:
:
:
Network x

NEW1
JMP

....

Network 1

JU NEW1

Network 2
:
:
:
:
Network x

Network 2
:
:
:
:
Network x

NEW1

NEW1

M5.5

Network 1

STL

I 4.7

M69.0

( )

SIMATIC S7

M5.5
I 4.7

Date:
File:

Siemens AG 2005. All rights reserved.

&

NEW1:
M69.0
=

14.10.2005
PRO1_07E.18

AN M5.5
AN I 4.7
=
M69.0

SITRAIN Training for


Automation and Industrial Solutions

Jump Instruction

In LAD/FBD, the label (NEW1) is entered as an identifier above the coil symbol
or assignment symbol. In STL it comes after the Jump (JU) instruction.
The label can have up to four characters, the first of which must be a letter or
the _ character.
The label marks the point where execution of the program is to continue. Any
instructions or networks between the jump instruction and the label are not
executed.
Jumps can be made both forwards and backwards. The jump instruction and the
jump destination must both be in the same block (max. jump length = 64kbyte).
The jump destination can only be used once in a block.
Jump instructions can be used in FBs, FCs and OBs.

Jump Label

A jump label (maximum four characters long) identifies the jump destination of a
jump instruction. In STL, this is an instruction, in LAD and FBD it is the
beginning of a network.
In STL, the label is specified to the left of the instruction from where program
execution is to continue.
In LAD and FBD, you use the Program Elements browser to insert a label:
Program Elements Jumps LABEL.

JMP

An unconditional jump instruction causes a program jump to a label regardless


of the RLO.

SITRAIN Training for


Automation and Industrial Solutions

Page 18

ST-PRO1
Binary Operations

Conditional Jump (Dependent on RLO)

LAD

Jump if
RLO=1

Jump if
RLO=0

I 0.0

I 0.2

I 0.1

I 0.3

FBD

NEW1

I 0.0

(JMP)

I 0.1

I 0.2

NEW2

(JMPN)

SIMATIC S7

Date:
File:

Siemens AG 2005. All rights reserved.

I 0.3

14.10.2005
PRO1_07E.19

&

&

STL

NEW1
JMP

A I 0.0
A I 0.1
JC NEW1

NEW2
JMPN

A I 0.2
A I 0.3
JCN NEW2

SITRAIN Training for


Automation and Industrial Solutions

JC

The "JC" conditional jump is only executed if the RLO is "1".


If the RLO is "0", the jump is not executed, the RLO is set to "1" and program
execution continues with the next instruction.

JCN

The "JCN" conditional jump is only executed if the RLO is "0".


If the RLO is "1", the jump is not executed and program execution continues with
the next instruction.

Note

STL provides additional jump operations, which are discussed in an advanced


programming course.

SITRAIN Training for


Automation and Industrial Solutions

Page 19

ST-PRO1
Binary Operations

Additional Exercise 4: Optimizing the Mode Section FC 15


OLD: without edge detection
T_System_ON
(I 0.0)
T_System_OFF
(I 0.1, NC contact)
L_System_ON
(Q4.1)

NEW: with edge detection


T_System_ON
(I 0.0)
T_System_OFF
(I 0.1, NC contact)
L_System_ON
(Q4.1)

SIMATIC S7

Date:
File:

Siemens AG 2005. All rights reserved.

14.10.2005
PRO1_07E.20

SITRAIN Training for


Automation and Industrial Solutions

FC 15 Up Till Now

The system (Q 4.1) is switched on with the simulator pushbutton I 0.0, and
switched off with the simulator pushbutton I 0.1 (NC) .
If you press both pushbuttons simultaneously, the system remains switched off
or is switched off if currently on. However, if both pushbuttons are pressed and
you let go of the OFF pushbutton, the system switches on again without having
to first press the ON pushbutton once more (see slide, upper function diagram
"OLD: without edge detection").

Task (1)

Expand the functionality of FC 15 using edge detection so that the ON


pushbutton must be pressed every time the system is switched on (see slide,
lower function diagram "NEW: with edge detection").
The criteria for switching on the system is no longer to be the pressed ON
pushbutton or its 1 signal, but the function of pressing or the "positive edge" of
the ON pushbutton signal.

What to Do

1. In the set condition for "L_System", insert an edge detection of the


pushbutton "T_System_ON". For the edge detection, use the bit memory
"EM_System_ON" (M 15.0) as edge memory bit.
2. Save the modified FC 15 block and download it into the CPU
3. Check whether your program fulfills the desired function !

Task (2)

Just as with switching on the system, accepting and/or switching on


"L_Mode_Manual" (Q 4.2) and "L_Mode_Auto" (Q 4.3) is also to happen using
"S_Mode_Select" (I 0.4).
Every time there is a mode change, the pushbutton "T_ Mode _Enable" (I 0.5)
must be pressed once more.
Use the bit memories "EM_Manual_ON" (M 15.1) and "EM_Auto_ON" (M 15.2)
for the required edge detections.

SITRAIN Training for


Automation and Industrial Solutions

Page 20

ST-PRO1
Binary Operations