Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 28

Digital Operations

M0.0 CMP ==I Q 9.7

IW0 IN1
IW2 IN2

T4
I0.7 S_ODT Q8.5
S Q
S5T#35s TV BI MW0
I0.5
R BCD QW12

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.1
Number Formats (16 Bits)
PG CPU

Sign (+) 2 9 6

BCD W#16#296
0 0 0 0 0 0 1 0 1 0 0 1 0 1 1 0
Positive
Numbers 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0
INTEGER
+296 28 25 23
= = =
256 + 32 + 8 = 296

Sign (-) 4 1 3
BCD W#16#F413
1 1 1 1 0 1 0 0 0 0 0 1 0 0 1 1
Negative
Numbers 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1
INTEGER
-413 2 8 27 2 4 23 22
= = = = =
256+ 128 + 16+8+ 4 = 412
- (412 + 1) = - 413

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.2
Number Formats (32 Bits)

BCD Sign (+) 0 0 0 0 2 9 6

DW#16#296 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 1 1 0

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DINT

+296 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0
28 25 23
= = =
Integer (32 Bit) = 256 + 32 + 8 = 296

REAL General Format of a Real Number = (Sign) • (1.f) • (2 e-127)


+0.75 Sign of
or Real No e = Exponent (8 Bit) f = Mantissa (23 Bit)
+7.5 E-1
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

0 0 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27 26 25 24 23 22 21 20 2-1 2-2 2-3 2-4 ..... 2-23

Real No = +1,5 * 2 126-127 = 0,75

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.3
Loading and Transferring Data (1)

LAD FBD STL

MOVE MOVE
L +5
EN ENO EN OUT MB5
T MB5

5 IN OUT MB5 5 IN ENO

Examples L +5 // 16-bit constant (Integer)


of Load L L#523123 // 32-bit constant (Double
Integer)
L B#16#EF // byte in hexadecimal form.
L 2#0010 0110 1110 0011 // 16-bit binary value
L 3.14 // 32-bit constant (Real)

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.4
Loading and Transferring Data (2)

Content of Content of
ACCU1 ACCU2
Programm

X X X X X X X X Y Y Y Y Y Y Y Y

:
:
L W#16#CAFE 0 0 0 0 C
0 A
0 F
0 E
0 X X X X X X X X

L W#16#AFFE 0 0 0 0 A
0 F
0 F
0 E
0 0 0 0 0 C A F E
:
:
:

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.5
Loading and Transferring Data (3)
Contents of ACCU1
Program
31 23 15 7 0

L MB 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 MB0

31 23 15 7 0
Load 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 MB0 MB1
L MW 0

31 23 15 7 0

L MD 0 MB0 MB1 MB2 MB3

T QD 4
QD 4

Transfer T QW 4
QW 4

T QB 4
QB 4

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.6
Timers: Time Formats for S5 Timers in STEP 7
102 101 100

Format for time specifications X X

Time base Time value (BCD code)

Timer cell in system data memory X X X X

Time base Time value (Binary number)

ACCU contents after “L T...” X X X X X X

Time value (Binary number)

102 101 100

ACCU contents after “LC T...” X X

Time base Time value (BCD code)

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.7
Timers: ON Delay (SD)
LAD FBD STL

T4 T4
I0.7 S_ODT Q8.5 S_ODT A I0.7
S Q I0.7 S BI MW0 L S5T#35s
S5T#35s BI MW0 S5T#35s QW12
SD T4
TV TV BCD
I0.5 Q8.5 A I0.5
R BCD QW12 I0.5 R Q = R T4
L T4
T MW0
RLO at S
LC T4
RLO at R T QW12
A T4
Timer = Q8.5
operation
Example

Data type 0,01s <-- 0 0


0,1s <-- 0 1
“S5TIME” 1s <-- 1 0 Time value: 0 . . . 999
10s <-- 1 1

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.8
Timers: Stored ON Delay (SS)
LAD FBD STL

T4 T4 A I0.7
I0.7 S_ODTS Q8.5 S_ODTS L S5T#35s
S Q I0.7 S BI MW0 SS T4
S5T#35s BI MW0 A I0.5
TV S5T#35s TV BCD QW12
I0.5 Q8.5 R T4
R BCD QW12 I0.5 R Q = L T4
T MW0
LC T4
T QW12
A T4
= Q8.5

RLO at S

RLO at R

Timer
operation
Example

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.9
Timers: OFF Delay (SF)
LAD FBD STL

