Beruflich Dokumente
Kultur Dokumente
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
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...............................................................
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
...
...
...
SIMATIC S7
Siemens AG 2005. All rights reserved.
Date:
File:
14.10.2005
PRO1_07E.2
Page 2
ST-PRO1
Binary Operations
Result of check
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:
Basically
14.10.2005
PRO1_07E.3
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.
Page 3
ST-PRO1
Binary Operations
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:
14.10.2005
PRO1_07E.4
Logic Tables
AND
OR
I 0.0
I 0.1
I 0.2
I 0.3
Q 8.0
Q 8.2
Page 4
ST-PRO1
Binary Operations
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:
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
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.
Page 5
ST-PRO1
Binary Operations
The
sensor
is a ...
NO
contact
The sensor
is ...
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:
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
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".
Page 6
ST-PRO1
Binary Operations
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:
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
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.
Page 7
ST-PRO1
Binary Operations
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:
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
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.
Page 8
ST-PRO1
Binary Operations
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:
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
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.
Page 9
ST-PRO1
Binary Operations
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:
I 2.0
14.10.2005
PRO1_07E.10
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.
Page 10
ST-PRO1
Binary Operations
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
SET
SIMATIC S7
not available
Date:
File:
14.10.2005
PRO1_07E.11
SET
= M 0.1
NOT
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.
Page 11
ST-PRO1
Binary Operations
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:
Task
14.10.2005
PRO1_07E.12
AI1
AI2
AI2
AO1
AO2
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).
What to Do
Page 12
ST-PRO1
Binary Operations
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:
Function
14.10.2005
PRO1_07E.13
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
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.
Page 13
ST-PRO1
Binary Operations
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:
14.10.2005
PRO1_07E.14
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.
Page 14
ST-PRO1
Binary Operations
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:
14.10.2005
PRO1_07E.15
Signal Edge
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).
Page 15
ST-PRO1
Binary Operations
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:
FC 16 Up Till Now
14.10.2005
PRO1_07E.16
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
What to Do
Page 16
ST-PRO1
Binary Operations
SIMATIC S7
Date:
File:
Note
14.10.2005
PRO1_07E.17
The following pages contain either further information or are for reference to
complete a topic.
Page 17
ST-PRO1
Binary Operations
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:
&
NEW1:
M69.0
=
14.10.2005
PRO1_07E.18
AN M5.5
AN I 4.7
=
M69.0
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
Page 18
ST-PRO1
Binary Operations
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:
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
JC
JCN
Note
Page 19
ST-PRO1
Binary Operations
SIMATIC S7
Date:
File:
14.10.2005
PRO1_07E.20
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)
What to Do
Task (2)
Page 20
ST-PRO1
Binary Operations