You are on page 1of 13

Date: 10.05.

2012
File: PRO1_09E.1
SIMATIC S7
Siemens AG 2000. All rights reserved.
SITRAINTraining for
Automation and Drives
Data Storage in Data Blocks
Date: 10.05.2012
File: PRO1_09E.2
SIMATIC S7
Siemens AG 2000. All rights reserved.
SITRAINTraining for
Automation and Drives
Bit memories
PIQ
PII
Storage Areas for Data
Data blocks
DBx
DBy
DBz
.
.
.
I/O area
L stack
Date: 10.05.2012
File: PRO1_09E.3
SIMATIC S7
Siemens AG 2000. All rights reserved.
SITRAINTraining for
Automation and Drives
Data Blocks (DBs)
Function
FC10
Function
FC20
Function
block
FB1
OB1
Global data
DB20
Accessible to all blocks
Instance data
DB5
Instance DB for FB1
Date: 10.05.2012
File: PRO1_09E.4
SIMATIC S7
Siemens AG 2000. All rights reserved.
SITRAINTraining for
Automation and Drives
Overview of Data Types in STEP 7
Elementary
data types
(up to 32 bits)
Complex
data types
(longer than 32 bits)
User-defined data types
(longer than 32 bits)
Bit data types (BOOL, BYTE, WORD, DWORD, CHAR)
Mathematical data types (INT, DINT, REAL)
Time types (S5TIME, TIME, DATE, TIME_OF_DAY)
Time (DATE_AND_TIME)
Array (ARRAY)
Structure (STRUCT)
Character chain (STRING)
Data type UDT (User Defined Type)
Date: 10.05.2012
File: PRO1_09E.5
SIMATIC S7
Siemens AG 2000. All rights reserved.
SITRAINTraining for
Automation and Drives
Elementary Data Types in STEP 7
BOOL 1 1 or 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 or 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
Keyword Length (in bits) Example of a constant of this type
Date: 10.05.2012
File: PRO1_09E.6
SIMATIC S7
Siemens AG 2000. All rights reserved.
SITRAINTraining for
Automation and Drives
Creating a New Data Block
Date: 10.05.2012
File: PRO1_09E.7
SIMATIC S7
Siemens AG 2000. All rights reserved.
SITRAINTraining for
Automation and Drives
Entering, Saving, Downloading and Monitoring a Data Block
Date: 10.05.2012
File: PRO1_09E.8
SIMATIC S7
Siemens AG 2000. All rights reserved.
SITRAINTraining for
Automation and Drives
Addressing Data Elements
0 7
8 Bits
Data Byte 0 DBB 0
Data Byte 1
DBW 0
Data Byte 8191
DBD 8188
DBW 8190
DBB 8191
Data Byte 2
DBD 0
Data Byte 3
DBX 4.1
Date: 10.05.2012
File: PRO1_09E.9
SIMATIC S7
Siemens AG 2000. All rights reserved.
SITRAINTraining for
Automation and Drives
Accessing Data Elements
DB 19 "Values"
Traditional
Access
Fully-qualified Access
or L DB99.DBB1 or L "Values".States
or A DB99.DBX0.0 or A "Values".Status
or L DB99.DBW2 or L "Values".Number
or L DB99.DBD8 or L "Values".Weight[1]
absolute symbolic
OPN DB 99
L DBB 1
1.0 States BYTE
OPN "Values"
A DBX 0.0
0.0 Status BOOL
OPN "Values"
T DBW 2
2.0 Number INT
4.0 Weight[1]REAL
OPN DB 99
L DBD 8
8.0 Weight[2]REAL
Add. Name Type
Date: 10.05.2012
File: PRO1_09E.10
SIMATIC S7
Siemens AG 2000. All rights reserved.
SITRAINTraining for
Automation and Drives
Exercise: Counting the Transported Parts (FC 18)
Date: 10.05.2012
File: PRO1_09E.11
SIMATIC S7
Siemens AG 2000. All rights reserved.
SITRAINTraining for
Automation and Drives
Complex Data Types
Keyword Length (in bits) 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 characters)
ARRAY user-defined Measured values: ARRAY[1..20]
(Group of elements INT
of the same data type)
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 element
(User Defined Data Type = user-defined
Template" consisting of STRUCT Drive: ARRAY[1..4]
elementary or complex Speed : INT UDT1
data types Current: REAL
END_STRUCT
Date: 10.05.2012
File: PRO1_09E.12
SIMATIC S7
Siemens AG 2000. All rights reserved.
SITRAINTraining for
Automation and Drives
Example of an Array
Display in the Program Editor (Data block DB 2):
Measuring_point
1. Measuring_point, data type Real
2. Measuring_point, data type Real
3. Measuring_point, data type Real
10. Measuring_point, data type Real
Array with the name "Measuring_point"
(several elements
of the same data type)

Date: 10.05.2012
File: PRO1_09E.13
SIMATIC S7
Siemens AG 2000. All rights reserved.
SITRAINTraining for
Automation and Drives
Example of a Structure
Display in the Program Editor (Data block DB 1):
Motor_data
Operating Speed, data type Integer
Rated Current, data type Real
Startup Current, data type Real
Turning Direction, data type Bool
Structure with the name "Motor_data"
(several elements
with different data types)

You might also like