T4 T4 A I0.7
I0.7 S_OFFDT Q8.5 S_OFFDT L S5T#35s
S Q I0.7 S BI MW0 SF T4
S5T#35s BI MW0 A I0.5
TV S5T#35s TV BCD QW12
I0.5 Q8.5 R T4
R BCD QW12 I0.5 R Q = L T4
T MW0
LC T4
T QW12
A T4
= Q8.5

RLO at S

RLO at R

Timer
operation
Example

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.10
Timers: Pulse (SP)
LAD FBD STL

T4 T4 A I0.7
I0.7 S_PULSE Q8.5 S_PULSE L S5T#35s
S Q I0.7 S BI MW0 SP T4
S5T#35s BI A I0.5
TV MW0 S5T#35s TV BCD QW12
I0.5 Q8.5 R T4
R BCD QW12 I0.5 R Q = L T4
T MW0
LC T4
T QW12
A T4
= Q8.5

RLO at S

RLO at R

Timer
operation
Example

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.11
Timers: Extended Pulse (SE)
LAD FBD STL

T4 T4 A I0.7
I0.7 S_PEXT Q8.5 S_PEXT L S5T#35s
S Q MW0 SE T4
I0.7 S BI
S5T#35s TV BI MW0 A I0.5
S5T#35s TV BCD QW12
I0.5 A8.5 R T4
R BCD QW12 I0.5 R = L T4
Q
T MW0
LC T4
T QW12
A T4
= Q8.5

RLO at S

RLO at R

Timer
Operation
Example

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.12
Timers: Bit Instructions
LAD FBD STL

Network 1:
T4
I0.0 T4 I0.0 & SD A I0.0
SD L S5T#5s
S5T#5s TV SD T4
S5T#5s

Network 2:

T4 Q 8.0 Q 8.0
A T4
T4 & =
= Q 8.0

Network 3:
T4
I0.1 T4 A I0.1
R I0.1 & R R T4

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.13
T4
Exercise
S_PULSE
I 0.7
I 0.7 S BI
TV BCD I 0.5
S5T#5s
I 0.5 R Q Q 8.0 Q8.0
5s
T4
S_PEXT I 0.7
I 0.7 S BI I 0.5
S5T#5s TV BCD
I 0.5 R Q Q 8.0 Q8.0

T4
S_ODT I 0.7
I 0.7 S BI I 0.5
S5T#5s TV BCD
I 0.5 R Q Q 8.0 Q8.0

T4
S_ODTS I 0.7
I 0.7 S BI I 0.5
S5T#5s TV BCD
I 0.5 R Q Q 8.0 Q8.0

T4
S_OFFDT I 0.7
I 0.7 S BI I 0.5
S5T#5s TV BCD
I 0.5 R Q Q 8.0 Q8.0

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.14
S5 Counters in STEP 7
LAD FBD STL

A I0.4
C5 C5
CU C5
S_CUD S_CUD A I0.5
I 0.4 Q 8.3
CU Q
Q I 0.4 CU CD C5
A I0.3
I 0.5
L C#20
CD I 0.5 CD
S C5
I 0.3 A I0.7
S I 0.3 S CV MW 4 R C5
L C5
C#20 PV CV MW 4 C#20 PV CV_BCD QW 12 T MW4
I 0.7 Q 8.3 LC C5
R CV_BCD QW 12 I 0.7 R Q
Q = T QW12
A C5
= Q8.3

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.15
Counters: Bit Instructions
LAD FBD STL

Network 1: C5
I0.0 SC
I0.0 C5
A I0.0
SC L C#20
C#20 CV
C#20 S C5
Network 2:
C5
I0.1 C5
I0.1 CU A I0.1
CU
CU C5

Network 3:
I0.2 C5 C5
A I0.2
CD I0.2 CD CD C5

Network 4:
C5 Q 4.0 Q 4.0
A C5
C5 = = Q 4.0

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.16
Counters: Function Diagram

CU

CD

5
4
3
Count
2
1
0

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.17
Exercise: Program for a Bottling Plant
(Filling Cycle and Bottle Count)
Plant ON/OFF:
I 0.0 = Start (NO contact, mom-cont. switch)
I 0.1 = Stop (NC contact) Main
container
Manual/Automatic mode:
I 0.4 = Manual /Automatic
I 0.5 = Adopt mode
I 0.2 = Jog forwards
I 0.3 = Jog backwards Q 9.0 (Q 5.0) Bottle sensor
Filling funnel I 16.7 (I 8.7)
Bottle
sensor
Bottle sensor I 16.6 (I 8.6)
I 16.5 (I 8.5)

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_09E.18
Conversion Operations BCD <-> Integer

