Storing Process Data in Data Blocks
SIMATIC S7 Date: 13.12.24 Information and Training Center
Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_10E.1
Storage Areas for Data
Local data DBz
.
Bit Memories
DBy .
Counters .
DBx
Timers
Data block
SIMATIC S7 Date: 13.12.24 Information and Training Center
Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_10E.2
Data Blocks (DBs)
Accessible to all blocks
Function
OB1
FC10
Global (Shared)
DB20
Function
FC20
Instance DB for FB1
Function Instance Data
Block DB5
FB1
SIMATIC S7 Date: 13.12.24 Information and Training Center
Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_10E.3
Overview of Data Types in STEP 7
Elementary • Bit data types (BOOL, BYTE, WORD, DWORD, CHAR)
Data types
• Mathematical data types (INT, DINT, REAL)
(up to 32 Bits)
• Time types (S5TIME, TIME, DATE, TIME_OF_DAY)
• Time types (DATE_AND_TIME)
Complex
Data types • Array (ARRAY)
(longer than 32 Bit)
• Structure (STRUCT)
• Character chain (STRING)
User-defined data type
(longer than 32 Bit) Data type UDT (User Defined Type )
SIMATIC S7 Date: 13.12.24 Information and Training Center
Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_10E.4
Elementary Data types in STEP 7
Keyword Length (in bits) Example
BOOL 1 1 или 0
BYTE 8 B#16#A9
WORD 16 W#16#12AF
DWORD 32 DW#16#ADAC1EF5
CHAR 8 'w'
S5TIME 16 S5T#5s_200ms
INT 16 123
DINT 32 65539
REAL 32 1.2 или 34.5E-12
TIME 32 T#2D_1H_3M_45S_12MS
DATE 16 D#1993-01-20
TIME_OF_DAY 32 TOD#12:23:45.12
SIMATIC S7 Date: 13.12.24 Information and Training Center
Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_10E.5
Complex Data types
Keyword Length (in bit) Example
DATE_AND_TIME 64 DT#97-09-24-12:14:55.0
STRING 8 * (number of ´This is a string´
(character string with characters +2) ´SIEMENS´
Max. 254 сharacter)
ARRAY user-defined Measured values: ARRAY[1..20]
(Group of elements INT
of the same data types)
STRUCT user-defined Motor: STRUCT
(group of elements Speed : INT
of different data types) Current: REAL
END_STRUCT
UDT UDT as block UDT – as array
(User Defined Data Type = user-defined element
“Template", consisting of STRUCT Drive: ARRAY[1..4]
elementary or complex Speed : INT UDT1
data type Current: REAL
END_STRUCT
SIMATIC S7 Date: 13.12.24 Information and Training Center
Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_10E.6
Example of an ARRAY
Measuring_point
1. Measuring_point, data types Real
2. Measuring_point, Data types Real
Array with the name "Measuring_point"
3. Measuring_point, Data types Real (several elements of same data type)
•
•
•
10. Measuring_point, Data types Real
Display in the Program Editor (Data Block DB 2):
SIMATIC S7 Date: 13.12.24 Information and Training Center
Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_10E.7
Example of a STRUCTURE
Motor_data
Operating Speed, data type Integer
Rated Current,data type Real Structure with the name “motor_data”
(several elements with different data types)
Startup Current,data type Real
Turning Direction, data type Bool
Display in the Program Editor (Data Block DB1):
SIMATIC S7 Date: 13.12.24 Information and Training Center
Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_10E.8
Defining the Address Priority (Symbolic/Absolute)
SIMATIC S7 Date: 13.12.24 Information and Training Center
Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_10E.9
Creating a New Data Block
SIMATIC S7 Date: 13.12.24 Information and Training Center
Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_10E.10
Initial Value, Actual Value, Initialization, Retentivity
SIMATIC S7 Date: 13.12.24 Information and Training Center
Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_10E.11
Entering, Saving Downloading and Monitoring a Data Block
SIMATIC S7 Date: 13.12.24 Information and Training Center
Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_10E.12
Addressing Data Elements
8 Biтs
7 0
Data byte 0 DBB 0
Data byte 1 DBW 0
Data byte 2
DBD 0
Data byte 3
DBX 4.1
DBD 8188
DBW 8190
DBB 8191
SIMATIC S7 Date: 13.12.24 Information and Training Center
Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_10E.13
Accessing Data Elements
SIMATIC S7 Date: 13.12.24 Information and Training Center
Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_10E.14
Exercise 1: Data Block as HMI Interface (DB99)
SIMATIC S7 Date: 13.12.24 Information and Training Center
Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_10E.15
Exercise 1: Hints on Tag Management + Startup Block
SIMATIC S7 Date: 13.12.24 Information and Training Center
Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_10E.16