Wiki source code of 10 Communication instruction

Version 21.1 by Stone Wu on 2022/09/26 14:49

Show last authors
1 = **Communication** =
2
3 == **Protocol** ==
4
5 **PROTOCOL(P)**
6
7 Set (s) protocol for (N) communication port.
8
9 -[PROTOCOL (S) (N)]
10
11 **Content, range and data type**
12
13 (% class="table-bordered" %)
14 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
15 |(S)|Protocol number to be set|-|Unsigned BIN 16 bit|ANY16
16 |(N)|Which communication port to set, 0 means COM1, 1 means COM2 *1|0, 1|Unsigned BIN 16 bit|ANY16
17
18 **Device used**
19
20 (% class="table-bordered" %)
21 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="10" %)**Devices**|(((
22 **Offset**
23
24 **modification**
25 )))|(((
26 **Pulse**
27
28 **extension**
29 )))
30 |**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|**H**|**[D]**|**XXP**
31 |(% rowspan="2" %)PROTOCOL|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|●
32 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|●
33
34 **Features**
35
36 This instruction is mainly used to set the protocol during run, and can also be used in the first cycle of run.
37
38 The value of the protocol address (COM1 SD2542, COM2 SD2592) and the protocol modification flag (COM1 SD2543, COM2 SD2593) can be directly set according to the command parameters.
39
40 The specific calculation formula for setting the protocol modification flag (COM1 SD2543, COM2 SD2593) is: (parameter setting value + offset of the corresponding serial port's initial special soft component + 10)*2
41
42 For example, setting the protocol to 2 is (2 +2593-2590 +10)*2, which is (2+3+10) *2=30. At this time, SD2592 will be set to 1, and SD2593 will be set to 32.
43
44 **✎Note: **Whether it is by self-calculation and then modifying the setting value of the identifier (COM1 SD2543, COM2 SD2593) to the protocol, or using this instruction to set, it is possible to modify the protocol when the PLC is in the RUN state.
45
46 Regarding the protocol modification flags (COM1 SD2543, COM2 SD2593): During the RUN process, the first cycle of setting the protocol and modifying the flags is correct (judging at END) to the correct first cycle. When the modification is completed, the protocol modification flags (COM1 SD2543, COM2 SD2593) is cleared, and then set the same value will not be processed. Mainly to avoid repeated settings multiple times.
47
48 **Agreement Number**
49
50 (% class="table-bordered" %)
51 |**Agreement Number**|**Content**
52 |0 H|Wecon Modbus slave
53 |2 H|ModbusRTU slave
54 |3 H|ModbusASCII slave
55 |10 H|User-defined protocol
56 |20 H|ModbusRTU master station
57 |30 H|ModbusASCII master
58
59 **Related software components**
60
61 (% class="table-bordered" %)
62 |**Devices**|**Content**
63 |SD2542|COM1 protocol settings
64 |SD2543|COM1 protocol modification sign
65 |SD2592|COM2 protocol settings
66 |SD2593|COM2 protocol modification sign
67
68 **✎Note:**
69
70 The setting of communication parameters will affect the overall communication. The processing in the PLC is to modify it when there is no communication or after a round of communication is completed. This point needs attention.
71
72 If the set protocol does not match the provided protocol number, the protocol modification flag (COM1 SD2543, COM2 SD2593) will not be cleared after setting. At this time, the protocol will not be set successfully, and it will run according to the original protocol.
73
74 **Error code**
75
76 (% class="table-bordered" %)
77 |**Error code**|**Content**
78 |4085H|The read address of (s) and (N) exceeds the device range
79 |4084H|(N) is not 1
80
81 **Example**
82
83 (% style="text-align:center" %)
84 [[image:10_html_2947ba20da1d1c90.png||class="img-thumbnail"]]
85
86 Example above
87
88 M1 changes from OFF to ON during the run
89
90 SD2592 will be set to 32 (20H), SD2593 will be set to 90 and then it will be cleared. At this time, it means that the setting is successful.
91
92 (% style="text-align:center" %)
93 [[image:10_html_38333ed8624e86d1.png||class="img-thumbnail"]]
94
95 If you turn M1 from OFF to ON again
96
97 SD2592 will be set to 32 (20H), SD2593 will be set to 90 but will not be cleared.
98
99 (% style="text-align:center" %)
100 [[image:10_html_54692bd97d6e3bfd.png||class="img-thumbnail"]]
101
102 = **Modbus serial port parameter setting** =
103
104 == {{id name="_PORTPARA/MODBUS串口参数设置"/}}{{id name="_Toc1121"/}}{{id name="_Toc11010"/}}**PORTPARA/Modbus serial port parameter setting** ==
105
106 **PORTPARA(P)**
107
108 Set (s) serial port parameters for (N) communication port.
109
110 -[PORTPARA (s) (N)]
111
112 **Content, range and data type**
113
114 (% class="table-bordered" %)
115 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
116 |(s)|Serial port parameters to be set|-|Unsigned BIN 16 bit|ANY16
117 |(N)|Which communication port to set, 0 means COM1, 1 means COM2|0, 1|Unsigned BIN 16 bit|ANY16
118
119 **Device used**
120
121 (% class="table-bordered" %)
122 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="10" %)**Devices**|(((
123 **Offset**
124
125 **modification**
126 )))|(((
127 **Pulse**
128
129 **extension**
130 )))
131 |**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|**H**|**[D]**|**XXP**
132 |(% rowspan="2" %)ECAMCUT|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|●
133 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|●
134
135 **Features**
136
137 This instruction is mainly used to set serial port parameters during run, and can also be used in the first cycle of run.
138
139 Can directly set the serial port parameter address (COM1 SD2540, COM2 SD2590) and the value of the serial parameter modification flag (COM1 SD2541, COM2 SD2591) according to the command parameters.
140
141 The specific calculation formula for setting the serial port parameter modification flags (COM1 SD2541, COM2 SD2591) is: (parameter setting value + offset of the corresponding serial port's initial special soft component + 10)*2
142
143 For example, setting the COM1 serial port parameter to 193 (HC1) is (193 +2541-2540 +10)*2 which is (193 +1+10) *2=408. At this time, 193 (HC1) will be set for SD2540 and 408 for SD2541.
144
145 **✎Note: **Whether it is by self-calculation and then to the serial port parameter to modify the flag (COM1 SD2541, COM2 SD2591) setting value, or use this instruction to set, it is possible to modify the serial port parameter when the PLC is in the RUN state.
146
147 About serial port parameter modification flags (COM1 SD2541, COM2 SD2591): During RUN, when the serial port parameters are set and the modified flag is correct (judging at END) to the correct first cycle, the serial port parameter modification flag (COM1 SD2541, COM2, SD2591) are cleared, and then set the same value will not be processed. Mainly to avoid repeated settings multiple times.
148
149 **Serial port parameter setting table**
150
151 (% class="table-bordered" %)
152 |(% colspan="2" %)**Bit number**|**B0**|**B1、B2**|**B3**|**B4、B5、B6、B7、B8、B9**|**B10**|**B11**
153 |(% colspan="2" %)**Name**|**Data length**|**Parity**|**Stop Bit**|**Baud Rate(bps)**|**STX**|**ETX**
154 |(% rowspan="2" %)**Content**|**0 off**|7bit|(% rowspan="2" %)(((
155 b2,b1
156
157 (0,0):None
158
159 (0,1):Odd parity(ODD)
160
161 (1,1):Even parity(EVEN)
162 )))|1bit|(% rowspan="2" %)(((
163 |4800|0111
164 |9600|1000
165 |19200|1001
166 |38400|1010
167 |57600|1011
168 |115200|1100
169 |187500|1101
170 |230400|1110
171 |460800|1111
172 |921600|10000
173 )))|Turn off STX function|Turn off ETX function
174 |**1 on**|8bit|2bit|Enable STX function, the specific value is set by D8124|Turn on the ETX function, the specific value is set by D8125
175
176 **Related software components**
177
178 (% class="table-bordered" %)
179 |**Devices**|**Content**
180 |SD2540|COM1 serial port parameter setting
181 |SD2541|COM1 serial port parameter modification identification
182 |SD2590|COM2 serial port parameter setting
183 |SD2591|COM2 serial port parameter modification sign
184
185 **✎Note:**
186
187 The setting of communication parameters will affect the overall communication. The processing in the PLC is to be modified when there is no communication or after a round of communication is completed. This point needs attention.
188
189 STX function and ETX function are only useful in the case of custom protocol.
190
191 If the set protocol does not match the provided protocol number, the serial port parameter modification flags (COM1 SD2541, COM2 SD2591) will not be cleared after setting. At this time, the protocol will not be set successfully, and it will run according to the original protocol.
192
193 **Error code**
194
195 (% class="table-bordered" %)
196 |**Error code**|**Content**
197 |4085H|The read address of (s) and (N) exceeds the device range
198 |4084H|(N) is not 0 or 1
199
200 **Example**
201
202 (% style="text-align:center" %)
203 [[image:10_html_4a65cac3b7fac971.png||class="img-thumbnail"]]
204
205 Example above
206
207 M1 changes from OFF->ON during run
208
209 SD2540 will be set to 129 (H81, baud rate: 9600, stop bit: 1, data bit: 8, parity bit: none), SD2541 will be set to 280 and then cleared. At this time it has been set successfully
210
211 (% style="text-align:center" %)
212 [[image:10_html_6c71076e92745b55.png||class="img-thumbnail"]]
213
214 If you turn M1 from OFF->ON again
215
216 SD2540 will be set to 129 (H81), SD2541 will be set to 280 but will be cleared.
217
218 (% style="text-align:center" %)
219 [[image:10_html_b19182554f11878c.png||class="img-thumbnail"]]
220
221 = {{id name="_Toc18012"/}}**{{id name="_Toc31925"/}}Modbus station number setting** =
222
223 == {{id name="_Toc27385"/}}**{{id name="_Toc31405"/}}STATION/Modbus station number setting** ==
224
225 **STATION(P)**
226
227 Under the Modbus slave station protocol. Set the station number (s) for the (N) communication port.
228
229 -[STATION (s) (N)]
230
231 **Content, range and data type**
232
233 (% class="table-bordered" %)
234 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
235 |(s)|Station number to be set|0 to 255|Unsigned BIN 16 bit|ANY16
236 |(N)|Which communication port to set 0 means COM1, 1 means COM2|0, 1|Unsigned BIN 16 bit|ANY16
237
238 **Device used**
239
240 (% class="table-bordered" %)
241 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="10" %)**Devices**|(((
242 **Offset**
243
244 **modification**
245 )))|(((
246 **Pulse**
247
248 **extension**
249 )))
250 |**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|**H**|**[D]**|**XXP**
251 |(% rowspan="2" %)ECAMCUT|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|(% rowspan="2" %)●
252 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●
253
254 **Features**
255
256 ●This instruction is mainly used to set the station number during run, and it can also be used in the first cycle of run.
257
258 ●The value of the station number address (COM1 SD2544, COM2 SD2594) and the station number modification flag (COM1 SD2545, COM2 SD2595) can be directly set according to the command parameters.
259
260 ●The specific calculation formula for setting the station number modification flag (COM1 SD2545, COM2 SD2595) is: (parameter setting value + offset of the corresponding serial port's initial special device + 10)*2
261
262 ●For example, setting the COM2 station number to 1 is (1 +2595-2590 +10)*2, which is (1 +5+10) *2=32. At this time, SD2594 will be set to 1, and SD2595 will be set to 32.
263
264 **✎Note: **Whether it is by self-calculation and then modifying the ID (COM1 SD2545, COM2 SD2595) setting value to the station number, or setting with this instruction, the station number can be modified when the PLC is in the RUN state.
265
266 ●Regarding station number modification identification (COM1 SD2545, COM2 SD2595): During RUN, when the station number is set and the modification identification is correct (judgment at END) to the correct first cycle, the station number will be modified when the modification is completed (COM1 SD2545, COM2 SD2595) are cleared, and then set the same value will not be processed. Mainly to avoid repeated settings multiple times.
267
268 **Related software components**
269
270 (% class="table-bordered" %)
271 |**Devices**|**Content**
272 |SD2544|COM1 station number setting
273 |SD2545|COM1 station number modification sign
274 |SD2594|COM2 station number setting
275 |SD2595|COM2 station number modification sign
276
277 **Error code**
278
279 (% class="table-bordered" %)
280 |**Error code**|**Content**
281 |4085H|The read address of (s) and (N) exceeds the device range
282 |(% rowspan="2" %)4084H|(s) not in the range of 0 to 255
283 |(N) is not 0 or 1
284
285 **✎Note:**
286
287 The setting of communication parameters will affect the overall communication. The processing in the PLC is to modify it when there is no communication or after a round of communication is completed. This point needs attention.
288
289 **Example**
290
291 (% style="text-align:center" %)
292 [[image:10_html_687577f8e28f9089.png||class="img-thumbnail"]]
293
294 Example above
295
296 M1 changes from OFF->ON during run
297
298 SD2594 will be set to 2, SD2595 will be set to 34 and then it will be cleared. At this time it has been set successfully
299
300 (% style="text-align:center" %)
301 [[image:10_html_b474623d8ed5305f.png||class="img-thumbnail"]]
302
303 If you turn M1 from OFF->ON again
304
305 SD2594 will be set to 2, SD2595 will be set to 34 but will not be cleared.
306
307 (% style="text-align:center" %)
308 [[image:10_html_309b7cb63c6f5d1b.png||class="img-thumbnail"]]
309
310 = {{id name="_Toc1836"/}}**{{id name="_Toc10711"/}}{{id name="_Toc29509"/}}{{id name="_Toc5112"/}}RS instruction** =
311
312 == {{id name="_Toc10635"/}}**{{id name="_Toc16249"/}}{{id name="_Toc17183"/}}{{id name="_Toc29599"/}}RS/External communication instruction** ==
313
314 **RS**
315
316 In the case of Modbus master station protocol: This instruction is the setting interface for the master station to send protocol frames. The function code (s), slave address (m), length (d) of the station number set according to the instruction, and the function code determines whether the data of n is required to be automatically combined to send and receive protocol frames. If it is a read type function code, the data will be written into (N).
317
318 -[RS (s) (m) (d) (N)]
319
320 **{{id name="_Toc26963"/}}Content, range and data type**
321
322 In the case of user-defined protocol:
323
324 (% class="table-bordered" %)
325 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
326 |(s)|The start address of register area that stores the data to be sent|-|Unsigned BIN 16 bit|ANY16
327 |(m)|The length of data to be sent (bytes)|0 to 523|Unsigned BIN 16 bit|ANY16
328 |(d)|The device start number that stores the written data|-|Unsigned BIN 16 it|ANY16
329 |(N)|Number of data written (bytes)|0 to 523|Unsigned BIN 16 bit|ANY16
330
331 In the case of Modbus protocol:
332
333 (% class="table-bordered" %)
334 |**Parameter**|**Content**|**Range**|**Data type**|(((
335 **Data type**
336
337 **(label)**
338 )))
339 |(s)|The high byte stores the station number of slave station, and the low byte stores function code of Modbus|-|Unsigned BIN 16 bit|ANY16
340 |(m)|Slave address. The address provided by the slave station will read or write data from this address of the slave station|-|Unsigned BIN 16 bit|ANY16
341 |(d)|Length. The length of Modbus read or write. The unit is determined by function code.|-|Unsigned BIN 16 bit|ANY16
342 |(N)|Start address for reading or writing data|-|Unsigned BIN 16 bit|ANY16
343
344 {{id name="_Toc26776"/}}{{id name="_Toc17529"/}}**Device used**
345
346 (% class="table-bordered" %)
347 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="6" %)**Devices**|**Offset modification**|(((
348 **Pulse**
349
350 **extension**
351 )))
352 |**T**|**C**|**D**|**R**|**K**|**H**|**[D]**|**XXP**
353 |(% rowspan="4" %)RS|Parameter 1|●|●|●|●|●|●| |
354 |Parameter 2|●|●|●|●|●|●| |
355 |Parameter 3|●|●|●|●|●|●| |
356 |Parameter 4|●|●|●|●|●|●| |
357
358 **{{id name="OLE_LINK409"/}}(1) {{id name="_Toc13811"/}}Custom protocol**
359
360 When the communication protocol is set as a [[custom protocol>>url:http://dict.cn/self-defined%20protocol]]. When the contact in before RS instruction is turned on and SM2591 is also turned on at the same time, if the sending length (m) is not 0, the data of (s) will be sent (m) bytes out, and then it will be in the mode of waiting for reception. When the data is received, (N) bytes of data will be stored in (d). SM2593 will be turned ON after receiving (N) data.
361
362 In addition, when the sending length (m) is 0, it will be in the receive-only mode. When the receiving length (N) is 0, it will be in the send-only mode.
363
364 To enable the start character (STX) and the end character (ETX) modes of RS instruction, the status of the 10th and 11th bits of the special address SD2600 must be set. See the table below for detailed settings:
365
366 (% class="table-bordered" %)
367 |(% colspan="2" %)**Bit number**|**B0**|**B1、B2**|**B3**|(((
368 **B4、B5、B6、**
369
370 **B7、B8、B9**
371 )))|**B10**|**B11**
372 |(% colspan="2" %)**Name**|**Data length**|**Parity**|**Stop Bit**|**Baud rate(bps)**|**STX**|**ETX**
373 |(% rowspan="2" %)**Content**|(((
374 **0**
375
376 **off**
377 )))|7-bit|(% rowspan="2" %)(((
378 b2, b1
379
380 (0,0): None
381
382 (0,1): Odd parity (ODD)
383
384 (1,1): Even parity (EVEN)
385 )))|1-bit|(% rowspan="2" %)(((
386 |9600|001000
387 |19200|001001
388 |38400|001010
389 |57600|001011
390 |115200|001100
391 |187500|001101
392 |230400|001110
393 |460800|001111
394 |921600|010000
395 )))|None|None
396 |(((
397 **1**
398
399 **on**
400 )))|8-bit|2-bit|Turn on STX, the STX value is set in SD2600|Turn on ETX, the ETX value is set in SD2601
401
402 **Example**
403
404 (% style="text-align:center" %)
405 [[image:10_html_dbd00c955b74b44.png||class="img-thumbnail"]]
406
407 When M1 is ON, the sending and receiving data of communication after executing instruction is stored as the following figure.
408
409 (% style="text-align:center" %)
410 [[image:10_html_fa670961ae3e6f05.gif||class="img-thumbnail"]]
411
412 Some configuration and preparation of serial communication are needed for actual programming to communicate as expected, such as setting the transceiver mode of serial port, baud rate, number of bits, parity, software protocol settings, timeout judgment conditions, and data preparation for the transceiver buffer, send and receive flag processing, etc.,
413
414 A relatively complete RS communication setup program is shown as follows:
415
416 (% style="text-align:center" %)
417 [[image:10_html_487e57593173359e.png||class="img-thumbnail"]]
418
419 (((
420 Serial port parameters settings:
421
422 Baud rate 112500, stop bit 1, data bit 8, parity bit none
423 )))
424
425 (((
426 Set the protocol as a custom protocol
427
428 Sending interval: 5ms
429
430 Receiving timeout: 100ms
431
432 Number of repetitions: 3 times
433
434 Timeout between characters: 30ms
435
436 Custom protocol, send start address D200, sending length 8, receive start address D300, receiving length 8,
437
438 Receive start address D300 Receive length 6
439
440 Send directly after trigger
441
442 After receiving, close the instruction directly and reset the instruction receiving flag
443 )))
444
445 For detailed user-defined protocol instructions, please refer to "__[[10.7.1 Custom protocol description>>path:#_10.7.1 Custom protocol description]]__"
446
447 **{{id name="_Toc24060"/}}(2) Modbus protocol**
448
449 When the protocol is set to Modbus master protocol (whether it is RTU or ASCII). When the contact before RS instruction is turned ON, the RS instruction will send the combined data frame according to the station number function code (s), slave station address (m), length (d) and judge whether the data of (N) is needed according to the function code.
450
451 (% style="text-align:center" %)
452 [[image:10_html_9d0ddca3305d21b0.png||class="img-thumbnail"]]
453
454 (% class="table-bordered" %)
455 |**Parameter**|**Content**
456 |(s)|The high byte stores the station number of slave station, and the low byte stores the function code of Modbus
457 |(m)|Slave address. The address provided by the slave station will read or write data from this address of the slave station
458 |(d)|Length, the length of Modbus read or write. The unit is determined by the function code.
459 |(N)|Start address for reading or writing data
460
461 (% style="text-align:center" %)
462 [[image:10_html_a7e64b4f4526b73e.png||class="img-thumbnail"]]
463
464 (((
465 Serial port parameter setting
466
467 Baud rate 115200, data bit 8, parity bit none, stop bit 1
468
469 Communication protocol setting: ModbusRTU master station protocol
470
471 Sending interval: 5ms
472
473 Receiving timeout: 100ms
474
475 Timeout retry times: 3 times
476
477 Station number 01H, function code 03H, slave address 10, length 05
478 )))
479
480 As the ladder program shown above:
481
482 When M1 is turned ON, PLC will send data (hexadecimal) from COM2 of PLC: 01 03 00 0A 00 05 A5 C8
483
484 01: represents slave address, the upper 8 bits of (s);
485
486 03: Modbus instruction code, the lower 8 bits of (s), meaning to read the slave register;
487
488 00 0A: The address of slave register to be read, the value of (m);
489
490 00 05: The number of registers to be read, the value of (d),
491
492 A5 C8: CRC check code.
493
494 For detailed custom protocol instructions, please refer to "[[(% class="wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink" %)__10.7.2 Modbus protocol description__>>path:#_10.7.2 Modbus protocol description]](%%)"
495
496 **✎Note: **
497
498 Although the RS instruction currently allows all the parameters of the instruction to use constants such as K and H, there are different restrictions depending on the protocol.
499
500 When the protocol is a custom protocol, S and D cannot be constants, otherwise it will report (3189H) error.
501
502 When the protocol is Modbus protocol, n cannot be a constant, otherwise it will report (3189H) error.
503
504 The combination of RTU protocol and 7-bit data bits cannot be set.
505
506 If the serial port parameter settings are different, it may still be able to communicate. At present, it is normal to set one.
507
508 Currently, the RS instruction cannot be used in interrupts and events.
509
510 **{{id name="_Toc8113"/}}Error code**
511
512 (% class="table-bordered" %)
513 |(% style="width:102px" %)**Error code**|(% style="width:979px" %)**Content**
514 |(% style="width:102px" %)4085H|(% style="width:979px" %)The read address of (s), (m), (d) and (N) exceed the device range.
515 |(% style="width:102px" %)3180H|(% style="width:979px" %)COM2 data reception error. There may be interference on the communication line, it is recommended to connect the ground wire.
516 |(% style="width:102px" %)3181H|(% style="width:979px" %)COM2 data reception timed out. "Check the wiring, check whether the serial port parameter settings are compatible with master and slave, check whether there is interference. Check whether the slave station is too late to respond. For this reason, you can try to increase the sending interval SD2546."
517 |(% style="width:102px" %)3182H|(% style="width:979px" %)COM2 CRC check error. There may be interference on the communication line, it is recommended to connect the ground wire.
518 |(% style="width:102px" %)3183H|(% style="width:979px" %)COM2 LRC check error. There may be interference on the communication line, it is recommended to connect the ground wire.
519 |(% style="width:102px" %)3184H|(% style="width:979px" %)The COM2 station number is incorrectly configured. Check the slave station number setting, and check whether there is any problem with the receiving and sending mechanism of slave station.
520 |(% style="width:102px" %)3185H|(% style="width:979px" %)COM2 send buffer overflow. Contact a technician if this error occurs
521 |(% style="width:102px" %)3186H|(% style="width:979px" %)COM2 function code is wrong. Check whether the set function code is a function code supported by PLC
522 |(% style="width:102px" %)3187H|(% style="width:979px" %)COM2 address is wrong. Check whether the slave station has this address (please refer to Modbus Abnormal 02)
523 |(% style="width:102px" %)3188H|(% style="width:979px" %)The length of COM2 is wrong. Check whether the communication length exceeds the length range specified by the Modbus protocol, or whether it exceeds the specified length range of the custom protocol.
524 |(% style="width:102px" %)3189H|(% style="width:979px" %)COM2 data error. "Check whether there are errors in the parameters of the instruction. Check whether the slave station supports the setting of this value. (Please refer to Modbus Abnormal 03)"
525 |(% style="width:102px" %)318AH|(% style="width:979px" %)COM2 slave station is busy. Slave station returns information: Slave station is busy (please refer to Modbus exception 06)
526 |(% style="width:102px" %)318BH|(% style="width:979px" %)COM2 slave station does not support function codes. Check whether the slave station supports this function code (please refer to Modbus exception 01)
527 |(% style="width:102px" %)318CH|(% style="width:979px" %)COM2 slave station is faulty. Slave station returns information: Slave station is faulty, please check whether the slave station is faulty (please refer to Modbus Abnormal 04)
528 |(% style="width:102px" %)318DH|(% style="width:979px" %)COM2 slave station confirmation. Slave station return information: slave station confirmation (please refer to Modbus abnormal 05)
529 |(% style="width:102px" %)318EH|(% style="width:979px" %)COM2 current protocol does not support this instruction or function. The related conmunication instruction of master station or the function of maste station cannot be used when it is set to slave station protocol, please change the protocol or close the contact before the corresponding instruction or diable the corresponding communication function.
530 |(% style="width:102px" %)318FH|(% style="width:979px" %)COM2 sending timed out. Contact a technician if this error occurs
531 |(% style="width:102px" %)31A0H|(% style="width:979px" %)COM2 is not available as a gateway. Slave station returns information: unavailable gateway (please refer to Modbus exception 0A)
532 |(% style="width:102px" %)31A1H|(% style="width:979px" %)COM2 indicates that no response was obtained from the target device. Slave station returns information: the device is not in the network (please refer to Modbus exception 0B)
533
534 = {{id name="_Toc3328"/}}**{{id name="_Toc27516"/}}{{id name="_Toc32747"/}}RS2 instruction** =
535
536 == **RS2/External communication instruction** ==
537
538 **RS2**
539
540 In custom protocol: This instruction is a communication send and receive instruction. It takes out (M) of the initial data specified (s) and send it, and stores (N) of the data received through the serial port in (d) and sent by (n1) automatic communication port.
541
542 In Modbus master station protocol: This instruction is the setting interface for the master station to send protocol frames. According to the station number function code (s), slave address (m), length (d) set by the instruction, and the function code to determine whether n data is required to automatically combined sending and receiving protocol frames. If it is a read type function code, the data would be written to (N) and sent by (n1) custom communication port.
543
544 -[RS2 (s) (m) (d) (N) (n1)]
545
546 **Content, range and data type**
547
548 In custom protocol
549
550 (% class="table-bordered" %)
551 |=(% scope="row" %)**Parameter**|=(% style="width: 453px;" %)**Content**|=(% style="width: 107px;" %)**Range**|=(% style="width: 207px;" %)**Data type**|=(% style="width: 197px;" %)**Data type (label)**
552 |=(s)|(% style="width:453px" %)The start address of register area that stores the data to be sent|(% style="width:107px" %)-|(% style="width:207px" %)Unsigned BIN 16 bit|(% style="width:197px" %)ANY16
553 |=(m)|(% style="width:453px" %)The length of data to be sent (bytes)|(% style="width:107px" %)0 to 528|(% style="width:207px" %)Unsigned BIN 16 bit|(% style="width:197px" %)ANY16
554 |=(d)|(% style="width:453px" %)The device start number that stores the written data|(% style="width:107px" %)-|(% style="width:207px" %)Unsigned BIN 16 bit|(% style="width:197px" %)ANY16
555 |=(N)|(% style="width:453px" %)Number of data written (bytes)|(% style="width:107px" %)0 to 528|(% style="width:207px" %)Unsigned BIN 16 bit|(% style="width:197px" %)ANY16
556 |=(n1)|(% style="width:453px" %)Specify the communication port|(% style="width:107px" %) |(% style="width:207px" %)Unsigned BIN 16 bit|(% style="width:197px" %)ANY16
557
558 In Modbus protocol
559
560 (% class="table-bordered" %)
561 |=(% scope="row" %)**Parameter**|=(% style="width: 517px;" %)**Content**|=(% style="width: 114px;" %)**Range**|=(% style="width: 173px;" %)**Data type**|=(% style="width: 185px;" %)**Data type (label)**
562 |=(s)|(% style="width:517px" %)The high byte stores the station number of slave station, and the low byte stores function code of Modbus|(% style="width:114px" %)-|(% style="width:173px" %)Unsigned BIN 16 bit|(% style="width:185px" %)ANY16
563 |=(m)|(% style="width:517px" %)Slave address. The address provided by the slave station will read or write data from this address of the slave station|(% style="width:114px" %)-|(% style="width:173px" %)Unsigned BIN 16 bit|(% style="width:185px" %)ANY16
564 |=(d)|(% style="width:517px" %)Length. The length of Modbus read or write. The unit is determined by function code.|(% style="width:114px" %)-|(% style="width:173px" %)Unsigned BIN 16 bit|(% style="width:185px" %)ANY16
565 |=(N)|(% style="width:517px" %)The start address of the data to be read or written|(% style="width:114px" %)-|(% style="width:173px" %)Unsigned BIN 16 bit|(% style="width:185px" %)ANY16
566 |=(n1)|(% style="width:517px" %)Specify the communicatiom port|(% style="width:114px" %) |(% style="width:173px" %)Unsigned BIN 16 bit|(% style="width:185px" %)ANY16
567
568 **Device used**
569
570 (% class="table-bordered" style="width:1078px" %)
571 |=(% rowspan="2" style="width: 116px;" %)**Instruction**|=(% rowspan="2" style="width: 101px;" %)**Parameter**|=(% colspan="7" style="width: 496px;" %)**Devices**|=(% style="width: 175px;" %)(((
572 **Offset modification**
573 )))|=(% style="width: 187px;" %)(((
574 **Pulse extension**
575 )))
576 |=(% style="width: 61px;" %)**T**|=(% style="width: 68px;" %)**C**|=(% style="width: 59px;" %)**D**|=(% style="width: 73px;" %)**R**|=(% style="width: 85px;" %)**SD**|=(% style="width: 79px;" %)**K**|=(% style="width: 71px;" %)**H**|=(% style="width: 175px;" %)**[D]**|=(% style="width: 187px;" %)**XXP**
577 |=(% rowspan="5" style="width: 116px;" %)RS2|(% style="width:101px" %)(s)|(% style="width:61px" %)●|(% style="width:68px" %)●|(% style="width:59px" %)●|(% style="width:73px" %)●|(% style="width:85px" %)●|(% style="width:79px" %)●|(% style="width:71px" %)●|(% style="width:175px" %)-|(% style="width:187px" %)-
578 |(% style="width:101px" %)(m)|(% style="width:61px" %)●|(% style="width:68px" %)●|(% style="width:59px" %)●|(% style="width:73px" %)●|(% style="width:85px" %)●|(% style="width:79px" %)●|(% style="width:71px" %)●|(% style="width:175px" %)-|(% style="width:187px" %)-
579 |(% style="width:101px" %)(d)|(% style="width:61px" %)●|(% style="width:68px" %)●|(% style="width:59px" %)●|(% style="width:73px" %)●|(% style="width:85px" %)●|(% style="width:79px" %)●|(% style="width:71px" %)●|(% style="width:175px" %)-|(% style="width:187px" %)-
580 |(% style="width:101px" %)(N)|(% style="width:61px" %)●|(% style="width:68px" %)●|(% style="width:59px" %)●|(% style="width:73px" %)●|(% style="width:85px" %)●|(% style="width:79px" %)●|(% style="width:71px" %)●|(% style="width:175px" %)-|(% style="width:187px" %)-
581 |(% style="width:101px" %)(n1)|(% style="width:61px" %) |(% style="width:68px" %) |(% style="width:59px" %) |(% style="width:73px" %) |(% style="width:85px" %) |(% style="width:79px" %)●|(% style="width:71px" %)●|(% style="width:175px" %) |(% style="width:187px" %)
582
583 **Features**
584
585 Parameter (n1) is the specified port. Curently, k0 indicates COM1, and k1 indicates COM2.
586
587 **(1) Custom protocol**
588
589 When the communication protocol is set as a [[custom protocol>>url:http://dict.cn/self-defined%20protocol]]. When the contact in before RS2 instruction is turned on and “sending control enable” is also turned on at the same time, and the sending length (m) is not 0, the data of (s) will be sent (m) bytes out, and then it will be in the mode of waiting for reception. When the data is received, (N) bytes of data will be stored in (d). “reception control or reception notice” will be turned ON after receiving (N) data.
590
591 In addition, when the sending length (m) is 0, it will be in the receive-only mode. When the receiving length (N) is 0, it will be in the send-only mode.
592
593 To enable the start character (STX) and the end character (ETX) modes of RS2 instruction, the status of the 10th and 11th bits of the special address “communication port setting” must be set. See the table below for detailed settings:
594
595 (% class="table-bordered" style="width:1073px" %)
596 |(% colspan="2" style="width:154px" %)**Bit number**|(% style="width:68px" %)**B0**|(% style="width:181px" %)**B1、B2**|(% style="width:68px" %)**B3**|(% style="width:180px" %)(((
597 **B4、B5、B6、**
598
599 **B7、B8、B9**
600 )))|(% style="width:207px" %)**B10**|(% style="width:213px" %)**B11**
601 |(% colspan="2" style="width:154px" %)**Name**|(% style="width:68px" %)**Data length**|(% style="width:181px" %)**Parity**|(% style="width:68px" %)**Stop Bit**|(% style="width:180px" %)**Baud rate(bps)**|(% style="width:207px" %)**STX**|(% style="width:213px" %)**ETX**
602 |(% rowspan="2" style="width:85px" %)**Content**|(% style="width:69px" %)(((
603 **0**
604
605 **off**
606 )))|(% style="width:68px" %)7-bit|(% rowspan="2" style="width:181px" %)(((
607 b2, b1
608
609 (0,0): none
610
611 (0,1): odd parity (ODD)
612
613 (1,1): even parity (EVEN)
614 )))|(% style="width:68px" %)1-bit|(% rowspan="2" style="width:180px" %)(((
615 (% style="width:164px" %)
616 |(% style="width:83px" %)9600|(% style="width:79px" %)001000
617 |(% style="width:83px" %)19200|(% style="width:79px" %)001001
618 |(% style="width:83px" %)38400|(% style="width:79px" %)001010
619 |(% style="width:83px" %)57600|(% style="width:79px" %)001011
620 |(% style="width:83px" %)115200|(% style="width:79px" %)001100
621 |(% style="width:83px" %)187500|(% style="width:79px" %)001101
622 |(% style="width:83px" %)230400|(% style="width:79px" %)001110
623 |(% style="width:83px" %)460800|(% style="width:79px" %)001111
624 |(% style="width:83px" %)921600|(% style="width:79px" %)010000
625 )))|(% style="width:207px" %)None|(% style="width:213px" %)None
626 |(% style="width:69px" %)(((
627 **1**
628
629 **on**
630 )))|(% style="width:68px" %)8-bit|(% style="width:68px" %)2-bit|(% style="width:207px" %)Turn on STX, the STX value is set in the device of the corresponding communication|(% style="width:213px" %)Turn on ETX, the ETX value is set in the device of the corresponding communication
631
632 **Example**
633
634 (% style="text-align:center" %)
635 [[image:10_html_42196c0b440282c3.gif||class="img-thumbnail"]]
636
637 When M1 is ON, the sending and receiving data of communication after executing instruction is stored as the following figure.
638
639 (% style="text-align:center" %)
640 [[image:image-20220926140831-1.jpeg||class="img-thumbnail"]]
641
642 Some configuration and preparation of serial communication are needed for actual programming to communicate as expected, such as setting the transceiver mode of serial port, baud rate, number of bits, parity, software protocol settings, timeout judgment conditions, and data preparation for the transceiver buffer, send and receive flag processing, etc.,
643
644 A relatively complete RS communication setup program is shown as follows:
645
646 (% style="text-align:center" %)
647 [[image:10_html_1917cca86a75115b.png||class="img-thumbnail"]]
648
649 (((
650 Set the protocol to a custom protocol.
651
652 Set serial port parameter: baud rate 115200 stop bit 1, data bit 8, no parity bit
653 )))
654
655 For detailed custom protocol instructions, please refer to "__[[10.7.1 Custom protocol description>>path:#_10.7.1 Custom protocol description]]__"
656
657 **(2) Modbus protocol**
658
659 When the protocol is set to Modbus master protocol (whether it is RTU or ASCII). When the contact before RS2 instruction is turned ON, the RS2 instruction will send the combined data frame according to the station number function code (s), slave station address (m), length (d) and judge whether the data of (N) is needed according to the function code.
660
661 (% style="text-align:center" %)
662 [[image:10_html_d97afb4fe5346ca.gif||class="img-thumbnail"]]
663
664 (% class="table-bordered" %)
665 |=(% scope="row" %)**Parameter**|=**Content**
666 |=(s)|The high byte stores the station number of slave station, and the low byte stores function code of Modbus
667 |=(m)|Slave address. The address provided by the slave station will read or write data from this address of the slave station
668 |=(d)|Length. The length of Modbus read or write. The unit is determined by function code.
669 |=(N)|The start address of the data to be read or written
670 |=(n1)|Specify the communicatiom port
671
672 (% style="text-align:center" %)
673 [[image:10_html_7400bc2aa339cd6d.png||class="img-thumbnail"]]
674
675 (((
676 As the ladder program shown above:
677
678 When M1 is turned ON, PLC will send data (hexadecimal) from COM2 of PLC: 01 03 00 0A 00 05 A5 C8
679
680 * 01: represents slave address, the high 8 bits of (s);
681 * 03: Modbus command code, the low 8 bits of (s), which means to read the slave register;
682 * 00 0A: The address of slave register to be read, the value of (m);
683 * 00 05: The number of registers to be read, the value of (d),
684 * A5 C8: CRC check code.
685 )))
686
687 For detailed custom protocol instructions, please refer to "[[(% class="wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink" %)__10.7.2 Modbus protocol description__>>path:#_10.7.2 Modbus protocol description]](%%)"
688
689 **✎Note: **
690
691 * The RS2 instruction allows parameters to be represented by K and H constants, but there are different restrictions depending on the protocol.
692 * When the protocol is a custom protocol, S and D cannot be constants, otherwise it will report (3X89H) error.
693 * When the protocol is Modbus protocol, n cannot be a constant, otherwise it will report (3X89H) error.
694 * When the protocol is set to the RTU protocol, only 8 bits of data can be selected
695 * If the serial port parameter settings are different, it may still be able to communicate. However, it is recommended that the serial port parameters be the same to avoid other faults.
696 * Currently, the RS2 instruction cannot be used in interrupts and events.
697
698 **Error code**
699
700 (% class="table-bordered" %)
701 |=(% scope="row" style="width: 104px;" %)**Error code**|=(% style="width: 977px;" %)**Content**
702 |=(% style="width: 104px;" %)4085H|(% style="width:977px" %)The read address of (s), (m), (d) and (N) exceed the device range.
703 |=(% style="width: 104px;" %)4084H|(% style="width:977px" %)The parameter value exceed the specified range
704 |=(% style="width: 104px;" %)3080H|(% style="width:977px" %)COM1 data reception error. There may be interference on the communication line, it is recommended to connect the ground wire.
705 |=(% style="width: 104px;" %)3081H|(% style="width:977px" %)COM1 data reception timed out. "Check the wiring, check whether the serial port parameter settings are compatible with master and slave, check whether there is interference. Check whether the slave station is too late to respond. For this reason, you can try to increase “the sending interval".
706 |=(% style="width: 104px;" %)3082H|(% style="width:977px" %)COM1 CRC check error. There may be interference on the communication line, it is recommended to connect the ground wire.
707 |=(% style="width: 104px;" %)3083H|(% style="width:977px" %)COM1 LRC check error. There may be interference on the communication line, it is recommended to connect the ground wire.
708 |=(% style="width: 104px;" %)3084H|(% style="width:977px" %)The COM1 station number is incorrectly configured. Check the slave station number setting, and check whether there is any problem with the receiving and sending mechanism of slave station.
709 |=(% style="width: 104px;" %)3085H|(% style="width:977px" %)COM1 send buffer overflow. Contact a technician if this error occurs.
710 |=(% style="width: 104px;" %)3086H|(% style="width:977px" %)COM1 function code is wrong. Check whether the set function code is a function code supported by PLC
711 |=(% style="width: 104px;" %)3087H|(% style="width:977px" %)COM1 address is wrong. Check whether the slave station has this address (please refer to Modbus Abnormal 02)
712 |=(% style="width: 104px;" %)3088H|(% style="width:977px" %)The length of COM1 is wrong. Check whether the communication length exceeds the length range specified by the Modbus protocol, or whether it exceeds the specified length range of the custom protocol.
713 |=(% style="width: 104px;" %)3089H|(% style="width:977px" %)COM1 data error. "Check whether there are errors in the parameters of the instruction. Check whether the slave station supports the setting of this value. (Please refer to Modbus Abnormal 03)"
714 |=(% style="width: 104px;" %)308AH|(% style="width:977px" %)COM1 slave station is busy. Slave station returns information: Slave station is busy (please refer to Modbus exception 06)
715 |=(% style="width: 104px;" %)308BH|(% style="width:977px" %)COM1 slave station does not support function codes. Check whether the slave station supports this function code (please refer to Modbus exception 01)
716 |=(% style="width: 104px;" %)308CH|(% style="width:977px" %)COM1 slave station is faulty. Slave station returns information: Slave station is faulty, please check whether the slave station is faulty (please refer to Modbus Abnormal 04)
717 |=(% style="width: 104px;" %)308DH|(% style="width:977px" %)COM1 slave station confirmation. Slave station return information: slave station confirmation (please refer to Modbus abnormal 05)
718 |=(% style="width: 104px;" %)308EH|(% style="width:977px" %)COM1 current protocol does not support this instruction or function. The related conmunication instruction of master station or the function of maste station cannot be used when it is set to slave station protocol, please change the protocol or close the contact before the corresponding instruction or diable the corresponding communication function.
719 |=(% style="width: 104px;" %)308FH|(% style="width:977px" %)COM1 sending timed out. Contact a technician if this error occurs.
720 |=(% style="width: 104px;" %)30A0H|(% style="width:977px" %)COM1 is not available as a gateway. Slave station returns information: unavailable gateway (please refer to Modbus exception 0A)
721 |=(% style="width: 104px;" %)30A1H|(% style="width:977px" %)COM1 indicates that no response was obtained from the target device. Slave station returns information: the device is not in the network (please refer to Modbus exception 0B)
722 |=(% style="width: 104px;" %)3181H|(% style="width:977px" %)COM2 data reception timed out. "Check the wiring, check whether the serial port parameter settings are compatible with master and slave, check whether there is interference. Check whether the slave station is too late to respond. For this reason, you can try to increase the “sending interval".
723 |=(% style="width: 104px;" %)3182H|(% style="width:977px" %)COM2 CRC check error. There may be interference on the communication line, it is recommended to connect the ground wire.
724 |=(% style="width: 104px;" %)3183H|(% style="width:977px" %)COM2 LRC check error. There may be interference on the communication line, it is recommended to connect the ground wire.
725 |=(% style="width: 104px;" %)3184H|(% style="width:977px" %)The COM2 station number is incorrectly configured. Check the slave station number setting, and check whether there is any problem with the receiving and sending mechanism of slave station.
726 |=(% style="width: 104px;" %)3185H|(% style="width:977px" %)COM2 send buffer overflow. Contact a technician if this error occurs.
727 |=(% style="width: 104px;" %)3186H|(% style="width:977px" %)COM2 function code is wrong. Check whether the set function code is a function code supported by PLC.
728 |=(% style="width: 104px;" %)3187H|(% style="width:977px" %)COM2 address is wrong. Check whether the slave station has this address (please refer to Modbus Abnormal 02)
729 |=(% style="width: 104px;" %)3188H|(% style="width:977px" %)The length of COM2 is wrong. Check whether the communication length exceeds the length range specified by the Modbus protocol, or whether it exceeds the specified length range of the custom protocol.
730 |=(% style="width: 104px;" %)3189H|(% style="width:977px" %)COM2 data error. "Check whether there are errors in the parameters of the instruction. Check whether the slave station supports the setting of this value. (Please refer to Modbus Abnormal 03)"
731 |=(% style="width: 104px;" %)318AH|(% style="width:977px" %)COM2 slave station is busy. Slave station returns information: Slave station is busy (please refer to Modbus exception 06)
732 |=(% style="width: 104px;" %)318BH|(% style="width:977px" %)COM2 slave station does not support function codes. Check whether the slave station supports this function code (please refer to Modbus exception 01)
733 |=(% style="width: 104px;" %)318CH|(% style="width:977px" %)COM2 slave station is faulty. Slave station returns information: Slave station is faulty, please check whether the slave station is faulty (please refer to Modbus Abnormal 04)
734 |=(% style="width: 104px;" %)318DH|(% style="width:977px" %)COM2 slave station confirmation. Slave station return information: slave station confirmation (please refer to Modbus abnormal 05)
735 |=(% style="width: 104px;" %)318EH|(% style="width:977px" %)COM2 current protocol does not support this instruction or function. The related conmunication instruction of master station or the function of maste station cannot be used when it is set to slave station protocol, please change the protocol or close the contact before the corresponding instruction or diable the corresponding communication function.
736 |=(% style="width: 104px;" %)318FH|(% style="width:977px" %)COM2 sending timed out. Contact a technician if this error occurs.
737 |=(% style="width: 104px;" %)31A0H|(% style="width:977px" %)COM2 is not available as a gateway. Slave station returns information: unavailable gateway (please refer to Modbus exception 0A)
738 |=(% style="width: 104px;" %)31A1H|(% style="width:977px" %)COM2 indicates that no response was obtained from the target device. Slave station returns information: the device is not in the network (please refer to Modbus exception 0B)
739
740 = **Expansion module communication** =
741
742 == {{id name="_Toc15142"/}}**{{id name="_Toc7013"/}}{{id name="_Toc4135"/}}Single word data writing from TO/PLC to the module (16-bit specification)** ==
743
744 **TO(P)**
745
746 Write the data at the start (N) point of the device specified in (s3) to the buffer memory in the intelligent function module specified in (s1) after the address specified in (s2).
747
748 -[TO (s1) (s2) (s3) (N)]
749
750 **{{id name="OLE_LINK401"/}}Content, range and data type**
751
752 (% class="table-bordered" %)
753 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
754 |(s1)|Module number, the first module is 0, the second module is 1, and so on|0 to 32767|Unsigned BIN 16 bit|ANY16
755 |(s2)|Start writing from which BFM in the module|0 to 32767|Unsigned BIN 16 bit|ANY16
756 |(s3)|Start number of the device storing the written data|-32768 to 32767|Signed BIN 16 bit|ANY16
757 |(N)|Number of data written|0 to 512|Unsigned BIN 16 bit|ANY16
758
759 **Device used**
760
761 (% class="table-bordered" %)
762 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="10" %)**Devices**|(((
763 **Offset**
764
765 **modification**
766 )))|(((
767 **Pulse**
768
769 **extension**
770 )))
771 |**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|**H**|**[D]**|**XXP**
772 |(% rowspan="4" %)TO|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|●
773 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|●
774 |Parameter 3|●|●|●|●|●|●|●|●|●|●|●|●
775 |Parameter 4|●|●|●|●|●|●|●|●|●|●|●|●
776
777 **Features**
778
779 Write the data at the start (N) point of the device specified in (s3) to the buffer memory in the intelligent function module specified in (s1) after the address specified in (s2).
780
781 (% style="text-align:center" %)
782 [[image:10_html_603a54a4bdbc6b8f.gif||class="img-thumbnail"]]
783
784 As the following Circuit program
785
786 (% style="text-align:center" %)
787 [[image:10_html_9d053b1a8c234094.png||class="img-thumbnail"]]
788
789 Indicates that when X1 is ON, write the data in the PLC's D220 register to the buffer register (BFM) #24 in the #1 (second) special module. When X1 is OFF, no operation is performed.
790
791 Currently LX5VPLC supports 16 special expansion modules at the same time.
792
793 The special devices used are as follows
794
795 (% class="table-bordered" %)
796 |**Devices**|**Content**
797 |SD2081|Total number of modules
798 |SD2082|Number of IO expansion modules
799 |SD2083|Number of special expansion modules
800 |SD2084|The first missing expansion module. When the value is -1, it means not lost
801
802 **Error code**
803
804 (% class="table-bordered" %)
805 |**Error code**|**Content**
806 |4085H|The read addresses of (s1), (s2), (s3) and (N) exceed the device range
807 |4084H|(s1) and (s2) is not in the range of 0 to 32767 or (N) is not in the range of 0 to 512
808 |7080H|Check error when communicating between PLC and module
809 |7081H|Expansion module communication message is abnormal
810 |7082H|FROM/TO instruction error
811 |7083H|The specified extension module was not found
812
813 **Example**
814
815 (% style="text-align:center" %)
816 [[image:10_html_936412ccc04cc4cb.png||class="img-thumbnail"]]
817
818 When M1 is turned on
819
820 The values of D200 and D201 will be passed to BFM2 and BFM3 of module #0 (the first)
821
822 (% style="text-align:center" %)
823 [[image:10_html_555c0224c9a9e02d.png||class="img-thumbnail"]]
824
825 (% style="text-align:center" %)
826 [[image:10_html_ab29c2a6c272559.png||class="img-thumbnail"]]
827
828 == **Double word data write from DTO/PLC to the module (32-bit specification)** ==
829
830 DTO(P)
831
832 Write the data of (N)×2 points from the device specified in (s3) to the buffer memory in the intelligent function module specified in (s1) and beyond the address specified in (s2).
833
834 -[DTO (s1) (s2) (s3) (N)]
835
836 **Content, range and data type**
837
838 (% class="table-bordered" %)
839 |**Parameter**|(% style="width:421px" %)**Content**|(% style="width:228px" %)**Range**|(% style="width:201px" %)**Data type**|**Data type (label)**
840 |(s1)|(% style="width:421px" %)Module number, the first module is 0, the second module is 1, and so on|(% style="width:228px" %)0 to 32767|(% style="width:201px" %)Unsigned BIN 16 bit|ANY16
841 |(s2)|(% style="width:421px" %)Start writing from which BFM in the module|(% style="width:228px" %)0 to 32767|(% style="width:201px" %)Unsigned BIN 16 bit|ANY16
842 |(s3)|(% style="width:421px" %)Start number of the device storing the written data|(% style="width:228px" %)-2147483648 to 2147483647|(% style="width:201px" %)Signed BIN 32 bit|ANY32
843 |(N)|(% style="width:421px" %)Number of data written|(% style="width:228px" %)0 to 256|(% style="width:201px" %)Unsigned BIN 16 bit|ANY16
844
845 **Device used**
846
847 (% class="table-bordered" %)
848 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="12" %)**Devices**|(((
849 **Offset**
850
851 **modification**
852 )))|(((
853 **Pulse**
854
855 **extension**
856 )))
857 |**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**[D]**|**XXP**
858 |(% rowspan="4" %)DTO|Parameter 1|●|●|●|●|●|●|●|●| | |●|●|●|●
859 |Parameter 2|●|●|●|●|●|●|●|●| | |●|●|●|●
860 |Parameter 3|●|●|●|●|●|●|●|●|●|●|●|●|●|●
861 |Parameter 4|●|●|●|●|●|●|●|●| | |●|●|●|●
862
863 **Features**
864
865 Write the data of (N)×2 points from the device specified in (s3) to the buffer memory in the intelligent function module specified in (s1) and beyond the address specified in (s2).
866
867 (% style="text-align:center" %)
868 [[image:10_html_86bfbd89b2652fbf.gif||class="img-thumbnail"]]
869
870 As the following Circuit program
871
872 (% style="text-align:center" %)
873 [[image:10_html_d3dfe7b80f649f8e.png||class="img-thumbnail"]]
874
875 Indicates that when M1 is ON, write the data in the PLC's D200 and D201 registers to the buffer registers (BFM) #1 and #2 in the #0 (first) special module. When X1 is OFF, no operation is performed.
876
877 Currently LX5V PLC supports 16 special expansion modules at the same time.
878
879 The special devices used are as follows
880
881 (% class="table-bordered" %)
882 |**Devices**|**Content**
883 |SD2081|Total number of modules
884 |SD2082|Number of IO expansion modules
885 |SD2083|Number of special expansion modules
886 |SD2084|The first missing expansion module. When the value is -1, it means not lost
887
888 **Error code**
889
890 (% class="table-bordered" %)
891 |**Error code**|**Content**
892 |4085H|(s1) (s2) (s3) (N) The read address exceeds the device range
893 |4084H|(s1) (s2) is not in the range of 0 to 32767 or (N) is not in the range of 0 to 256
894 |7080H|Check error when communicating between PLC and module
895 |7081H|Expansion module communication message is abnormal
896 |7082H|FROM/TO instruction error
897 |7083H|The specified extension module was not found
898
899 **Example**
900
901 (% style="text-align:center" %)
902 [[image:10_html_12ff08a3df52558c.png||class="img-thumbnail"]]
903
904 When M1 is turned on
905
906 The values from D200 to D203 will be transferred to BFM1 to BFM4 of module #0 (first)
907
908 (% style="text-align:center" %)
909 [[image:10_html_fe06c272cbdd1f7f.png||class="img-thumbnail"]]
910
911 (% style="text-align:center" %)
912 [[image:10_html_adeb00a341e12368.png||class="img-thumbnail"]]
913
914 == {{id name="_Toc9726"/}}**{{id name="_Toc721"/}}{{id name="_Toc151"/}}{{id name="_Toc25394"/}}FROM/Read single word data from the module (16-bit specification)** ==
915
916 **FROM(P)**
917
918 Read (N) word data from the buffer memory specified in (s2) in the module specified in (s1), and store it in the device specified in (d) and later.
919
920 Ladder
921
922 -[FROM (s1) (s2) (d) (N)]
923
924 **Content, range and data type**
925
926 (% class="table-bordered" %)
927 |**Parameter**|(% style="width:432px" %)**Content**|(% style="width:156px" %)**Range**|(% style="width:154px" %)**Data type**|(% style="width:230px" %)**Data type (label)**
928 |(s1)|(% style="width:432px" %)Module number, the first module is 0, the second module is 1, and so on|(% style="width:156px" %)0 to 32767|(% style="width:154px" %)Unsigned BIN 16 bit|(% style="width:230px" %)ANY16
929 |(s2)|(% style="width:432px" %)Start reading from which BFM in the module|(% style="width:156px" %)0 to 32767|(% style="width:154px" %)Unsigned BIN 16 bit|(% style="width:230px" %)ANY16
930 |(d)|(% style="width:432px" %)Start number of the device storing the read data|(% style="width:156px" %)-|(% style="width:154px" %)Signed BIN 16 bit|(% style="width:230px" %)ANY16
931 |(N)|(% style="width:432px" %)Number of read data|(% style="width:156px" %)0 to 512|(% style="width:154px" %)Unsigned BIN 16 bit|(% style="width:230px" %)ANY16
932
933 **Device used**
934
935 (% class="table-bordered" style="width:1098px" %)
936 |=(% rowspan="2" style="width: 76px;" %)**Instruction**|=(% rowspan="2" style="width: 114px;" %)**Parameter**|=(% colspan="10" style="width: 490px;" %)**Devices**|=(% style="width: 218px;" %)(((
937 **Offset modification**
938 )))|=(% style="width: 119px;" %)(((
939 **Pulse extension**
940 )))
941 |=(% style="width: 53px;" %)**KnY**|=(% style="width: 63px;" %)**KnM**|=(% style="width: 49px;" %)**KnS**|=(% style="width: 41px;" %)**T**|=(% style="width: 65px;" %)**C**|=(% style="width: 48px;" %)**D**|=(% style="width: 52px;" %)**R**|=(% style="width: 39px;" %)**SD**|=(% style="width: 48px;" %)**K**|=(% style="width: 34px;" %)**H**|=(% style="width: 218px;" %)**[D]**|=(% style="width: 119px;" %)**XXP**
942 |=(% rowspan="4" style="width: 76px;" %)FROM|(% style="width:114px" %)Parameter 1|(% style="width:53px" %)●|(% style="width:63px" %)●|(% style="width:49px" %)●|(% style="width:41px" %)●|(% style="width:65px" %)●|(% style="width:48px" %)●|(% style="width:52px" %)●|(% style="width:39px" %)●|(% style="width:48px" %)●|(% style="width:34px" %)●|(% style="width:218px" %)●|(% style="width:119px" %)●
943 |(% style="width:114px" %)Parameter 2|(% style="width:53px" %)●|(% style="width:63px" %)●|(% style="width:49px" %)●|(% style="width:41px" %)●|(% style="width:65px" %)●|(% style="width:48px" %)●|(% style="width:52px" %)●|(% style="width:39px" %)●|(% style="width:48px" %)●|(% style="width:34px" %)●|(% style="width:218px" %)●|(% style="width:119px" %)●
944 |(% style="width:114px" %)Parameter 3|(% style="width:53px" %)●|(% style="width:63px" %)●|(% style="width:49px" %)●|(% style="width:41px" %)●|(% style="width:65px" %)●|(% style="width:48px" %)●|(% style="width:52px" %)●|(% style="width:39px" %)●|(% style="width:48px" %) |(% style="width:34px" %) |(% style="width:218px" %)●|(% style="width:119px" %)●
945 |(% style="width:114px" %)Parameter 4|(% style="width:53px" %)●|(% style="width:63px" %)●|(% style="width:49px" %)●|(% style="width:41px" %)●|(% style="width:65px" %)●|(% style="width:48px" %)●|(% style="width:52px" %)●|(% style="width:39px" %)●|(% style="width:48px" %)●|(% style="width:34px" %)●|(% style="width:218px" %)●|(% style="width:119px" %)●
946
947 **Features**
948
949 Read (N) word data from the buffer memory specified in (s2) in the intelligent function module specified in (s1) and store it in the device specified in (d) and later.
950
951 (% style="text-align:center" %)
952 [[image:10_html_1b9d34e74f852368.gif||class="img-thumbnail"]]
953
954 As the following Circuit program
955
956 (% style="text-align:center" %)
957 [[image:10_html_ad9897d46ca8f957.png||class="img-thumbnail"]]
958
959 It means that when M1 is ON, the data in the buffer registers (BFM) #10 and #11 in the special module #0 (the first) will be written into the D200 and D201 registers of the PLC. When M1 is OFF, no operation is performed.
960
961 Currently LX5V PLC supports 16 special expansion modules at the same time.
962
963 The special soft components used are as follows:
964
965 (% class="table-bordered" %)
966 |=(% scope="row" style="width: 163px;" %)**Devices**|=(% style="width: 911px;" %)**Content**
967 |=(% style="width: 163px;" %)SD2081|(% style="width:911px" %)Total number of modules
968 |=(% style="width: 163px;" %)SD2082|(% style="width:911px" %)Number of IO expansion modules
969 |=(% style="width: 163px;" %)SD2083|(% style="width:911px" %)Number of special expansion modules
970 |=(% style="width: 163px;" %)SD2084|(% style="width:911px" %)The first missing expansion module. When the value is -1, it means not lost
971
972 **Error code**
973
974 (% class="table-bordered" %)
975 |=(% scope="row" %)**Error code**|=**Content**
976 |=4085H|(s1) (s2) (N) The read address exceeds the device range
977 |=4086H|(d) The write address exceeds the device range
978 |=4084H|(s1) (s2) is not in the range of 0 to 32767 or (N) is not in the range of 0 to 512
979 |=7080H|Check error when communicating between PLC and module
980 |=7081H|Expansion module communication message is abnormal
981 |=7082H|FROM/TO instruction error
982 |=7083H|The specified extension module was not found
983
984 **Example**
985
986 (% style="text-align:center" %)
987 [[image:10_html_a9071734dc5cfce5.png||class="img-thumbnail"]]
988
989 When M1 is turned on
990
991 The values of BFM3, BFM4, and BFM5 of the #0 (first) module will be transferred to D200, D201, D202
992
993 (% style="text-align:center" %)
994 [[image:10_html_f1df0562ea9002cf.png||class="img-thumbnail"]]
995
996 (% style="text-align:center" %)
997 [[image:10_html_73bb66d1890735ff.png||class="img-thumbnail"]]
998
999 == {{id name="_Toc18124"/}}{{id name="_Toc10981"/}}{{id name="_Toc21090"/}}**DFROM/single word data read from the module (32-bit specification)** ==
1000
1001 **DFROM(P)**
1002
1003 Read (N)*2 words of data from the buffer memory specified in (s2) in the module specified in (s1), and store it in the device specified in (d) and later.
1004
1005 -[DFROM (s1) (s2) (d) (N)]
1006
1007 **Content, range and data type**
1008
1009 (% class="table-bordered" %)
1010 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
1011 |(s1)|Module number, the first module is 0, the second module is 1, and so on|0 to 32767|Unsigned BIN 16 bit|ANY16
1012 |(s2)|Start reading from which BFM in the module|0 to 32767|Unsigned BIN 16 bit|ANY16
1013 |(d)|Start number of the device storing the read data|-|Signed BIN 32 bit|ANY32
1014 |(N)|Number of read data|0 to 256|Unsigned BIN 16 bit|ANY16
1015
1016 **Device used**
1017
1018 (% class="table-bordered" %)
1019 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="12" %)**Devices**|**Offset modification**|(((
1020 **Pulse**
1021
1022 **extension**
1023 )))
1024 |**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**[D]**|**XXP**
1025 |(% rowspan="4" %)DFROM|Parameter 1|●|●|●|●|●|●|●|●| | |●|●|●|●
1026 |Parameter 2|●|●|●|●|●|●|●|●| | |●|●|●|●
1027 |Parameter 3|●|●|●|●|●|●|●|●|●|●| | |●|●
1028 |Parameter 4|●|●|●|●|●|●|●|●| | |●|●|●|●
1029
1030 **Features**
1031
1032 Read (N)×2 words of data from the buffer memory specified in (s2) in the intelligent function module specified in (s1), and store it in the device specified in (d) and later.
1033
1034 (% style="text-align:center" %)
1035 [[image:10_html_ea4017a0483ddbbe.gif||class="img-thumbnail"]]
1036
1037 As the following Circuit program
1038
1039 (% style="text-align:center" %)
1040 [[image:10_html_6d0c9e8bc37fe95.png||class="img-thumbnail"]]
1041
1042 It means that when M1 is ON, the data in the buffer register (BFM) #10 to #13 in the special module #0 (the first) will be written to the D200 to D203 registers of the PLC. When M1 is OFF, no operation is performed.
1043
1044 Currently LX5VPLC supports 16 special expansion modules at the same time.
1045
1046 The special soft components used are as follows:
1047
1048 (% class="table-bordered" %)
1049 |**Devices**|**Content**
1050 |SD2081|Total number of modules
1051 |SD2082|Number of IO expansion modules
1052 |SD2083|Number of special expansion modules
1053 |SD2084|The first missing expansion module. When the value is -1, it means not lost
1054
1055 **Error code**
1056
1057 (% class="table-bordered" %)
1058 |**Error code**|**Content**
1059 |4085H|(s1) (s2) (N) The read address exceeds the device range
1060 |4086H|(d) The write address exceeds the device range
1061 |4084H|(s1) (s2) is not in the range of 0 to 32767 or (N) is not in the range of 0 to 256
1062 |7080H|Check error when communicating between PLC and module
1063 |7081H|Expansion module communication message is abnormal
1064 |7082H|FROM/TO instruction error
1065 |7083H|The specified extension module was not found
1066
1067 **Example**
1068
1069 (% style="text-align:center" %)
1070 [[image:10_html_7389fb305b495d09.png||class="img-thumbnail"]]
1071
1072 When M1 is turned on
1073
1074 The value of BFM3 to BFM8 of module #0 (first) will be transferred to D200 to D205
1075
1076 (% style="text-align:center" %)
1077 [[image:10_html_2f6f4ddff10c30ec.png||class="img-thumbnail"]]
1078
1079 (% style="text-align:center" %)
1080 [[image:10_html_8a1de3e41b64afe1.png||class="img-thumbnail"]]
1081
1082 = {{id name="_Toc28953"/}}**{{id name="_Toc13721"/}}{{id name="_Toc14994"/}}{{id name="_Toc4655"/}}RS and RS2 instructions corresponding protocol description** =
1083
1084 == {{id name="_10.7.1 Custom protocol description"/}}**{{id name="_Toc19972"/}}{{id name="_Toc7163"/}}{{id name="_Toc25715"/}}{{id name="_Toc23891"/}}{{id name="_Toc21391"/}}{{id name="_自定义协议说明"/}}Custom protocol description** ==
1085
1086 **{{id name="_Toc28071132"/}}Introduction**
1087
1088 The function of custom protocol is that it can directly transmit data with the device without any processing or communicate with other devices with the corresponding protocol set by the customer.
1089
1090 At present, the custom protocol of 5V PLC is configured and sent by COM2, and the instruction used is RS instruction, and it need to configure the protocol and serial port parameters through the Devices.
1091
1092 The current custom protocol is generally close to 3V series.
1093
1094 **{{id name="_Toc28071133"/}}Basic configuration**
1095
1096 **(1) Instructions**
1097
1098 The RS instruction itself has the same usage as the previous RS instruction at 3V, and it can use R device.
1099
1100 -[RS (s) (m) (d) (N)]
1101
1102 **Content, range and data type**
1103
1104 (% class="table-bordered" %)
1105 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
1106 |(s)|The start address of the register area where the data to be sent is stored|-|Unsigned BIN 16 bit|ANY16
1107 |(m)|Is the length of the data to be sent (number of bytes)|0 to 528|Unsigned BIN 16 bit|ANY16
1108 |(d)|Start number of the device storing the written data|-|Unsigned BIN 16 bit|ANY16
1109 |(N)|Number of data written|0 to 528|Unsigned BIN 16 bit|ANY16
1110
1111 **{{id name="_Toc20319"/}}Device used**
1112
1113 (% class="table-bordered" %)
1114 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="6" %)**Devices**|**Offset modification**|(((
1115 **Pulse**
1116
1117 **extension**
1118 )))
1119 |**T**|**C**|**D**|**R**|**K**|**H**|**[D]**|**XXP**
1120 |(% rowspan="4" %)RS|Parameter 1|●|●|●|●|●|●| |
1121 |Parameter 2|●|●|●|●|●|●| |
1122 |Parameter 3|●|●|●|●|●|●| |
1123 |Parameter 4|●|●|●|●|●|●| |
1124
1125 **✎Note: **Although the RS instruction currently allows all the parameters of the instruction to use constants such as K and H, there are different restrictions according to the different protocol. When the protocol is a custom protocol, S and D cannot be constants, otherwise it will report an error.
1126
1127 **{{id name="_Toc28071135"/}}(2) Special device settings**
1128
1129 Special address table
1130
1131 (% class="table-bordered" %)
1132 |(% colspan="2" %)**COM2 special D device (SD)**|(% colspan="2" %)**COM2 special M Device (SM)**
1133 |2590|__**Communication port setting**__|2590|__**Send control on**__
1134 |2591|__**Serial parameter modification identification**__|2591|__**Send control/send reminder**__
1135 |2592|Protocol settings|2592|__**Receive control on**__
1136 |2593|Protocol modification logo|2593|__**Accept control/receive prompt**__
1137 |2594|Station number setting|2594|__**8-bit mode (for custom protocol)**__
1138 |2595|Station number modification logo|2595|
1139 |2596|(((
1140 __**Sending interval (0.1ms) 0-32767**__
1141
1142 __**It is 10 (1ms) when set to 0**__
1143 )))|2596|
1144 |2597|(((
1145 __**Communication timeout setting (10ms) 0-32767**__
1146
1147 __**It is 10(100ms) when set to 0**__
1148 )))|2597|
1149 |2598|__**Timeout retry times 0-32767**__|2598|
1150 |2599|(((
1151 __**Character interval timeout setting (for custom protocol) (0.1ms)**__
1152
1153 __**0-32767 . It is 10 (1ms) when set to 0**__
1154 )))|2599|
1155 |2600|__**STX value**__|2600|
1156 |2601|__**ETX value**__|2601|
1157 |...| |...|
1158 |2610|**The amount of data received**|2610|**Communication complete flag**
1159 |2611|**Last error**|2611|**Receiving flag**
1160 |2612|**Current error**|2612|**Retry occurred**
1161 |2613|**Error steps**|2613|**Communication error**
1162 |2614|**Error station number**|2614|**Communication timeout**
1163 |2615|**Cumulative number of errors**|2615|
1164
1165 The contents that the custom protocol will be used and set has been marked with underline and bold.
1166
1167 In addition, the devices to be used as judgment conditions have also been marked in bold in the table.
1168
1169 **✎Note: **COM1 currently does not support custom protocols.
1170
1171 **{{id name="_Toc28071136"/}}1) Communication port setting SD2590**
1172
1173 (% class="table-bordered" %)
1174 |(% colspan="2" %)**Bit number**|**B0**|**B1、B2**|**B3**|(((
1175 **B4、B5、B6、**
1176
1177 **B7、B8、B9**
1178 )))|**B10**|**B11**
1179 |(% colspan="2" %)**Name**|**Data length**|**Parity**|**Stop Bit**|**Baud rate(bps)**|**STX**|**ETX**
1180 |(% rowspan="2" %)**Content**|**0 off**|7 bit|(% rowspan="2" %)(((
1181 b2,b1
1182
1183 (0,0): None
1184
1185 (0,1): Odd parity (ODD)
1186
1187 (1,1): Even parity (EVEN)
1188 )))|1 bit|(% rowspan="2" %)(((
1189 |4800|0111
1190 |9600|1000
1191 |19200|1001
1192 |38400|1010
1193 |57600|1011
1194 |115200|1100
1195 |187500|1101
1196 |230400|1110
1197 |460800|1111
1198 |921600|10000
1199 )))|None|None
1200 |**1 on**|8 bit|2 bit|Turn on ETX, the ETX value is set in SD2600|Turn on ETX, the ETX value is set in SD2601
1201
1202 Set the serial port parameters to SD2590 according to the bit settings provided in the table above. The setting is roughly the same as 3V. It is mainly because the baud rate can be set to a higher baud rate, the bit used need backward two bits when STX and ETX start.
1203
1204 For example: To set the serial port parameters: baud rate 115200, stop bit 1, data bit 8, no parity bit, turn on STX, you need to set the value H4C1 (K1217) on SD2590. The parameters directly set to SD2590 are only valid in the first cycle of PLC RUN.
1205
1206 If you need to modify it during RUN, you can use the PORTPARAM instruction to set it.
1207
1208 **{{id name="_Toc28071137"/}}2) Protocol setting SD2592**
1209
1210 (% class="table-bordered" %)
1211 |(% colspan="2" %)**Protocol settings**|(% colspan="2" %)**Protocol settings**
1212 |0 H|Wecon Modbus slave station|10 H|Cunstom protocol
1213 |2 H|ModbusRTU slave station|20 H|ModbusRTU master station
1214 |3 H|ModbusASCII slave station|30 H|ModbusASCII master station
1215
1216 The corresponding protocol can be set by setting the corresponding value in SD2592.
1217
1218 The parameters directly set to SD2592 are only valid in the first cycle of PLC RUN.
1219
1220 If you need to modify it during RUN, you can use the PROTOCOL instruction to set it.
1221
1222 **{{id name="_Toc28071138"/}}3) Sending interval SD2596**
1223
1224 The main function of sending interval is: how long to wait for sending the next instruction after one instruction is completed. If the value is set to 0, there is basically no waiting for sending interval, but it will be affected by the scan cycle.
1225
1226 The unit of the sending interval is 0.1ms, that is, the interval time is 10ms when the setting is 100.
1227
1228 **{{id name="_Toc28071139"/}}4) Communication timeout SD2597 and timeout retry SD2598**
1229
1230 (% style="text-align:center" %)
1231 [[image:10_html_53f716718aad2197.png||class="img-thumbnail"]]
1232
1233 The main function of communication timeout is: How long does it take to wait for no data to be received after the PLC sends retry or occurs an error. When 0 is set, the default is 100ms.
1234
1235 The unit of communication timeout is 10ms, that is, the timeout judgment time is 10ms when the setting is 100.
1236
1237 When a receiving timeout occurs, it will determine whether there are retry times and the current retry times. If the retry times are greater than or equal to SD2598, an error will be reported.
1238
1239 If SD2598 is set to 0, it will not try again.
1240
1241 If it is set to 1, send once again after sending a timeout.
1242
1243 **{{id name="_Toc28071140"/}}5) Character interval timeout SD2599**
1244
1245 Currently this setting is only available for custom protocols.
1246
1247 The main function of the character interval timeout is: after receiving at least one character before the communication timeout, judge whether the interval time between the following two characters has exceeded. if it is, report an error and end the communication.
1248
1249 (% style="text-align:center" %)
1250 [[image:10_html_3725d523c70bd43d.png||class="img-thumbnail"]]
1251
1252 This setting is mainly designed considering that some devices may send slow or have other specific sending requirements.
1253
1254 {{id name="_Toc28071141"/}}The character interval timeout will not retry.
1255
1256 **(3) Serial port parameter setting instructions**
1257
1258 **1) Host computer interface settings**
1259
1260 (% style="text-align:center" %)
1261 [[image:10_html_3f08ef293fcbfcf1.png||class="img-thumbnail"]]
1262
1263 Through the PLC parameter setting in the upper computer interface, If protocol is set to none, it is a custom protocol.
1264
1265 The serial port parameter content mainly sets the serial port parameters such as baud rate and data bit.
1266
1267 After the start character is enabled, the start/end character can be sent. The start/end character will also be distinguished when receiving. See the description in the sending and receiving process for details.
1268
1269 **✎Note: **The characters here are decimal values.
1270
1271 **{{id name="_Toc28071142"/}}2) PORTPARA instruction**
1272
1273 -[PORTPARA (s) (N)]
1274
1275 **Content, range and data type**
1276
1277 (% class="table-bordered" %)
1278 |**Parameter**|**Content**|**Range**|**Data type**|(((
1279 **Data type**
1280
1281 **(label)**
1282 )))
1283 |(s)|Serial port parameters to be set|0 to 256|Unsigned BIN 16 bit|ANY16
1284 |(N)|Which communication port to set (0 means COM1, 1 means COM2)|0, 1|Unsigned BIN 16 bit|ANY16
1285
1286 **{{id name="_Toc23976"/}}Device used**
1287
1288 (% class="table-bordered" %)
1289 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="10" %)**Devices**|**Offset modification**|(((
1290 **Pulse**
1291
1292 **extension**
1293 )))
1294 |**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|**H**|**[D]**|**XXP**
1295 |(% rowspan="2" %)PROTPARA|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|●
1296 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|●
1297
1298 Function: To set communication parameters when running.
1299
1300 Please refer to "PORTPARA instruction description" for details.
1301
1302 **{{id name="_Toc28071143"/}}3) PROTOCOL instruction**
1303
1304 -[PROTOCOL (s) (N)]
1305
1306 **Content, range and data type**
1307
1308 (% class="table-bordered" %)
1309 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
1310 |(s)|Protocol number to be set|0 to 65535|Unsigned BIN 16 bit|ANY16
1311 |(N)|Which communication port to set (0 means COM1, 1 means COM2 *1)|1|Unsigned BIN 16 bit|ANY16
1312
1313 **{{id name="_Toc1191"/}}Device used**
1314
1315 (% class="table-bordered" %)
1316 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="10" %)**Devices**|(((
1317 **Offset**
1318
1319 **modification**
1320 )))|(((
1321 **Pulse**
1322
1323 **extension**
1324 )))
1325 |**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|**H**|**[D]**|**XXP**
1326 |(% rowspan="2" %)PORTOCOL|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|
1327 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|
1328
1329 **Features:**
1330
1331 It is used to set the communication protocol when running. The above instruction actually sets a specific value for the parameter modification flag. The specific calculation formula is: (parameter setting value + the offset of the start special device corresponding to the serial port + 10)*2
1332
1333 For example, setting the protocol to Modbusrtu master station (H20) is (0x20 +2593-2590 +10)*2, that is (32 +3+10) *2=90. This is to prevent the serial port parameters from being modified at will.
1334
1335 The trigger of setting parameters in custom protocol will not change the value until an instruction is completed.
1336
1337 The trigger of setting parameters in Modbus master station protocol won’t change the value until an instruction is completed.
1338
1339 The trigger of setting parameters in the Modbus slave protocol can be switched as long as it is not processing the received data. Please refer to "PROTOCOL instruction description" for details.
1340
1341 **4) Priority description of serial port parameters**
1342
1343 The priority of serial port parameter settings are listed as blow. The serial port parameters are saved by power failure currently.
1344
1345 Serial port parameter set instruction setting = Ladder program MOV instruction set the corresponding SD device > the download parameters of host computer > Previous power-off save data.
1346
1347 **(4) Ladder program**
1348
1349 (% style="text-align:center" %)
1350 [[image:10_html_487e57593173359e.png||class="img-thumbnail"]]
1351
1352 (((
1353 Set serial port parameters:
1354
1355 Baud rate 112500, stop bit 1, data bit 8, no parity bit none
1356
1357 Set protocol to custom protocol
1358
1359 Sending interval: 5ms
1360
1361 Receiving timeout: 100ms
1362
1363 Number of repetitions: 3 times
1364
1365 Characters interval timeout: 30ms
1366
1367 Custom protocol sending start address D200, sending length 8.
1368
1369 Receiving start address D300, receiving length 6
1370
1371 Send directly after trigger
1372
1373 After receiving is completed, close the instruction directly and reset the instruction receiving flag
1374 )))
1375
1376 **{{id name="_Toc28071145"/}}Sending and receiving process**
1377
1378 **{{id name="_Toc28071146"/}}(1) Sending and receiving mechanism**
1379
1380 **1) **{{id name="_Toc28071147"/}}**No start character (STX) and end character (ETX)**
1381
1382 ①16-bit (SM2594 is OFF)
1383
1384 The devices will be divided into high and low directly, and send data from the low address first and then the high address in order.
1385
1386 (% style="text-align:center" %)
1387 [[image:10_html_5891dcc3161d6651.png||class="img-thumbnail"]]
1388
1389
1390 (% style="text-align:center" %)
1391 [[image:10_html_8e673e3933d24e02.gif||class="img-thumbnail"]]
1392
1393 ②8-bit (SM2594 is ON)
1394
1395 Get the value of the low address of device directly and send it
1396
1397 (% style="text-align:center" %)
1398 [[image:10_html_1d76c606ba1b2ba8.png||class="img-thumbnail"]]
1399
1400 (% style="text-align:center" %)
1401 [[image:10_html_a46b2be94cb51e78.png||class="img-thumbnail"]]
1402
1403 The data sent in the case of the ladder program and the data above should be 70 E1 31 62 6C.
1404
1405 (% style="text-align:center" %)
1406 [[image:10_html_1920f501fdbca9b8.png||class="img-thumbnail"]]
1407
1408 Receiving will also be stored in the lower address
1409
1410 **{{id name="_Toc28071148"/}}2) Open and set the start character STX**
1411
1412 The value of the start character SD2600 is only valid in the low bit
1413
1414 When STX is enabled, the send will start with STX. When receiving, the send will start with STX, but STX will not be displayed.
1415
1416 If it receives the STX during the receiving, the receiving will restart.
1417
1418 If the first character is not received, the timeout period is judged by the first character timeout. When a character is received, no matter what data is received, the inter-character timeout will be counted from the last character received.
1419
1420 (% style="text-align:center" %)
1421 [[image:10_html_bd054fd74ccaddc.png||class="img-thumbnail"]]
1422
1423 (% style="text-align:center" %)
1424 [[image:10_html_a46b2be94cb51e78.png||class="img-thumbnail"]]
1425
1426 For example, the result of the above ladder program and the above data sending is FE 70 7D E1 00 31.
1427
1428 Sending FE 51 26 34 15 to the PLC at this time will receive the following data. And if you send FE 25 63 FE 51 26 34 15 you will also receive the following data.
1429
1430 (% style="text-align:center" %)
1431 [[image:10_html_f2dbc2f6fb276e3f.png||class="img-thumbnail"]]
1432
1433 **{{id name="_Toc28071149"/}}3) Open and set the end character ETX situation**
1434
1435 The value of ending character SD2601 is only valid in the low bit.
1436
1437 When ETX is enabled, the send will end with ETX.
1438
1439 When ETX is received, SM2610 and SM2593 are immediately turned ON, regardless of whether sufficient length is received.
1440
1441 (% style="text-align:center" %)
1442 [[image:10_html_17fa71d20bec1531.png||class="img-thumbnail"]]
1443
1444 (% style="text-align:center" %)
1445 [[image:10_html_a46b2be94cb51e78.png||class="img-thumbnail"]]
1446
1447 For example, the result of the above Circuit program and the above data transmission is 70 7D E1 00 31 FD.
1448
1449 If the above Circuit program sends 01 06 FD to him, the following data will be received. If the FD is sent directly, it will be judged as the end directly.
1450
1451 (% style="text-align:center" %)
1452 [[image:10_html_72c7fdeee574504.png||class="img-thumbnail"]]
1453
1454 **{{id name="_Toc28071150"/}}4) Both the start character STX and the end character ETX are turned on**
1455
1456 When both are opened, it is basically a combination of the above single opened states. But if only ETX data is received when both start, it will not end immediately. It will judge the character interval time and does not start receiving data.
1457
1458 **{{id name="_Toc28071151"/}}(2) Receiving after sending (similar to Modbus master station mechanism)**
1459
1460 **{{id name="_Toc28071152"/}}1) Send control switch (SM2590) and receive control switch (SM2592) OFF (default)**
1461
1462 When the contact of RS instruction is on, turn SM2591 on and send it immediately. SM2591 will be automatically OFF immediately after sending.
1463
1464 After sending, SM2593 is ON, it will always stop at this instruction, and wait for it to be OFF and then receive data. If it is OFF, it will start to receive data.
1465
1466 After the first character timeout period (SD2597), if no character is received, it is judged as a timeout. If there are retry times, it will retry. But after retrying, the communication still does not report an error, and SM2593 and SM2614 are turned on.
1467
1468 After receiving the first character, it will judge whether that the interval between characters exceeds the time set by SD2599. If it it doesn’t. it will report an error.(For the details, please refer to [the timeout of the interval character].)
1469
1470 When there are two or more instructions, the first RS instruction which is set ON will be sent after SM2591 is ON. Later, if this RS instruction is completed*1, then turn ON, SM2591 will switch to the next RS instruction*2 in the ladder sequence.
1471
1472 When there are two or more instructions, switch to another one during the data reception and it continue to stay back in the original instruction to until the reception is complete.
1473
1474 **✎Note:**
1475
1476 **✎**Completion refers to receiving data or reporting an error.
1477
1478 **✎**If there is no other open RS instruction after the ladder sequence, it will return to the first RS instruction that was opened in the ladder sequence for execution.
1479
1480 **{{id name="_Toc28071153"/}}2) The sending way when the sending control switch (SM2590) is ON**
1481
1482 When the sending control switch (SM2590) is ON, there is no need to set SM2591 ON. At this time, as long as the contact of the RS instruction is triggered, it can be sent, and SM2591 is automatically turned ON.
1483
1484 **{{id name="_Toc28071154"/}}3) The receiving way when the receiving control switch (SM2592) is ON**
1485
1486 When the receiving control switch (SM2592) is ON, SM2593 will be OFF automatically when the instruction is executed. It will no longer judge the status of SM2593 when receiving, and SM2593 will still be turned ON after receiving.
1487
1488 **{{id name="_Toc28071155"/}}4) Sending control switch (SM2590) and receiving control switch (SM2592) ON**
1489
1490 In this case, you only need to trigger the contact before the RS instruction to send data, then it will automatically switch to the waiting status. When the reception is completed, it will turn to the next RS instruction that is turned on.
1491
1492 **{{id name="_Toc28071156"/}}(3) Send-only**
1493
1494 (% style="text-align:center" %)
1495 [[image:10_html_ee6092e0d3a61be2.png||class="img-thumbnail"]]
1496
1497 When the sending length is set to a value other than 0, and the receiving length is set to 0, it is send-only mode.
1498
1499 **{{id name="_Toc28071157"/}}1) The sending control switch (SM2590) is OFF**
1500
1501 When SM2591 is turned ON, the data will be sent without receiving.
1502
1503 When there are two or more instructions, the first RS instruction which is turned ON will be sent after SM2591 is turned ON. After this RS instruction is completed, then turn ON SM2591 will switch to the next RS instruction in the ladder program.
1504
1505 **{{id name="_Toc28071158"/}}2) The Sending control switch (SM2590) is ON**
1506
1507 The RS instruction will be sent when triggered. Multiple instructions are triggered and sent in a loop. During the sending cycle, the interval will be sent according to the set sending interval.
1508
1509 **{{id name="_Toc28071159"/}}(4) Receive-only**
1510
1511 (% style="text-align:center" %)
1512 [[image:10_html_46075eaee9d78457.png||class="img-thumbnail"]]
1513
1514 When the sending length is 0 and the receiving length is not 0, it is only receiving.
1515
1516 **{{id name="_Toc28071160"/}}1) SM2592 receiving control switch OFF**
1517
1518 SM2593 will be turned ON when receiving, and the ladder program control must be turned OFF to continue receiving. SM2593 will not turn ON without receiving data.
1519
1520 When multiple instructions are enabled to receive only at the same time, it will start to receive from the smallest number of steps in the ladder diagram. Time out or received data will be forwarded to the second to continue receiving.
1521
1522 **{{id name="_Toc28071161"/}}2) SM2592 receiving control switch ON**
1523
1524 It can receive normally and will not be controlled by the flag bit. The SM2593 receiving identifier serves as the receiving prompt identifier,and SM2593 will not turn ON without receiving data.
1525
1526 If multiple RS receive only instructions are turned on at the same time, the receiving position is uncertain due to the timeout judgment and switching to the next one.
1527
1528 **{{id name="_Toc28071162"/}}(5) Use receive-only and send-only methods to send after receiving (similar to Modbus slave mechanism)**
1529
1530 (% style="text-align:center" %)
1531 [[image:10_html_a70fbc189fa39660.png||class="img-thumbnail"]]
1532
1533 (((
1534 Receive-only: When it is determined that the reception is complete, it will determine the instruction to be triggered according to the received content, and save the received data at the same time.
1535
1536 Send-only: The content sent by triggered M2 is different from that of triggered M3. After the trigger is over, they will return to trigger the receive-only of M1.
1537 )))
1538
1539 **{{id name="_Toc28071163"/}}10.7.1.4 Error message**
1540
1541 Currently The Error code will be displayed on SD7, SD0, SD 2611 and SD2612.
1542
1543 The Error codes that will appear in the custom protocol are mainly as follows.
1544
1545 (% class="table-bordered" %)
1546 |(% style="width:106px" %)**Error code**|(% style="width:975px" %)**Content**
1547 |(% style="width:106px" %)3181H|(% style="width:975px" %)Data receiving timeout
1548 |(% style="width:106px" %)3188H|(% style="width:975px" %)Wrong length
1549 |(% style="width:106px" %)3189H|(% style="width:975px" %)COM2 data error. "Check whether there are errors in the parameters of instruction. Check whether the slave station supports the setting of this value. (Please refer to Modbus exception 03)"
1550 |(% style="width:106px" %)318EH|(% style="width:975px" %)(((
1551 Current protocol does not support this instruction
1552
1553 (This error is only displayed on SD7 and SD0)
1554 )))
1555 |(% style="width:106px" %)318FH|(% style="width:975px" %)COM2 sending timed out. Contact a technician if this error occurs
1556 |(% style="width:106px" %)3190H|(% style="width:975px" %)COM2 receiving data exceeds the buffer limit.
1557
1558 After resetting the protocol or communication parameters, the error will be cleared.
1559
1560 In addition, the communication completion/communication error/communication timeout flag will be set after the executed instruction.
1561
1562 **10.7.1.5 The difference with Mitsubishi**
1563
1564 The current differences:
1565
1566 1. STX and ETX: Mitsubishi can set up to 4 bytes, we only have one byte.
1567 1. Add sum check and CR, LF.
1568 1. The instruction control of Mitsubishi is that the first instruction triggered is fixed to execute this instruction. It will not be switched to other instructions midway, unless the contact of this instruction is closed.
1569
1570 == **Modbus protocol description** ==
1571
1572 **Introduction**
1573
1574 The Modbus master station protocol is generally close to LX3V. The address was modified in the slave station.
1575
1576 **Basic configuration**
1577
1578 **(1) Introduction**
1579
1580 The RS instruction has the same usage as the previous RS instruction of 3V, and can use R device.
1581
1582 -[RS (s) (m) (d) (N)]
1583
1584 **Content, range and data type**
1585
1586 (% class="table-bordered" %)
1587 |**Parameter**|(% style="width:589px" %)**Content**|(% style="width:119px" %)**Range**|(% style="width:168px" %)**Data type**|(% style="width:113px" %)**Data type (label)**
1588 |(s)|(% style="width:589px" %)The high byte stores the station number of slave station, and the low byte stores the Modbus function code.|(% style="width:119px" %)-|(% style="width:168px" %)Unsigned BIN 16 bit|(% style="width:113px" %)ANY16
1589 |(m)|(% style="width:589px" %)Slave address. The address provided by slave station will read or write data from this address of the slave station|(% style="width:119px" %)-|(% style="width:168px" %)Unsigned BIN 16 bit|(% style="width:113px" %)ANY16
1590 |(d)|(% style="width:589px" %)Length. The length of Modbus read or write. The unit is determined by function code.|(% style="width:119px" %)-|(% style="width:168px" %)Unsigned BIN 16 bit|(% style="width:113px" %)ANY16
1591 |(N)|(% style="width:589px" %)Start address for reading or writing data|(% style="width:119px" %)-|(% style="width:168px" %)Unsigned BIN 16 bit|(% style="width:113px" %)ANY16
1592
1593 **{{id name="_Toc20576"/}}Device used**
1594
1595 (% class="table-bordered" style="width:1058px" %)
1596 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="6" style="width:348px" %)**Devices**|(% style="width:226px" %)**Offset modification**|(((
1597 **Pulse**
1598
1599 **extension**
1600 )))
1601 |**T**|**C**|**D**|**R**|**K**|(% style="width:96px" %)**H**|(% style="width:226px" %)**[D]**|**XXP**
1602 |(% rowspan="4" %)RS|Parameter 1|●|●|●|●|●|(% style="width:96px" %)●|(% style="width:226px" %) |
1603 |Parameter 2|●|●|●|●|●|(% style="width:96px" %)●|(% style="width:226px" %) |
1604 |Parameter 3|●|●|●|●|●|(% style="width:96px" %)●|(% style="width:226px" %) |
1605 |Parameter 4|●|●|●|●| |(% style="width:96px" %) |(% style="width:226px" %) |
1606
1607 **✎Note: **Although the RS instruction currently allows all the parameters of the instruction to use constants such as K and H, there are different restrictions according to the different protocols. When the protocol is Modbus master station protocol, n cannot be a constant, otherwise an error will be reported.
1608
1609 **{{id name="_Toc33979607"/}}(2) Special device setting**
1610
1611 Special address table
1612
1613 (% class="table-bordered" %)
1614 |(% colspan="2" %)**COM 1 special D device (SD)**
1615 |2540|__**Communication port settings**__
1616 |2541|__**Serial parameter modification identification**__
1617 |2542|
1618 |2543|
1619 |2544|__**Station number setting**__
1620 |2545|__**Station number modification logo**__
1621
1622 **✎Note: **COM1 does not support modifying the protocol.
1623
1624 (% class="table-bordered" %)
1625 |(% colspan="2" %)**COM2 special D device (SD)**|(% colspan="2" %)**COM2 special M Device (SM)**
1626 |2590|__**Communication port setting**__|2590|Send control start
1627 |2591|__**Serial parameter modification identifier**__|2591|**Send control/send reminder**
1628 |2592|__**Protocol setting**__|2592|Receive control start
1629 |2593|__**Protocol modification identifier**__|2593|**Receive control/receive prompt**
1630 |2594|__**Station number setting**__|2594|8-bit mode (for custom protocol)
1631 |2595|__**Station number modification identifier**__|2595|
1632 |2596|(((
1633 __**Sending interval (0.1ms) 0-32767.**__
1634
1635 __**It is 10 when set to 0 (1ms)**__
1636 )))|2596|
1637 |2597|(((
1638 __**Communication timeout setting (10ms) 0-32767**__
1639
1640 __**It is 10 when set to 0 (100ms)**__
1641 )))|2597|
1642 |2598|__**Timeout retry times 0-32767**__|2598|
1643 |2599|Character interval timeout setting (for custom protocol) (0.1ms) 0-32767. It is 10 when set to 0 (1ms)|2599|
1644 |2600|STX value|2600|
1645 |2601|ETX value|2601|
1646 |...| |...|
1647 |2610|**The amount of data received**|2610|**Communication complete flag**
1648 |2611|**Last error**|2611|**Receiving flag**
1649 |2612|**Current error**|2612|**Retry occurred**
1650 |2613|**Error steps**|2613|**Communication error**
1651 |2614|**Error station number**|2614|**Communication timeout**
1652 |2615|**Cumulative number of errors**|2615|
1653
1654 {{id name="_Toc33979608"/}}The contents that the custom protocol will be used and set has been marked with underline and bold. In addition, the devices to be used as judgment conditions have also been marked in bold in the table.
1655
1656 **1) Communication port setting SD2590**
1657
1658 (% class="table-bordered" %)
1659 |(% colspan="2" %)**Bit number**|**B0**|**B1、B2**|**B3**|**B4、B5、B6、B7、B8、B9**
1660 |(% colspan="2" %)**Name**|**Data length**|**Parity**|**Stop Bit**|**Baud rate(bps)**
1661 |(% rowspan="2" %)**Content**|**0 off**|7 bit|(% rowspan="2" %)(((
1662 b2,b1
1663
1664 (0,0): None
1665
1666 (0,1): Odd parity (ODD)
1667
1668 (1,1): Even parity (EVEN)
1669 )))|1 bit|(% rowspan="2" %)(((
1670 |4800|0111
1671 |9600|1000
1672 |19200|1001
1673 |38400|1010
1674 |57600|1011
1675 |115200|1100
1676 |187500|1101
1677 |230400|1110
1678 |460800|1111
1679 |921600|10000
1680 )))
1681 |**1 on**|8 bit|2 bit
1682
1683 Set the serial port parameters to SD2590 according to the bit settings provided in the table above. The setting is roughly the same as 3V. It is mainly because the baud rate can be set to a higher baud rate, the bit used need backward two bits when STX and ETX start.
1684
1685 {{id name="_Toc33979609"/}}For example: To set the serial port parameters: baud rate 115200, stop bit 1, data bit 8, no parity bit, you need to set the value H4C1 (K1217) on SD2590. The parameters directly set to SD2590 are only valid in the first cycle of PLC RUN. If you need to modify it during RUN, you can use the PORTPARAM instruction to set it.
1686
1687 **2) Protocol setting SD2592**
1688
1689 (% class="table-bordered" %)
1690 |(% colspan="4" %)**Protocol settings**
1691 |0 H|Wecon Modbus slave station|10 H|Custom protocol
1692 |2 H|ModbusRTU slave station|20 H|ModbusRTU master station
1693 |3 H|ModbusASCII slave station|30 H|ModbusASCII master station
1694
1695 The corresponding protocol can be set by setting the corresponding value in SD2592. The parameters directly set to SD2592 are only valid in the first cycle of PLC RUN. If you need to modify it during RUN, you can use the PROTOCOL instruction to set it. COM1 cannot use protocols other than Wecon Modbus slave station Currently.
1696
1697 **{{id name="_Toc33979610"/}}3) Sending interval SD2596**
1698
1699 The main function of sending interval is: how long to wait for sending the next instruction after one instruction is completed. If it is set to 0, there is basically no waiting for interval sending, but it will be affected by the scan cycle. The unit of the sending interval is 0.1ms, that is, the interval is 10ms when set to 100.
1700
1701 **{{id name="_Toc33979611"/}}4) Communication timeout SD2597 and timeout retry SD2598**
1702
1703 (% style="text-align:center" %)
1704 [[image:10_html_8c204d3cecb508d7.png||class="img-thumbnail"]]
1705
1706 The main function of communication timeout is: How long does it take to wait for no data to be received and then retry or report an error after the PLC sends. When it is set to 0, the default value is 100ms.
1707
1708 The unit of communication timeout is 10ms, that is, the timeout determine time is 100ms when set to 10.
1709
1710 When a receiving timeout occurs, it will determine whether there are retry times and the current retry times. If the retry times are greater than or equal to SD2598, an error will be reported.
1711
1712 If SD2598 is set to 0, it will not retry.
1713
1714 If it is set to 1, send once and then send once again after timeout.
1715
1716 (% class="wikigeneratedid" id="HSerialportparametersetting" %)
1717 **Serial port parameter setting**
1718
1719 (% class="wikigeneratedid" id="HPORTPARAinstruction" %)
1720 **PORTPARA instruction**
1721
1722 -[PORTPARA (s) (N)]
1723
1724 **Content, range and data type**
1725
1726 (% class="table-bordered" %)
1727 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
1728 |(s1)|The start number of the device that stores the number of digits of converted value|-|Signed BIN 16 bit|ANY16_S_ARRAY
1729 |(s2)|Converted BIN data|-2147483648 to 2147483647|Signed BIN 32 bit|ANY32_S
1730
1731 **{{id name="_Toc3250"/}}Device used**
1732
1733 (% class="table-bordered" %)
1734 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="10" %)**Devices**|(((
1735 **Offset**
1736
1737 **modification**
1738 )))|(((
1739 **Pulse**
1740
1741 **extension**
1742 )))
1743 |**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|**H**|**[D]**|**XXP**
1744 |(% rowspan="2" %)PORTPARA|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|●
1745 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|●
1746
1747 **Features**
1748
1749 Set communication parameters when used for run. Please refer to "__[[PORTPARA instruction description>>path:#_PORTPARA/MODBUS serial port parameter setting]]__" for details**.**
1750
1751 **PROTOCOL instruction**
1752
1753 -[PROTOCOL (s) (N)]
1754
1755 **Content, range and data type**
1756
1757 (% class="table-bordered" %)
1758 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
1759 |(s)|Protocol number to be set|0 to 65535|Unsigned BIN 16 bit|ANY16
1760 |(N)|Which communication port to set (0 means COM1, 1 means COM2 *1)|1|Unsigned BIN 16 bit|ANY16
1761
1762 **Device used**
1763
1764 (% class="table-bordered" %)
1765 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="10" %)**Devices**|**Offset modification**|(((
1766 **Pulse**
1767
1768 **extension**
1769 )))
1770 |**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|(% style="width:33px" %)**H**|**[D]**|**XXP**
1771 |(% rowspan="2" %)PROTOCOL|Parameter 1|●|●|●|●|●|●|●|●|●|(% style="width:33px" %)●|●|●
1772 |Parameter 2|●|●|●|●|●|●|●|●|●|(% style="width:33px" %)●|●|●
1773
1774 **{{id name="_Toc13079"/}}Features**
1775
1776 Set the communication protocol when used for run. The instruction above actually is to set a specific value for the parameter modification flag.
1777
1778 The calculation formula is: (parameter setting value + the offset of the start special device corresponding to the serial port + 10)*2
1779
1780 For example, setting the protocol to ModbusRTU master station (H20) is (0x20 +2593-2590 +10)*2, which is (32 +3+10) *2=90. This is to prevent the serial port parameters from being modified at will. .
1781
1782 In Modbus master protocol, the trigger of setting parameters is to change the value after an instruction is completed.
1783
1784 In Modbus slave protocol, the trigger of setting parameters is that to switch as long as it is not processing the received data.
1785
1786 For details, please refer to "PROTOCOL instruction description"
1787
1788 **3) Host computer settings**
1789
1790 The PLC parameter setting of host computer can set the corresponding serial port parameters.
1791
1792 (% style="text-align:center" %)
1793 [[image:10_html_4208a2ce93bb23e7.png||class="img-thumbnail"]]
1794
1795 Specialized protocol station number cannot be 0.
1796
1797 The station number under ModbusRTU and ModbusASCII protocol is 0: the protocol sets the master station.
1798
1799 The station number under ModbusRTU and ModbusASCII protocol is not 0: the protocol sets the slave station.
1800
1801 The serial port parameters are filled in according to the content in the form.
1802
1803 **✎Note: **RTU protocol cannot set data bit of 7-bit.
1804
1805 **4)Priority description of serial port parameters**
1806
1807 The priority of serial port parameter settings are listed as blow. The serial port parameters are saved by power failure currently.
1808
1809 Serial port parameter set instruction setting = Ladder program MOV instruction set the corresponding SD device > the download parameters of host computer > Previous power-off save data.
1810
1811 **{{id name="_Toc33979615"/}}(4) Basic ladder program**
1812
1813 (% style="text-align:center" %)
1814 [[image:10_html_a7e64b4f4526b73e.png||class="img-thumbnail"]]
1815
1816 (((
1817 Serial port parameter setting
1818
1819 Baud rate 115200, data bit 8, parity bit none, stop bit 1
1820
1821 Communication protocol setting: ModbusRTU master station protocol
1822
1823 Sending interval: 5ms
1824
1825 Receiving timeout: 100ms
1826
1827 Timeout retry times: 3 times
1828
1829 Station number 01H, function code 03H, slave address 10, length 05
1830
1831
1832 )))
1833
1834 **{{id name="_Toc33979616"/}}10.7.2.3 Send and receive process**
1835
1836 **{{id name="_Toc33979617"/}}(1) Modbus master station**
1837
1838 When programming, before each RS (Modbus mode) instruction, the assignment of each operand unit, such as the communication operation object address, operation type, operation register address, data number, sending or receiving unit, etc., is completed, once the execution starts, the system program will automatically calculate the CRC check, organize the communication frame, and complete the operation of sending data and receiving response.
1839
1840 If you use Modbus-ASC protocol communication (set SD2592 as H30), the HEX-ASC format conversion of sending and receiving data is automatically completed by the PLC system program. The RS (Modbus mode) instruction method and the Modbus-RTU protocol method are exactly the same.
1841
1842 In the plc program, if multiple RS (Modbus mode) instructions are driven, the system program will still execute the "sending, waiting for answer, receiving, verification, analysis and storage" of an RS instruction, and then perform the same process for the next RS instruction until all RS instructions are executed and then restarted. You don not need to care about the timing and process of its execution, which simplifies the PLC programming design. This is the advantage of Modbus instruction.
1843
1844 Modbus master function list
1845
1846 (% class="table-bordered" %)
1847 |**Function code**|**Function name**|**Details**
1848 |0x01|Coil readout|Coil readout (multiple points optional)
1849 |0x02|Input readout|Input and read (multiple points optional)
1850 |0x03|Holding register readout|Holding register readout(multiple points optional)
1851 |0x04|Input register readout|Input register readout (multiple points optional)
1852 |0x05|1 coil write|Coil writing (only 1 point)
1853 |0x06|1 register write|Holding register write (only 1 point)
1854 |0x0F|Batch coil write|Multi-point coil writing
1855 |0x10|Batch register write|Multi-point holding register write
1856
1857 (((
1858 Serial port parameter setting
1859
1860 Baud rate 115200, data bit 8, no parity bit, stop bit 1
1861
1862 Example:
1863 )))
1864
1865 (% style="text-align:center" %)
1866 [[image:10_html_a7e64b4f4526b73e.png||class="img-thumbnail"]]
1867
1868 (((
1869 Communication protocol setting: ModbusRTU master station protocol
1870
1871 Sending interval: 5ms
1872
1873 Receiving timeout: 100ms
1874
1875 Timeout retry times: 3 times
1876
1877 Station number 01H, function code 03H, slave address 10, length 05
1878
1879
1880 )))
1881
1882 As shown in the ladder program shown:
1883
1884 When M1 is turned ON, PLC will send data (hexadecimal) from COM2 of PLC: 01 03 00 0A 00 05 A5 C8
1885
1886 * 01: Slave address, the high 8 bits of (s);
1887 * 03: Modbus instruction code, the lower 8 bits of (s). It is to read the slave register;
1888 * 00 0A: The address of the slave register to be read, the value of (m);
1889 * 00 05: The number of registers to be read, the value of (d),
1890 * A5 C8: CRC check code.
1891
1892 **✎Note: **
1893
1894 When using 1 coil to write (0x05), the value used for writing 1 is 0xFF00, and the value used for writing 0 is 0x0000.
1895
1896 When using batch coil write (0x0F), pay attention to the high and low byte exchange. For example, when writing 1 length, the fourth parameter value is 1 (0x0001), which means 0 is sent. You need to write 256 (0x0100) to write 1 to the target address.
1897
1898 **{{id name="_Toc33979618"/}}(2) Modbus slave**
1899
1900 When the PLC series is used as a Modbus slave, it supports Modbus communication operation instructions such as 0x01, 0x03, 0x05, 0x06, 0x 0f, 0x10. The coils of the PLC that can be read and written include M, S, T, C, X (only Read) SM, Y, LC, HSC and other variables through these instructions. Register variables include D, T, C, R, SD, LC, HSC.
1901
1902 When the Modbus communication master accesses (reads or rewrites) the internal variables of the PLC slave, it must follow the following communication instruction frame definition and the variable address index method in order to carry out normal communication operations.
1903
1904 **{{id name="_Toc33979619"/}}1) instruction code 0x01 (01): read coil**
1905
1906 (% class="table-bordered" %)
1907 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
1908 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
1909 |2|0x01 (instruction code)|1 byte|Read coil
1910 |3|Coil start address|2 bytes|High bit in front, low bit in back, see coil addressing
1911 |4|Number of coils|2 bytes|High bit in front, low bit in back (N)
1912 |5|CRC check|2 bytes|Low bit in front, high bit in back
1913
1914 Response frame format: slave address + 0x01 + number of bytes + coil status + CRC check
1915
1916 (% class="table-bordered" %)
1917 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
1918 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
1919 |2|0x01 (instruction code)|1 byte|Read coil
1920 |3|Number of bytes|1 byte|Value: [(N+7)/8]
1921 |4|Coil state|[(N+7)/8] bytes|Every 8 coils are combined into one byte. If the last one is less than 8 bits, fill in 0 in the undefined part. The first 8 coils are in the first byte, and the coil with the smallest address is in the lowest bit. And so on
1922 |5|CRC check|2 bytes|High bit first, then low bit
1923
1924 Error response: refer to error response frame.
1925
1926 **{{id name="_Toc33979620"/}}2) instruction code 0x03 (03): read register**
1927
1928 Request frame format: slave address + 0x03 + register start address + number of registers + CRC check.
1929
1930 (% class="table-bordered" %)
1931 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
1932 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
1933 |2|0x03 (instruction code)|1 byte|Read register
1934 |3|Register start address|2 bytes|High bit in front, low bit in back, see register addressing
1935 |4|Number of registers|2 bytes|High bit in front, low bit in back (N)
1936 |5|CRC check|2 bytes|High bit in front, low bit in back
1937
1938 Response frame format: slave address + 0x03 + number of bytes + register value + CRC check.
1939
1940 (% class="table-bordered" %)
1941 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
1942 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
1943 |2|0x03 (instruction code)|1 byte|Read register
1944 |3|Number of bytes|1 byte|Value: N*2
1945 |4|Register value|N*2 bytes|Every two bytes represent a register value, with high bit in front, low bit in back. The smallest register address comes first
1946 |5|CRC check|2 bytes|High bit in front, low bit in back
1947
1948 Error response: See error response frame.
1949
1950 **{{id name="_Toc216324734"/}}3)** {{id name="_Toc267753989"/}}{{id name="_Toc33979621"/}}**instruction code 0x05 (05): write single coil**
1951
1952 Request frame format: slave address + 0x05 + coil address + coil status + CRC check.
1953
1954 (% class="table-bordered" %)
1955 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
1956 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
1957 |2|0x05 (instruction code)|1 byte|Write single coil
1958 |3|Coil address|2 bytes|High bit in front, low bit in back, see coil addressing
1959 |4|Coil state|2 bytes|High bit in front, low bit in back. Non-zero is valid
1960 |5|CRC check|2 bytes|High bit in front, low bit in back
1961
1962 Response frame format: slave address + 0x05 + coil address + coil status + CRC check.
1963
1964 (% class="table-bordered" %)
1965 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
1966 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
1967 |2|0x05 (instruction code)|1 byte|Write single coil
1968 |3|Coil address|2 bytes|High bit in front, low bit in back, see coil addressing
1969 |4|Coil state|2 bytes|High bit in front, low bit in back. Non-zero is valid
1970 |5|CRC check|2 bytes|High bit in front, low bit in back
1971
1972 {{id name="_Toc33979622"/}}{{id name="_Toc267753990"/}}{{id name="_Toc216324735"/}}Error response: see error response frame. The coil status 0xFF00 means ON, and 0x0000 means OFF.
1973
1974 **4) instruction code 0x06 (06): write a single register**
1975
1976 Request frame format: slave address + 0x06 + register address + register value + CRC check.
1977
1978 (% class="table-bordered" %)
1979 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
1980 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
1981 |2|0x06 (instruction code)|1 byte|Write single coil
1982 |3|Register|2 bytes|High bit in front, low bit in back, see coil addressing
1983 |4|Register value|2 bytes|High bit in front, low bit in back. Non-zero is valid
1984 |5|CRC check|2 bytes|High bit in front, low bit in back
1985
1986 Response frame format: slave address + 0x06 + register address + register value + CRC check.
1987
1988 (% class="table-bordered" %)
1989 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
1990 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
1991 |2|0x06 (instruction code)|1 byte|Write single coil
1992 |3|Register|2 bytes|High bit in front, low bit in back, see coil addressing
1993 |4|Register value|2 bytes|High bit in front, low bit in back. Non-zero is valid
1994 |5|CRC check|2 bytes|High bit in front, low bit in back
1995
1996 Error response: See error response frame.{{id name="_Toc33979623"/}}{{id name="_Toc216324736"/}}{{id name="_Toc267753991"/}}
1997
1998 **5) instruction code 0x 0f (15): write multiple coils**
1999
2000 Request frame format: slave address + 0x 0f + coil start address + coil number + byte number + coil status + CRC check.
2001
2002 (% class="table-bordered" %)
2003 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
2004 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
2005 |2|0x 0f (instruction code)|1 byte|Write multiple single coils
2006 |3|Coil start address|2 bytes|High bit in front, low bit in back, see coil addressing
2007 |4|Number of coils|2 bytes|High bit in front, low bit in back. The maximum of N is 1968
2008 |5|Number of bytes|1 byte|Value: [(N+7)/8]
2009 |6|Coil state|[(N+7)/8] bytes|Every 8 coils are combined into one byte. If the last one is less than 8 bits, fill in 0 in the undefined part. The first 8 coils are in the first byte, and the coil with the smallest address is in the lowest bit. And so on
2010 |7|CRC check|2 bytes|High bit in front, low bit in back
2011
2012 Response frame format: slave address + 0x 0f + coil start address + coil number + CRC check
2013
2014 (% class="table-bordered" %)
2015 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
2016 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
2017 |2|0x 0f (instruction code)|1 byte|Write multiple single coils
2018 |3|Coil start address|2 bytes|High bit in front, low bit in back, see coil addressing
2019 |4|Number of coils|2 bytes|High bit in front, low bit in back
2020 |5|CRC check|2 bytes|High bit in front, low bit in back
2021
2022 Error response: See error response frame.
2023
2024 **{{id name="_Toc33979624"/}}6)** {{id name="_Toc216324737"/}}{{id name="_Toc267753992"/}}**3.2.6 instruction code 0x10 (16): write multiple registers**
2025
2026 Request frame format: slave address + 0x10 + register start address + register number + byte number + register value + CRC check.
2027
2028 (% class="table-bordered" %)
2029 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
2030 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
2031 |2|0x10(instruction code)|1 byte|Write multiple registers
2032 |3|Register start address|2 bytes|High bit in front, low bit in back, see register addressing
2033 |4|Number of registers|2 bytes|High bit in front, low bit in back. The maximum of N is 120
2034 |5|Number of bytes|1 byte|Value: N*2
2035 |6|Register value|N*2 (N*4)|
2036 |7|CRC check|2 bytes|High bit in front, low bit in back
2037
2038 Response frame format: slave address + 0x10 + register start address + register number + CRC check.
2039
2040 (% class="table-bordered" %)
2041 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
2042 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
2043 |2|0x10 (instruction code)|1 byte|Write multiple registers
2044 |3|Register start address|2 bytes|High bit in front, low bit in back, see register addressing
2045 |4|Number of registers|2 bytes|High bit in front, low bit in back. The maximum of N is 120
2046 |5|CRC check|2 bytes|High bit in front, low bit in back
2047
2048 Error response: See error response frame.{{id name="_Toc33979625"/}}{{id name="_Toc216324738"/}}{{id name="_Toc267753993"/}}
2049
2050 **7) Error response frame**
2051
2052 Error response: slave address + (instruction code + 0x80) + Error code + CRC check.
2053
2054 (% class="table-bordered" %)
2055 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
2056 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
2057 |2|Instruction code+0x80|1 byte|Error instruction code
2058 |3|Code|1 byte|1 to 4
2059 |4|CRC check|2 bytes|High bit in front, low bit in back
2060
2061 (% class="table-bordered" %)
2062 |**Serial number**|**Error code**|**Instruction**
2063 |1|01|Unsupported function code
2064 |2|02|Wrong address or function code
2065 |3|03|Wrong length
2066 |4|04|Imperfect instruction
2067 |5|05|Address not allowed
2068
2069 **{{id name="_Toc33979626"/}}8) Slave address table**
2070
2071 (% class="table-bordered" %)
2072 |(% colspan="5" %)**Word address**
2073 |**Address type**|**Occupy**|**Address range**|**Decimal address**|**Total reserved address size**
2074 |T0 to T511|512 WORD|0x0000-0x01ff|0|1536
2075 |C0 to C255|256 WORD|0x0600-0x06ff|1536|1024
2076 |LC0 to LC255|512 WORD|0x0A00-0x0BFF|2560|1024
2077 |HSC0 to HSC15|32 WORD|0x0E00-0x0E1F|3584|512
2078 |D0 to D7999|8000 WORD|0x1000-0x2F3F|4096|16384
2079 |SD0 to SD4095|4096 WORD|0x5000-0x5FFF|20480|12288
2080 |R0 to R30000|30000 WORD|0x8000-0xF52F|32768|30000
2081
2082 (% class="table-bordered" %)
2083 |(% colspan="5" %)**Bit address**
2084 |**Address type**|**Occupy**|**Address range**|**Decimal address**|**Total reserved address size**
2085 |T0 to T511|512 bit|0x0000-0x01ff| |1536
2086 |C0 to C255|256 bit|0x0600-0x06ff|1536|1024
2087 |LC0 to LC255|256 bit|0x0A00-0x0AFF|2560|1024
2088 |HSC0 to HSC15|16 bit|0x0E00-0x0E0F|3584|512
2089 |M0 to M8000|8000 bit|0x1000-0x2F3F|4096|16384
2090 |SM0 to SM4095|4096 bit|0x5000-0x5FFF|20480|12288
2091 |Reserved| |0x8000-0xBFFF| |16383
2092 |S0 to S4095|4096 bit|0xC000-0xCFFF|49152|8192
2093 |X0 to X1023|1024 bit|0xE000-0xE3FF|57344|4096
2094 |Y0 to Y1023|1024 bit|0xF000-0xF3FF|61440|4096
2095
2096 **Error message**
2097
2098 Currently the Error code will be displayed on SD7 and SD0 and SD2611 and SD2612.
2099
2100 The Error codes that appear in the Modbus protocol are mainly as follows.
2101
2102 (% class="table-bordered" %)
2103 |(% style="width:101px" %)**Error code**|(% style="width:980px" %)**Content**
2104 |(% style="width:101px" %)4085H|(% style="width:980px" %)(s)(m)(d)(N) The read address is out of the device range (this error is only displayed on SD7 and SD0)
2105 |(% style="width:101px" %)3180H|(% style="width:980px" %)COM2 data reception error. There may be interference on the communication line, it is recommended to connect the ground wire.
2106 |(% style="width:101px" %)3181H|(% style="width:980px" %)COM2 data reception timed out. "Check the wiring, check whether the serial port parameter settings are compatible with master and slave, check whether there is interference. Check whether the slave station is too late to respond. For this reason, you can try to increase the sending interval SD2546."
2107 |(% style="width:101px" %)3182H|(% style="width:980px" %)COM2 CRC check error. There may be interference on the communication line, it is recommended to connect the ground wire.
2108 |(% style="width:101px" %)3183H|(% style="width:980px" %)COM2 LRC check error. There may be interference on the communication line, it is recommended to connect the ground wire.
2109 |(% style="width:101px" %)3184H|(% style="width:980px" %)The COM2 station number is incorrectly configured. Check the slave station number setting. And check whether there is any problem with the receiving and sending mechanism from the station.
2110 |(% style="width:101px" %)3185H|(% style="width:980px" %)COM2 send buffer overflow. Contact a technician if this error occurs
2111 |(% style="width:101px" %)3186H|(% style="width:980px" %)COM2 function code is wrong. Check whether the set function code is a function code supported by PLC
2112 |(% style="width:101px" %)3187H|(% style="width:980px" %)COM2 address is wrong. Check whether the slave station has this address (please refer to Modbus Abnormal 02)
2113 |(% style="width:101px" %)3188H|(% style="width:980px" %)The length of COM2 is wrong. Check whether the communication length exceeds the length range specified by the Modbus protocol, or whether it exceeds the specified length range of the custom protocol.
2114 |(% style="width:101px" %)3189H|(% style="width:980px" %)COM2 data error. "Check whether there are errors in the parameters of the instruction. Check whether the slave station supports the setting of this value. (Please refer to Modbus Abnormal 03)"
2115 |(% style="width:101px" %)318AH|(% style="width:980px" %)COM2 slave is busy. Slave station returns information: Slave station is busy (please refer to Modbus exception 06)
2116 |(% style="width:101px" %)318BH|(% style="width:980px" %)The COM2 slave station does not support function codes. Check whether the slave station supports this function code (please refer to Modbus exception 01)
2117 |(% style="width:101px" %)318CH|(% style="width:980px" %)The COM2 slave is faulty. Slave station returns information: Slave station is faulty, please check whether the slave station is faulty (please refer to Modbus Abnormal 04)
2118 |(% style="width:101px" %)318DH|(% style="width:980px" %)COM2 slave confirms. Slave station return information: slave station confirmation (please refer to Modbus abnormal 05)
2119 |(% style="width:101px" %)318EH|(% style="width:980px" %)COM2 current protocol does not support this instruction. RS instruction cannot be used when it is set to slave station protocol, please change the protocol or close the contact before RS instruction (this error is only displayed on SD7 and SD0)
2120 |(% style="width:101px" %)318FH|(% style="width:980px" %)COM2 sending timed out. Contact a technician if this error occurs
2121 |(% style="width:101px" %)3190H|(% style="width:980px" %)COM2 receiving data exceeds the buffer limit.
2122 |(% style="width:101px" %)31A0H|(% style="width:980px" %)COM2 is not available as a gateway. Returned information from the station: unavailable gateway (please refer to Modbus exception 0A)
2123 |(% style="width:101px" %)31A1H|(% style="width:980px" %)COM2 indicates that no response was obtained from the target device. Slave station returns information: the device is not in the network (please refer to Modbus exception 0B)
2124
2125 After resetting the protocol or communication parameters, the error will be cleared.
2126
2127 In addition, the communication completion/communication error/communication timeout flag will be set after the executed instruction.
2128
2129 == {{id name="_10.7 WECON MODBUS protocol description"/}}**PLCLINK/Fast interconnect** ==
2130
2131 PLCLINK function is used to simplify the fast connection between PLCs. The fast communication of the LX5V series PLC could be achieved only using the configuration parameters without using the communication instruction(RS).
2132
2133 The topological diagram is shown in the figure below.
2134
2135 (% style="text-align:center" %)
2136 [[image:image-20220614170612-1.jpeg]]
2137
2138 When using the PLCLINK function:
2139
2140 * Master station configuration: Select COM2 port and set the protocol to PLCLINK protocol.
2141 * Slave configuration: Select COM1 or COM2 and set the protocol to dedicated protocol.
2142
2143 (% class="wikigeneratedid" id="H28129Createatable" %)
2144 **(1) Create a table**
2145
2146 In [Project manager]-[Extended function]-[PLCLINK], right click [PLCLINK], and click it to create a table.
2147
2148 (% style="text-align:center" %)
2149 [[image:10_html_347d7923523ad9af.png||class="img-thumbnail"]]
2150
2151 Click it and a prompt box as below would pop up.
2152
2153 (% style="text-align:center" %)
2154 [[image:10_html_dbbb9b1ddaa56dce.png||class="img-thumbnail"]]
2155
2156 Click "Yes" will automatically change the protocol to PLCLINK, click "No" will not change the protocol.
2157
2158 The number of PLCLINK protocol is H60.
2159
2160 (% class="table-bordered" %)
2161 |**0H**|Wecon Modbus slave station
2162 |**2H**|ModbusRTU slave station
2163 |**3H**|ModbusASCII slave station
2164 |**10H**|user-defined protocol
2165 |**20H**|ModbusRTU main station
2166 |**30H**|ModbusASCII main station
2167 |**60H**|PLCLINK protocol
2168
2169 Click "Yes" will generate an empty table MAIN.
2170
2171 (% style="text-align:center" %)
2172 [[image:10_html_39ce9cf6a41c3901.png||class="img-thumbnail"]]
2173
2174 Double click MAIN will pop up the POLCLINK table as below.
2175
2176 (% style="text-align:center" %)
2177 [[image:10_html_14072bc2a32c267.png||class="img-thumbnail"]]
2178
2179 Currently only one PLCLINK table can be created. Creating a new table after creating one is disallowed.
2180
2181 (% style="text-align:center" %)
2182 [[image:10_html_f4bec5285beb7949.png||class="img-thumbnail"]]
2183
2184 (2) Write the table
2185
2186 Write station number in
2187
2188 After writing the station number in the new instruction station number in the table, click the new instruction to add the communication instruction.
2189
2190 The range of station number is 1 to 31. The maximum number of communication instruction is 255.
2191
2192 (% style="text-align:center" %)
2193 [[image:10_html_21d3b9789058efb3.png||class="img-thumbnail"]]
2194
2195 (% style="text-align:center" %)
2196 [[image:10_html_20232344eaa6cb2a.png||class="img-thumbnail"]]
2197
2198 Currently the station number is only selected by drop-down box.
2199
2200 (% style="text-align:center" %)
2201 [[image:10_html_f09857f93ae04f0a.png||class="img-thumbnail"]]
2202
2203 The devices of main station and slave station are selected by drop-down box.
2204
2205 (% style="text-align:center" %)
2206 [[image:10_html_99c7d435825defd1.png||class="img-thumbnail"]]
2207
2208 (% style="text-align:center" %)
2209 [[image:10_html_f62cce6501331b8d.png||class="img-thumbnail"]]
2210
2211 The transfer direction are read and write, and also selected by drop-down box.
2212
2213 (% style="text-align:center" %)
2214 [[image:10_html_7b3de12a134b4e95.png||class="img-thumbnail"]]
2215
2216 The device address range limitations are as below.
2217
2218 1. The device address could not exceed the current device range
2219 1. {{id name="OLE_LINK102"/}}In the device of bit written, the mantissa of points of X and Y must be zero, such as X0, X10, X20, Y0, Y10, Y20 and so on. The software PLC Editor 2 will adjust automatically.
2220 1. {{id name="OLE_LINK106"/}}The Points of bit device other than X and Y must be a multiple of 8,such as M0, M8, N16, T(bit) 16, C(bit) 24 and so on. The software PLC Editor 2 will adjust automatically.
2221 1. {{id name="OLE_LINK103"/}}Bit device must communicate with bit device , and word device must communicate with word device. Double word device can only communicate with double word device. This is to avoid length perception differences.
2222
2223 {{id name="OLE_LINK104"/}}The number limitations of slave station device are as below.
2224
2225 1. The number of bit device ranges from 8 to 2,032.
2226 1. {{id name="OLE_LINK105"/}}The number of word device ranges from 1 to 126.
2227 1. The number of double word device ranges from 1 to 63. HSC can only use a maximum of 16 due to the number limitation.
2228 1. The number of bit device must be a multiple of 8, such as 8, 16, 24, 32 and so on. The software PLC Editor 2 will adjust automatically.display the corresponding device address and range.
2229
2230 (3) Download
2231
2232 {{id name="OLE_LINK107"/}}Currently PLCLINK could only be downloaded with the program and could not downloaded separately.
2233
2234 (% style="text-align:center" %)
2235 [[image:10_html_a586bd0ca75cd8f.png||class="img-thumbnail"]]
2236
2237 Click on PLCLINK in monitoring mode to re-write part of the table into PLC, but the start device could not be modified.
2238
2239 (% style="text-align:center" %)
2240 [[image:10_html_92ca328b83e6ef12.png||class="img-thumbnail"]]
2241
2242 In monitoring mode, monitoring read and monitoring write could not be executed if the ladder program comparison is incorrect.
2243
2244 (4) Automatic check
2245
2246 Click “Check” in monitoring mode, the PLC that can communicate will be automatically searched and enabled. Stations that could not communicate will be closed. The Stations without instructions will not be checked. The PLCLINK table will be updated after the automatic check of the upper computer is finished.
2247
2248 (% style="text-align:center" %)
2249 [[image:10_html_d6ff78427b75140d.png||class="img-thumbnail"]]
2250
2251 Write 1 to in the table for addresses whose start address is offset 12 (for example, R200 is R212). The corresponding function is as below.
2252
2253 (% class="table-bordered" %)
2254 |**S1+12**|(((
2255 Auto check mode
2256
2257 (Reserved)
2258 )))|(((
2259 {{id name="OLE_LINK109"/}}0: No check; 1: Automatic check mode; 2: Automatic check in progress.
2260
2261 {{id name="OLE_LINK110"/}}{{id name="OLE_LINK111"/}}When enabled, all the station numbers will send data to determine whether the station number exists. The corresponding communication switch will be turned on if it exists. If not, the corresponding communication switch will be turned off.
2262 )))
2263
2264 No error will be reported during auto check after the auto check is enabled. After the check is complete, the corresponding station number will be automatically enabled and disabled.
2265
2266 (% class="table-bordered" %)
2267 |**S1+13**|Corresponding station number communication switch 1|(((
2268 The switch control of station 1 to 15
2269
2270 {{id name="OLE_LINK112"/}}Bit0: ON: Station number 0 (broadcast) normal communication
2271
2272 OFF: Station number 0 (broadcast) communication prohibited (broadcast prohibited)
2273
2274 Bit1: ON: Station number 1 normal communication; OFF: Station 1 communication prohibited
2275
2276 Bit2: ON: Station number 2 normal communication; OFF: Station 2 communication prohibited
2277 )))
2278 |**S1+14**|Corresponding station number communication switch 2|The switch control of station 16 to 31
2279
2280 Click [station number enable] to set the station enable according to the corresponding situations.
2281
2282 (% style="text-align:center" %)
2283 [[image:10_html_beda0fdc84802959.png||class="img-thumbnail"]]
2284
2285 (% style="text-align:center" %)
2286 [[image:10_html_f84703130b23d8f6.png||class="img-thumbnail"]]
2287
2288 **✎Note: **When in the automatic check state, forcibly turn off the automatic check state (write 0 in S1+12), an error may occur.
2289
2290 {{id name="OLE_LINK113"/}}(5) Main station parameter configuration
2291
2292 (% style="text-align:center" %)
2293 [[image:10_html_434fac0fa8c16597.png||class="img-thumbnail"]]
2294
2295 The protocol must be PLCLINK protocol, and the data bit can not be 7-bit data bit. Other parameters can be selected as required.
2296
2297 (6) Slave station configuration
2298
2299 For PLCLINK communication ports, select the dedicated protocol from the station protocol.
2300
2301 (% style="text-align:center" %)
2302 [[image:10_html_2641eb7c39f4f4aa.png||class="img-thumbnail"]]
2303
2304 The settings of Baud rate, data bit, stop bit, parity bit must be consistent with main station. The parameters above are consistent if not modified. The station number needs to be configured separately. The slave station number ranges from 1 to 31.
2305
2306 {{id name="OLE_LINK115"/}}(7) Close PLCLINK
2307
2308 In S1+11, The pause and start of PLCLINK are controlled by bit 8. If bit 8 is ON, PLCLINK would be closed. No error is reported when switching protocol after this function is disabled.
2309
2310 (% class="table-bordered" %)
2311 |**S1+11**|Operation state|(((
2312 Bit0=1,Port is occupied. This function obtains the right of data transaction transmission.
2313
2314 Bit2=1,One cycle has been executed.
2315
2316 {{id name="OLE_LINK114"/}}Bit4,Communication transmission output indication
2317
2318 Bit5,Communication error output indication (Exceeds the number of retry times)
2319
2320 Bit6,Communication completion output indication
2321
2322 Bit8,PLCLINK suspension (0: Normal operation, 1: Operation paused)
2323 )))
2324
2325 (8) Table contents
2326
2327 {{id name="OLE_LINK119"/}}Currently the communication table is downloaded to the device to operate. The details of the table are as follows.
2328
2329 (% class="table-bordered" %)
2330 |(% rowspan="2" %)**Address offset**|(% colspan="2" %){{id name="OLE_LINK116"/}}**Brief description**|(% rowspan="2" %)**Detailed description**
2331 |**High byte**|**Low byte**
2332 |S1+0|(% colspan="2" %)Header|{{id name="OLE_LINK117"/}}Header =70h, correct PLCLINK table. (modification prohibited)
2333 |S1+1|(% colspan="2" %)Number of communication instructions|1 to 255 (modification prohibited)
2334 |S1+2|(% colspan="2" %)Version|{{id name="OLE_LINK121"/}}{{id name="OLE_LINK118"/}}V1.100 (modification prohibited)
2335 |S1+3|(% colspan="2" %){{id name="OLE_LINK120"/}}The start address of communication table|modification prohibited
2336 |S1+4|(% colspan="2" %)Check bit of the number of header and communication|Simple check calculation for table header, number of communication instructions, version, and the start address of communication table ((modification prohibited))
2337 |S1+5|(% colspan="2" %)Which instruction currently is running|Display the current running command (read only)
2338 |S1+6|Station NO.1|Read/write direction|(% rowspan="5" %)The instruction content of current communication
2339 |S1+7|(% colspan="2" %)The data start address of station NO.1
2340 |S1+8|Station NO.2|Address type distinction
2341 |S1+9|(% colspan="2" %)The data start address of station NO.2
2342 |S1+10|(% colspan="2" %)Data length
2343 |S1+11|(% colspan="2" %)Operation state|(((
2344 Bit0=1,Port is occupied. This function obtains the right of data transaction transmission.
2345
2346 Bit2=1, One cycle has been executed.
2347
2348 Bit4, Communication transmission output indication
2349
2350 Bit5, Communication error output indication (Exceeds the number of retry times)
2351
2352 Bit6, Communication completion output indication
2353
2354 Bit8, PLCLINK suspension (0: Normal operation, 1: Operation paused)
2355 )))
2356 |S1+12|(% colspan="2" %)Auto check mode (Reserved)|(((
2357 0: No check; 1: Automatic check mode; 2: Automatic check in progress.
2358
2359 When enabled, all the station numbers will send data to determine whether the station number exists. The corresponding communication switch will be turned on if it exists. If not, the corresponding communication switch will be turned off.
2360 )))
2361 |S1+13|(% colspan="2" %)Corresponding station number communication switch 1|(((
2362 The switch control of station 1 to 15
2363
2364 Bit0: ON: Station NO. 0 (broadcast) normal communication
2365
2366 OFF: Station NO.0 (broadcast) communication prohibited (broadcast prohibited)
2367
2368 Bit1: ON: Station NO.1 normal communication;
2369
2370 OFF: Station NO.1 communication prohibited
2371
2372 Bit2: ON: Station NO.2 normal communication;
2373
2374 OFF: Station NO.2 communication prohibited
2375 )))
2376 |S1+14|(% colspan="2" %)Corresponding station number communication switch 2|The switch control of station 16 to 31
2377 |S1+15|(% colspan="2" %)Reserved|
2378 |S1+16|(% colspan="2" %)Reserved|
2379 |S1+17|(% colspan="2" %)Reserved|
2380 |S1+18|(% colspan="2" %)Reserved|
2381 |S1+19|(% colspan="2" %)Reserved|
2382 |S1+20|(% colspan="2" %)Reserved|
2383 |S1+21|Station NO.1|Read/write direction|(((
2384 • Station NO. 1 to 32, FF(FF represents main station)
2385
2386 • Function code:
2387
2388 ~=01H, read
2389
2390 ~=02H, write
2391 )))
2392 |S1+22|(% colspan="2" %)The data start address of station NO.1|• Valid word. Define operating the start address of slave station data
2393 |S1+23|Station NO.2|Address type distinction|(((
2394 •Station NO.0 to 32 (If it is 0, broadcast to all the slave stations on behalf of master station, and slave stations do not respond
2395
2396 •Distinguish the type of the starting device for storing data in the main station.
2397
2398 Main station address type distinction. 0: word address; 1: bit address
2399 )))
2400 |S1+24|(% colspan="2" %)The data start address of station NO.2|• Valid word. Define operating the start device of slave station data. Define the corresponding address by MUDBUS address of 5V.
2401 |S1+25|(% colspan="2" %)Data length|• Valid word. Range 1 to 126(bit data), 1 to 2,032(bit data)
2402 |S1+26|Station NO.1|Read/write direction|(% rowspan="5" %)(((
2403 The second data transmission description.
2404
2405 Main station address type distinction.
2406 )))
2407 |S1+27|(% colspan="2" %)The data start address of station NO.1
2408 |S1+28|Station NO.2|Address type distinction
2409 |S1+29|(% colspan="2" %)The data start address of station NO.2
2410 |S1+30|(% colspan="2" %)Data length
2411 |•|(% colspan="2" %) | 
2412 |•|(% colspan="2" %) | 
2413 |S1+20+ n×5|(% colspan="2" %)Reserved|• n is the total number of data transmission commands.
2414
2415 **{{id name="_Toc27709"/}}✎Note: **
2416
2417 1. It is forbidden to modify S0 to S4.
2418 1. It is not recommended to change the value except the function enable or station number enable. Otherwise, the operation or upload may be abnormal.
2419
2420 **{{id name="_Toc18822"/}}Error code**
2421
2422 (% class="table-bordered" %)
2423 |(% style="width:105px" %)**Error code**|(% style="width:976px" %)**Contents**
2424 |(% style="width:105px" %)31C0H|(% style="width:976px" %){{id name="OLE_LINK129"/}}Abnormal PLCLINK header. Re-download the program.
2425 |(% style="width:105px" %)31C1H|(% style="width:976px" %)PLCLINK function is not supported by COM port currently.
2426 |(% style="width:105px" %)31C2H|(% style="width:976px" %)PLCLINK table version is incompatible. Re-download the program.
2427 |(% style="width:105px" %)31C3H|(% style="width:976px" %)The number of PLCLINK command exceeds the range. The value ranges from 1 to 255 Currently.
2428 |(% style="width:105px" %)31C4H|(% style="width:976px" %){{id name="OLE_LINK133"/}}{{id name="OLE_LINK132"/}}The station number of PLCLINK table exceeds the range. Check the station number in the table.
2429 |(% style="width:105px" %)31C5H|(% style="width:976px" %)PLCLINK table exceeds the range of device. Check the corresponding device range of table.
2430 |(% style="width:105px" %)31C6H|(% style="width:976px" %)The device used by PLCLINK table command exceeds the range. Check the device used for each command in the table.
2431 |(% style="width:105px" %)3180H|(% style="width:976px" %)COM2 data reception error. There may be interference on the communication line. It is recommended to connect the ground wire.
2432 |(% style="width:105px" %)3181H|(% style="width:976px" %)COM2 data reception time. Check wiring, whether the parameters of the serial port setting is master-slave correspondence, whether there is interference, whether it is caused by the delay of the slave station. For this reason, try to increase the sending interval SD2546.
2433 |(% style="width:105px" %)3182H|(% style="width:976px" %)COM2 CRC check error. There may be interference on the communication line. It is recommended to connect the ground wire.
2434 |(% style="width:105px" %)3184H|(% style="width:976px" %)COM2 station number error. Check the setting of slave station number. Check whether there is a problem with the slave receiving and sending mechanism.
2435 |(% style="width:105px" %)3186H|(% style="width:976px" %){{id name="OLE_LINK135"/}}COM2 function code error. Check whether the function code is supported by PLC.
2436 |(% style="width:105px" %)3187H|(% style="width:976px" %)COM2 address error.
2437 |(% style="width:105px" %)3188H|(% style="width:976px" %){{id name="OLE_LINK136"/}}COM2 length error. Check whether the communication length exceeds the length range specified by Modbus or user-defined protocol.
2438 |(% style="width:105px" %)3189H|(% style="width:976px" %){{id name="OLE_LINK137"/}}{{id name="OLE_LINK138"/}}COM2 data error. Check whether the parameter of instruction is wrong. Check whether the setting of the value is supported by slave station. (Please refer to Modbus abnormal 03)
2439 |(% style="width:105px" %)318AH|(% style="width:976px" %){{id name="OLE_LINK139"/}}{{id name="OLE_LINK140"/}}COM2 slave station is busy. Slave station returns message: Slave station is busy. (Please refer to Modbus abnormal 06)
2440 |(% style="width:105px" %)318BH|(% style="width:976px" %){{id name="OLE_LINK141"/}}COM2 slave station does not support function codes. Check whether the function code is supported by slave station. (Please refer to Modbus abnormal 01)
2441 |(% style="width:105px" %)318CH|(% style="width:976px" %)COM2 slave station fault. Slave station returns message: Slave station is fault. Check whether the slave station is faulty. (Please refer to Modbus abnormal 04)
2442 |(% style="width:105px" %)318DH|(% style="width:976px" %)COM2 slave station confirmation. Slave station returns message: Slave station confirmation.(Please refer to Modbus abnormal 05)
2443 |(% style="width:105px" %)318EH|(% style="width:976px" %)COM2 does not support this instruction or function. When slave station protocol is set, the corresponding communication instruction or function of main station could not be used. Please change the protocol or close the contacts before the corresponding instruction, or the corresponding communication function.
2444 |(% style="width:105px" %)3190H|(% style="width:976px" %)The data received by COM2 exceeds the cache limit.
2445
2446 **{{id name="_Toc25970"/}}Example**
2447
2448 Create a PLCLINK table and automatically switch the Com2 protocol to PLCLINK.
2449
2450 (% style="text-align:center" %)
2451 [[image:10_html_c4962fb2076781b9.png||class="img-thumbnail"]]
2452
2453 {{id name="OLE_LINK143"/}}Open PLCLINK table, write the master station D10 to the slave station D10 device number 10, and read the slave station D10 to the master station D20 device number 10.
2454
2455 (% style="text-align:center" %)
2456 [[image:10_html_3244c013d7d800c3.png||class="img-thumbnail"]]
2457
2458 {{id name="OLE_LINK144"/}}Connect Com2 of master station PLC to COM1 of slave station, and set the slave station number to 1. After downloading, set the value of main station D10 to 1 and D11 to 8192 . Then, D20 will change to 1 and and D21 will change to 8192.
2459
2460 (% style="text-align:center" %)
2461 [[image:10_html_ae5ef70ce179ad5e.png||class="img-thumbnail"]]
2462
2463 **{{id name="_Toc27083"/}}The situation of connecting more than one**
2464
2465 When adding commands, the station number that corresponding more slave station number can add more station number communication connections
2466
2467 (% style="text-align:center" %)
2468 [[image:10_html_98f836562979721.png||class="img-thumbnail"]]
2469
2470 == {{id name="_Toc7760"/}}**Wecon Modbus protocol description** ==
2471
2472 The current Wecon Modbus protocol description (special protocol) is modified based on the ModbusRTU protocol.
2473
2474 Therefore, 7-bit data bits cannot be used in the serial port parameter part.
2475
2476 The protocol of COM0 and COM1 can only use WECON Modbus protocol at present and cannot be changed.
2477
2478 This protocol is fully compatible with Modbus RTU protocol, and the address is also the same as the default address of LX5VPLC's Modbus RTU protocol.
2479
2480 The extended function is mainly used to communicate with PLCEDITOR.