18
Date: 12.05.22 File: PRO1_10E.1 SIMATIC S7 Siemens AG 1999. All rights reserved. Information and Training Center Knowledge for Automation Data Storage in Data Blocks

10 Data Storage in Data Blocks

Embed Size (px)

DESCRIPTION

Data Storage in Data Blocks in plc

Citation preview

Page 1: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.1

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge for Automation

Data Storage in Data Blocks

Page 2: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.2

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge for Automation

Bit memories

PIQ

PII

Storage Areas for Data

Data blocks

DBx

DBy

DBz

. . .

I/O area

L stack

Page 3: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.3

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge for Automation

Data Blocks (DBs)

FunctionFC10

FunctionFC20

FunctionblockFB1

OB1Global data

DB20

Accessible to all blocks

Instance data

DB5

Instance DB for FB1

Page 4: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.4

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge for Automation

Overview of Data Types in STEP 7

Elementarydata types(up to 32 bits)

Complexdata 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)

Page 5: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.5

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge for Automation

Elementary Data Types in STEP 7

BOOL 1 1 or 0BYTE 8 B#16#A9WORD 16 W#16#12AFDWORD 32 DW#16#ADAC1EF5CHAR 8 ' w '

S5TIME 16 S5T#5s_200ms

INT 16 123DINT 32 65539REAL 32 1.2 or 34.5E-12

TIME 32 T#2D_1H_3M_45S_12MSDATE 16 D#1993-01-20TIME_OF_DAY 32 TOD#12:23:45.12

Keyword Length (in bits) Example of a constant of this type

Page 6: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.6

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge for Automation

Complex Data TypesKeyword 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 : INTof 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

Page 7: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.7

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge 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 elementswith different data types)

Motor_data

Page 8: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.8

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge 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 elementsof the same data type) •

••

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

Measuring_point

Page 9: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.9

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge for Automation

Creating a New Data Block

Page 10: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.10

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge for Automation

Entering, Saving, Downloading and Monitoring a Data Block

Page 11: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.11

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge for Automation

Addressing Data Elements

078 Bits

Data Byte 0 DBB 0

Data Byte 1 DBW 0

Data Byte 8191

DBD 8188

DBW 8190DBB 8191

Data Byte 2 DBD 0

Data Byte 3

DBX 4.1

Page 12: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.12

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge for Automation

Accessing Data Elements

0123456789

DB 19 (Symbol name: Values)

Data bit 0.0 with theelement 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

TraditionalAccess

symbolic

Fully-qualified Access

1)

OPN DB19L DBW2

Number

OPN DB19A DBX 0.01)

OPN DB19L DBB5

Loop

absolute

Page 13: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.13

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge for Automation

Validity of an Open DB

OB 1

OPN DB 4L DBW2 DB 4

T DBW 2 DB 4

FC 1

DB 4

CALL FC 1

T DBW 4

DB 5OPN DB 5L DBB6

DB 5L DBW 0

T DBW 8

CALL FC 2

FC 2

DB 5

DB 6

OPN DB 6

L DBB6

DB 2T DB2.DBB 0

DB 2L DBW 4

L DBW 10 DB ??

FB 1

CALL FB1, DB1

???!

Page 14: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.14

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge 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

Recipe3

Flour

Milk

Eggs

Yeast

Sugar

Flour

Milk

Eggs

Yeast

Sugar

DB created according to UDT

Recipe1

Flour

Milk

Eggs

Yeast

Sugar

Array with3 elementsof type UDT

Page 15: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.15

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge for Automation

Entering a UDT Block

Page 16: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.16

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge for Automation

Creating a Data Block Referencing a Data Type

Page 17: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.17

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge for Automation

Example: Array of UDTs

Declaration View

Data View

Page 18: 10 Data Storage in Data Blocks

Date: 28.04.23File: PRO1_10E.18

SIMATIC S7Siemens AG 1999. All rights reserved.

Information and Training CenterKnowledge 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