You are on page 1of 22

Binary Operations

I0.0 I0.1 Q 8.0

Q 8.1 (MCRA)

I 0.0
( MCR< )

I 1.0 I 1.1 Q 8.0


( )

M0.0
I1.2 Q 9.3
SR
S Q

I1.3
R

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.1
Cyclical Program Execution
Start-up block (OB 100)
Execution once after e.g. power on

Input
Start of the cycle monitoring time
Module

Reading the signal states from the modules


and saving the data in the process image (PII)
CPU Cycle

Execution of the program in OB1 Block


(cyclical execution) A I 0.1
OB 1 A I 0.2
Events (time-of-day interrupt, hardware interrupts etc.)
= Q8.0
call other OBs, FBs, FCs, etc.

Writing the process-image output table Output


(PIQ) to the output modules Module

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.2
Process Images

PII PIQ
User
Byte 0 Program Byte 0
Byte 1 Byte 1
Byte 2 1 Byte 2
: : :
: : : 1
: A I 2.0 :
= Q 4.3
:
:
:
:
CPU Memory Area CPU Memory Area

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.3
Program Structure

Linear Program Program Partitioned into Areas Structured Program

Recipe A
Pump
OB 1 OB 1 Recipe B OB 1

Mixer
Outlet

Outlet

All instructions are The instructions for the indi- Reuseable functions are loaded
found in one block vidual functions are found in into individual blocks.
(normally in the individual blocks. OB 1 calls the OB 1 (or other blocks) call
organization block OB 1) individual blocks one after the these blocks and pass on the
other. pertinent data.

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.4
Types of Program Blocks

Operating System

Cycle

Time OB
FB FC SFB
Organization
Process Blocks

FB FB SFC
Error

OB = Organization Block
Legend:
FB = Function Block
FC = Function
SFB = System Function Block
SFC = System Function FB with instance
data block

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.5
Normally Open and Normally Closed Contacts, Sensors and Symbols

Process Interpretation in PLC program

The The sensor Voltage Signal Check for Check for


sensor is ... present state signal state “1” signal state “0”
is a ... at at
input? input Symbol / Result of Symbol / Result of
Instruction check Instruction check

NO activated
contact LAD: LAD:
Yes 1 “Yes“ “No”
1 0
“NO contact” “NC contact”
not No
activated 0 “No” “Yes”
0 1
FBD: FBD:
& &
NC activated
No 0 “No” “Yes”
contact
0 1

not
STL: STL:
activated Yes 1 “Yes” “No”
A I x.y 1 AN I x.y 0

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.6
Exercise
Task: In all three examples the light should be on when S1 is activated and S2 is not activated!

Hardware

S1 S2 S1 S2 S1 S2

II1.0
1.0 II1.1
1.1 II1.0
1.0 II1.1
1.1 II1.0
1.0 II1.1
1.1
Programmable controller Programmable controller Programmable controller
Q 4.0 Q 4.0 Q 4.0

Light Light Light

Software
I 1.0 I 1.1 Q 4.0 I1.0 I1.1 Q 4.0 I1.0 I1.1 Q 4.0
LAD

I 1.0 & I1.0 & I1.0 &

FDB
I1.1 Q 4.0 I1.1 Q 4.0 I1.1 Q 4.0

....... I1.0 ....... I1.0 ....... I1.0


STL ....... I1.1 ....... I1.1 ....... I1.1
....... Q 4.0 ....... Q 4.0 ....... Q 4.0

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.7
Addressing of S7-300 Modules

Slot No. 1 2 4 5 6 7 8 9 10

Modules PS CPU SM SM SM SM SM SM SM

Address 0.0
Address 0.7
Address 1.0
Address 1.7

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.8
DI/DO Addressing in Multi-Tier Configurations

PS IM 96.0 100.0 104.0 108.0 112.0 116.0 120.0 124.0


Rack
3 (Receive) to to to to to to to to
99.7 103.7 107.7 111.7 115.7 119.7 123.7 127.7

PS IM 64.0 68.0 72.0 76.0 80.0 84.0 88.0 92.0


