《數(shù)據(jù)塊中數(shù)據(jù)存儲》由會員分享,可在線閱讀,更多相關《數(shù)據(jù)塊中數(shù)據(jù)存儲(16頁珍藏版)》請在裝配圖網上搜索。
1、Date: 22.10.2021 File: DBs.1 SIMATIC S7 Siemens AG 2003. All rights reserved. SITRAIN Training for Automation and Drives 數(shù)據(jù)塊中的數(shù)據(jù)存儲數(shù)據(jù)塊中的數(shù)據(jù)存儲 Date: 22.10.2021 File: DBs.2 SIMATIC S7 Siemens AG 2003. All rights reserved. SITRAIN Training for Automation and Drives 目標 學習了本章之后,你將學習了本章之后,你將 . . 懂得全局數(shù)據(jù)塊的用途
2、. 熟悉基本和復雜數(shù)據(jù)類型 . 能夠對帶有單元變量的數(shù)據(jù)塊編輯、存儲和下裝到CPU . 熟悉并能夠應用編址數(shù)據(jù)塊變量 Date: 22.10.2021 File: DBs.3 SIMATIC S7 Siemens AG 2003. All rights reserved. SITRAIN Training for Automation and Drives 位存儲器位存儲器 PIQ PII 數(shù)據(jù)存儲區(qū)數(shù)據(jù)存儲區(qū) 數(shù)據(jù)塊數(shù)據(jù)塊 DBx DBy DBz . . . I/O 區(qū)區(qū) L 堆棧堆棧 Date: 22.10.2021 File: DBs.4 SIMATIC S7 Siemens AG 20
3、03. All rights reserved. SITRAIN Training for Automation and Drives 數(shù)據(jù)塊數(shù)據(jù)塊 (DB) 功能功能 FC10 功能功能 FC20 功能塊功能塊 FB1 OB1 全局數(shù)據(jù)全局數(shù)據(jù) DB20 所有塊可以訪問所有塊可以訪問 背景數(shù)據(jù)背景數(shù)據(jù) DB5 FB1的背景的背景DB Date: 22.10.2021 File: DBs.5 SIMATIC S7 Siemens AG 2003. All rights reserved. SITRAIN Training for Automation and Drives STEP 7數(shù)據(jù)類型
4、概述數(shù)據(jù)類型概述 基本數(shù)據(jù) 類型 (到32 位) 復雜數(shù)據(jù) 類型 (長于32位) 用戶定義數(shù)據(jù)類型 (長于 32 位) 位數(shù)據(jù)類型位數(shù)據(jù)類型 (BOOL, BYTE, WORD, DWORD, CHAR) 數(shù)學數(shù)據(jù)類型數(shù)學數(shù)據(jù)類型 (INT, DINT, REAL) 定時器類型定時器類型 (S5TIME, TIME, DATE, TIME_OF_DAY) 時間時間 (DATE_AND_TIME) 矩陣矩陣 (ARRAY) 結構結構 (STRUCT) 字符串字符串 (STRING) 數(shù)據(jù)類型數(shù)據(jù)類型 UDT (用戶定義數(shù)據(jù)類型) Date: 22.10.2021 File: DBs.6 SIMA
5、TIC S7 Siemens AG 2003. All rights reserved. SITRAIN Training for Automation and Drives STEP 7基本數(shù)據(jù)類型基本數(shù)據(jù)類型 BOOL 1 True 或 False (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 L#65539 REAL 32 1.2 或 34.5E-12 TIME 32 T#2D_1H_3M_45S_12MS
6、 關鍵字關鍵字 長度長度 (位位) 該類型的常數(shù)舉例該類型的常數(shù)舉例 Date: 22.10.2021 File: DBs.7 SIMATIC S7 Siemens AG 2003. All rights reserved. SITRAIN Training for Automation and Drives 建立新數(shù)據(jù)塊建立新數(shù)據(jù)塊 Date: 22.10.2021 File: DBs.8 SIMATIC S7 Siemens AG 2003. All rights reserved. SITRAIN Training for Automation and Drives 輸入、保存、下載和監(jiān)
7、視數(shù)據(jù)塊輸入、保存、下載和監(jiān)視數(shù)據(jù)塊 Declaration View Data View Date: 22.10.2021 File: DBs.9 SIMATIC S7 Siemens AG 2003. All rights reserved. SITRAIN Training for Automation and Drives 尋址數(shù)據(jù)單元尋址數(shù)據(jù)單元 0 7 8 位 數(shù)據(jù)字節(jié) 0 DBB 0 數(shù)據(jù)字節(jié) 1 DBW 0 數(shù)據(jù)字節(jié) 8191 DBD 8188 DBW 8190 DBB 8191 數(shù)據(jù)字節(jié) 2 DBD 0 數(shù)據(jù)字節(jié) 3 DBX 4.1 Date: 22.10.2021 File
8、: DBs.10 SIMATIC S7 Siemens AG 2003. All rights reserved. SITRAIN Training for Automation and Drives 訪問數(shù)據(jù)單元訪問數(shù)據(jù)單元 DB 99 Values 傳統(tǒng)訪問方法 完全表示訪問 或 L DB99.DBB1 或 L Values.States 或 A DB99.DBX0.0 或 A Values.Status 或 T DB99.DBW2 或 T Values.Number 或 L DB99.DBD8 或 L Values.Weight2 絕對尋址 符號尋址 OPN DB 99 L DBB 1
9、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 Weight1REAL OPN DB 99 L DBD 8 8.0 Weight2REAL Add. Name Type Date: 22.10.2021 File: DBs.11 SIMATIC S7 Siemens AG 2003. All rights reserved. SITRAIN Training for Automation and Drives 練習練習: 計數(shù)傳送的零件計數(shù)傳送的零件 (FC 1
10、8, DB 18): 0 8 1 5 QW 6 ACTUAL-number of parts SETPOINT-number of parts IW 2 Q 8.4 模擬器模擬器 CPU 程序程序: DB 18, FC 18 傳送帶模型傳送帶模型 - LED ACTUAL=SETPOINT Date: 22.10.2021 File: DBs.12 SIMATIC S7 Siemens AG 2003. All rights reserved. SITRAIN Training for Automation and Drives 練習練習: 計數(shù)傳送的零件計數(shù)傳送的零件(FC 18), 答案提
11、示答案提示 NW 2: Counting using memory word, ACTUAL number of parts NW 1: Set counter to 0 MOVE EN IN OUT ENO 復位的條件 0 DB_Parts.ACT_Number_of_parts NW 4: Readin SETPOINT number of parts and convert from BCD to Integer 來自數(shù)碼撥輪 ( IW 2)的值從 BCD 轉換到整數(shù) - 把零件的給定值 (Integer)存儲在 MW 200 NW 5: ACTUAL-SETPOINT comparis
12、on, LED (red LED Q8.4) 比較實際值 (“DB_Parts”.ACT_Number_of_parts)和給定值(MW 200),比較的結果送到紅色的LED NW 3: Display ACTUAL number of parts on BCD digital display 零件的實際值(DB_Parts.ACT_Number_of_parts)從整數(shù)到BCD轉換 -結果在 BCD 數(shù)字顯示 ( QW 6) ADD_I EN IN1 IN2 OUT ENO 計數(shù)事件的上升沿 1 DB_Parts.ACT_Number_of_parts DB_Parts.ACT_Number
13、_of_parts Date: 22.10.2021 File: DBs.13 SIMATIC S7 Siemens AG 2003. All rights reserved. SITRAIN Training for Automation and Drives 復雜數(shù)據(jù)類型復雜數(shù)據(jù)類型 關鍵字關鍵字 長度長度 (位位) 舉例舉例 DATE_AND_TIME 64 DT#97-09-24-12:14:55.0 STRING 8 * (字符個數(shù)+2 ) This is a string (最多254個字符的字符串) SIEMENS ARRAY 用戶定義 Measured values : ARR
14、AY1.20 (相同數(shù)據(jù)類型的元素組) INT STRUCT 用戶定義 Motor: STRUCT (不同數(shù)據(jù)類型的元素組) Speed : INT Current: REAL END_STRUCT UDT UDT 作為塊 UDT作為array 元素 (用戶定義數(shù)據(jù)類型 = 用戶定義 基本或復雜數(shù)據(jù)類型 STRUCT Drive: ARRAY1.4 組成的模板) Speed : INT UDT1 Current: REAL END_STRUCT Date: 22.10.2021 File: DBs.14 SIMATIC S7 Siemens AG 2003. All rights reserv
15、ed. SITRAIN Training for Automation and Drives 矩陣舉例矩陣舉例 程序編輯器中的顯示程序編輯器中的顯示 (數(shù)據(jù)塊數(shù)據(jù)塊 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 帶有名字“Measuring_point” 的矩陣 (相同數(shù)據(jù)類型的幾個元素) Date: 22.10.2
16、021 File: DBs.15 SIMATIC S7 Siemens AG 2003. All rights reserved. SITRAIN Training for Automation and Drives 結構舉例結構舉例 程序編輯器中的顯示程序編輯器中的顯示 (數(shù)據(jù)塊數(shù)據(jù)塊 DB 1): Motor_data Speed, data type Integer Rated_current, data type Real Starting_current, data type Real Direction, data type Bool 帶有名字“Motor_data” 的結構 (不同數(shù)據(jù)類型的幾個元素) Date: 22.10.2021 File: DBs.16 SIMATIC S7 Siemens AG 2003. All rights reserved. SITRAIN Training for Automation and Drives 練習(選作): 數(shù)據(jù)塊和數(shù)據(jù)格式 IB1 DB10. DBW2 DB11. DBW8 BIN BCD QW6 DB11. DBW10 BIN BCD QW6 IB2 MW2 BCD BIN MW4 IB3 MW6 BCD BIN MW8 I0.7=“0” : BEC : BE