Các khối tổ chức ngắt

- Cột Active: bấm chọn để tích cực OB tương ứng

- Cột Execution: có các tùy chọn None (không tác động), Once (một lần), Every

minute, hour, day, week, month, year (theo chu kỳ phút, giờ, ngày, tháng, năm)

end of month (cuối tháng)

- Cột Start Date và Time of Day: ghi ngày (mm.dd.yy) và giờ (hh:mm) bắt đầu

gây ra ngắt. Nếu cài đặt xảy ra một lần thì ngày giờ này phải là tương lai so với

giờ của PLC.

Nếu đã cài đặt các thông số xong, ta trở lại Project thêm vào khối OB ngắt tương

ứng (ví dụ OB10), mở khối ra và lập trình cho khối. Các thông số và chương trình sẽ được

truyền xuống PLC khi thực hiện download. Nếu trong chương trình không có khối OB tương

ứng khi được gọi đến thì sẽ gây sự cố gọi OB85, nếu chưa cài OB85 thì PLC Stop.

 

pdf14 trang | Chuyên mục: Điều Khiển Tự Động | Chia sẻ: tuando | Lượt xem: 461 | Lượt tải: 0download
Tóm tắt nội dung Các khối tổ chức ngắt, để xem tài liệu hoàn chỉnh bạn click vào nút "TẢI VỀ" ở trên
. 
Block transfer: save time of day 
from start event information of 
OB10 to the memory area MB100 to 
MB107. 
Lập trình OB1
CALL FC 12 Calls the function FC12 
Lập trình OB80
Variable Name Data Type Declaration Comment 
STARTINFO STRUCT TEMP Entire start event information of OB80 declared as 
structure 
E_ID WORD TEMP Event ID: 
PR_CLASS BYTE TEMP Priority class 
OB_NO BYTE TEMP OB number 
RESERVED_1 BYTE TEMP Reserved 
RESERVED_2 BYTE TEMP Reserved 
A1_INFO WORD TEMP Additional information about the event that caused the 
error 
A2_INFO DWORD TEMP Additional information about the event ID, priority 
class, and OB no. of the error 
T_STMP STRUCT TEMP Structure for time-of-day details 
YEAR BYTE TEMP 
MONTH BYTE TEMP 
DAY BYTE TEMP 
HOUR BYTE TEMP 
MINUTES BYTE TEMP 
SECONDS BYTE TEMP 
MSEC_WDAY WORD TEMP 
END_STRUCT TEMP 
END_STRUCT TEMP 
STL (OB80) Explanation 
Network 1
AN Q 4.1 
S Q 4.1 
CALL SFC 20 
SRCBLK := #STARTINFO 
RET_VAL := MW 210 
DSTBLK := P#M 110.0 Byte 20 
Set output Q 4.1 if time error occurred. 
Block transfer: save entire start event information to 
memory area MB110 to MB129. 
2/ Ngắt trễ 
Có bốn ngắt thời trễ OB20..OB23 được kích hoạt bởi hàm SFC32 (SRT_DINT). Sau 
khi gọi SFC32 một thời gian, OB tương ứng sẽ hoạt động. Khi chưa đến thời điểm kích hoạt 
có thể hủy OB bằng SFC33 (CAN_DINT). 
CPU 312 Không
CPU 313..316 OB20
CPU 318, 412, 413 OB20, OB21
CPU 414, 416, 417 OB20..23
2,1/ SFC 32: khởi động ngắt
Parameter Declaration Data Type Memory Area Description
OB_NR INPUT INT I, Q, M, D, L,
constant
Number of the OB, to be started after a time
delay (OB20 to OB23).
DTIME INPUT TIME I, Q, M, D, L,
constant
Length of the delay (1 to 60000 ms)
SIGN INPUT WORD I, Q, M, D, L,
constant
Identifier that is entered in the start event
information of the OB when the time-delay OB is
called.
RET_VAL OUTPUT INT I, Q, M, D, L If an error occurs while the function is active, the
actual parameter of RET_VAL contains an error
code.
Error Code (W#16#...) Explanation
0000 No error occurred.
8090 Incorrect parameter OB_NR
8091 Incorrect parameter DTIME
2.2/ Truy vấn ngắt trì hoãn SFC34 "QRY_DINT"
Parameter Declaration Data Memory Area Description
Type
OB_NR INPUT INT I, Q, M, D, L, Number of the OB, whose STATUS will be
constant queried (OB20 to OB23).
RET_VAL OUTPUT INT I, Q, M, D, L If an error occurs while the function is being
processed, the actual parameter of RET_VAL
contains an error code.
STATUS OUTPUT WORD I, Q, M, D, L Status of the time-delay interrupt, see following
table.
OUTPUT STATUS
Bit Value Meaning
0 0 Time-delay interrupt is enabled by the operating system.
1 0 New time-delay interrupts are not rejected.
2 0 Time-delay interrupt is not activated or has elapsed.
3 - -
4 0 Time-delay interrupt-OB is not loaded.
5 0 The execution of the time-delay interrupt OB is disabled by an active test
function.
ERROR RET_VAL
Error Code (W#16#...) Explanation
0000 No error occurred
8090 Incorrect parameter OB_NR
2.3/ Triệt tiêu ngắt trì hoãn SFC33 "CAN_DINT"
Parameter Declaration Data Type Memory Area Description
OB_NR INPUT INT I, Q, M, D, L, Number of the OB to be canceled (OB20 to
constant OB23).
RET_VAL OUTPUT INT I, Q, M, D, L If an error occurs while the function is active,
the actual parameter of RET_VAL contains an
error code.
Error Code (W#16#...) Explanation
0000 No error has occurred.
8090 Incorrect parameter OB_NR
80A0 Time-delay interrupt has not started.
Bảng biến địa phương của OB20 
Variable Type Description
OB20_EV_CLASS BYTE Event class and identifiers:
B#16#11: interrupt is active
OB20_STRT_INF BYTE B#16#21: start request for OB20
(B#16#22: start request for OB21)
(B#16#23: start request for OB22)
(B#16#24: start request for OB23)
OB20_PRIORITY BYTE Assigned priority class: default values 3 (OB20) to 6 (OB23)
OB20_OB_NUMBR BYTE OB number (20 to 23)
OB20_RESERVED_1 BYTE Reserved
OB20_RESERVED_2 BYTE Reserved
OB20_SIGN WORD User ID: input parameter SIGN from the call for SFC32
(SRT_DINT)
OB20_DTIME TIME Elapsed delay time in ms
OB20_DATE_TIME DATE_AND_TIME Date and time of day when the OB was called
Ví dụ 2: Mỗi khi I0.0 ON thì 10 s sau Q0.0 ON. I0.2 ON thì reset Q0.0. Nếu trong 
khoảng delay mà I0.1 ON thì Q0.0 vẫn OFF 
Bảng ký hiệu:
Address Meaning 
I0.0 Input to enable "start time-delay interrupt" 
I0.1 Input to cancel a time-delay interrupt 
I0.2 Input to reset output Q 4.0 
Q4.0 Output set by the time-delay interrupt OB (OB20) 
MB1 Used for edge flag and binary result (status bit BR) buffer for SFCs 
MW4 STATUS of time-delay interrupt (SFC34 "QRY_TINT") 
MD10 Seconds and milliseconds BCD-coded from the start event information of OB1 
MW 100 RET_VAL of SFC32 "SRT_DINT" 
MW102 RET_VAL of SFC34 "QRY_DINT" 
MW104 RET_VAL of SFC33 "CAN_DINT" 
MW106 RET_VAL of SFC20 "BLKMOV" 
MB120 to 
MB139 
Memory for start event information of OB20 
MD140 Seconds and milliseconds BCD-coded from the start event information of OB20 
MW144 Seconds and milliseconds BCD-coded from the start event information of OB1; acquired from 
start event information of OB20 (user-specific ID SIGN) 
Bảng biến địa phương của OB20
Variable Name Data Type Declaration Comment 
STARTINFO STRUCT TEMP Start information for OB20 
E_ID WORD TEMP Event ID: 
PC_NO BYTE TEMP Priority class 
OB_NO BYTE TEMP OB number 
D_ID 1 BYTE TEMP Data ID 1 
D_ID 2 BYTE TEMP Data ID 2 
SIGN WORD TEMP User-specific ID 
DTIME TIME TEMP Time with which the time-delay interrupt is started 
T_STMP STRUCT TEMP Structure for time-of-day details 
(time stamp) 
YEAR BYTE TEMP 
MONTH BYTE TEMP 
DAY BYTE TEMP 
HOUR BYTE TEMP 
MINUTES BYTE TEMP 
SECONDS BYTE TEMP 
MSEC_WDAY WORD TEMP 
END_STRUCT TEMP 
END_STRUCT TEMP 
STL (OB20) Explanation 
Network 1 
SET 
= Q 4.0 
Network 2: 
L QW 4 
T PQW 4 
Network 3: 
L #STARTINFO.T_STMP.SECONDS 
T MW 140 
L #STARTINFO.T_STMP.MSEC_WDAY 
T MW 142 
L MD 140 
SRD 4 
T MD 140 
Network 4: 
L #STARTINFO.SIGN 
T MW 144 
Network 5: 
CALL SFC 20 
SRCBLK := STARTINFO 
RET_VAL := MW 106 
DSTBLK := P#M 120.0 Byte 20 
Set output Q 4.0 unconditionally 
Activate output word immediately 
Read seconds from start event information 
Read milliseconds and day of week from start event 
information 
Eliminate day of week and 
write milliseconds back (now BCD-coded in MW 142) 
Read starting time of time-delay interrupt (= call SFC32) 
from start event information 
Copy start event information to memory area (MB120 to 
MB139) 
Bảng biến địa phương của OB1
Variable Name Data Type Declaration Comment 
STARTINFO STRUCT TEMP Start information for OB1 
E_ID WORD TEMP Event ID: 
PC_NO BYTE TEMP Priority class 
OB_NO BYTE TEMP OB number 
D_ID 1 BYTE TEMP Data ID 1 
D_ID 2 BYTE TEMP Data ID 2 
CUR_CYC INT TEMP Current cycle time 
MIN_CYC INT TEMP Minimum cycle time 
MAX_CYC INT TEMP Maximum cycle time 
T_STMP STRUCT TEMP Structure for time-of-day details 
(time stamp) 
YEAR BYTE TEMP 
MONTH BYTE TEMP 
DAY BYTE TEMP 
HOUR BYTE TEMP 
MINUTES BYTE TEMP 
SECONDS BYTE TEMP 
MSEC_WDAY WORD TEMP 
END_STRUCT TEMP 
END_STRUCT TEMP 
STL (OB1) Explanation 
Network 1 
L #STARTINFO.T_STMP.SECONDS 
T MW 10 
L #STARTINFO.T_STMP.MSEC_WDAY 
T MW 12 
L MD 10 
SRD 4 
T MD 10 
Network 2: 
A I 0.0 
FP M 1.0 
= M 1.1 
Network 3: 
A M 1.1 
JNB m001 
CALL SFC 32 
OB_NO := 20 
DTME := T#10S 
SIGN := MW 12 
RET_VAL:= MW 100 
m001: NOP 0 
Network 4: 
CALL SFC 34 
OB_NO := 20 
RET_VAL:= MW 102 
STATUS := MW 4 
Network 5: 
A I 0.1 
FP M 1.3 
= M 1.4 
Network 6: 
Read seconds from start event information 
Read milliseconds and day of week from start 
event information 
Eliminate day of week and 
write milliseconds back (now BCD-coded in MW 
12) 
Positive edge at input I 0.0? 
If so, start time-delay interrupt (starting time of 
time-delay interrupt assigned to the parameter 
SIGN) 
Query status of time-delay interrupt (SFC 
QRY_DINT) 
Positive edge at input I 0.1? 
...and time-delay interrupt is activated (bit 2 of 
time-delay interrupt STATUS)? 
Then cancel time-delay interrupt 
A M 1.4 
A M 5.2 
JNB m002 
CALL SFC 33 
OB_NO := 20 
RET_VAL:= MW 104 
m002: NOP 0 
A I 0.2 
R Q 4.0 
Reset output Q 4.0 with input I 0.2 
3 . NGẮT CHU KỲ 
Ngắt chu kỳ OB30..OB38 được gọi đến theo chu kỳ tuần hoàn. Thời gian thực hiện 
mỗi ngắt chu kỳ OB phải nhỏ hơn nhiều chu kỳ ngắt, nếu không OB80 sẽ được gọi.
Chu kỳ ngắt được xác định bởi khoảng (interval) là số nguyên chỉ chu kỳ( đơn vị 
ms) và lệch pha (phase offset) là thời gian trễ m (đơn vị ms), 0<= m < n, gọi OB ngắt chu 
kỳ khi đến thời điểm ấn định. Dùng phase offset để tránh các OB ngắt cùng được gọi đồng 
thời . Hai giá trị này được cài đặt bằng STEP 7 và có giá trị mặc định như bảng sau:
OB Number Default Interval Default Priority Class
OB30 5 s 7
OB31 2 s 8
OB32 1 s 9
OB33 500 ms 10
OB34 200 ms 11
OB35 100 ms 12
OB36 50 ms 13
OB37 20 ms 14
OB38 10 ms 15
Số các OB ngắt chu kỳ phụ thuộc CPU
CPU 312 Không có
CPU 313 316 OB35
CPU 318, 412, 413 OB32, OB35
CPU 414 OB32..OB35
CPU 416, 417 OB30..OB38
Bảng biến địa phương
Variable Type Description
OB35_EV_CLASS BYTE Event class and identifiers
B#16#11: interrupt is active
OB35_STRT_INF BYTE (B#16#31: start request for OB30)
,,,
B#16#36: start request for OB35
(B#16#39: start request for OB38)
OB35_PRIORITY BYTE Assigned priority class: defaults 7 (OB30) to 15
(OB38)
OB35_OB_NUMBR BYTE OB number (30 to 38)
OB35_RESERVED_1 BYTE Reserved
OB35_RESERVED_2 BYTE Reserved
OB35_PHASE_OFFSET WORD Phase offset [ms]
OB35_RESERVED_3 INT Reserved
OB35_EXC_FREQ INT Interval in milliseconds
OB35_DATE_TIME DATE_AND_TIME Date and time of day when the OB was called

File đính kèm:

  • pdfcac_khoi_to_chuc_ngat.pdf