Rack (Receive) to to to to to to to to
2 67.7 70.7 75.7 79.7 83.7 87.7 91.7 95.7

PS
IM 32.0 36.0 40.0 44.0 48.0 52.0 56.0 60.0
Rack to to to to to to to to
1 (Receive)
35.7 39.7 43.7 47.7 51.7 55.7 59.7 63.7

PS 0.0 4.0 8.0 12.0 16.0 20.0 24.0 28.0


CPU IM
Rack (Send) to to to to to to to to
0 3.7 7.7 11.7 15.7 19.7 23.7 27.7 31.7

Slot 1 2 3 4 5 6 7 8 9 10 11

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.9
Binary Logic Operations: AND, OR

Circuit Diag. LAD FBD STL

S1 (I 0.0)
I0.0 I0.1 Q 8.0 I 0.0 & Q 8.0 A I0.0
= A I0.1
AND S2 (I 0.1) I 0.1
= Q 8.0
Q 8.1 Q 8.1 = Q 8.1
=

L1 L2
(Q 8.0) (Q 8.1)

S3
(I 0.2) I0.2 Q 8.2
Q 8.2 O I0.2
S4 I 0.2 >=1
OR = O I0.3
(I 0.3) I 0.3 = Q 8.2
I0.3

L3 (Q 8.2)

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.10
Binary Logic Operations: Exclusive OR (XOR)

LAD FBD STL

I 0.4 & A I0.4


I0.4 I0.5 Q 8.0 Q 8.0 AN I0.5
I 0.5 >=1
= O
AN I0.4
I 0.4 & A I0.5
I0.4 I0.5 I 0.5 = Q8.0

Q 8.0 X I0.4
I 0.4 XOR X I0.5
=
I 0.5 = Q8.0

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.11
Result of Logic Operation, First Check. Examples

Example 1 Example 2 Example 3

Result of Check

Result of Check

Result of Check
Result of Logic

Result of Logic

Result of Logic
Signal State

Signal State

Signal State
First Check

First Check

First Check
Operation

Operation
Operation
A I 1.0 0 1 1

AN I 1.1 0 1 0

A M 4.0 0 1 1

= Q 8.0

= Q 8.1

A I 2.0 0 1 0

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.12
Assignment, Setting, Resetting

LAD FBD STL

I 1.0 I 1.1
Q 8.0 A I 1.0
I 1.0 & A I 1.1
Assignment ( ) Q 8.0
= Q 8.0
I 1.1 =

I 1.2 I 1.3
Q 8.1 I 1.2 A I 1.2
& Q 8.1
Set (S ) A I 1.3
I 1.3 S S Q 8.1

I 1.4 Q 8.1
(R) I 1.4 O I 1.4
>=1 Q 8.1 O I 1.5
Reset I 1.5 R R Q 8.1
I 1.5

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.13
Setting / Resetting a Flip Flop

LAD FBD STL

M0.0 M0.0
I1.2 Q 9.3 A I 1.2
SR SR S M 0.0
Dominant S Q I1.2 S
Reset A I 1.3
Q9.3 R M 0.0
I1.3
R = A M 0.0
R I1.3 Q
= Q 9.3

M0.0 M0.0
I1.3 Q 9.3 A I 1.3
Dominant RS RS R M 0.0
R Q I1.3 R
Set A I 1.2
Q9.3 S M 0.0
I1.2
= A M 0.0
S I1.2 S Q
= Q 9.3

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.14
Connector

LAD STL

I 1.0 I 1.1 M0.0 I 2.0 I 2.1 M 1.1 Q 4.0


( ) NOT ( ) ( ) A I 1.0
A I 1.1
= M 0.0
A M 0.0
FBD A I 2.0
A I 2.1
NOT
I 1.0 & = M 1.1
M0.0
A M 1.1
I 1.1 &
= Q 4.0
I 2.0 M1.1 Q 4.0
I 2.1 =

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.15
Instructions, that Affect the RLO
LAD FBD STL

