Đồ án Ngắt trong S7 300 - Nguyễn Đại Trung

Quá trình thực hiện đồ án.

.1. Quá trình.

 Chọn đề tài.

 Thu thập tài liệu.

 Xử lý tài liệu.

2. Phương pháp.

 Phương pháp tham khảo tài liệu.

 Phương pháp thực nghiệm bằng phần mềm

 

docx27 trang | Chia sẻ: hienduc166 | Lượt xem: 612 | Lượt tải: 0download
Bạn đang xem trước 20 trang tài liệu Đồ án Ngắt trong S7 300 - Nguyễn Đại Trung, để xem tài liệu hoàn chỉnh bạn click vào nút TẢI VỀ ở trên
Neáu caøi ñaët xaûy ra moät laàn thì ngaøy giôø naøy phaûi laø töông lai so vôùi giôø cuûa PLC.
Neáu ñaõ caøi ñaët caùc thoâng soá xong, ta trôû laïi Project theâm vaøo khoái OB ngaét töông öùng (ví duï OB10), môû khoái ra vaø laäp trình cho khoái. Caùc thoâng soá vaø chöông trình seõ ñöôïc truyeàn xuoáng PLC khi thöïc hieän download. Neáu trong chöông trình khoâng coù khoái OB töông öùng khi ñöôïc goïi ñeán thì seõ gaây söï coá goïi OB85, neáu chöa caøi OB85 thì PLC Stop.
Giôø cuûa PLC caàn phaûi chænh cho chính xaùc, vôùi maùy tính laäp trình keát noái PLC, vaøo menu PLC- Diplay Accessible Nodes- MPI, sau ñoù choïn PLC- Set Time of Day .
	Sau ñaây giôùi thieäu veà caøi ñaët ngaét baèng chöông trình. Tröôùc heát trong coät Active ta phaûi tích cöïc OB, sau ñoù phaûi coù khoái OB ñoù trong Project; caùc haøm SFC 28 ñeán SFC 31 ñöôïc söû duïng trong chöông trình vôùi caùc chöùc naêng sau:
