Version 2.4 by Leo Wei on 2022/07/28 11:27

Show last authors
1 = **6.14.1 RS instruction** =
2
3 **Instruction description**
4
5 (% class="table-bordered" %)
6 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
7 |RS|Serial data transfer|16|No|RS S m D n|9
8
9 RS is a transceiver instruction that automatically sends the data stored in the specific register to the serial port sequentially and stores the data received by serial port in the specific area. It is equivalent to directly access the communication buffer.
10
11 (% class="table-bordered" %)
12 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
13 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
14 |S| | | | | | | | | | | | | |√| |
15 |m| | | | |√|√| | | | | | | |√| |
16 |D| | | | | | | | | | | | | |√| |
17 |n| | | | |√|√| | | | | | | |√| |
18
19 COM2 (communication port): it uses RS485, it supports program protocol (PLC protocol), MODBUS protocol (MODBUS-RTU slave, MODBUS-RTU master, MODBUS-ASCII slave, MODBUS-ASCII master), N:N network protocol (so far, only available in LX3VP series PLC). The communication protocol is set by D8126, the communication parameters are set by D8120, the detailed as below.
20
21 (% class="table-bordered" %)
22 |(% colspan="3" %)**Communication setting for COM2**
23 |**Protocol**|**The value of D8126**|**Communication parameters**
24 |HMI monitor protocol (PLC protocol)|0x01|Set by D8120
25 |MODBUS-RTU slave|0x02|Set by D8120
26 |MODBUS-ASCII slave|0x03|Set by D8120
27 |User-defined protocol|0x10|Set by D8120
28 |MODBUS-RTU master|0x20|Set by D8120
29 |MODBUS-ASCII master|0x30|Set by D8120
30
31 (% class="table-bordered" %)
32 |(% rowspan="2" %)**Item**|(% rowspan="2" %)**Parameter**|(% colspan="8" %)**Bit value of D8120**
33 |**b7**|**b6**|**b5**|**b4**|**b3**|**b2**|**b1**|**b0**
34 |(% rowspan="6" %)**Baud rate (Bps)**|115200|1|1|0|0|-|-|-|-
35 |57600|1|0|1|1|-|-|-|-
36 |38400|1|0|1|0|-|-|-|-
37 |19200|1|0|0|1|-|-|-|-
38 |9600|1|0|0|0|-|-|-|-
39 |4800|0|1|1|1|-|-|-|-
40 |(% rowspan="2" %)**Stop bit**|1 bit|-|-|-|-|0|-|-|-
41 |2 bit|-|-|-|-|1|-|-|-
42 |(% rowspan="3" %)**Parity**|None|-|-|-|-|-|0|0|-
43 |Odd|-|-|-|-|-|0|1|-
44 |Even|-|-|-|-|-|1|1|-
45 |(% rowspan="2" %)**Data bit**|7 bit|-|-|-|-|-|-|-|0
46 |8 bit|-|-|-|-|-|-|-|1
47 |(% colspan="10" %)Example: the communication format is 9600.1.8.None, b7b6b5b4=1000, b3=0, b2b1=00, b 0=1. D8120=81H ( (10000001)2=81H, 81H means hexadecimal number)
48
49 **RS (user-defined Protocol) Instruction Description**
50
51 * S: the head address of the register where the to be sent data stored in
52 * m: the length of the to be sent data (byte), 0 to 256.
53 * D: the head address of the register where the receive data stored in
54 * n: the length of the receive data(byte),0 to 256
55
56 **Example**
57
58 (% style="text-align:center" %)
59 [[image:7-13 External Device SER instruction_html_f99ab6b4507ab8d3.jpg||class="img-thumbnail" height="52" width="400"]]
60
61 When X1 is ON, the receive data and the sand data is shown as below.
62
63 (% style="text-align:center" %)
64 [[image:7-13 External Device SER instruction_html_786790195df2bc8c.jpg||class="img-thumbnail" height="182" width="300"]]
65
66 The RS (MODBUS mode) instruction automatically sets the M8123 once every time a transmit data is received and the acknowledge operation is received. Using this flag, it is possible to determine whether the RS instruction has been executed.
67
68 (% style="text-align:center" %)
69 [[image:7-13 External Device SER instruction_html_85ff4d260275024.jpg||class="img-thumbnail" height="205" width="400"]]
70
71 In actual programming, you need to do some preparation for serial communication and configuration, such as baud rate, check bit, timeout judgment condition, protocol etc. The same example, a relatively complete set of RS communication procedures are as follows.
72
73 (% style="text-align:center" %)
74 [[image:7-13 External Device SER instruction_html_8740de6f5aae261a.jpg||class="img-thumbnail" height="252" width="500"]]
75
76 **RS (MODBUS Protocol) Instruction Description**
77
78 The definitions of each operand in the RS (MODBUS mode) instruction are different from those of a standard RS instruction (user-defined protocol).
79
80 * S: Slave address (high byte), communication command (low byte, defined by MODBUS protocol);
81 * m: Start address of accessing slave;
82 * D: Data length, unit: word;
83 * n: Start address of data storage, the take up length of the subsequent address defined by D;
84
85 (% style="text-align:center" %)
86 [[image:7-13 External Device SER instruction_html_4db9718f9518d45c.jpg||class="img-thumbnail" height="253" width="700"]]
87
88 **Program example**
89
90 The PLC is set to MODBUS-RTU master mode, it reads data from address 100 of Slave 1, and read the data stored in D10.
91
92 (% style="text-align:center" %)
93 [[image:7-13 External Device SER instruction_html_49cd20661ddc2025.jpg||class="img-thumbnail" height="357" width="600"]]
94
95 = **6.14.2 RS2 instruction** =
96
97 **Instruction description**
98
99 (% class="table-bordered" %)
100 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
101 |RS2|Serial data transfer 2|16|No|RS S m D n n1|11
102
103 This instruction is mainly used for serial data transfer instruction in BD board module.
104
105 RS2 is a transceiver instruction that automatically sends the data stored in the specific register to the serial port sequentially and stores the data received by serial port in the specific area. It is equivalent to directly access the communication buffer.
106
107 The RS2 instruction is used to configure the communication protocol according to the CPAVL instruction. For details, refer to the LX3V-2RS485-BD User's Manual, LX3V-ETH-BD User's Manual or the CPAVL Instruction Manual.
108
109 (% class="table-bordered" %)
110 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
111 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
112 |S| | | | | | | | | | | | | |√| |
113 |m| | | | |√|√| | | | | | | |√| |
114 |D| | | | | | | | | | | | | |√| |
115 |n| | | | |√|√| | | | | | | |√| |
116 |n1| | | | |√|√| | | | | | | |√| |
117
118 **In LX3V-2RS485-BD module**
119
120 * User-defined protocol
121
122 S: Starting address of transmitted data.
123
124 m: Length of transmitted data, the range is 0~~256
125
126 D: Starting address for storage data.
127
128 n: Length of received data, the range is 0~~256
129
130 n1: Serial port Number, 2 means using COM2, 3 means using COM3, 4 means using COM4, 5 means using COM5, 6 means using COM6; Program could write multiple RS2 instructions, but only one RS2 instruction could be triggered at the same time.
131
132 (% style="text-align:center" %)
133 [[image:7-13 External Device SER instruction_html_a4079aa3cd82e7eb.jpg||class="img-thumbnail" height="50" width="400"]]
134
135 In this example, n1 is set K2, so the RS2 instruction is used in COM2. When X1 is triggered program will transfer data as below shows.
136
137 (% style="text-align:center" %)
138 [[image:7-13 External Device SER instruction_html_ca7e65648e2980fe.jpg||class="img-thumbnail" height="182" width="300"]]
139
140 * MODBUS protocol
141
142 The definitions of each operand in the RS2 (MODBUS mode) instruction are different from those of a standard RS instruction (user-defined protocol).
143
144 S: Slave station address (high byte), communicational command (low byte, define by MODBUS protocol);
145
146 M: Register start address of call on slave station;
147
148 D: Data length will be read or write, units is word;
149
150 N: Memory units original address for read or write data, engross continuous address units, length decided by D;
151
152 n1: Serial port Number, 2 means using COM2, 3 means using COM3, 4 means using COM4, 5 means using COM5, 6 means using COM6; Program could write multiple RS2 instructions, but only one RS2 instruction could be triggered at the same time.
153
154 (% style="text-align:center" %)
155 [[image:7-13 External Device SER instruction_html_dfa23bea9dee8a88.jpg||class="img-thumbnail" height="48" width="400"]]
156
157 In this example, n1 is set K2, so the RS2 instruction is used in COM2. When X1 is triggered program will transfer data as below shows.
158
159 (% style="text-align:center" %)
160 [[image:7-13 External Device SER instruction_html_6acd67cc98548727.png||class="img-thumbnail" height="181" width="400"]]
161
162
163 (% style="text-align:center" %)
164 [[image:7-13 External Device SER instruction_html_7fc920c883b7f391.jpg||class="img-thumbnail" height="151" width="300"]]
165
166 **In LX3V-ETH-BD module**
167
168 * MODBUS TCP protocol
169
170 S: The address of slave (high byte) and communication command (low byte, defined by MODBUS protocol);
171
172 m: The starting address number of the slave
173
174 D: The length of the data (read or writes), the unit is word. (The specific setting is shown in the following table)
175
176 (% class="table-bordered" %)
177 |**Function code**|**Length**|**Length (HEX)**
178 |Write coils|1968|0x7B0
179 |Read coils|2000|0x7D0
180 |Write registers|123|0x7B
181 |Read registers|125|0x7D
182
183 n: The starting address of the storage unit for reading or writing data, occupying the subsequent address unit, and the length is determined by the D
184
185 n1: The connection number corresponding to the Ethernet port connection number (specific settings is shown as the following table)
186
187 (% class="table-bordered" %)
188 |(% colspan="2" %)**Ethernet port 1**|**Connection number**|(% colspan="2" %)**Ethernet port 2**|**Connection number**
189 |(% rowspan="8" %)[[image:7-13 External Device SER instruction_html_73c5c45307d9b823.png]]|Connection 1|1000|(% rowspan="8" %)[[image:7-13 External Device SER instruction_html_73c5c45307d9b823.png]]|Connection 1|1100
190 |Connection 2|1001|Connection 2|1101
191 |Connection 3|1002|Connection 3|1102
192 |Connection 4|1003|Connection 4|1103
193 |Connection 5|1004|Connection 5|1104
194 |Connection 6|1005|Connection 6|1105
195 |Connection 7|1006|Connection 7|1106
196 |Connection 8|1007|Connection 8|1107
197
198 (% style="text-align:center" %)
199 [[image:7-13 External Device SER instruction_html_d344a5e717691faa.jpg||class="img-thumbnail" height="40" width="400"]]
200
201 In this example n1 is set as K1002, then RS2 is configured for Ethernet port 1, connection 3. When x1 is ON, the data is shown as below.
202
203 (% style="text-align:center" %)
204 [[image:7-13 External Device SER instruction_html_a993395de96a215.png||class="img-thumbnail" height="131" width="300"]]
205
206
207 (% style="text-align:center" %)
208 [[image:7-13 External Device SER instruction_html_5fcfd4f1bba9596b.jpg||class="img-thumbnail" height="173" width="300"]]
209
210 = **6.14.3 RSLIST instruction** =
211
212 **Instruction description**
213
214 (% class="table-bordered" %)
215 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
216 |RSLIST|Formulated communication instructions|16|No|RSLIST S,,1,, S,,2,, m1|9
217
218 (% class="table-bordered" %)
219 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
220 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
221 |S,,1,,| | | | | | | | | | | | | |√| |
222 |S,,2,,| | | | | | | | | | | | | |√| |
223 |m1| | |√| | | | | | | | | | | | |
224
225 Only LX3VP series and above plc (advanced series) support RSLIST instruction, and major version number and this version number of LX3VP series plc must be "25103" and "16001" and above edition, while major version number and this version number of LX3VPE series plc must be "25201" and "16001" and above edition.
226
227 This instruction is the one tabulating RS instruction, which replaces communication protocol by changing D8126 (communication protocol). Most of its functions are the same as the ones of RS instruction, but with simplified cumbersome engineering writing, in which, parameters of each transmission command are directly set by table.
228
229 S,,1,, is the starting device address controlled by table, with value range of D0~~D7999; The addresses of starting device between S,,1,,~~S,,4,,+4+n*6 couldnot be occupied by other instructions. (As far as possible, store data in power-down save (latched) (D200-D7999) to avoid data loss).
230
231 (% class="table-bordered" %)
232 |(% colspan="4" %)**Communication table of RSLIST instruction (MODBUS protocol)**
233 |**Address**|(% colspan="2" %)**Name**|**Function description**
234 |S,,1,,+0|(% colspan="2" %)Header|Header = 50h, correct MODBUS and MODBUSASC protocol communication form. ( No modification )
235 |S,,1,,+1|(% colspan="2" %)Communication command number|Communication command number: A transmission needs to use six devices to describe, that is, six devices describe a data transmission. ( No modification )
236 |S,,1,,+2|(% colspan="2" %)Check bit of header and communication command number|Check header and communication command number ( No modification )
237 |S,,1,,+3|(% colspan="2" %)Error replication number (retry times) (for all commands)|(((
238 Error replication number (retry times)
239
240 (0-255)
241 )))
242 |S,,1,,+4|Slave station number of current communication|Function code|(((
243 Station number: 0 ~~ 255 (0 means that the master station broadcast to all slave station, while slave station does not respond to the received information.)
244
245 Function code: please check the table below.
246 )))
247 |S,,1,,+5|(% colspan="2" %)Start address of Slave data|Word is valid. Define start address of Slave.
248 |S,,1,,+6|(% colspan="2" %)Data length|Word is valid, range: 1~~126 (word data), 1 ~~ 2039 (bit data).
249 |S,,1,,+7|(% colspan="2" %)Master stores data starting device|Word is valid. Define Master to receive the start address of data.
250 |S,,1,,+8|(% colspan="2" %)Sending control bit|Sending control bit: no running temporarily as long as it’s 0. (when it is not 0, no execution)
251 |S,,1,,+9|(% colspan="2" %)Single error replication number(retry times)|Single error replication number (retry times)(0-255)
252 |S,,1,,+10|Slave station number|Function code|(% rowspan="6" %)Description of second data transmission
253 |S,,1,,+11|(% colspan="2" %)Start address of Slave data
254 |S,,1,,+12|(% colspan="2" %)Data length
255 |S,,1,,+13|(% colspan="2" %)Master stores data starting device
256 |S,,1,,+14|(% colspan="2" %)Sending control bit
257 |S,,1,,+15|(% colspan="2" %)Single error replication number (Retry times)
258 |…|(% colspan="2" %)…|…
259 |S,,1,,+4+n*6|(% colspan="2" %)Save|N is the total number of data transmission commands
260
261 (% class="table-bordered" %)
262 |(% colspan="3" %)**Communication table of RSLIST instruction (User-defined protocol)**
263 |**Address**|**Name**|**Function description**
264 |S,,1,,+0|Header|Header = 51h, correct MODBUS and MODBUSASC protocol communication form. ( No modification )
265 |S,,1,,+1|Communication command number|Communication command number: A transmission needs to use six devices to describe, that is, six devices describe a data transmission. ( No modification )
266 |S,,1,,+2|Check bit of header and communication command number|Check header and communication command number ( No modification )
267 |S,,1,,+3|Error replication number (retry times) (for all commands)|(((
268 Error replication number (retry times)
269
270 (0-255)
271 )))
272 |S,,1,,+4|Master sends data starting device|Receive the start address of data.
273 |S,,1,,+5|Data length of Master|Word is valid. PLC determines data length according to cache block. (LX3VP:0~~528)
274 |S,,1,,+6|Master receives data starting device|Word is valid. Define Master to send the start address of data.
275 |S,,1,,+7|Data length of slave station|Word is valid. PLC determines data length according to cache block. (LX3VP:0~~528)
276 |S,,1,,+8|Sending control bit|Sending control bit: no running temporarily as long as it’s 0. (when it is not 0, no execution)
277 |S,,1,,+9|Single error replication number (Retry times)|Single error replication number(Retry times) (0-255)
278 |S,,1,,+10|Data length of Master|(% rowspan="6" %)Description of second data transmission.
279 |S,,1,,+11|Data length of Slave
280 |S,,1,,+12|Master sends data starting device
281 |S,,1,,+13|Master receives data starting device
282 |S,,1,,+14|Sending control bit
283 |S,,1,,+15|Single error replication number (Retry time)
284 |…|…|…
285 |S,,1,,+4+n*6|Save|N is the total number of data transmission commands
286
287 S,,2,, is the starting device address of table cache, with value range of D0~~D7999; the addresses of cache starting device between S,,2,,~~S,,2,,+12 couldnot be occupied by other instructions.
288
289 Note: any random data in the above operation-forbidden area will lead to communication anomalies.
290
291 (% class="table-bordered" %)
292 |**Address**|**High byte**|**Low byte**|**Operated**
293 |S,,2,,+0|(% colspan="2" %)Operation serial number: indicate which command is operating at present.|No
294 |S,,2,,+1|(% colspan="2" %)(((
295 Result code:
296
297 ~= 0, normal;
298
299 ~= Other value, abnormal
300 )))|No
301 |(% rowspan="2" %)S,,2,,+2|Slave station device number|Function code|No
302 |(% colspan="2" %)User-defined Protocol: master station sends starting device|No
303 |S,,2,,+3|(% colspan="2" %)(((
304 Start address of Master device
305
306 (User-defined protocol: Master receives the start address of data)
307 )))|No
308 |S,,2,,+4|(% colspan="2" %)(((
309 Received or sent data size
310
311 (User-defined protocol: data size received by master
312 )))|No
313 |S,,2,,+5|(% colspan="2" %)Error replication number(Retry times) of current command|No
314 |S,,2,,+6|(% colspan="2" %)Error times record|No
315 |S,,2,,+7|(% colspan="2" %)(((
316 Bit0 = 1, Port has been occupied, this command waits for data transmission rights;
317
318 Bit4, communication transmission output indication is represented by "M1";
319
320 Bit5, communication error output indication is represented by "M1 + 1";
321
322 Bit6, communication completion output indication is represented by "M1 + 2".
323 )))|No
324 |S,,2,,+8|(% colspan="2" %)Select which command to implement|Yes
325 |S,,2,,+9|(% colspan="2" %)Select which command to open and close: which command|Yes
326 |S,,2,,+10|(% colspan="2" %)(((
327 Select which command to open and close:
328
329 0: none, 1: close, 2: open;
330 )))|Yes
331 |S,,2,,+11|(% colspan="2" %)(System occupancy)|No
332
333 (% class="table-bordered" %)
334 |**Name**|**Numerical value**|**Function description**
335 |(% rowspan="6" %)Function code|01H|Read the state of consecutive multiple single-points from Slave
336 |03H|Read data of consecutive multiple registers from Slave
337 |05H|Write the state of individual single-point into Slave
338 |06H|Write data of single register into Slave
339 |0FH|Write the state of consecutive multiple single-points into Slave
340 |10H|Write data of consecutive multiple registers into Slave
341 |(% rowspan="12" %)(((
342 Result code
343
344 (error code)
345 )))|0x00|successful communication transaction
346 |0x01|frame error
347 |0x02|illegal communication table (header error)
348 |0x04|Data length error (the position read or written by command is beyond range of device size)
349 |0x05|the set read and write length range is beyond device range (starting device plus the length is beyond the range of D0-D7999)
350 |0x06|Function code error (incorrect function code or not supporting this function code).
351 |0x07|Slave station number error
352 |0x08|Slave-- --address error
353 |0x09|No response in Slave ( abnormal time-out)
354 |0x0A|Abnormal communications (receive erroneous data or slave station responses to error message).
355 |0x0B|selected commands exceed maximum number of commands
356 |0x0F|Skip this command (the sending control bit of this command is not 0)
357
358 m1 is the start address of communication flag, with value range of M0 ~~ M3068; (m1~~m1+2) couldnot be used by other instructions.
359
360 (% class="table-bordered" %)
361 |**Address**|**Function**
362 |m1+0|Transmission flag
363 |m1+1|Error flag
364 |m1+2|Completion flag
365
366 Other related settings are listed below:
367
368 (% class="table-bordered" %)
369 |(% rowspan="2" %)**Item**|(% rowspan="2" %)**Parameter**|(% colspan="8" %)**Bit value of D8120**
370 |**b7**|**b6**|**b5**|**b4**|**b3**|**b2**|**b1**|**b0**
371 |(% rowspan="6" %)**Baud rate (Bps)**|115200|1|1|0|0|-|-|-|-
372 |57600|1|0|1|1|-|-|-|-
373 |38400|1|0|1|0|-|-|-|-
374 |19200|1|0|0|1|-|-|-|-
375 |9600|1|0|0|0|-|-|-|-
376 |4800|0|1|1|1|-|-|-|-
377 |(% rowspan="2" %)**Stop bit**|1 bit|-|-|-|-|0|-|-|-
378 |2 bit|-|-|-|-|1|-|-|-
379 |(% rowspan="3" %)**Parity**|None|-|-|-|-|-|0|0|-
380 |Odd|-|-|-|-|-|0|1|-
381 |Even|-|-|-|-|-|1|1|-
382 |(% rowspan="2" %)**Data bit**|7 bit|-|-|-|-|-|-|-|0
383 |8 bit|-|-|-|-|-|-|-|1
384 |(% colspan="10" %)Example: the communication format is 9600.1.8.None, b7b6b5b4=1000, b3=0, b2b1=00, b 0=1. D8120=81H ( (10000001)2=81H, 81H means hexadecimal number)
385
386 (% class="table-bordered" %)
387 |**Address**|**Description**
388 |D8120|Com2 port communication format, interface configuration settings (see the above table for details).
389 |D8122|(((
390 User-defined protocol: send remaining data (for RS instruction only);
391
392 MODBUS protocol: command sending interval, 0 = 5ms. Unit 0.1ms
393 )))
394 |D8124|starting character STX (only for RS user-defined protocol)
395 |D8125|terminating character ETX (only for RS user-defined protocol)
396 |D8126|Communication protocol settings, interface configuration settings
397 |D8129|(((
398 MODBUS: determine the time of communication timeout, interface configuration settings, the default is 10 (10ms)
399
400 RS user-defined protocol: inter-character timeout, interface configuration settings, the default is 10 (10ms)
401 )))
402 |D8172|(((
403 First character timeout, interface configuration settings, the default is 10 (10ms)
404
405 First character timeout is not calculated when M8172 is 0. (only for RS user-defined protocol)
406 )))
407
408 **Create new RSLIST table**
409
410 Right click (Project Manager -> Project Property -> Extended Function -> RSLIST Table) to create or edit table, as shown below:
411
412 (% style="text-align:center" %)
413 [[image:7-13 External Device SER instruction_html_4ff024f75d9314f7.jpg||class="img-thumbnail" height="333" width="600"]]
414
415 * **Table setting interface as below**
416 * **Communication protocol:** should be consistent with the configuration of communication protocol control address (D8126, etc.) (Modbus Master / RS user-defined protocol).
417 * **Default error repeat count:** use the replication number (retry times)of a single error when it is not 0; use the error replication number (retry times) set in header when it is 0; default 3 times when both are 0. The set replication number includes number of times for the first run, that is, repeat errors only for two times and then turn to the next when the set replication number is 2.
418 * **Table initial address:** should be consistent with in the corresponding RSLIST instruction.
419 * **Address allocation:** Table space could be automatically configured or selected as fixed length (4 + n * 6), where n is the number of communication commands.
420
421 (% style="text-align:center" %)
422 [[image:7-13 External Device SER instruction_html_50413327a9995482.jpg||class="img-thumbnail" height="382" width="600"]]
423
424 **✎Note: **Number of table commands should be less than 255. And do address planning to avoid data confusion caused by repeatedly occupied addresses.
425
426 **Modbus Protocol Configuration**
427
428 * **Ladder configuration**
429
430 (% style="text-align:center" %)
431 [[image:7-13 External Device SER instruction_html_7db6be9bc094da69.jpg||class="img-thumbnail" height="192" width="700"]]
432
433 * **Table configuration**
434
435 (% style="text-align:center" %)
436 [[image:7-13 External Device SER instruction_html_9e317e72b272a62c.jpg||class="img-thumbnail" height="199" width="700"]]
437
438 Table start address is D300, which corresponds to the RSLIST instruction in ladder.
439
440 When M1 = ON, RSLIST instruction starts execution. When "YES" in "whether to enable command” is selected as instruction in the table ", number 1 and 3 instructions in execution table are executed cyclically; when “No” is selected, execution is controlled by “S,,2,,+8”=D208. As shown in the above ladder, D208 = 2 is triggered every 500ms, that is, number 2 instruction in the table is executed every 500ms. (Read data of 20 addresses starting from station 100 and store the read data in D500-D519 separately).
441
442 * **Communication command configuration**
443
444 (% style="text-align:center" %)
445 [[image:7-13 External Device SER instruction_html_470675f5c972bfff.jpg||class="img-thumbnail" height="428" width="400"]]
446
447 **Slave station number: **(limited between 0-255). Account 0 is used as broadcast and will not receive. See "Function Code List".
448
449 The data start address (D device) range in master station is (D0-D7999). Store relevant data in power-down save (D200-D7999) to avoid data loss. Store data start address in slave station.
450
451 **Byte of data:** (bit length in bits, word length in words), range 1 to 126 (word data), 1 to 2039 (bit data).
452
453 **Error repeat time:** 0 indicates that this error replication number (retry times) is the same as the one in table edit.
454
455 **Default starting command:**
456
457 Yes: execute cyclically when RSLIST is started;
458
459 No: execute only when +8 is in action.
460
461 **RS User-defined Protocol**
462
463 * **Ladder configuration**
464
465 (% style="text-align:center" %)
466 [[image:7-13 External Device SER instruction_html_6676db814338fe9c.jpg||class="img-thumbnail" height="240" width="700"]]
467
468 * **Table configuration**
469
470 (% style="text-align:center" %)
471 [[image:7-13 External Device SER instruction_html_5a81c6af47197dac.jpg||class="img-thumbnail" height="164" width="600"]]
472
473 The table start address is D800, which corresponds to the RSLIST instruction in ladder.
474
475 When M2=ON, RSLIST instruction starts execution. When "YES" in "whether to enable command” is selected as instruction in the table ", number 2 instructions in execution table are executed cyclically; when “No” is selected, execution is controlled by“S,,2,,+8”=D208. As shown in the above ladder, D708 = 1 is triggered every 500ms, that is, number 1 instruction in the table is executed every 500ms. (Send data of the 20 addresses starting from D1000 to device and store the returned data in the 20 addressed starting from D1020.)
476
477 * **Communication command configuration**
478
479 (% style="text-align:center" %)
480 [[image:7-13 External Device SER instruction_html_781f373e7a5f9a60.jpg||class="img-thumbnail" height="399" width="400"]]
481
482 **Starting address of delivery** (D device) range is (D0-D7999). Store relevant data in power-down save (D200-D7999) to avoid data loss.
483
484 **Sending length:** the length here is in BYTE (range LX3VP: 0-528). No sending when the sent data length is 0.The receiving start address (D device) range is (D0-D7999). Store relevant data in power-down save (D200-D7999) to avoid data loss.
485
486 **Receiving length:** the length here is in BYTE (range LX3VP: 0-528). No receiving when the received data length is 0.
487
488 **Error repeat count:** 0 indicates that this error replication number (retry times)is the same as the one in table edit.
489
490 **Default starting command:**
491
492 Yes: execute cyclically when RSLIST is started;
493
494 No: execute only when +8 is in action;
495
496 = **6.14.4 CPAVL instruction (Ethernet port)** =
497
498 **Instruction description**
499
500 (% class="table-bordered" %)
501 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
502 |CPAVL|Communication port setting|16|No|CPAVL S D M|7
503
504 * S: The starting address of “D” device;
505 * D: The starting address of “M” device;
506 * M: Serial port Number, 0 means using COM0, 1 means using COM1, 2 means using COM2, 3 means using COM3, 4 means using COM4, 5 means using COM5, 6 means using COM6; Program could write multiple RS2 instructions, but only one RS2 instruction could be triggered at the same time.
507
508 (% class="table-bordered" %)
509 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
510 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
511 |S| | | | | | | | | | | | | |√| |
512 |D| | |√| | | | | | | | | | | | |
513 |m| | | | |√|√| | | | | | | | | |
514
515 (% class="table-bordered" %)
516 |(% colspan="3" %)**Connection number description**
517 |(% rowspan="3" %)**CPAVL instruction**|Port|Connection number
518 |Ethernet port 1|1000
519 |Ethernet port 2|1100
520
521 **✎Note: **
522
523 Only need one CPAVL instruction to configure multiple connections. The RS instruction needs to be used for the corresponding connection.
524
525 **Address definition**
526
527 * M device (Bit)
528
529 (% class="table-bordered" %)
530 |**Bit address**|**Description**|**Connection**|**Bit address**|**Description**|**Connection**
531 |D+0|Reserved|(% rowspan="10" %)Connection 1 Configuration|D+10|Reserved|(% rowspan="10" %)Connection2 Configuration
532 |D+1|Instruction execution|D+11|Instruction execution
533 |D+2|Instruction execution state|D+12|Instruction execution state
534 |D+3|Communication error flag|D+13|Communication error flag
535 |D+4|Reserved|D+14|Reserved
536 |D+5|Reserved|D+15|Reserved
537 |D+6|Reserved|D+16|Reserved
538 |D+7|Reserved|D+17|Reserved
539 |D+8|Reserved|D+18|Reserved
540 |D+9|Timeout flag|D+19|Timeout flag
541 |D+20|…|…|D+30|…|…
542
543 * D device (Word)
544
545 (% class="table-bordered" %)
546 |(% style="width:69px" %)**Word Address**|(% style="width:219px" %)**Description D**|(% style="width:464px" %)**Detailed description**|(% style="width:200px" %)**Other instructions**|(% style="width:125px" %)**Read and write features**
547 |(% style="width:69px" %)0|(% style="width:219px" %) |(% style="width:464px" %)Version number|(% rowspan="23" style="width:200px" %)BD Board parameter settings|(% style="width:125px" %)R
548 |(% style="width:69px" %)1|(% rowspan="4" style="width:219px" %)BD Board IP Address|(% style="width:464px" %)IP First 1 Section|(% style="width:125px" %)R/W
549 |(% style="width:69px" %)2|(% style="width:464px" %)IP First 2 Section|(% style="width:125px" %)R/W
550 |(% style="width:69px" %)3|(% style="width:464px" %)IP First 3 Section|(% style="width:125px" %)R/W
551 |(% style="width:69px" %)4|(% style="width:464px" %)IP First 4 Section|(% style="width:125px" %)R/W
552 |(% style="width:69px" %)5|(% style="width:219px" %)Port |(% style="width:464px" %)0 default K502|(% style="width:125px" %)R/W
553 |(% style="width:69px" %)6|(% rowspan="4" style="width:219px" %)Gateway|(% style="width:464px" %)Gateway first 1 Section|(% style="width:125px" %)R/W
554 |(% style="width:69px" %)7|(% style="width:464px" %)Gateway first 2 Section|(% style="width:125px" %)R/W
555 |(% style="width:69px" %)8|(% style="width:464px" %)Gateway first 3 Section|(% style="width:125px" %)R/W
556 |(% style="width:69px" %)9|(% style="width:464px" %)Gateway first 4 Section|(% style="width:125px" %)R/W
557 |(% style="width:69px" %)10|(% rowspan="4" style="width:219px" %)Subnet mask|(% style="width:464px" %)Subnet mask first 1 Section|(% style="width:125px" %)R/W
558 |(% style="width:69px" %)11|(% style="width:464px" %)Subnet mask first 2 Section|(% style="width:125px" %)R/W
559 |(% style="width:69px" %)12|(% style="width:464px" %)Subnet mask first 3 Section|(% style="width:125px" %)R/W
560 |(% style="width:69px" %)13|(% style="width:464px" %)Subnet mask first 4 Section|(% style="width:125px" %)R/W
561 |(% style="width:69px" %)14|(% rowspan="6" style="width:219px" %)MAC|(% style="width:464px" %)MAC First 1 Section|(% style="width:125px" %)R
562 |(% style="width:69px" %)15|(% style="width:464px" %)MAC First 2 Section|(% style="width:125px" %)R
563 |(% style="width:69px" %)16|(% style="width:464px" %)MAC First 3 Section|(% style="width:125px" %)R
564 |(% style="width:69px" %)17|(% style="width:464px" %)MAC First 4 Section|(% style="width:125px" %)R
565 |(% style="width:69px" %)18|(% style="width:464px" %)MAC First 5 Section|(% style="width:125px" %)R
566 |(% style="width:69px" %)19|(% style="width:464px" %)MAC First6 Section|(% style="width:125px" %)R
567 |(% style="width:69px" %)20|(% style="width:219px" %)(Reserved)|(% style="width:464px" %) |(% style="width:125px" %)R/W
568 |(% style="width:69px" %)21|(% style="width:219px" %)(Reserved)|(% style="width:464px" %) |(% style="width:125px" %)R/W
569 |(% style="width:69px" %)22|(% style="width:219px" %)Number of connections|(% style="width:464px" %)How many connections are required to set the number of connections|(% style="width:125px" %)R/W
570 |(% style="width:69px" %)23|(% style="width:219px" %)Protocol |(% style="width:464px" %)Protocol|(% rowspan="12" style="width:200px" %)Connection 1 Configuration|(% style="width:125px" %)R/W
571 |(% style="width:69px" %)24|(% rowspan="4" style="width:219px" %)Slaves IP|(% style="width:464px" %)IP First 1 Section|(% style="width:125px" %)R/W
572 |(% style="width:69px" %)25|(% style="width:464px" %)IP First 2 Section|(% style="width:125px" %)R/W
573 |(% style="width:69px" %)26|(% style="width:464px" %)IP First 3 Section|(% style="width:125px" %)R/W
574 |(% style="width:69px" %)27|(% style="width:464px" %)IP First 4 Section|(% style="width:125px" %)R/W
575 |(% style="width:69px" %)28|(% style="width:219px" %)Port |(% style="width:464px" %)0 default K502|(% style="width:125px" %)R/W
576 |(% style="width:69px" %)29|(% style="width:219px" %)(Reserved)|(% style="width:464px" %) |(% style="width:125px" %)R/W
577 |(% style="width:69px" %)30|(% style="width:219px" %)Instruction sending interval|(% style="width:464px" %)Set the instruction sending interval. Unit: 0.1ms|(% style="width:125px" %)R/W
578 |(% style="width:69px" %)31|(% style="width:219px" %)(Reserved)|(% style="width:464px" %) |(% style="width:125px" %)R/W
579 |(% style="width:69px" %)32|(% style="width:219px" %)(Reserved)|(% style="width:464px" %) |(% style="width:125px" %)R/W
580 |(% style="width:69px" %)33|(% style="width:219px" %)(Reserved)|(% style="width:464px" %) |(% style="width:125px" %)R/W
581 |(% style="width:69px" %)34|(% style="width:219px" %)Timeout |(% style="width:464px" %) |(% style="width:125px" %)R/W
582 |(% style="width:69px" %)35|(% style="width:219px" %)Protocol |(% style="width:464px" %)Communication protocol|(% rowspan="12" style="width:200px" %)Connection 2 Configuration|(% style="width:125px" %)R/W
583 |(% style="width:69px" %)36|(% rowspan="4" style="width:219px" %)Slaves IP|(% style="width:464px" %)IP First 1 Section|(% style="width:125px" %)R/W
584 |(% style="width:69px" %)37|(% style="width:464px" %)IP First 2 Section|(% style="width:125px" %)R/W
585 |(% style="width:69px" %)38|(% style="width:464px" %)IP First 3 Section|(% style="width:125px" %)R/W
586 |(% style="width:69px" %)39|(% style="width:464px" %)IP First 4 Section|(% style="width:125px" %)R/W
587 |(% style="width:69px" %)40|(% style="width:219px" %)Port|(% style="width:464px" %)0 default K502|(% style="width:125px" %)R/W
588 |(% style="width:69px" %)41|(% style="width:219px" %)(Reserved)|(% style="width:464px" %) |(% style="width:125px" %)R/W
589 |(% style="width:69px" %)42|(% style="width:219px" %)(Reserved)|(% style="width:464px" %) |(% style="width:125px" %)R/W
590 |(% style="width:69px" %)43|(% style="width:219px" %)(Reserved)|(% style="width:464px" %) |(% style="width:125px" %)R/W
591 |(% style="width:69px" %)44|(% style="width:219px" %)(Reserved)|(% style="width:464px" %) |(% style="width:125px" %)R/W
592 |(% style="width:69px" %)45|(% style="width:219px" %)(Reserved)|(% style="width:464px" %) |(% style="width:125px" %)R/W
593 |(% style="width:69px" %)46|(% style="width:219px" %)Timeout |(% style="width:464px" %) |(% style="width:125px" %)R/W
594 |(% style="width:69px" %)47|(% style="width:219px" %)…|(% style="width:464px" %)…|(% style="width:200px" %)…|(% style="width:125px" %)R/W
595
596 **Program example**
597
598 (% style="text-align:center" %)
599 [[image:7-13 External Device SER instruction_html_1eee36136b02fca0.jpg||class="img-thumbnail" height="56" width="400"]]
600
601 Use the Ethernet port 1, and the parameter table start from D300 and M300.
602
603 * The Ethernet parameter setting of LX3V-ETH-BD
604
605 (% style="text-align:center" %)
606 [[image:7-13 External Device SER instruction_html_c12c82215871e47.jpg||class="img-thumbnail" height="288" width="400"]]
607
608 * MODBUS protocol setting
609
610 (% style="text-align:center" %)
611 [[image:7-13 External Device SER instruction_html_4533fce5143a0c70.jpg||class="img-thumbnail" height="422" width="500"]]
612
613 = **6.14.5 CPAVL instruction (Serial port)** =
614
615 **Instruction description**
616
617 (% class="table-bordered" %)
618 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
619 |CPAVL|Communication port setting|16|No|CPAVL S D M|7
620
621 * S: The starting address of “D” device;
622 * D: The starting address of “M” device;
623 * M: Serial port Number, 0 means using COM0, 1 means using COM1, 2 means using COM2, 3 means using COM3, 4 means using COM4, 5 means using COM5, 6 means using COM6; Program could write multiple RS2 instructions, but only one RS2 instruction could be triggered at the same time.
624
625 (% class="table-bordered" %)
626 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
627 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
628 |S| | | | | | | | | | | | | |√| |
629 |D| | |√| | | | | | | | | | | | |
630 |m| | | | |√|√| | | | | | | | | |
631
632 **Address definition**
633
634 (% style="text-align:center" %)
635 [[image:7-13 External Device SER instruction_html_6744c256b2335f3f.jpg||class="img-thumbnail" height="80" width="400"]]
636
637 Setting the parameters of COM4 are in 20 consecutive addresses beginning of D0 and M0.
638
639 (% class="table-bordered" %)
640 |**Bit address**|**Content**|**Word address**|**Content**
641 |D+0|Retention|S+0|Communication format, defined is 0
642 |D+1|Sending(RS2)|S+1|Station number, defined is 0
643 |D+2|(((
644 Sending flag (RS2)
645
646 Instruction state (MODBUS)
647 )))|S+2|(((
648 Remaining amount of data transmission(RS2)
649
650 Interval of sending(MODBUS)
651 )))
652 |D+3|(((
653 Receiving flag(RS2)
654
655 Communication error flag (MODBUS)
656 )))|S+3|The number of receiving data (RS2)
657 |D+4|Receiving (RS2)|S+4|Starting code STX(RS2)
658 |D+5|Retention|S+5|Ending code ETX(RS2)
659 |D+6|Retention|S+6|Communication protocol
660 |D+7|Retention|S+7|Retention
661 |D+8|Retention|S+8|Retention
662 |D+9|Timeout flag|S+9|Timeout, defined is 10 (10ms)
663 |D+10~~ D+19|Retention|S+10~~ S+19|Retention
664
665 **Program example**
666
667 * MODBUS RTU Master
668
669 (% style="text-align:center" %)
670 [[image:7-13 External Device SER instruction_html_5ea4c300a73b396.png||class="img-thumbnail" height="245" width="300"]]
671
672
673 (% style="text-align:center" %)
674 [[image:7-13 External Device SER instruction_html_38257913ae8790.jpg||class="img-thumbnail" height="214" width="400"]]
675
676 Users could set MODBUS RTU master communication by RS2 instruction, as above example shows. RS2 is a communication instruction, which could send data in the specified register area to the serial port and store receive data to specified register. Equivalent to the user program directly access the communication cache, with the help of the user program processing of the communication cache, to achieve the communication. RS instruction only is available in COM2 port, but RS2 instruction could be available in COM3/ COM4/ COM5/ COM6 ports.
677
678 * MODBUS RTU Slave
679
680 (% style="text-align:center" %)
681 [[image:7-13 External Device SER instruction_html_3b9c39db83816a1f.png||class="img-thumbnail" height="185" width="300"]]
682
683
684 (% style="text-align:center" %)
685 [[image:7-13 External Device SER instruction_html_4ac69501b2ed2704.jpg||class="img-thumbnail" height="120" width="400"]]
686
687 When plc switches from stop to run state, PLC performs MODBUS RTU Slave communication; the function code and address mapping are consistent with COM2.
688
689 (% class="table-bordered" %)
690 |**PLC internal address**|**MODBUS address**|**Number**|**Description**
691 |D0~~D8255|0 (0)|8256|
692 |T0~~T255|0x F000 (61440)|256|
693 |C0~~C199|0x F400 (62464)|200|
694 |C200~~C255|0x F700 (63232)|56|32-bit register
695
696 * User-defined
697
698 (% style="text-align:center" %)
699 [[image:7-13 External Device SER instruction_html_f0db03b2b0d7e1d2.png||class="img-thumbnail" height="117" width="250"]]
700
701
702 (% style="text-align:center" %)
703 [[image:7-13 External Device SER instruction_html_7ba0af683d7db0f6.png||class="img-thumbnail" height="116" width="250"]]
704
705 (% style="text-align:center" %)
706 [[image:7-13 External Device SER instruction_html_caaa523850bdac20.png||class="img-thumbnail" height="150" width="250"]]
707
708 (% style="text-align:center" %)
709 [[image:7-13 External Device SER instruction_html_93f45ee150331274.jpg||class="img-thumbnail" height="325" width="400"]]
710
711 = **6.14.6 PRUN instruction** =
712
713 **Instruction description**
714
715 (% class="table-bordered" %)
716 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
717 |PRUN|(% rowspan="4" %)Transmission of Octal bits|16|No|(% rowspan="4" %)PRUN S D|5
718 |PRUNP|16|Yes|5
719 |DPRUN|32|No|9
720 |DPRUNP|32|Yes|9
721
722 The instruction is used for coping the bit variables (the width unit is of octal) of the continuous addresses starting with S to the bit variable set starting with D in batch.
723
724 * S: The starting address of the bit variables to be copied, where the unit digit of the addresses must be 0, such as X10, M20;
725 * D: The starting address of the target bit variables, where the unit digit of the addresses must be 0, such as X10, M20;
726
727 (% class="table-bordered" %)
728 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
729 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
730 |S| | | | | | | |√| |√| | | | | |
731 |D| | | | | | | | |√|√| | | | | |
732
733 **Program example**
734
735 Example 1
736
737 (% style="text-align:center" %)
738 [[image:7-13 External Device SER instruction_html_3293776174646ccf.jpg||class="img-thumbnail" height="60" width="400"]]
739
740 (% style="text-align:center" %)
741 [[image:7-13 External Device SER instruction_html_5b80287b320b1cc0.jpg||class="img-thumbnail" height="126" width="600"]]
742
743 Example 2
744
745 (% style="text-align:center" %)
746 [[image:7-13 External Device SER instruction_html_af1ed04131e3732.jpg||class="img-thumbnail" height="53" width="400"]]
747
748 (% style="text-align:center" %)
749 [[image:7-13 External Device SER instruction_html_c58911b98d6888db.jpg||class="img-thumbnail" height="124" width="600"]]
750
751 = **6.14.7 ASCI instruction** =
752
753 **Instruction description**
754
755 (% class="table-bordered" %)
756 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
757 |ASCI|(% rowspan="2" %)Converts a data value from hexadecimal to ASCII|16|No|(% rowspan="2" %)ASCI S D n|7
758 |ASCIP|16|Yes|7
759
760 This instruction reads n hexadecimal data characters from head source address (S) and converts them in to the equivalent ASCII code.
761
762 * S: The source address;
763 * D: The store address;
764 * n: The data length;
765
766 (% class="table-bordered" %)
767 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
768 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
769 |S| | | | |√|√| |√|√|√|√|√|√|√|√|√
770 |D| | | | | | | | |√|√|√|√|√|√| |
771 |n|(% colspan="16" %)Constant, n=1~~256
772
773 **Program example**
774
775 (% style="text-align:center" %)
776 [[image:7-13 External Device SER instruction_html_66c5cfc4713bdf0b.jpg||class="img-thumbnail" height="98" width="600"]]
777
778 The M8161 flag determines the width mode of the target variable for calculation result storage. When M8161=OFF, it is 16bit mode, which means the higher byte and lower byte are saved respectively. When M8161=ON, it is 8bit mode, which means that only the lower byte is used to save result and the actual variable range length is longer.
779
780 (% style="text-align:center" %)
781 [[image:7-13 External Device SER instruction_html_bfac61ddc96b9a82.jpg||class="img-thumbnail" height="194" width="700"]]
782
783 (% style="text-align:center" %)
784 [[image:7-13 External Device SER instruction_html_151fd06affcbc3b8.jpg||class="img-thumbnail" height="154" width="400"]]
785
786 * When M8161=OFF
787
788 (% style="text-align:center" %)
789 [[image:7-13 External Device SER instruction_html_c5eb9280902d1523.jpg||class="img-thumbnail" height="225" width="700"]]
790
791 When M8161=ON
792
793 (% style="text-align:center" %)
794 [[image:7-13 External Device SER instruction_html_657f7883d3e7bd87.jpg||class="img-thumbnail" height="402" width="700"]]
795
796 **Points to note**
797
798 Instructions such as RS / HEX / ASCI / CCD share the M8161 mode flag, please pay attention on it when programming.
799
800 = **6.14.8 HEX instruction** =
801
802 **Instruction description**
803
804 (% class="table-bordered" %)
805 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
806 |HEX|(% rowspan="2" %)Converts a data value from hexadecimal to ASCII|16|No|(% rowspan="2" %)HEX S D n|7
807 |HEXP|16|Yes|7
808
809 This instruction reads n ASCII data bytes from head source address (S) and converts them in to the equivalent Hexadecimal character, and saved result in D.
810
811 * S: The variable address or constant to be converted. If it is a register variable, the conversion interval will has a width of a 32bit variable.
812 * D: The starting address for storing the ASCII code.
813 * n: The data length;
814
815 (% class="table-bordered" %)
816 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
817 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
818 |S| | | | |√|√| |√|√|√|√|√|√|√|√|√
819 |D| | | | | | | | |√|√|√|√|√|√| |
820 |n|(% colspan="16" %)Constant, n=1~~256
821
822 **Program example**
823
824 (% style="text-align:center" %)
825 [[image:7-13 External Device SER instruction_html_5c5559d29754df6a.jpg||class="img-thumbnail" height="69" width="400"]]
826
827 For example, the following data is starting from D100.
828
829 (% style="text-align:center" %)
830 [[image:7-13 External Device SER instruction_html_c75a66125ec0cf6.jpg||class="img-thumbnail" height="271" width="700"]]
831
832 (% style="text-align:center" %)
833 [[image:7-13 External Device SER instruction_html_90be70230a6898d2.jpg||class="img-thumbnail" height="254" width="700"]]
834
835 The M8161 flag determines the width mode of the target variable for calculation result storage. When M8161=OFF, it is 16bit mode, which means the higher byte and lower byte are saved respectively. When M8161=ON, it is 8bit mode, which means that only the lower byte is used to save result and the actual variable range length is longer.
836
837 * When M8161=OFF
838
839 (% style="text-align:center" %)
840 [[image:7-13 External Device SER instruction_html_d9179ef38213328e.jpg||class="img-thumbnail" height="137" width="700"]]
841
842 * When M8161=ON
843
844 (% style="text-align:center" %)
845 [[image:7-13 External Device SER instruction_html_e0c12c92f19a1236.jpg||class="img-thumbnail" height="137" width="700"]]
846
847 **Points to note**
848
849 * Instructions such as RS / HEX / ASCI / CCD share the M8161 mode flag, please pay attention on it when programming;
850 * S data area of the source data must be ASCII characters, or error occur when conversion;
851 * If the output data is in BCD format please do BCD-BIN conversion after HEX conversion, then users could get correct value;
852
853 = **6.14.9 CCD instruction** =
854
855 **Instruction description**
856
857 (% class="table-bordered" %)
858 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
859 |CCD|(% rowspan="2" %)Check Code|16|No|(% rowspan="2" %)CCD S D n|7
860 |CCDP|16|Yes|7
861
862 This instruction looks at a byte stack of data from head address (S) for n bytes and checks the vertical bit pattern for parity and sums the total data stack. These two pieces of data are then stored at the destination (D).
863
864 * S: The starting address of variables, which are to be checked and calculated;
865 * D: Respectively used for saving “SUM” result (D+1) is respectively used for saving “XOR” result;
866 * n: The bit number occupied by variables for checking
867
868 (% class="table-bordered" %)
869 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
870 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
871 |S| | | | | | | |√|√|√|√|√|√|√| |
872 |D| | | | | | | | |√|√|√|√|√|√| |
873 |n|(% colspan="16" %)Constant, n=1~~256
874
875 **Program example**
876
877 (% style="text-align:center" %)
878 [[image:7-13 External Device SER instruction_html_e0a2ba4435f0dc1a.jpg||class="img-thumbnail" height="71" width="400"]]
879
880 (% style="text-align:center" %)
881 [[image:7-13 External Device SER instruction_html_22098ca4de465ce7.jpg||class="img-thumbnail" height="249" width="700"]]
882
883 The M8161 flag determines the width mode of the target variable for calculation result storage. When M8161=OFF, it is 16bit mode, which means the higher byte and lower byte are saved respectively. When M8161=ON, it is 8bit mode, which means that only the lower byte is used to save result and the actual variable range length is longer.
884
885 The “SUM” is quite simply a summation of the total quantity of data in the data stack.
886
887 The "XOR" logical calculation means:
888
889 * The involved variables are converted to binary format.
890 * Then it counts the number of variables with bit0=1. If it is even, the calculation result of bit0 is 0. If it is odd, the calculation result of bit0 is 1.
891 * Then it counts the number of variables with bit1=1. If it is even, the calculation result of bit1 is 0; if it is odd, the calculation result of bit1 is 1.
892 * In the same way, calculation is implemented from bit2 to bit7. After that, the binary HEX value converted from binary is the “XOR” result (polarity value).
893
894 **Note for use**
895
896 * Instructions such as RS / HEX / ASCI / CCD share the M8161 mode flag, please pay attention on it when programming;
897
898 = **6.14.10 PID instruction** =
899
900 **Instruction description**
901
902 (% class="table-bordered" %)
903 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
904 |PID|PID operation|16|No|PID S,,1,, S,,2,, S,,3,, D|9
905
906 This instruction is for PID operation; it is used for control of close-loop system parameter. PID control is widely used in mechanical equipment, pneumatic equipment, constant pressure water supply, electronic equipment and so on.
907
908 * S,,1,,: The predefined set value;
909 * S,,2,,: The current value;
910 * S,,3,,: The operation parameter, it takes the next 25 addresses, the value range is D0 ~~ D7975, it is best to specify the retentive memory, for saving parameter when power OFF;
911 * D: The destination device, it is better to specify the non-retentive memory, otherwise users need to initialize it before executing instruction;
912
913 (% class="table-bordered" %)
914 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
915 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
916 |S,,1,,| | | | | | | | | | | | | |√| |
917 |S,,2,,| | | | | | | | | | | | | |√| |
918 |S,,3,,| | | | | | | | | | | | | |√| |
919 |D| | | | | | | | | | | | | |√| |
920
921 **Program example**
922
923 (% style="text-align:center" %)
924 [[image:7-13 External Device SER instruction_html_7b436597fadf66dc.jpg||class="img-thumbnail" height="53" width="400"]]
925
926 D9 is target value, D10 is current value, the unit for D9 and D10 must be the same.
927
928 D200~~D224 are used for storing the set value and process value of PID operation. These values must be set item by item before executing PID operation.
929
930 D130 is used for storing the calculated value, it is used for controlling the implementation of the action.
931
932 (% class="table-bordered" %)
933 |(% colspan="3" %)**Operation parameters (S,,3,,+N)**
934 |**Unit**|**Function**|**Description**
935 |S,,3,,|Sample time(Ts)|(((
936 Setting range 1~32767(ms), but must longer than scouldning cycle of plc
937
938 program
939 )))
940 |S,,3,,+1|(((
941 Reaction
942
943 direction(ACT)
944 )))|(((
945 bit0: 0=positive action; 1=negative action;
946
947 bit3: 0=one way; 1=two way;
948
949 bit4: 0=disable self-tuning; 1=enable self-tuning;
950
951 Others couldnot be used.
952 )))
953 |S,,3,,+2|(((
954 Maximum
955
956 climbing(Delta T)
957 )))|Setting range 0~~320
958 |S,,3,,+3|Proportional gain(Kp)|Setting range: 0~~32767, note:this value is magnified 256 times, actual value is Kp/256
959 |S,,3,,+4|Integral gain(Ki)|Setting range: 0~~32767, Ki=16384Ts/Ti, Ti is integral time
960 |S,,3,,+5|Derivative gain(Kd)|Setting time: 0~~32767, Kd≈Td/Ts, Td is derivative time
961 |S,,3,,+6|Filter (C0)|Range: 0~~1024
962 |S,,3,,+7|Output lower limit|Recommended range: -2000~~2000, when S3+1 bit3=0, please set 0; S3+1 bit3=1, please set -2000
963 |S,,3,,+8|Output upper limit|Recommended values: 2000
964 |S,,3,,+9|Retain |Retain
965
966 * Self-tuning example
967
968 (% style="text-align:center" %)
969 [[image:7-13 External Device SER instruction_html_2337238c0f91917.jpg||class="img-thumbnail" height="295" width="400"]]
970
971 **Error code**
972
973 If an error occurs in the set value of the control parameters or in the PID operation, the operation error flag M8067 turns on and the following data is stored in D8067 according to the error details.
974
975 (% class="table-bordered" %)
976 |**Error code**|**Error content**|(% style="width:171px" %)**State**|(% style="width:596px" %)**Processing method**
977 |K6705|(((
978 Operand of application instruction
979
980 outside of target device
981 )))|(% rowspan="8" style="width:171px" %)Stop PID operation|(% rowspan="10" style="width:596px" %)Please check data for PID operation
982 |K6706|(((
983 Operand of application instruction
984
985 outside of target device
986 )))
987 |K6730|(((
988 (TS< 0 )
989
990 Sampling time(TS) outside of target device (TS< 0 )
991 )))
992 |K6732|Filter (C0) outside (C0<0 or 1024≤C0)
993 |K6732|Maximum rate of raise(DeltaT) outsideΔT<0 or 320≤ΔT
994 |K6733|Proportional gain(KP) outside of target range
995 |K6734|(((
996 Integral gain (KI)outside of target
997
998 range(KI<0)
999 )))
1000 |K6735|Derivative gain outside of target range(KD<0)
1001 |K6740|Sampling time≤ operation cycle|(% rowspan="2" style="width:171px" %)Continue PID operation
1002 |K6742|Variation of measured value exceed ((PV<-32768 or 32767 < ( PV )
1003 |K6751|Direction of Self-tuning isn’t match|(% style="width:171px" %)Continue PID self-tuning|(% style="width:596px" %)The action direction between set value and current value are not match. Please correct the target value, self-tuning output, estimated value, then self-tuning.
1004 |K6752|Self-tuning action is improper|(% style="width:171px" %)Self-tuning|(% style="width:596px" %)Self-tuning measured value couldnot be correct action, due to changes in the upper and lower. Please make the sampling time is much greater than the output change cycle, increase the input filter constant. After changing the setting, please perform auto-tuning again.
1005
1006 **Note for use**
1007
1008 The correct measured value must be read into the PID measured value (PV) before the PID operation is executed. In particular, pay attention to the conversion time when performing PID operation on the value of the analog input module.
1009
1010 PID instruction could be used multiple times and executed at the same time, but variable area of PID instruction couldnot overlap; it also could be used in step instruction, jump instruction, timer interruption, subroutine, but please delete S,,3,,+9 cache unit before execute PID instruction.
1011
1012 The maximum error of sampling time TS is - (1 execution cycle+ l ms)~~ +(1 execution cycle). If sampling time TS≤1 execution cycle OF PLC, then will have below PID operational error (K6740), and execute PID algorithm as TS = execution cycle, in that case, it is better to use constant scouldning mode or use the PID instruction in timer interrupt (16□□~~18□□)