A I0.0
I0.0 I0.1
Q8.0 I0.0 & A I0.1
NOT Q8.0
NOT ( ) I0.1 = NOT
= Q8.0

CLR not available not available CLR

SET not available not available SET

I1.6 A I1.6
SAVE ( SAVE ) I1.6 & SAVE SAVE

BR Q8.1 Q8.1 A BR
BR ( ) BR = = Q 8.1

15 8 1
Status word
BR RLO

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.16
Master Control Relay Function
LAD FBD STL

( MCRA ) MCRA MCRA // Activated

I0.0
A I0.0 // Enable MCR
( MCR< ) A0.0 & MCR<
MCR( // Open MCR

I0.7 Q8.5 Q8.5


( ) A I0.7 // NO Contact
A0.7 & =
= Q8.5 // Output Coil
M0.6 M0.6
= M0.6 // Output Coil
( ) =

Q16.0 Q16.0 A I0.4 // NO Contact


I0.4
(S) A0.4 & S S Q16.0 // Set Output

( MCR> ) MCR> )MCR // Close MCR

M69.0 AN M5.5 // Emerg.Contact


M5.5 I4.7 M5.5 M69.0
( ) & AN I4.7 // Emerg.Contact
I4.7 =
= M69.0 // Output Coil
( MCRD ) MCRD
MCRD // Deactivate

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.17
Unconditional Jump (Independent of RLO)

LAD FBD STL

Network 1 Network 1 Network 1


NEW1 NEW1
( JMP ) .... JMP JU NEW1

Network 2 Network 2 Network 2


: : :
: : :
: : :
: : :
Network x Network x Network x

NEW1 NEW1

M69.0 NEW1: AN M5.5


M5.5 I4.7 M5.5 & M69.0 AN I4.7
( ) =
I 4.7 = M69.0

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.18
Conditional Jump (Dependent on RLO)

LAD FBD STL

I 0.0 I 0.1 NEW1 I0.0 & A I0.0


Jump if NEW1 A I0.1
RLO=1 (JMP) I0.1 JMP JC NEW1

Jump if I 0.2 I 0.3 I0.2 & A I0.2


NEW2 NEW2
RLO=0 A I0.3
(JMPN) I0.3 JMPN JCN NEW2

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.19
RLO - Edge Detection
LAD FBD STL

A I1.0
I1.0 I1.1 M1.0 M8.0 I1.0 &
M1.0 M8.0 A I1.1
P FP M1.0
I1.1 P = = M8.0

I1.0 I1.1 M1.1 M8.1 I1.0 A I 1.0


& M8.1 A I 1.1
M1.1
N FN M1.1
I1.1 N = = M8.1

OB1-Cycle
I1.0

I1.1

RLO
Example
M1.0

M1.1

M8.0
M8.1

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.20
Signal - Edge Detection
LAD FBD STL

I1.1 I1.0 & A I1.0


I1.0 M8.0 I1.1 A (
POS POS M8.0 A I1.1
Q
M1.0 M_BIT = FP
M1.0 M_BIT M1.0
)
I1.1 =
I1.0 I1.0 &
M8.1 I1.1 M8.0
NEG A I1.0
Q NEG M8.1
A (
M1.1 M_BIT M1.1 M_BIT = A I1.1
FN
M1.1
I1.0 )
=
I1.1 M8.1

Example M1.0

M1.1
OB1-Cycle
M8.0

M8.1

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.21
Exercise: Program for a Bottling Plant (Mode Selection)
Plant ON/OFF: Manual/Automatic mode:
I 0.0 = Start (Mom.-cont. switch with NO function) I 0.4 = Manual/Automatic (Switch)
I 0.1 = Stop (Mom.-cont. switch with NC function) I 0.5 = Adopt mode (Momentary-
contact switch, NO function)
I 0.2 = Jog forward (M-C sw., NO funct.)
I 0.3 = Jog backward (M-C sw., NO func.)

Bottle
sensor
I 16.6 (I 8.6)

M
Q 20.5 (Q 8.5) Conveyor forwards
Q 20.6 (Q 8.6) Conveyor backwards

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_08E.22

You might also like