0% found this document useful (0 votes)
14 views30 pages

Double Integer Data Type in SIMATIC S7

1) The document discusses different number formats used in digital operations including binary coded decimal (BCD), integer, double integer, and real or floating-point numbers. 2) It provides examples of positive and negative numbers represented in 16-bit and 32-bit formats, and explains how integers, double integers, and real numbers are stored and represented. 3) Different number formats have distinct value ranges and are used for various arithmetic operations in industrial control systems for acquiring, processing, and outputting data from field devices and processes.

Uploaded by

thaibkpro
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views30 pages

Double Integer Data Type in SIMATIC S7

1) The document discusses different number formats used in digital operations including binary coded decimal (BCD), integer, double integer, and real or floating-point numbers. 2) It provides examples of positive and negative numbers represented in 16-bit and 32-bit formats, and explains how integers, double integers, and real numbers are stored and represented. 3) Different number formats have distinct value ranges and are used for various arithmetic operations in industrial control systems for acquiring, processing, and outputting data from field devices and processes.

Uploaded by

thaibkpro
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Digital Operations

F1

SIMATIC S7 Date: 04.03.2019


File: 06_.1
Acquiring, Processing and Outputting Data

Operating Thumbwheel
0248 buttons,
+ monitoring V

processes Potentiometer,
0 8 1 5 7-segment
display
Operator Panel

Control such as MPI


Processing
unit the values

DI/ AI/
DO AO

such as PROFIBUS

Process Field devices


controller

SIMATIC S7 Date: 04.03.2019


File: 06_.2
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 28 27 24 23 22
= = = = =
256+ 128 + 16+8+ 4 = 412
- (412 + 1) = - 413

SIMATIC S7 Date: 04.03.2019


File: 06_.3
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) • (2e-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: 04.03.2019


File: 06_.4
Integer (INT, 16-Bit Integer) Data Type
Value range -32,768 to +32,767 Arithmetic
(without sign: 0 to operations: such as + I, * I, <I,
65,535) ==I
Display Formats:
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

DEC: + 662 BIN.: 2# 0000001010010110 HEX: W#16#0 2 9 6


without
+29 sign
Sign +27 0

positive +24 6 x 16 = 6
numbers +22 9 x 161 = 144
+21 2 x 162 = 512
+ 662 662

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

DEC: - 662 BIN.: 2# 1111110101101010 HEX: W#16#F D6 A


-215 witho
+214 ut
Sign sign
+213
negative +212 10 x 160 =10
numbers +211 6 x 161 = 96
2
+210 +28 +26 13 x 16 = 3328
Representation as +25 +23 +21 15 x 163 = 61440
Twos complement - 662 64874

SIMATIC S7 Date: 04.03.2019


File: 06_.5
Double Integer (DINT, 32-Bit Integer) Data Type

Value range L# -2,147,483,648 to L#+2,147,483,647 Operations: such as + D, * D, <D, ==D


(without sign: 0 to 4,294,967,295)

Display Formats:
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
DEC: L# +540809 BIN.: 2# 00000000000010000100000010001001

Sign
positive
numbers

HEX: DW#16# 0 0 0 8 4 0 8 9
(without sign)

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

DEC: L# -540809 BIN.: 2# 11111111111101111011111101110111

Sign
negative
numbers

Representation as HEX: DW#16# F F F 7 B F 7 7


Twos complement
(without sign)

SIMATIC S7 Date: 04.03.2019


File: 06_.6
REAL (Floating-point Number, 32 Bit) Data Type

Value range -3.402823•10+38 to -1.175495•10-38 , 0.0, +1.175495•10-38 to +3.402823•10+38

Operations: such as + R, * R, <R, ==R


sin, acos, ln, exp, SQR

General format of a Real number = (Sign) • (1 + f) • (2e-127)

Example: 0.75

Sign of
Real no. e = Exponent (8 Bit) f = Mantissa (23 Bit)

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: 04.03.2019


File: 06_.7
The BCD Code for Inputting and Outputting Integers

Value range 16 Bit: - 999 to + 999 Conversion


32 Bit: -9999999 to + 9999999 operations: BTI, BTD, ITB,
DTB
(no arithmetic!)

0 2 9 6

16 Bit: BIN.: 2# 0 0 0 0 0 0 1 0 1 0 0 1 0 1 1 0

Sign (+) 2 9 6

HEX: W#16# 0 2 9 6 DEC: + 662


32 Bit: Sign (+) 0 0 0 0 2 9 6

BIN.: 2# 0 x x x 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

HEX: DW#16# 0 0 0 0 2 9 6 DEC: + 662

SIMATIC S7 Date: 04.03.2019


File: 06_.8
"Monitor / Modify Variables": Display Formats

Accessed in between Invalid value !!!

SIMATIC S7 Date: 04.03.2019


File: 06_.9
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: 04.03.2019


File: 06_.10
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: 04.03.2019


File: 06_.11
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: 04.03.2019


File: 06_.12
Time Formats for Traditional S5-Timers in STEP 7

Time specifications as constants


S5T#35s200ms
(Time base: 01 (100ms), Number of units of time: 352)

01 3 5 2

Time specifications per variable X X 0 1 0 0 1 1 0 1 0 1 0 0 1 0

Time base Units of time (BCD-coded)

29 28 27 26 25 24 23 22 21 20
Accu 1 contents after “L T...” exec. X X X X X X 0 1 0 1 1 0 0 0 0 0

Residual units of time (Integer)

01 3 5 2

Accu 1 cont. after “LC T...” exec. X X 0 1 0 0 1 1 0 1 0 1 0 0 1 0

Time base Residual units of time (BCD-coded)

SIMATIC S7 Date: 04.03.2019


File: 06_.13
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 TV BI MW0 S5T#35s QW12
SD T4
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: 04.03.2019


File: 06_.14
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: 04.03.2019


File: 06_.15
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: 04.03.2019


File: 06_.16
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 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: 04.03.2019


File: 06_.17
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: 04.03.2019


File: 06_.18
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: 04.03.2019


File: 06_.19
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
Q 8.3 LC C5
I 0.7
R CV_BCD QW 12 I 0.7 R Q
Q = T QW12
A C5
= Q8.3

SIMATIC S7 Date: 04.03.2019


File: 06_.20
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: 04.03.2019


File: 06_.21
Counters: Function Diagram

CU

CD

5
4
3
Count
2
1
0

SIMATIC S7 Date: 04.03.2019


File: 06_.22
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: 04.03.2019


File: 06_.23
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: 04.03.2019


File: 06_.24
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: 04.03.2019


File: 06_.25
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: 04.03.2019


File: 06_.26
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
MW11 OUT MW7 IN2 ENO
T MW7
IN2 MW11

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: 04.03.2019


File: 06_.27
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: 04.03.2019


File: 06_.28
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: 04.03.2019


File: 06_.29
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: 04.03.2019


File: 06_.30

You might also like