background image

Date:

01.02.11

File:

PRO1_10E.1

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

Data Storage in Data Blocks

background image

Date:

01.02.11

File:

PRO1_10E.2

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

Bit memories

PIQ

PII

Storage Areas for Data

Data blocks

DBx

DBy

DBz

..

.

I/O area

L stack

background image

Date:

01.02.11

File:

PRO1_10E.3

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

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

background image

Date:

01.02.11

File:

PRO1_10E.4

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

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)

background image

Date:

01.02.11

File:

PRO1_10E.5

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

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

background image

Date:

01.02.11

File:

PRO1_10E.6

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

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 

background image

Date:

01.02.11

File:

PRO1_10E.7

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

Example of a Structure

Display in the Program Editor (Data block DB 1):

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) 

Motor_data

background image

Date:

01.02.11

File:

PRO1_10E.8

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

Example of an Array

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) 

Display in the Program Editor (Data block DB 2):

Measuring_point

background image

Date:

01.02.11

File:

PRO1_10E.9

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

Creating a New Data Block

background image

Date:

01.02.11

File:

PRO1_10E.10

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

Entering, Saving, Downloading and Monitoring a Data 

Block

background image

Date:

01.02.11

File:

PRO1_10E.11

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

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

background image

Date:

01.02.11

File:

PRO1_10E.12

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

Accessing Data Elements

0
1
2
3
4
5
6
7
8
9

DB 19 

(Symbol name: Values)

Data bit 0.0 with the

element name "Start"

or

 

A DB19.DBX0.0

or

 

A “Values".Start

or

 

L DB19.DBW2

or

  L “Values".Number

or

 

L DB19.DBB5

or

 

L “Values".Loop

Traditional

Access

symbolic

Fully-qualified Access

1)

OPN DB19

L DBW2

Number

OPN DB19

A DBX 0.0

1)

OPN DB19

L DBB5

Loop

absolute

background image

Date:

01.02.11

File:

PRO1_10E.13

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

Validity of an Open DB

OB 1

OPN DB 4

L

DBW2

DB 4

T

DBW 2

DB 4

FC 1

DB 4

CALL FC 1

T

DBW 4

DB 5

OPN DB 5

L

DBB6

DB 5

L

DBW 0

T

DBW 8

CALL FC 2

FC 2

DB 5

DB 6

OPN DB 6

L

DBB6

DB 2

T   DB2.DBB 0

DB 2

L

DBW 4

L

DBW 10 DB ??

FB 1

CALL FB1, DB1

???

!

background image

Date:

01.02.11

File:

PRO1_10E.14

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

Global DB (Example)

UDT block as Template

User-Defined Data Type (UDT)

Flour
Milk

Eggs

Yeast

Sugar

Recipe 

2

Flour
Milk

Eggs

Yeast

Sugar

Recipe

3

Flour
Milk

Eggs

Yeast

Sugar

Flour
Milk

Eggs

Yeast

Sugar

DB created according to UDT

Recipe

1

Flour
Milk

Eggs

Yeast

Sugar

Array with

3 elements

of type UDT

background image

Date:

01.02.11

File:

PRO1_10E.15

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

Entering a UDT Block

background image

Date:

01.02.11

File:

PRO1_10E.16

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

Creating a Data Block Referencing a Data Type

background image

Date:

01.02.11

File:

PRO1_10E.17

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

Example: Array of UDTs

Declaration View

Data View

background image

Date:

01.02.11

File:

PRO1_10E.18

SIMATIC S7

Siemens AG 1999. All rights reserved.

Information and Training Center

Knowledge for Automation

Exercise: Program for a Bottling Plant - Data Storage

Full bottles (MW102)

Empty bottles (MW 100)

"Broken" bottles (MW 104)

Data block DB5

Variable: full

Variable: empty

Variable: broken


Document Outline