Date,2009-7-30
File,SSP1_12C.1
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
数据块中的数据存储
Date,2009-7-30
File,SSP1_12C.2
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
位存储器
PIQ
PII
数据存储区数据块
DBx
DBy
DBz
.,
.
I/O 区
L 堆栈
Date,2009-7-30
File,SSP1_12C.3
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
数据块 (DB)
功能
FC10
功能
FC20
功能块
FB1
OB1
全局数据
DB20
所有块可以访问背景数据
DB5
FB1的背景 DB
Date,2009-7-30
File,SSP1_12C.4
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
STEP 7数据类型概述基本数据类型
(到 32 位 )
复杂数据类型
(长于 32位 )
用户定义数据类型
(长于 32 位 )
位数据类型 (BOOL,BYTE,WORD,DWORD,CHAR)
数学数据类型 (INT,DINT,REAL)
定时器类型 (S5TIME,TIME,DATE,TIME_OF_DAY)
时间 (DATE_AND_TIME)
矩阵 (ARRAY)
结构 (STRUCT)
字符串 (STRING)
数据类型 UDT (用户定义数据类型 )
Date,2009-7-30
File,SSP1_12C.5
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
STEP 7基本数据类型
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
DATE 16 D#1993-01-20
TIME_OF_DAY 32 TOD#12:23:45.12
关键字 长度 (位 ) 该类型的常数举例
Date,2009-7-30
File,SSP1_12C.6
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
复杂数据类型关键字 长度 (位 ) 举例
DATE_AND_TIME 64 DT#97-09-24-12:14:55.0
STRING 8 * (字符个数 +2 ) ′This is a string′
(最多 254个字符的字符串 ) ′SIEMENS′
ARRAY 用户定义 测量值,ARRAY[1..20]
(相同数据类型的元素组 ) INT
STRUCT 用户定义 Motor,STRUCT
(不同数据类型的元素组 ) Speed,INT
Current,REAL
END_STRUCT
UDT UDT as block UDT as array element
(用户定义数据类型 = 用户定义基本或复杂数据类型组成的 STRUCT Drive,ARRAY[1..4]
模板) Speed,INT UDT1
Current,REAL
END_STRUCT
Date,2009-7-30
File,SSP1_12C.7
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
结构举例程序编辑器中的显示 (数据块 DB 1):
Operating Speed,data type Integer
Rated Current,data type Real
Startup Current,data type Real
Turning Direction,data type Bool
带有名字,Motor_data” 的结构
(不同数据类型的几个元素 )
Motor_data
Date,2009-7-30
File,SSP1_12C.8
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
矩阵举例
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” 的矩阵
(相同数据类型的几个元素 )
程序编辑器中的显示 (数据块 DB 2):
Measuring_point
Date,2009-7-30
File,SSP1_12C.9
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
建立新数据块
Date,2009-7-30
File,SSP1_12C.10
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
输入、保存、下载和监视数据块
Date,2009-7-30
File,SSP1_12C.11
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
寻址数据单元
07
8 位数据字节 0 DBB 0
数据字节 1 DBW 0
数据字节 8191
DBD 8188
DBW 8190
DBB 8191
数据字节 2 DBD 0
数据字节 3
DBX 4.1
Date,2009-7-30
File,SSP1_12C.12
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
访问数据单元
0
1
2
3
4
5
6
7
8
9
DB 19
(符号名,Values)
带有元素名字,Start” 的 数据位 0.0
或 A DB19.DBX0.0 或 A,Values”.Start
或 L DB19.DBW2 或 L,Values”.Number
或 L DB19.DBB5 或 L,Values”.Loop
传统访问方法符号寻址完全表示访问
1)
OPN DB19
L DBW2Number
OPN DB19
A DBX 0.01)
OPN DB19
L DBB5
Loop
绝对寻址
Date,2009-7-30
File,SSP1_12C.13
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
打开数据块的合法性
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 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
!
Date,2009-7-30
File,SSP1_12C.14
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
全局 DB (例如 )UDT 块作为模板用户定义数据类型 (UDT)
Flour
Milk
Eggs
Yeast
Sugar
配方
2
Flour
Milk
Eggs
Yeast
Sugar
配方
3
Flour
Milk
Eggs
Yeast
Sugar
Flour
Milk
Eggs
Yeast
Sugar
根据 UDT建立的 DB
配方
1
Flour
Milk
Eggs
Yeast
Sugar
带有三个 UDT
类型的元素
Date,2009-7-30
File,SSP1_12C.15
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
输入 UDT块
Date,2009-7-30
File,SSP1_12C.16
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
根据数据类型建立数据块
Date,2009-7-30
File,SSP1_12C.17
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
举例,UDT中矩阵声明查看数据查看
Date,2009-7-30
File,SSP1_12C.18
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
练习 12.1,数据块和数据格式
IB1 DB10.DBW1 DB11.DBW8+ = BIN
BCD QW6
DB11.
DBW9
BIN
BCD QW6
IB2 MW1
BCD
BIN MW3
IB3 MW5
BCD
BIN MW7


I0.7=“0”,BEC
,BE
Date,2009-7-30
File,SSP1_12C.19
SIMATIC S7
Siemens AG 2000,All rights reserved.
Information and Training Center
Know ledge for Automation
练习 12.2:瓶装线编程 - 数据存储满瓶 (MW102)
空瓶 (MW 100)
碎瓶 (MW 104)
数据块 DB5
变量,full
变量,empty
变量,broken