Number Conversion
entered in BCD 0 81 5 BCD->Integer
User program with
Task
integer math
operations
Number Conversion
displayed 0 2 4 8 BCD<-Integer
in BCD

LAD FBD STL

BCD_I BCD_I L IW4


EN ENO EN OUT MW20 BTI
T MW20
IW4 IN OUT MW20 IW4 IN ENO

I_BCD I_BCD L MW10


EN ENO EN OUT QW12 ITB
T QW12
MW10 IN OUT QW12 MW10 IN ENO

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.19
Conversion Operations I -> DI -> REAL

Data in integer format


(16 bits)

Conversion from Conversion from Math


Task integer to double integer program
double integer to real number with
real numbers

F AWL
I_DI
B MD14
EN OUT
D DI_R
ENO EN OUT MD26
MW12 IN L MW12
LAD ENO ITD
MD14 IN
DTR
T MD26
I_DI DI_R
EN ENO EN ENO

MW12 IN OUT MD14 MD14 IN OUT MD26

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.20
Comparison Operations

LAD FBD STL

M0.0 CMP ==I Q 9.7 CMP ==I A M0.0


A(
L IW0
IW0 IN1
L IW2
IW0 IN1
==I
IW2 IN2 IW2 IN2 )
&
Q9.7
= Q9.7
=
M0.0

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.21
Digital Logic Operations

WXOR_W L IW 0
WOR_W
L W#16#5F2A
WAND_W
AW / OW / XOW
EN ENO
T MW10
IW0 IN1
OUT MW10 15 0
W#16#5F2A IN2
IW0 = 0 1 0 0 0 0 0 0 0 0 1 1 0 0 1 0

W#16#5F2A = 0 1 0 1 1 1 1 1 0 0 1 0 1 0 1 0

AND OR XOR

MW10 after “AW” 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0

MW10 after “OW” 0 1 0 1 1 1 1 1 0 0 1 1 1 0 1 0

MW10 nach “XOW” 0 0 0 1 1 1 1 1 0 0 0 1 1 0 0 0

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.22
Basic Mathematical Functions
LAD FBD STL

ADD_I ADD_I L MW4


Addition EN ENO EN OUT MW6 L MW10
MW4 IN1 MW4 IN1 +I
MW10 IN2 OUT MW6 MW10 IN2 ENO T MW6

SUB_I SUB_I L MW5


Subtrac- MW7
tion EN ENO EN OUT L MW11
MW5 IN1 MW5 IN1 -I
T MW7
MW11 IN2 OUT MW7 MW11 IN2 ENO

MUL_R MUL_R L MD6


Multipli- MD66
cation EN ENO EN OUT L MD12
MD6 IN1 MD6 IN1 *R
MD12 IN2 MD66 MD12 IN2 ENO T MD66

DIV_R DIV_R L MD40


EN OUT MD32
Division EN ENO L MD4
MD40 IN1 MD40 IN1 /R
MD4 IN2 OUT MD32 MD4 IN2 ENO T MD32

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.23
Exercise: Program for a Bottling Plant (Production Data)

Empty bottles MW 100

Full bottles MW 102

"Broken" bottles MW 104

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.24
Exercise : Program for a Bottling Plant
(Number of Packaging Units)

(QW 6)

Program entered in LAD

Program converted to STL

Program entered in STL

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.25
Shift Operations (Word / Doubleword)

SHL_W

L MW8 or:
EN ENO
L MW4 L MW4
MW4 IN SLW SLW 2
OUT MW12 T MW12 T MW12
MW8 N
= +2

Shift Left Word: Shift Right Word:

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1
IN IN
EN0 =1 EN0 = 0

1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0
OUT OUT

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.26
Shift Right Signed Integer

SHR_I
L MW8 or:
EN EN0 L MW4 L MW4
SSI SSI 3
MW4 IN
T MW12 T MW12
MW8 N OUT MW12
= +3

Shift a Signed Integer to the Right:


15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 1
IN IN
EN0 = 0 EN0 = 1

1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1
OUT OUT

SIMATIC S7 Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.27
Doubleword Rotation Operations

ROL_DW

ENO L MW6 or:


EN
L MD2 L MD2
MD2 IN RLD RLD 4
OUT MD12 T MD12 T MD12
MW6 N
= +4

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

IN: 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1

Rotate 4 places
to the left :

OUT: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 1 1

SIMATIC S7 OUT Date: 27.12.20 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: SYH_09E.28

You might also like