Data Blocks SIMATIC S7 Siemens AG 2006. All rights reserved. Date: File: 2/8/2012 PRO1_10E.1 SITRAIN Training for Automation and Industrial Solutions Objectives Upon completion of this chapter the participant will ... SIMATIC S7 Siemens AG 2006. All rights reserved. ... understand the purpose of global data blocks ... be familiar with elementary and complex data types ... be able to monitor a data block ... be familiar with the possibilities for addressing data block variables Date: File: 2/8/2012 PRO1_10E.2 SITRAIN Training for Automation and Industrial Solutions Data Blocks (DBs) Accessible to all blocks OB1 Function FC10 Function FC20 Global (shared) data DB20 Instance DB for FB1 Function Block FB1 SIMATIC S7 Siemens AG 2006. All rights reserved. Date: File: 2/8/2012 PRO1_10E.3 Instance data DB5 SITRAIN Training for Automation and Industrial Solutions Overview of Data Types in STEP 7 Elementary data types (up to 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 type (DATE_AND_TIME) Complex data types (longer than 32 bits) • Array (ARRAY) • Structure (STRUCT) • Character chain (STRING) User-defined data types (longer than 32 bits) SIMATIC S7 Siemens AG 2006. All rights reserved. UDT data type (User Defined Data Type) Date: File: 2/8/2012 PRO1_10E.4 SITRAIN Training for Automation and Industrial Solutions Elementary Data Types in STEP 7 Keyword Length (in bits) BOOL 1 BYTE 8 Constants Variables 1 or 0 I 1.0 B#16#A9 MB70 WORD 16 W#16#12AF MW72 DWORD 32 QD40 DW#16#ADAC1EF5 CHAR 8 'w' DBB4 S5TIME 16 S5T#5s_200ms MW30 INT 16 DINT 32 123 #Value L#65539 MD80 REAL SIMATIC S7 Siemens AG 2006. All rights reserved. 32 1.2 or 34.5E-12 Date: File: DBD60 2/8/2012 PRO1_10E.5 SITRAIN Training for Automation and Industrial Solutions Complex Data Types Keyword Length (in bits) Example DATE_AND_TIME 64 DT#01-08-24-12:14:55:234-1 STRING (character string with max. 254 characters) 8 * (number of ´This is a string´ characters +2) ´SIEMENS´ ARRAY (Group of elements of the same data type) userdefined Measured values: ARRAY[1..20] INT STRUCT (Group of elements of different data types) userdefined Motor: STRUCT Speed : INT Current : REAL END_STRUCT UDT UDT as block (User Defined Data Type = user- "Template" consisting of defined STRUCT Speed elementary or complex data types SIMATIC S7 Siemens AG 2006. All rights reserved. UDT as array element Date: File: : INT Current : REAL UDT1 END_STRUCT 2/8/2012 PRO1_10E.6 Drive: ARRAY[1..4] SITRAIN Training for Automation and Industrial Solutions Creating a Data Block SIMATIC S7 Siemens AG 2006. All rights reserved. Date: File: 2/8/2012 PRO1_10E.7 SITRAIN Training for Automation and Industrial Solutions Entering, Saving, Downloading and Monitoring a Data Block Declaration View Data View SIMATIC S7 Siemens AG 2006. All rights reserved. Date: File: 2/8/2012 PRO1_10E.8 SITRAIN Training for Automation and Industrial Solutions Initial Value, Actual Value, Initialization, Retentivity Load Memory Work Memory DB DB Initial values + Actual values DB (with data types) Actual values CPU with STEP 7 Program Upload in PG Initial values Initialize data block + Actual values DB is retentive until the next transmission PG CPU With every CPU startup (i.e. with every STOP-RUN transition) the DB data are reset to the initial loading state SIMATIC S7 Siemens AG 2006. All rights reserved. Date: File: 2/8/2012 PRO1_10E.9 x SITRAIN Training for Automation and Industrial Solutions Addressing Data Elements 8 Bits 7 0 Data Byte 0 DBB 0 Data Byte 1 DBW 0 Data Byte 2 DBD 0 Data Byte 3 DBX 4.1 DBD 2000 DBW 2002 DBB 2003 SIMATIC S7 Siemens AG 2006. All rights reserved. Date: File: 2/8/2012 PRO1_10E.10 SITRAIN Training for Automation and Industrial Solutions Accessing Data Elements DB 18 "Parts" Addr. Name Type 0.0 Act_Quantity INT 2.0 FL_Aux BOOL 4.0 Number INT 6.0 10.0 Weight[1] Weight[2] SIMATIC S7 Siemens AG 2006. All rights reserved. Traditional Access Fully-qualified Access absolute symbolic OPN "Parts" L DBW0 or L DB18.DBW0 or L "Parts".ACT_ Quantity OPN DB 18 A DBX2.0 or A DB18.DBX2.0 or A "Parts".FL_Aux REAL REAL OPN "Parts" T DBW 4 or T DB18.DBW4 or T "Parts".Number OPN L or L DB18.DBD10 or L "Parts".Weight[2] DB 18 DBD 10 Date: File: 2/8/2012 PRO1_10E.11 SITRAIN Training for Automation and Industrial Solutions Exercise 1: Replacing Bit Memory Variables with DB Variables SIMATIC S7 Siemens AG 2006. All rights reserved. Date: File: 2/8/2012 PRO1_10E.12 SITRAIN Training for Automation and Industrial Solutions Exercise 2: Connecting WinCC flexible Tags to DB Variables Tags in WinCC flexible SIMATIC S7 Siemens AG 2006. All rights reserved. Variables in STEP7 Date: File: 2/8/2012 PRO1_10E.13 SITRAIN Training for Automation and Industrial Solutions If You Want to Know More SIMATIC S7 Siemens AG 2006. All rights reserved. Date: File: 2/8/2012 PRO1_10E.14 SITRAIN Training for Automation and Industrial Solutions Example of an ARRAY 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) Display in the Program Editor (Data Block DB 2): SIMATIC S7 Siemens AG 2006. All rights reserved. Date: File: 2/8/2012 PRO1_10E.15 SITRAIN Training for Automation and Industrial Solutions Example of a STRUCTURE Motor_data Speed, data type Integer Structure with the name "Motor_data" (several elements with different data types) Rated_current, data type Real Starting_current, data type Real Direction, data type Bool Display in the Program Editor (Data block DB 1): SIMATIC S7 Siemens AG 2006. All rights reserved. Date: File: 2/8/2012 PRO1_10E.16 SITRAIN Training for Automation and Industrial Solutions Defining the Address Priority (Symbolic/Absolute) SIMATIC S7 Siemens AG 2006. All rights reserved. Date: File: 2/8/2012 PRO1_10E.17 SITRAIN Training for Automation and Industrial Solutions