Löu tröõ döõ lieäu trong khoái döõ lieäu
SIMATIC S7
Siemens AG 1999. All rights reserved.
Date:
File:
29.10.15
STOE_02VN.1
Information and Training Center
Knowledge for Automation
Vùng Lưu Trữ Dữ Liệu
Bit nhớ
DBz
PIQ
PII
DBx
Vùng I/O
Ngăn xếp L
SIMATIC S7
Siemens AG 1999. All rights reserved.
.
.
.
DBy
Date:
File:
29.10.15
STOE_02VN.2
Các khối dữ liệu
Information and Training Center
Knowledge for Automation
Khối dữ liệu (DB)
Kết nối tới tất cả các khối
OB1
Chức năng
FC10
Global data
DB20
Chức năng
FC20
Instance DB for FB1
Khối
chức năng
FB1
SIMATIC S7
Siemens AG 1999. All rights reserved.
Date:
File:
29.10.15
STOE_02VN.3
Instance data
DB5
Information and Training Center
Knowledge for Automation
Tóm lược các dạng dữ liệu trong STEP 7
Dạng dữ liệu
sơ cấp
(tới 32 bit)
• Dạng dữ liệu Bit (BOOL, BYTE, WORD, DWORD, CHAR)
• Dạng dữ liệu toán học (INT, DINT, REAL)
• Dạng thời gian (S5TIME, TIME, DATE, TIME_OF_DAY)
• Thời gian(DATE_AND_TIME)
Dạng dữ liệu
phức tạp
(hơn 32 bit)
• Mảng (ARRAY)
• Cấu trúc (STRUCT)
• Chuỗi ký tự (STRING)
Dạng dữ liệu người dùng đònh nghóa
(hơn 32 bit)
SIMATIC S7
Siemens AG 1999. All rights reserved.
Dạng dữ liệu UDT(User Defined Type)
Date:
File:
29.10.15
STOE_02VN.4
Information and Training Center
Knowledge for Automation
Dạng dữ liệu sơ cấp trong STEP 7
Từ khóa
Ví dụ hằng số
Độ dài (bit)
BOOL
BYTE
WORD
DWORD
CHAR
1
8
16
32
8
1 or 0
B#16#A9
W#16#12AF
DW#16#ADAC1EF5
'w'
S5TIME
16
S5T#5s_200ms
INT
DINT
REAL
16
32
32
123
65539
1.2 or 34.5E-12
TIME
DATE
TIME_OF_DAY
32
16
32
T#2D_1H_3M_45S_12MS
D#1993-01-20
TOD#12:23:45.12
SIMATIC S7
Siemens AG 1999. All rights reserved.
Date:
File:
29.10.15
STOE_02VN.5
Information and Training Center
Knowledge for Automation
Dạng dữ liệu phức
Dạng
Độ dài (bit)
Ví dụ
NGÀY VÀ GIỜ
64
DT#97-09-24-12:14:55.0
CHUỖI
(chuỗi ký tự
max. 254 ký tự)
8 * (số ký tự +2)
´một chuỗi´
´SIEMENS´
MẢNG
(Nhóm phần tử
có cùng dạng dữ liệu)
Người dùng đònh nghóa
STRUCT
(Nhóm phần tử
khác dạng dữ liệu)
Người dùng đònh nghóa
Giá trò đo được: ARRAY[1..20]
INT
Động cơ: STRUCT
tốc độ : INT
dòng điện: REAL
END_STRUCT
UDT
UDT như khối
UDT như mảng
(User Defined Data Type = Người dùng đònh nghóa
Gồm các dạng dữ liệu
STRUCT
Drive: ARRAY[1..4]
sơ cấp hoặc phức )
tốc độ : INT
UDT1
dòng điện REAL
END_STRUCT
SIMATIC S7
Siemens AG 1999. All rights reserved.
Date:
File:
29.10.15
STOE_02VN.6
Information and Training Center
Knowledge for Automation
Ví dụ về cấu trúc
Motor _ Data
Tốc độ làm việc, dạng dữ liệu Integer
Dòng điện đònh mức,dạng dữ liệu Real
Dòng điện khởi động,dạng dữ liệu Real
Cấu trúc có tên "Motor_data"
(nhiều yếu tố của các dạng
dữ liệu khác nhau)
Hướng quay,dạng dữ liệu Bool
Hiển thò trong chương trình soạn thảo (khối dữ liệu DB 1):
SIMATIC S7
Siemens AG 1999. All rights reserved.
Date:
File:
29.10.15
STOE_02VN.7
Information and Training Center
Knowledge for Automation
Ví dụ về mảng
Measuring_point
1. Measuring_point, dạng dữ liệu Real
2. Measuring_point, dạng dữ liệu Real
3. Measuring_point, dạng dữ liệu Real
•
•
•
10. Measuring_point, dạng dữ liệu Real
Mảng có tên "Measuring_point"
(nhiều yếu tố có cùng dạng dữ liệu)
Hiển thò trong chương trình soạn thảo (khối dữ liệu DB 2):
SIMATIC S7
Siemens AG 1999. All rights reserved.
Date:
File:
29.10.15
STOE_02VN.8
Information and Training Center
Knowledge for Automation
Taùo khoỏi dửừ lieọu mụựi
SIMATIC S7
Siemens AG 1999. All rights reserved.
Date:
File:
29.10.15
STOE_02VN.9
Information and Training Center
Knowledge for Automation
Nhập,lưu trữ,nạp và quản lý khối dữ liệu ( Data Block)
SIMATIC S7
Siemens AG 1999. All rights reserved.
Date:
File:
29.10.15
STOE_02VN.10
Information and Training Center
Knowledge for Automation
Ñaët ñòa chæ döõ lieäu
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 8188
DBW 8190
DBB 8191
Data Byte 8191
SIMATIC S7
Siemens AG 1999. All rights reserved.
Date:
File:
29.10.15
STOE_02VN.11
Information and Training Center
Knowledge for Automation
Truy cập dữ liệu
DB 19
(Tên ký hiệu: Values)
Ký
hiệu
or
A DB19.DBX0.0
or
A “Values".Start
Number
OPN DB19
L DBW2
or
L DB19.DBW2
or
L “Values".Number
Loop
OPN DB19
L DBB5
or
L DB19.DBB5
or
L “Values".Loop
1
3
Tuyệt
đối
OPN DB19
A DBX 0.0
1)
0
2
Truy xuất toàn diện
Truy xuất
thông thường
4
5
6
7
8
9
1) Bit dữ liệu 0.0 có tên "Start"
SIMATIC S7
Siemens AG 1999. All rights reserved.
Date:
File:
29.10.15
STOE_02VN.12
Information and Training Center
Knowledge for Automation
Mụỷ hụùp leọ moọt DB
OB 1
OPN
L
DB 4
DBW2
FC 1
DB 4
CALL FC 1
DBW 4 DB 4
T
OPN
L
DB 5
DBB6
DB 5
CALL FC 2
T
DBW 2
DB 4
DBW 0 DB 5
L
FC 2
T
DBW 8 DB 5
OPN
DB 6
L
DBB6
DB 6
T DB2.DBB 0 DB 2
L
DBW 4 DB 2
FB 1
CALL FB1, DB1
!
L
DBW 10
SIMATIC S7
Siemens AG 1999. All rights reserved.
DB ??
???
Date:
File:
29.10.15
STOE_02VN.13
Information and Training Center
Knowledge for Automation
Dạng dữ liệu người dùng đònh nghóa (UDT)
Khối UDT như bảng mẫu
Global DB (ví dụ)
bột
bột
sữa
sữa
trứng
trứng
men
men
đường
đường
Công thức
1
bột
sữa
trứng
men
DB được tạo theo UDT
đường
Bột
bột
sữa
sữa
trứng
trứng
men
men
đường
đường
SIMATIC S7
Siemens AG 1999. All rights reserved.
Công thức
2
Date:
File:
29.10.15
STOE_02VN.14
Mảng có 3 phần
với dữ liệu dạng
UDT
Công thức
3
Information and Training Center
Knowledge for Automation
Nhaäp moät khoái UDT
SIMATIC S7
Siemens AG 1999. All rights reserved.
Date:
File:
29.10.15
STOE_02VN.15
Information and Training Center
Knowledge for Automation
Taùo khoỏi dửừ lieọu theo daùng dửừ lieọu
SIMATIC S7
Siemens AG 1999. All rights reserved.
Date:
File:
29.10.15
STOE_02VN.16
Information and Training Center
Knowledge for Automation
Vớ duù: maỷng UDT
Xem khai baựo
Xem dửừ lieọu
SIMATIC S7
Siemens AG 1999. All rights reserved.
Date:
File:
29.10.15
STOE_02VN.17
Information and Training Center
Knowledge for Automation
Bài tập: chương trình hệ thống làm đầy chai - lưu trữ dữ liệu
Khối dữ liệu DB5
Chai rỗng (MW 100)
Biến : rỗng
Chai đầy (MW102)
Biến : đầy
Biến : hư
chai “hư" (MW 104)
SIMATIC S7
Siemens AG 1999. All rights reserved.
Date:
File:
29.10.15
STOE_02VN.18
Information and Training Center
Knowledge for Automation