Giáo trình Siemens S7-200 - Chương 2: Tập lệnh S7-200

1. LỆNH LOGIC

Bao gồm các lệnh:

- Tiếp điểm thường hở (NO).

- Tiếp điểm thường đóng (NC).

- Hàm đảo (NOT).

- Xung cạnh lên (P).

- Xung cạnh xuống (N).

- Ngõ ra out.

- Lệnh SET và RESET.

2. Real Time Clock (RTC)

2.1. ĐỌC-RTC (READ_RTC)

Lệnh đọc đồng hồ thời gian thực là lệnh đọc thời gian và ngày tháng hiện hành từ

đồng hồ và đưa chúng vào bộ đệm 8 byte bắt đầu tại địa chỉ T

 

pdf30 trang | Chuyên mục: PLC | Chia sẻ: tuando | Lượt xem: 663 | Lượt tải: 0download
Tóm tắt nội dung Giáo trình Siemens S7-200 - Chương 2: Tập lệnh S7-200, để xem tài liệu hoàn chỉnh bạn click vào nút "TẢI VỀ" ở trên
UT) là số 
thực 32 bit. 
11.4. Chia 
Lệnh DIV_R là lệnh chia 2 số thực (IN1 và IN2) 32 bit và kết quả (OUT) là số thực 
32 bit. 
Siemens S7-200 Tập lệnh 
DuyMinh Software Page 20 www.minh.webhop.net 
11.5. Căn Bậc hai 
Lệnh SQRT lấy căn bậc hai của số thực 32 bit (IN) và kết quả (OUT) là số thực 32 
bit. 
11.6. Sin 
Lệnh SIN tính sin của góc (IN) số thực 32 bit và kết quả (OUT) 32 bit số thực. 
11.7. Cos 
11.8. Tan 
11.9. LN 
11.10. EXP 
11.11. PID 
Siemens S7-200 Tập lệnh 
DuyMinh Software Page 21 www.minh.webhop.net 
12. CÁC LỆNH TOÁN HỌC SỐ NGUYÊN 
12.1. CỘNG 16 BIT 
Lệnh ADD_I (Add Integer) là lệnh cộng 2 số nguyên 16 bit (IN1 và IN2) và kết quả 
cũng là số nguyên 16 bit (OUT). 
12.2. CỘNG 32 BIT 
Lệnh ADD_DI (Add Double Integer) là lệnh cộng 2 số nguyên 32 bit (IN1 và IN2) và 
kết quả cũng là số nguyên 32 bit (OUT). 
12.3. TRỪ 16 BIT 
Lệnh SUB_I (Subtract Integer) là lệnh trừ 2 số nguyên 16 bit (IN1 và IN2) và kết 
quả cũng là số nguyên 16 bit (OUT). 
12.4. TRỪ 32 BIT 
Lệnh SUB_DI (Add Double Integer) là lệnh trừ 2 số nguyên 32 bit (IN1 và IN2) và 
kết quả cũng là số nguyên 32 bit (OUT). 
Siemens S7-200 Tập lệnh 
DuyMinh Software Page 22 www.minh.webhop.net 
12.5. NHÂN 
Lệnh MUL (Multiply Integer to Double Integer) nhân 2 số nguyên 16 bit (IN1 và IN2) 
và kết quả là số nguyên 32 bit (OUT). 
12.6. NHÂN 16 BIT 
Lệnh MUL_I (Multiply Integer) nhân 2 số nguyên 16 bit (IN1 và IN2) và kết quả là 
số nguyên 16 bit (OUT). 
12.7. NHÂN 32 BIT 
Lệnh MUL_DI (Multiply Integer) nhân 2 số nguyên 32 bit (IN1 và IN2) và kết quả là 
số nguyên 32 bit (OUT). 
12.8. CHIA 
Siemens S7-200 Tập lệnh 
DuyMinh Software Page 23 www.minh.webhop.net 
Lệnh DIV (Divide Integer to Double Integer) chia 2 số nguyên 16 bit (IN1 và IN2) và 
kết quả là số nguyên 32 bit (OUT) trong đó phần dư là 16 bit có trọng số cao và phần 
nguyên là 16 bit có trọng số thấp . 
12.9. CHIA 16 BIT 
Lệnh DIV_I (Divide Integer) chia 2 số nguyên 16 bit (IN1 và IN2) và kết quả là số 
nguyên 16 bit (OUT). 
12.10. CHIA 32 BIT 
Lệnh DIV_D (Divide Double Integer) chia 2 số nguyên 32-bit (IN1 và IN2) và kết 
quả là số nguyên 32 bit (OUT). 
12.11. 
The Increment Byte and Decrement Byte instructions add or subtract 1 to or from 
the input byte (IN) and place the result into the variable specified by OUT. 
Increment and decrement byte operations are unsigned. 
Siemens S7-200 Tập lệnh 
DuyMinh Software Page 24 www.minh.webhop.net 
12.12. 
12.13. 
The Increment Double Word and Decrement Double Word instructions add or 
subtract 1 to or from the input double word (IN) and place the result in OUT. 
12.14. 
12.15. 
12.16. 
13. Table 
13.1. LIFO 
Siemens S7-200 Tập lệnh 
DuyMinh Software Page 25 www.minh.webhop.net 
The Last-In-First-Out (LIFO) instruction moves the newest (or last) entry in the table 
to the output memory address by removing the last entry in the table (TBL) and moving 
the value to the location specified by DATA. The entry count in the table is decremented 
for each instruction execution. 
13.2. FIFO 
The First-In-First-Out (FIFO) instruction moves the oldest (or first) entry in a table to 
the output memory address by removing the first entry in the table (TBL) and moving the 
value to the location specified by DATA. All other entries of the table are shifted up one 
location. The entry count in the table is decremented for each instruction execution. 
13.3. ADD TO TABLE 
Lệnh Add To Table (ATT) instruction adds word values (DATA) to the table (TBL). 
The first value of the table is the maximum table length (TL). The second value is 
the entry count (EC), which specifies the number of entries in the table. New data are 
added to the table after the last entry. Each time new data are added to the table, the 
entry count is incremented.A table may have up to 100 entries, excluding both 
parameters specifying the maximum number of entries and the actual number of entries. 
13.4. Memory Fill 
The Memory Fill (FILL) instruction writes N consecutive words, beginning at 
address OUT, with the word value contained in address IN. 
N has a range of 1 to 255. 
Siemens S7-200 Tập lệnh 
DuyMinh Software Page 26 www.minh.webhop.net 
13.5. Table Find 
The Table Find (TBL) instruction searches a table (TBL) for data that matches 
certain criteria. 
The Table Find instruction searches the table, starting with the table entry specified 
by INDX, for the data value (PTN) that matches the search criteria defined by CMD. 
The command parameter (CMD) is given a numeric value of 1 to 4 that corresponds 
to =, , , respectively.If a match is found, the INDX points to the matching entry 
in the table. 
To find the next matching entry, the INDX must be incremented before invoking the 
Table Find instruction again. If a match is not found, the INDX has a value equal to the 
entry count.A table may have up to 100 entries. 
The data entries (area to be searched) are numbered from 0 to a maximum value of 
99. 
14. CÁC LỆNH ĐIỀU KHIỂN CHƯƠNG TRÌNH 
14.1. Lệnh FOR 
Lệnh FOR thực thi các lệnh giữa FOR và NEXT. Cần xác định giá trị index hoạc số 
đếm lặp vòng (INDX), giá trị bắt đầu (INIT), và giá trị kết thúc (FINAL). 
Siemens S7-200 Tập lệnh 
DuyMinh Software Page 27 www.minh.webhop.net 
14.2. Lệnh NEXT 
Lệnh NEXT đánh dấu sự kết thúc của vòng lặp FOR. Sử dụng FOR/NEXT để mô 
tả vòng lặp được lặp lại với số lần xác định. 
Mỗi lệnh FOR cần phải có lệnh NEXT. You can nest FOR/NEXT loops (place a 
FOR/NEXT loop within a FOR/NEXT loop) to a depth of eight. 
For example, given an INIT value of 1 and a FINAL value of 10, the instructions 
between the FOR and the NEXT are executed 10 times with the INDX value being 
incremented: 1, 2, 3, ...10.If the starting value is greater than the final value, the loop is 
not executed. 
After each execution of the instructions between the FOR and the NEXT instruction, 
the INDX value is incremented and the result is compared to the final value. If the INDX 
is greater than the final value, the loop is terminated. 
14.3. 
The Jump to Label (JMP) instruction performs a branch to the specified label (n) 
within the program. When a jump is taken, the top of stack value is always a logical 1. 
14.4. 
The Label (LBL) instruction marks the location of the jump destination (n). 
You can use the Jump instruction in the main program, in subroutines, or in 
interrupt routines. The Jump and its corresponding Label instruction must always be 
located within the same segment of code (either the main program, a subroutine, or an 
interrupt routine).You cannot jump from the main program to a label in either a subroutine 
or an interrupt routine. 
Likewise, you cannot jump from a subroutine or interrupt routine to a label outside 
that subroutine or interrupt routine.You can use a Jump instruction within an SCR 
segment, but the corresponding Label instruction must be located within the same SCR 
segment. 
14.5. 
14.6. 
14.7. 
Siemens S7-200 Tập lệnh 
DuyMinh Software Page 28 www.minh.webhop.net 
14.8. 
14.9. 
14.10. 
14.11. 
14.12. 
Nếu thông số ngõ vào IN có giá trị bằng zero, thì then set the diagnostic LED OFF. 
Còn nếu thông số ngõ vào IN có giá trị lớn hơn zero thì then set the diagnostic LED ON 
(yellow). 
The CPU light emitting diode (LED) labeled SF/ DIAG can be configured to indicate 
yellow when either the conditions specified in the System Block are true or when the 
DIAG_LED instruction is executed with a non-zero IN parameter.System Block 
(Configure LED) check box options: 
1) SF/ DIAG LED ON (yellow) when an item is forced in the CPU 
2) SF/ DIAG LED ON (yellow) khi module có lỗi I/O. 
Uncheck both Configure LED options to give the DIAG_LED instruction sole control 
over SF/ DIAG yellow illumination. A CPU System Fault (SF) is indicated with red 
illumination. 
15. CÁC LỆNH TRUYỀN THÔNG 
15.1. LỆNH TRUYỀN XMT 
Lệnh Transmit (XMT) sử dụng trong chế độ truyền thông Freeport để truyền dữ liệu 
qua port truyền thông. 
Siemens S7-200 Tập lệnh 
DuyMinh Software Page 29 www.minh.webhop.net 
15.2. LỆNH NHẬN RCV 
Lệnh Receive (RCV) sử dụng trong chế độ truyền thông Freeport để nhận dữ liệu 
qua port truyền thông. 
15.3. NETWORK READ 
The Network Read (NETR) instruction initiates a communication operation to gather 
data from a remote device through the specified port (PORT), as defined by the table 
(TBL). 
15.4. NETWORK WRITE 
The Network Write (NETW) instruction initiates a communication operation to write 
data to a remote device through the specified port (PORT), as defined by the table (TBL). 
The NETR instruction can read up to 16 bytes of information from a remote station, 
and the NETW instruction can write up to 16 bytes of information to a remote station. 
You can have any number of NETR/NETW instructions in the program, but only a 
maximum of eight NETR and NETW instructions may be activated at any one time. 
For example, you can have 4 NETRs and 4 NETWs, or 2 NETRs and 6 NETWs 
active at the same time in a given S7-200. 
Siemens S7-200 Tập lệnh 
DuyMinh Software Page 30 www.minh.webhop.net 
15.5. GET PORT ADDRESS 
The Get Port Address (GPA) instruction reads the station address of the S7-200 
CPU port specified in PORT and places the value in the address specified in ADDR. 
15.6. SET PORT ADDRESS 
Lệnh Set Port Address (SPA) cài đặt địa chỉ port (PORT) và giá trị định nghĩa trong 
ADDR. The new address is not saved permanently. After a power cycle, the affected port 
will return to the last address (the one that was downloaded with the system block). 

File đính kèm:

  • pdfgiao_trinh_siemens_s7_200_chuong_2_tap_lenh_s7_200.pdf
Tài liệu liên quan