Caøi ñaët thoâng soá ngaét thôøi gian (SFC28 "SET_TINT")
Huøy boû ngaét thôøi gian (SFC29 "CAN_TINT")
Tích cöïc ngaét thôøi gian (SFC30 "ACT_TINT")
Truy vaán (query) ngaét thôøi gian (SFC31 "QRY_TINT")
Tröôùc khi khoái OB ngaét thôøi gian ñöôïc thöïc hieän, phaûi thoûa caùc ñieàu kieän sau:
Ñaët ngaøy giôø duøng STEP 7 hay SFC28
Tích cöïc duøng STEP 7 hay SFC30
Caøi ñaët OB trong Project
Ngaét thôøi gian lieân keát vôùi khoái döõ lieäu ñòa phöông
Variable
Type
Description
OB10_EV_CLASS
BYTE
Event class and identifiers: B#16#11 = interrupt is active
OB10_STRT_INFO
BYTE
B#16#11: start request for OB10
(B#16#12: start request for OB11)
:
:
(B#16#18: start request for OB17)
OB10_PRIORITY
BYTE
Assigned priority class; default 2
OB10_OB_NUMBR
BYTE
OB number (10 to 17)
OB10_RESERVED_1
BYTE
Reserved
OB10_RESERVED_2
BYTE
Reserved
OB10_PERIOD_EXE
WORD
The OB is executed at the specified intervals:
W#16#0000: once
W#16#0201: once every minute
W#16#0401: once hourly
W#16#1001: once daily
W#16#1201: once weekly
W#16#1401: once monthly
W#16#1801: once yearly
OB10_RESERVED_3
INT
Reserved
OB10_RESERVED_4
INT
Reserved
OB10_DATE_TIME
DATE_AND_TIME
Date and time of day when the OB was called
1.2 SFC28 "SET_TINT"
	Baûng caùc tham soá khi goïi SFC 28
Parameter
(Thông số)
Declaration
Data Type
Memory Area
Description
OB_NR
INPUT
INT
I, Q, M, D, L, 
constant
Number of the OB started at the time SDT +
multiple of PERIOD (OB10 to OB17).
SDT
INPUT
DT
D, L, constant
Start date and time: The seconds and
milliseconds of the specified start time are
ignored and set to 0.
PERIOD
INPUT
WORD
I, Q, M, D, L, 
constant
Periods from start point SDT onwards:
W#16#0000 = once
W#16#0201 = every minute
W#16#0401 = hourly
W#16#1001 = daily
W#16#1202 = weekly
W#16#1401 = monthly
W#16#1801 = yearly
W#16#2001 = at month’s end
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.
1.3 SFC29 CAN_TINT"
Parameter
Declaration
Data Type
Memory Area
Description
OB_NR
INPUT
INT
I, Q, M, D, L,
 constant
Number of the OB, in which the start date
time will be canceled (OB10 to OB17).
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.
1.4 SFC30 “ACT_TINT"
Parameter
Declaration
Data Type
Memory Area
Description
OB_NR
INPUT
INT
I, Q, M, D, L, constant
Number of the OB to be activated (OB10 to
OB17).
1.5 SFC31 "QRY_TINT"
Parameter
Declaration
Data Type
Memory Area
Description
OB_NR
INPUT
INT
I, Q, M, D, L,
constant
Number of the OB, whose status will be
queried (OB10 to OB17).
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.
STATUS
OUTPUT
WORD
I, Q, M, D, L
Status of the time-of-day interrupt;
see following table.
STATUS
Bit
Value
Meaning
0
0
Time-of-day interrupt is enabled by operating system.
1
0
New time-of-day interrupts are accepted.
2
0
Time-of-day interrupt is not activated or has elapsed.
3
-
-
4
0
Time-of-day interrupt OB is not loaded.
5
0
The execution of the time-of-day interrupt OB is disabled by an active test
function.
 2. Ngắt trể so với thời điểm định trước:
 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
Khoâng
CPU 313..316
OB20
CPU 318, 412, 413
OB20, OB21
CPU 414, 416, 417
OB20..23
Ví dụ: Mỗi lần nhấn I0.0 thì sau 10s 0B20 được gọi
 2.1 SFC 32: khôûi ñoäng ngaé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 vaán ngaét trì hoaõ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/ Trieät tieâu ngaét trì hoaõ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.
Baûng bieán ñòa phöông cuû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
 3. Ngắt theo 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), đơ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. 
Bảng mô tả ngắt theo chu kỳ. 
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
Ví dụ: Thiết lập ngắt định thời cho CPU 414 
Số lượng ngắt của các OB phụ thuộc vào 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
Baûng bieá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
 4. Ngắt phần cứng: Các khối 0B40 đến 0B47
Tín hiệu ngắt được phát từ module mở rộng (module I/O,AI/AO) hoặc từ các cổng vào số onboard.
Chế độ báo ngắt cứng thường được sử dụng trong các chương trình điều khiển đòi hỏi có sự đáp ứng nhanh với tín hiệu từ ngoài đưa vào.
Một điều đặc biệt của ngắt cứng là trong khoảng thời gian thực hiện chương trình của OB40 (hoặc OB40÷OB47). Hệ thống sẽ không nhận và thực hiện bất cứ một tín hiệu ngắt cứng nào khác
III. Bài tập ứng dụng
 Lập trình ngắt thời giancho bài toán;lúc 8 giờ ngày 1 tháng 6 năm 2011 , Q0.0 ON. I0.0 tích cực ngắt và I0.1 hủy ngắt. 
 Chương trình bao gồm:
 OB1 gọi FC20
 FC20 đặt thời điểm ngắt, tích cực ngắt, hủy ngắt
 OB10	 đặt / xóa Q0.0 ,ấn định lần ngắt kế
 FC3	đổi ngày giờ ra dạng thích hợp
 SFC28	caøi ñaët thoâng soá ngaét thôøi gian
 SFC29	huøy boû ngaét thôøi gian 
 SFC30	tích cöïc ngaét thôøi gian
 SPC31	truy vaán (query) ngaét thôøi gian
 Vào simatic s7 300 chọn nguồn, cpu, ngỏ vào, ra. Ta được bảng như sau: 
 Lập trình OB1
 Lập trình cho OB10
Lập trình cho FC20

File đính kèm:

  • docxdo an mon hoc 3.docx