Wiki source code of 10 Communication instruction

Version 15.1 by Stone Wu on 2022/09/26 14:07

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: 515px;" %)**Content**|=(% style="width: 94px;" %)**Range**|=(% style="width: 193px;" %)**Data type**|=**Data type (label)**
552 |=(s)|(% style="width:515px" %)The start address of register area that stores the data to be sent|(% style="width:94px" %)-|(% style="width:193px" %)Unsigned BIN 16 bit|ANY16
553 |=(m)|(% style="width:515px" %)The length of data to be sent (bytes)|(% style="width:94px" %)0 to 528|(% style="width:193px" %)Unsigned BIN 16 bit|ANY16
554 |=(d)|(% style="width:515px" %)The device start number that stores the written data|(% style="width:94px" %)-|(% style="width:193px" %)Unsigned BIN 16 bit|ANY16
555 |=(N)|(% style="width:515px" %)Number of data written (bytes)|(% style="width:94px" %)0 to 528|(% style="width:193px" %)Unsigned BIN 16 bit|ANY16
556 |=(n1)|(% style="width:515px" %)Specify the communication port|(% style="width:94px" %) |(% style="width:193px" %)Unsigned BIN 16 bit|ANY16
557
558 In Modbus protocol
559
560 (% class="table-bordered" %)
561 |=(% scope="row" %)**Parameter**|=(% style="width: 596px;" %)**Content**|=(% style="width: 87px;" %)**Range**|=(% style="width: 153px;" %)**Data type**|=(% style="width: 153px;" %)**Data type (label)**
562 |=(s)|(% style="width:596px" %)The high byte stores the station number of slave station, and the low byte stores function code of Modbus|(% style="width:87px" %)-|(% style="width:153px" %)Unsigned BIN 16 bit|(% style="width:153px" %)ANY16
563 |=(m)|(% style="width:596px" %)Slave address. The address provided by the slave station will read or write data from this address of the slave station|(% style="width:87px" %)-|(% style="width:153px" %)Unsigned BIN 16 bit|(% style="width:153px" %)ANY16
564 |=(d)|(% style="width:596px" %)Length. The length of Modbus read or write. The unit is determined by function code.|(% style="width:87px" %)-|(% style="width:153px" %)Unsigned BIN 16 bit|(% style="width:153px" %)ANY16
565 |=(N)|(% style="width:596px" %)The start address of the data to be read or written|(% style="width:87px" %)-|(% style="width:153px" %)Unsigned BIN 16 bit|(% style="width:153px" %)ANY16
566 |=(n1)|(% style="width:596px" %)Specify the communicatiom port|(% style="width:87px" %) |(% style="width:153px" %)Unsigned BIN 16 bit|(% style="width:153px" %)ANY16
567
568 **Device used**
569
570 (% class="table-bordered" style="width:1092px" %)
571 |=(% rowspan="2" style="width: 116px;" %)**Instruction**|=(% rowspan="2" style="width: 101px;" %)**Parameter**|=(% colspan="7" style="width: 521px;" %)**Devices**|=(% style="width: 177px;" %)(((
572 **Offset modification**
573 )))|=(((
574 **Pulse extension**
575 )))
576 |=(% style="width: 86px;" %)**T**|=(% style="width: 112px;" %)**C**|=(% style="width: 67px;" %)**D**|=(% style="width: 83px;" %)**R**|=**SD**|=**K**|=(% style="width: 47px;" %)**H**|=(% style="width: 177px;" %)**[D]**|=**XXP**
577 |=(% rowspan="5" style="width: 116px;" %)RS2|(% style="width:101px" %)(s)|(% style="width:86px" %)●|(% style="width:112px" %)●|(% style="width:67px" %)●|(% style="width:83px" %)●|●|●|(% style="width:47px" %)●|(% style="width:177px" %)-|-
578 |(% style="width:101px" %)(m)|(% style="width:86px" %)●|(% style="width:112px" %)●|(% style="width:67px" %)●|(% style="width:83px" %)●|●|●|(% style="width:47px" %)●|(% style="width:177px" %)-|-
579 |(% style="width:101px" %)(d)|(% style="width:86px" %)●|(% style="width:112px" %)●|(% style="width:67px" %)●|(% style="width:83px" %)●|●|●|(% style="width:47px" %)●|(% style="width:177px" %)-|-
580 |(% style="width:101px" %)(N)|(% style="width:86px" %)●|(% style="width:112px" %)●|(% style="width:67px" %)●|(% style="width:83px" %)●|●|●|(% style="width:47px" %)●|(% style="width:177px" %)-|-
581 |(% style="width:101px" %)(n1)|(% style="width:86px" %) |(% style="width:112px" %) |(% style="width:67px" %) |(% style="width:83px" %) | |●|(% style="width:47px" %)●|(% style="width:177px" %) |
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" %)__10.7.2 Modbus protocol description__>>path:#_10.7.2 Modbus protocol description]](%%)"
688
689 **✎Note: **
690
691 * 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.
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**|**Content**|**Range**|**Data type**|**Data type (label)**
840 |(s1)|Module number, the first module is 0, the second module is 1, and so on|0 to 32767|Unsigned BIN 16 bit|ANY16
841 |(s2)|Start writing from which BFM in the module|0 to 32767|Unsigned BIN 16 bit|ANY16
842 |(s3)|Start number of the device storing the written data|-2147483648 to 2147483647|Signed BIN 32 bit|ANY32
843 |(N)|Number of data written|0 to 256|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 LX5VPLC 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**|**Content**|**Range**|**Data type**|**Data type (label)**
928 |(s1)|Module number, the first module is 0, the second module is 1, and so on|0 to 32767|Unsigned BIN 16 bit|ANY16
929 |(s2)|Start reading from which BFM in the module|0 to 32767|Unsigned BIN 16 bit|ANY16
930 |(d)|Start number of the device storing the read data|-|Signed BIN 16 bit|ANY16
931 |(N)|Number of read data|0 to 512|Unsigned BIN 16 bit|ANY16
932
933 **Device used**
934
935 (% class="table-bordered" %)
936 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="10" %)**Devices**|(((
937 **Offset**
938
939 **modification**
940 )))|(((
941 **Pulse**
942
943 **extension**
944 )))
945 |**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|**H**|**[D]**|**XXP**
946 |(% rowspan="4" %)FROM|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|●
947 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|●
948 |Parameter 3|●|●|●|●|●|●|●|●| | |●|●
949 |Parameter 4|●|●|●|●|●|●|●|●|●|●|●|●
950
951 **Features**
952
953 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.
954
955 (% style="text-align:center" %)
956 [[image:10_html_1b9d34e74f852368.gif||class="img-thumbnail"]]
957
958 As the following Circuit program
959
960 (% style="text-align:center" %)
961 [[image:10_html_ad9897d46ca8f957.png||class="img-thumbnail"]]
962
963 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.
964
965 Currently LX5VPLC supports 16 special expansion modules at the same time.
966
967 The special soft components used are as follows:
968
969 (% class="table-bordered" %)
970 |**Devices**|**Content**
971 |SD2081|Total number of modules
972 |SD2082|Number of IO expansion modules
973 |SD2083|Number of special expansion modules
974 |SD2084|The first missing expansion module. When the value is -1, it means not lost
975
976 **Error code**
977
978 (% class="table-bordered" %)
979 |**Error code**|**Content**
980 |4085H|(s1) (s2) (N) The read address exceeds the device range
981 |4086H|(d) The write address exceeds the device range
982 |4084H|(s1) (s2) is not in the range of 0 to 32767 or (N) is not in the range of 0 to 512
983 |7080H|Check error when communicating between PLC and module
984 |7081H|Expansion module communication message is abnormal
985 |7082H|FROM/TO instruction error
986 |7083H|The specified extension module was not found
987
988 **Example**
989
990 (% style="text-align:center" %)
991 [[image:10_html_a9071734dc5cfce5.png||class="img-thumbnail"]]
992
993 When M1 is turned on
994
995 The values of BFM3, BFM4, and BFM5 of the #0 (first) module will be transferred to D200, D201, D202
996
997 (% style="text-align:center" %)
998 [[image:10_html_f1df0562ea9002cf.png||class="img-thumbnail"]]
999
1000 (% style="text-align:center" %)
1001 [[image:10_html_73bb66d1890735ff.png||class="img-thumbnail"]]
1002
1003 == {{id name="_Toc18124"/}}{{id name="_Toc10981"/}}{{id name="_Toc21090"/}}**DFROM/single word data read from the module (32-bit specification)** ==
1004
1005 **DFROM(P)**
1006
1007 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.
1008
1009 -[DFROM (s1) (s2) (d) (N)]
1010
1011 **Content, range and data type**
1012
1013 (% class="table-bordered" %)
1014 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
1015 |(s1)|Module number, the first module is 0, the second module is 1, and so on|0 to 32767|Unsigned BIN 16 bit|ANY16
1016 |(s2)|Start reading from which BFM in the module|0 to 32767|Unsigned BIN 16 bit|ANY16
1017 |(d)|Start number of the device storing the read data|-|Signed BIN 32 bit|ANY32
1018 |(N)|Number of read data|0 to 256|Unsigned BIN 16 bit|ANY16
1019
1020 **Device used**
1021
1022 (% class="table-bordered" %)
1023 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="12" %)**Devices**|**Offset modification**|(((
1024 **Pulse**
1025
1026 **extension**
1027 )))
1028 |**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**[D]**|**XXP**
1029 |(% rowspan="4" %)DFROM|Parameter 1|●|●|●|●|●|●|●|●| | |●|●|●|●
1030 |Parameter 2|●|●|●|●|●|●|●|●| | |●|●|●|●
1031 |Parameter 3|●|●|●|●|●|●|●|●|●|●| | |●|●
1032 |Parameter 4|●|●|●|●|●|●|●|●| | |●|●|●|●
1033
1034 **Features**
1035
1036 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.
1037
1038 (% style="text-align:center" %)
1039 [[image:10_html_ea4017a0483ddbbe.gif||class="img-thumbnail"]]
1040
1041 As the following Circuit program
1042
1043 (% style="text-align:center" %)
1044 [[image:10_html_6d0c9e8bc37fe95.png||class="img-thumbnail"]]
1045
1046 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.
1047
1048 Currently LX5VPLC supports 16 special expansion modules at the same time.
1049
1050 The special soft components used are as follows:
1051
1052 (% class="table-bordered" %)
1053 |**Devices**|**Content**
1054 |SD2081|Total number of modules
1055 |SD2082|Number of IO expansion modules
1056 |SD2083|Number of special expansion modules
1057 |SD2084|The first missing expansion module. When the value is -1, it means not lost
1058
1059 **Error code**
1060
1061 (% class="table-bordered" %)
1062 |**Error code**|**Content**
1063 |4085H|(s1) (s2) (N) The read address exceeds the device range
1064 |4086H|(d) The write address exceeds the device range
1065 |4084H|(s1) (s2) is not in the range of 0 to 32767 or (N) is not in the range of 0 to 256
1066 |7080H|Check error when communicating between PLC and module
1067 |7081H|Expansion module communication message is abnormal
1068 |7082H|FROM/TO instruction error
1069 |7083H|The specified extension module was not found
1070
1071 **Example**
1072
1073 (% style="text-align:center" %)
1074 [[image:10_html_7389fb305b495d09.png||class="img-thumbnail"]]
1075
1076 When M1 is turned on
1077
1078 The value of BFM3 to BFM8 of module #0 (first) will be transferred to D200 to D205
1079
1080 (% style="text-align:center" %)
1081 [[image:10_html_2f6f4ddff10c30ec.png||class="img-thumbnail"]]
1082
1083 (% style="text-align:center" %)
1084 [[image:10_html_8a1de3e41b64afe1.png||class="img-thumbnail"]]
1085
1086 = {{id name="_Toc28953"/}}**{{id name="_Toc13721"/}}{{id name="_Toc14994"/}}{{id name="_Toc4655"/}}RS and RS2 instructions corresponding protocol description** =
1087
1088 == {{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** ==
1089
1090 **{{id name="_Toc28071132"/}}Introduction**
1091
1092 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.
1093
1094 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.
1095
1096 The current custom protocol is generally close to 3V series.
1097
1098 **{{id name="_Toc28071133"/}}Basic configuration**
1099
1100 **(1) Instructions**
1101
1102 The RS instruction itself has the same usage as the previous RS instruction at 3V, and it can use R device.
1103
1104 -[RS (s) (m) (d) (N)]
1105
1106 **Content, range and data type**
1107
1108 (% class="table-bordered" %)
1109 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
1110 |(s)|The start address of the register area where the data to be sent is stored|-|Unsigned BIN 16 bit|ANY16
1111 |(m)|Is the length of the data to be sent (number of bytes)|0 to 528|Unsigned BIN 16 bit|ANY16
1112 |(d)|Start number of the device storing the written data|-|Unsigned BIN 16 bit|ANY16
1113 |(N)|Number of data written|0 to 528|Unsigned BIN 16 bit|ANY16
1114
1115 **{{id name="_Toc20319"/}}Device used**
1116
1117 (% class="table-bordered" %)
1118 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="6" %)**Devices**|**Offset modification**|(((
1119 **Pulse**
1120
1121 **extension**
1122 )))
1123 |**T**|**C**|**D**|**R**|**K**|**H**|**[D]**|**XXP**
1124 |(% rowspan="4" %)RS|Parameter 1|●|●|●|●|●|●| |
1125 |Parameter 2|●|●|●|●|●|●| |
1126 |Parameter 3|●|●|●|●|●|●| |
1127 |Parameter 4|●|●|●|●|●|●| |
1128
1129 **✎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.
1130
1131 **{{id name="_Toc28071135"/}}(2) Special device settings**
1132
1133 Special address table
1134
1135 (% class="table-bordered" %)
1136 |(% colspan="2" %)**COM2 special D device (SD)**|(% colspan="2" %)**COM2 special M Device (SM)**
1137 |2590|__**Communication port setting**__|2590|__**Send control on**__
1138 |2591|__**Serial parameter modification identification**__|2591|__**Send control/send reminder**__
1139 |2592|Protocol settings|2592|__**Receive control on**__
1140 |2593|Protocol modification logo|2593|__**Accept control/receive prompt**__
1141 |2594|Station number setting|2594|__**8-bit mode (for custom protocol)**__
1142 |2595|Station number modification logo|2595|
1143 |2596|(((
1144 __**Sending interval (0.1ms) 0-32767**__
1145
1146 __**It is 10 (1ms) when set to 0**__
1147 )))|2596|
1148 |2597|(((
1149 __**Communication timeout setting (10ms) 0-32767**__
1150
1151 __**It is 10(100ms) when set to 0**__
1152 )))|2597|
1153 |2598|__**Timeout retry times 0-32767**__|2598|
1154 |2599|(((
1155 __**Character interval timeout setting (for custom protocol) (0.1ms)**__
1156
1157 __**0-32767 . It is 10 (1ms) when set to 0**__
1158 )))|2599|
1159 |2600|__**STX value**__|2600|
1160 |2601|__**ETX value**__|2601|
1161 |...| |...|
1162 |2610|**The amount of data received**|2610|**Communication complete flag**
1163 |2611|**Last error**|2611|**Receiving flag**
1164 |2612|**Current error**|2612|**Retry occurred**
1165 |2613|**Error steps**|2613|**Communication error**
1166 |2614|**Error station number**|2614|**Communication timeout**
1167 |2615|**Cumulative number of errors**|2615|
1168
1169 The contents that the custom protocol will be used and set has been marked with underline and bold.
1170
1171 In addition, the devices to be used as judgment conditions have also been marked in bold in the table.
1172
1173 **✎Note: **COM1 currently does not support custom protocols.
1174
1175 **{{id name="_Toc28071136"/}}1) Communication port setting SD2590**
1176
1177 (% class="table-bordered" %)
1178 |(% colspan="2" %)**Bit number**|**B0**|**B1、B2**|**B3**|(((
1179 **B4、B5、B6、**
1180
1181 **B7、B8、B9**
1182 )))|**B10**|**B11**
1183 |(% colspan="2" %)**Name**|**Data length**|**Parity**|**Stop Bit**|**Baud rate(bps)**|**STX**|**ETX**
1184 |(% rowspan="2" %)**Content**|**0 off**|7 bit|(% rowspan="2" %)(((
1185 b2,b1
1186
1187 (0,0): None
1188
1189 (0,1): Odd parity (ODD)
1190
1191 (1,1): Even parity (EVEN)
1192 )))|1 bit|(% rowspan="2" %)(((
1193 |4800|0111
1194 |9600|1000
1195 |19200|1001
1196 |38400|1010
1197 |57600|1011
1198 |115200|1100
1199 |187500|1101
1200 |230400|1110
1201 |460800|1111
1202 |921600|10000
1203 )))|None|None
1204 |**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
1205
1206 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.
1207
1208 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.
1209
1210 If you need to modify it during RUN, you can use the PORTPARAM instruction to set it.
1211
1212 **{{id name="_Toc28071137"/}}2) Protocol setting SD2592**
1213
1214 (% class="table-bordered" %)
1215 |(% colspan="2" %)**Protocol settings**|(% colspan="2" %)**Protocol settings**
1216 |0 H|Wecon Modbus slave station|10 H|Cunstom protocol
1217 |2 H|ModbusRTU slave station|20 H|ModbusRTU master station
1218 |3 H|ModbusASCII slave station|30 H|ModbusASCII master station
1219
1220 The corresponding protocol can be set by setting the corresponding value in SD2592.
1221
1222 The parameters directly set to SD2592 are only valid in the first cycle of PLC RUN.
1223
1224 If you need to modify it during RUN, you can use the PROTOCOL instruction to set it.
1225
1226 **{{id name="_Toc28071138"/}}3) Sending interval SD2596**
1227
1228 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.
1229
1230 The unit of the sending interval is 0.1ms, that is, the interval time is 10ms when the setting is 100.
1231
1232 **{{id name="_Toc28071139"/}}4) Communication timeout SD2597 and timeout retry SD2598**
1233
1234 (% style="text-align:center" %)
1235 [[image:10_html_53f716718aad2197.png||class="img-thumbnail"]]
1236
1237 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.
1238
1239 The unit of communication timeout is 10ms, that is, the timeout judgment time is 10ms when the setting is 100.
1240
1241 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.
1242
1243 If SD2598 is set to 0, it will not try again.
1244
1245 If it is set to 1, send once again after sending a timeout.
1246
1247 **{{id name="_Toc28071140"/}}5) Character interval timeout SD2599**
1248
1249 Currently this setting is only available for custom protocols.
1250
1251 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.
1252
1253 (% style="text-align:center" %)
1254 [[image:10_html_3725d523c70bd43d.png||class="img-thumbnail"]]
1255
1256 This setting is mainly designed considering that some devices may send slow or have other specific sending requirements.
1257
1258 {{id name="_Toc28071141"/}}The character interval timeout will not retry.
1259
1260 **(3) Serial port parameter setting instructions**
1261
1262 **1) Host computer interface settings**
1263
1264 (% style="text-align:center" %)
1265 [[image:10_html_3f08ef293fcbfcf1.png||class="img-thumbnail"]]
1266
1267 Through the PLC parameter setting in the upper computer interface, If protocol is set to none, it is a custom protocol.
1268
1269 The serial port parameter content mainly sets the serial port parameters such as baud rate and data bit.
1270
1271 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.
1272
1273 **✎Note: **The characters here are decimal values.
1274
1275 **{{id name="_Toc28071142"/}}2) PORTPARA instruction**
1276
1277 -[PORTPARA (s) (N)]
1278
1279 **Content, range and data type**
1280
1281 (% class="table-bordered" %)
1282 |**Parameter**|**Content**|**Range**|**Data type**|(((
1283 **Data type**
1284
1285 **(label)**
1286 )))
1287 |(s)|Serial port parameters to be set|0 to 256|Unsigned BIN 16 bit|ANY16
1288 |(N)|Which communication port to set (0 means COM1, 1 means COM2)|0, 1|Unsigned BIN 16 bit|ANY16
1289
1290 **{{id name="_Toc23976"/}}Device used**
1291
1292 (% class="table-bordered" %)
1293 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="10" %)**Devices**|**Offset modification**|(((
1294 **Pulse**
1295
1296 **extension**
1297 )))
1298 |**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|**H**|**[D]**|**XXP**
1299 |(% rowspan="2" %)PROTPARA|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|●
1300 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|●
1301
1302 Function: To set communication parameters when running.
1303
1304 Please refer to "PORTPARA instruction description" for details.
1305
1306 **{{id name="_Toc28071143"/}}3) PROTOCOL instruction**
1307
1308 -[PROTOCOL (s) (N)]
1309
1310 **Content, range and data type**
1311
1312 (% class="table-bordered" %)
1313 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
1314 |(s)|Protocol number to be set|0 to 65535|Unsigned BIN 16 bit|ANY16
1315 |(N)|Which communication port to set (0 means COM1, 1 means COM2 *1)|1|Unsigned BIN 16 bit|ANY16
1316
1317 **{{id name="_Toc1191"/}}Device used**
1318
1319 (% class="table-bordered" %)
1320 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="10" %)**Devices**|(((
1321 **Offset**
1322
1323 **modification**
1324 )))|(((
1325 **Pulse**
1326
1327 **extension**
1328 )))
1329 |**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|**H**|**[D]**|**XXP**
1330 |(% rowspan="2" %)PORTOCOL|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|
1331 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|
1332
1333 **Features:**
1334
1335 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
1336
1337 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.
1338
1339 The trigger of setting parameters in custom protocol will not change the value until an instruction is completed.
1340
1341 The trigger of setting parameters in Modbus master station protocol won’t change the value until an instruction is completed.
1342
1343 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.
1344
1345 **4) Priority description of serial port parameters**
1346
1347 The priority of serial port parameter settings are listed as blow. The serial port parameters are saved by power failure currently.
1348
1349 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.
1350
1351 **(4) Ladder program**
1352
1353 (% style="text-align:center" %)
1354 [[image:10_html_487e57593173359e.png||class="img-thumbnail"]]
1355
1356 (((
1357 Set serial port parameters:
1358
1359 Baud rate 112500, stop bit 1, data bit 8, no parity bit none
1360
1361 Set protocol to custom protocol
1362
1363 Sending interval: 5ms
1364
1365 Receiving timeout: 100ms
1366
1367 Number of repetitions: 3 times
1368
1369 Characters interval timeout: 30ms
1370
1371 Custom protocol sending start address D200, sending length 8.
1372
1373 Receiving start address D300, receiving length 6
1374
1375 Send directly after trigger
1376
1377 After receiving is completed, close the instruction directly and reset the instruction receiving flag
1378 )))
1379
1380 **{{id name="_Toc28071145"/}}Sending and receiving process**
1381
1382 **{{id name="_Toc28071146"/}}(1) Sending and receiving mechanism**
1383
1384 **1) **{{id name="_Toc28071147"/}}**No start character (STX) and end character (ETX)**
1385
1386 ①16-bit (SM2594 is OFF)
1387
1388 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.
1389
1390 (% style="text-align:center" %)
1391 [[image:10_html_5891dcc3161d6651.png||class="img-thumbnail"]]
1392
1393
1394 (% style="text-align:center" %)
1395 [[image:10_html_8e673e3933d24e02.gif||class="img-thumbnail"]]
1396
1397 ②8-bit (SM2594 is ON)
1398
1399 Get the value of the low address of device directly and send it
1400
1401 (% style="text-align:center" %)
1402 [[image:10_html_1d76c606ba1b2ba8.png||class="img-thumbnail"]]
1403
1404 (% style="text-align:center" %)
1405 [[image:10_html_a46b2be94cb51e78.png||class="img-thumbnail"]]
1406
1407 The data sent in the case of the ladder program and the data above should be 70 E1 31 62 6C.
1408
1409 (% style="text-align:center" %)
1410 [[image:10_html_1920f501fdbca9b8.png||class="img-thumbnail"]]
1411
1412 Receiving will also be stored in the lower address
1413
1414 **{{id name="_Toc28071148"/}}2) Open and set the start character STX**
1415
1416 The value of the start character SD2600 is only valid in the low bit
1417
1418 When STX is enabled, the send will start with STX. When receiving, the send will start with STX, but STX will not be displayed.
1419
1420 If it receives the STX during the receiving, the receiving will restart.
1421
1422 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.
1423
1424 (% style="text-align:center" %)
1425 [[image:10_html_bd054fd74ccaddc.png||class="img-thumbnail"]]
1426
1427 (% style="text-align:center" %)
1428 [[image:10_html_a46b2be94cb51e78.png||class="img-thumbnail"]]
1429
1430 For example, the result of the above ladder program and the above data sending is FE 70 7D E1 00 31.
1431
1432 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.
1433
1434 (% style="text-align:center" %)
1435 [[image:10_html_f2dbc2f6fb276e3f.png||class="img-thumbnail"]]
1436
1437 **{{id name="_Toc28071149"/}}3) Open and set the end character ETX situation**
1438
1439 The value of ending character SD2601 is only valid in the low bit.
1440
1441 When ETX is enabled, the send will end with ETX.
1442
1443 When ETX is received, SM2610 and SM2593 are immediately turned ON, regardless of whether sufficient length is received.
1444
1445 (% style="text-align:center" %)
1446 [[image:10_html_17fa71d20bec1531.png||class="img-thumbnail"]]
1447
1448 (% style="text-align:center" %)
1449 [[image:10_html_a46b2be94cb51e78.png||class="img-thumbnail"]]
1450
1451 For example, the result of the above Circuit program and the above data transmission is 70 7D E1 00 31 FD.
1452
1453 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.
1454
1455 (% style="text-align:center" %)
1456 [[image:10_html_72c7fdeee574504.png||class="img-thumbnail"]]
1457
1458 **{{id name="_Toc28071150"/}}4) Both the start character STX and the end character ETX are turned on**
1459
1460 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.
1461
1462 **{{id name="_Toc28071151"/}}(2) Receiving after sending (similar to Modbus master station mechanism)**
1463
1464 **{{id name="_Toc28071152"/}}1) Send control switch (SM2590) and receive control switch (SM2592) OFF (default)**
1465
1466 When the contact of RS instruction is on, turn SM2591 on and send it immediately. SM2591 will be automatically OFF immediately after sending.
1467
1468 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.
1469
1470 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.
1471
1472 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].)
1473
1474 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.
1475
1476 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.
1477
1478 **✎Note:**
1479
1480 **✎**Completion refers to receiving data or reporting an error.
1481
1482 **✎**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.
1483
1484 **{{id name="_Toc28071153"/}}2) The sending way when the sending control switch (SM2590) is ON**
1485
1486 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.
1487
1488 **{{id name="_Toc28071154"/}}3) The receiving way when the receiving control switch (SM2592) is ON**
1489
1490 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.
1491
1492 **{{id name="_Toc28071155"/}}4) Sending control switch (SM2590) and receiving control switch (SM2592) ON**
1493
1494 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.
1495
1496 **{{id name="_Toc28071156"/}}(3) Send-only**
1497
1498 (% style="text-align:center" %)
1499 [[image:10_html_ee6092e0d3a61be2.png||class="img-thumbnail"]]
1500
1501 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.
1502
1503 **{{id name="_Toc28071157"/}}1) The sending control switch (SM2590) is OFF**
1504
1505 When SM2591 is turned ON, the data will be sent without receiving.
1506
1507 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.
1508
1509 **{{id name="_Toc28071158"/}}2) The Sending control switch (SM2590) is ON**
1510
1511 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.
1512
1513 **{{id name="_Toc28071159"/}}(4) Receive-only**
1514
1515 (% style="text-align:center" %)
1516 [[image:10_html_46075eaee9d78457.png||class="img-thumbnail"]]
1517
1518 When the sending length is 0 and the receiving length is not 0, it is only receiving.
1519
1520 **{{id name="_Toc28071160"/}}1) SM2592 receiving control switch OFF**
1521
1522 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.
1523
1524 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.
1525
1526 **{{id name="_Toc28071161"/}}2) SM2592 receiving control switch ON**
1527
1528 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.
1529
1530 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.
1531
1532 **{{id name="_Toc28071162"/}}(5) Use receive-only and send-only methods to send after receiving (similar to Modbus slave mechanism)**
1533
1534 (% style="text-align:center" %)
1535 [[image:10_html_a70fbc189fa39660.png||class="img-thumbnail"]]
1536
1537 (((
1538 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.
1539
1540 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.
1541 )))
1542
1543 **{{id name="_Toc28071163"/}}10.7.1.4 Error message**
1544
1545 Currently The Error code will be displayed on SD7, SD0, SD 2611 and SD2612.
1546
1547 The Error codes that will appear in the custom protocol are mainly as follows.
1548
1549 (% class="table-bordered" %)
1550 |(% style="width:106px" %)**Error code**|(% style="width:975px" %)**Content**
1551 |(% style="width:106px" %)3181H|(% style="width:975px" %)Data receiving timeout
1552 |(% style="width:106px" %)3188H|(% style="width:975px" %)Wrong length
1553 |(% 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)"
1554 |(% style="width:106px" %)318EH|(% style="width:975px" %)(((
1555 Current protocol does not support this instruction
1556
1557 (This error is only displayed on SD7 and SD0)
1558 )))
1559 |(% style="width:106px" %)318FH|(% style="width:975px" %)COM2 sending timed out. Contact a technician if this error occurs
1560 |(% style="width:106px" %)3190H|(% style="width:975px" %)COM2 receiving data exceeds the buffer limit.
1561
1562 After resetting the protocol or communication parameters, the error will be cleared.
1563
1564 In addition, the communication completion/communication error/communication timeout flag will be set after the executed instruction.
1565
1566 **10.7.1.5 The difference with Mitsubishi**
1567
1568 The current differences:
1569
1570 1. STX and ETX: Mitsubishi can set up to 4 bytes, we only have one byte.
1571 1. Add sum check and CR, LF.
1572 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.
1573
1574 == **Modbus protocol description** ==
1575
1576 **Introduction**
1577
1578 The Modbus master station protocol is generally close to LX3V. The address was modified in the slave station.
1579
1580 **Basic configuration**
1581
1582 **(1) Introduction**
1583
1584 The RS instruction has the same usage as the previous RS instruction of 3V, and can use R device.
1585
1586 -[RS (s) (m) (d) (N)]
1587
1588 **Content, range and data type**
1589
1590 (% class="table-bordered" %)
1591 |**Parameter**|(% style="width:589px" %)**Content**|(% style="width:119px" %)**Range**|(% style="width:168px" %)**Data type**|(% style="width:113px" %)**Data type (label)**
1592 |(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
1593 |(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
1594 |(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
1595 |(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
1596
1597 **{{id name="_Toc20576"/}}Device used**
1598
1599 (% class="table-bordered" style="width:1058px" %)
1600 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="6" style="width:348px" %)**Devices**|(% style="width:226px" %)**Offset modification**|(((
1601 **Pulse**
1602
1603 **extension**
1604 )))
1605 |**T**|**C**|**D**|**R**|**K**|(% style="width:96px" %)**H**|(% style="width:226px" %)**[D]**|**XXP**
1606 |(% rowspan="4" %)RS|Parameter 1|●|●|●|●|●|(% style="width:96px" %)●|(% style="width:226px" %) |
1607 |Parameter 2|●|●|●|●|●|(% style="width:96px" %)●|(% style="width:226px" %) |
1608 |Parameter 3|●|●|●|●|●|(% style="width:96px" %)●|(% style="width:226px" %) |
1609 |Parameter 4|●|●|●|●| |(% style="width:96px" %) |(% style="width:226px" %) |
1610
1611 **✎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.
1612
1613 **{{id name="_Toc33979607"/}}(2) Special device setting**
1614
1615 Special address table
1616
1617 (% class="table-bordered" %)
1618 |(% colspan="2" %)**COM 1 special D device (SD)**
1619 |2540|__**Communication port settings**__
1620 |2541|__**Serial parameter modification identification**__
1621 |2542|
1622 |2543|
1623 |2544|__**Station number setting**__
1624 |2545|__**Station number modification logo**__
1625
1626 **✎Note: **COM1 does not support modifying the protocol.
1627
1628 (% class="table-bordered" %)
1629 |(% colspan="2" %)**COM2 special D device (SD)**|(% colspan="2" %)**COM2 special M Device (SM)**
1630 |2590|__**Communication port setting**__|2590|Send control start
1631 |2591|__**Serial parameter modification identifier**__|2591|**Send control/send reminder**
1632 |2592|__**Protocol setting**__|2592|Receive control start
1633 |2593|__**Protocol modification identifier**__|2593|**Receive control/receive prompt**
1634 |2594|__**Station number setting**__|2594|8-bit mode (for custom protocol)
1635 |2595|__**Station number modification identifier**__|2595|
1636 |2596|(((
1637 __**Sending interval (0.1ms) 0-32767.**__
1638
1639 __**It is 10 when set to 0 (1ms)**__
1640 )))|2596|
1641 |2597|(((
1642 __**Communication timeout setting (10ms) 0-32767**__
1643
1644 __**It is 10 when set to 0 (100ms)**__
1645 )))|2597|
1646 |2598|__**Timeout retry times 0-32767**__|2598|
1647 |2599|Character interval timeout setting (for custom protocol) (0.1ms) 0-32767. It is 10 when set to 0 (1ms)|2599|
1648 |2600|STX value|2600|
1649 |2601|ETX value|2601|
1650 |...| |...|
1651 |2610|**The amount of data received**|2610|**Communication complete flag**
1652 |2611|**Last error**|2611|**Receiving flag**
1653 |2612|**Current error**|2612|**Retry occurred**
1654 |2613|**Error steps**|2613|**Communication error**
1655 |2614|**Error station number**|2614|**Communication timeout**
1656 |2615|**Cumulative number of errors**|2615|
1657
1658 {{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.
1659
1660 **1) Communication port setting SD2590**
1661
1662 (% class="table-bordered" %)
1663 |(% colspan="2" %)**Bit number**|**B0**|**B1、B2**|**B3**|**B4、B5、B6、B7、B8、B9**
1664 |(% colspan="2" %)**Name**|**Data length**|**Parity**|**Stop Bit**|**Baud rate(bps)**
1665 |(% rowspan="2" %)**Content**|**0 off**|7 bit|(% rowspan="2" %)(((
1666 b2,b1
1667
1668 (0,0): None
1669
1670 (0,1): Odd parity (ODD)
1671
1672 (1,1): Even parity (EVEN)
1673 )))|1 bit|(% rowspan="2" %)(((
1674 |4800|0111
1675 |9600|1000
1676 |19200|1001
1677 |38400|1010
1678 |57600|1011
1679 |115200|1100
1680 |187500|1101
1681 |230400|1110
1682 |460800|1111
1683 |921600|10000
1684 )))
1685 |**1 on**|8 bit|2 bit
1686
1687 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.
1688
1689 {{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.
1690
1691 **2) Protocol setting SD2592**
1692
1693 (% class="table-bordered" %)
1694 |(% colspan="4" %)**Protocol settings**
1695 |0 H|Wecon Modbus slave station|10 H|Custom protocol
1696 |2 H|ModbusRTU slave station|20 H|ModbusRTU master station
1697 |3 H|ModbusASCII slave station|30 H|ModbusASCII master station
1698
1699 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.
1700
1701 **{{id name="_Toc33979610"/}}3) Sending interval SD2596**
1702
1703 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.
1704
1705 **{{id name="_Toc33979611"/}}4) Communication timeout SD2597 and timeout retry SD2598**
1706
1707 (% style="text-align:center" %)
1708 [[image:10_html_8c204d3cecb508d7.png||class="img-thumbnail"]]
1709
1710 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.
1711
1712 The unit of communication timeout is 10ms, that is, the timeout determine time is 100ms when set to 10.
1713
1714 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.
1715
1716 If SD2598 is set to 0, it will not retry.
1717
1718 If it is set to 1, send once and then send once again after timeout.
1719
1720 (% class="wikigeneratedid" id="HSerialportparametersetting" %)
1721 **Serial port parameter setting**
1722
1723 (% class="wikigeneratedid" id="HPORTPARAinstruction" %)
1724 **PORTPARA instruction**
1725
1726 -[PORTPARA (s) (N)]
1727
1728 **Content, range and data type**
1729
1730 (% class="table-bordered" %)
1731 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
1732 |(s1)|The start number of the device that stores the number of digits of converted value|-|Signed BIN 16 bit|ANY16_S_ARRAY
1733 |(s2)|Converted BIN data|-2147483648 to 2147483647|Signed BIN 32 bit|ANY32_S
1734
1735 **{{id name="_Toc3250"/}}Device used**
1736
1737 (% class="table-bordered" %)
1738 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="10" %)**Devices**|(((
1739 **Offset**
1740
1741 **modification**
1742 )))|(((
1743 **Pulse**
1744
1745 **extension**
1746 )))
1747 |**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|**H**|**[D]**|**XXP**
1748 |(% rowspan="2" %)PORTPARA|Parameter 1|●|●|●|●|●|●|●|●|●|●|●|●
1749 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|●
1750
1751 **Features**
1752
1753 Set communication parameters when used for run. Please refer to "__[[PORTPARA instruction description>>path:#_PORTPARA/MODBUS serial port parameter setting]]__" for details**.**
1754
1755 **PROTOCOL instruction**
1756
1757 -[PROTOCOL (s) (N)]
1758
1759 **Content, range and data type**
1760
1761 (% class="table-bordered" %)
1762 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
1763 |(s)|Protocol number to be set|0 to 65535|Unsigned BIN 16 bit|ANY16
1764 |(N)|Which communication port to set (0 means COM1, 1 means COM2 *1)|1|Unsigned BIN 16 bit|ANY16
1765
1766 **Device used**
1767
1768 (% class="table-bordered" %)
1769 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="10" %)**Devices**|**Offset modification**|(((
1770 **Pulse**
1771
1772 **extension**
1773 )))
1774 |**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|(% style="width:33px" %)**H**|**[D]**|**XXP**
1775 |(% rowspan="2" %)PROTOCOL|Parameter 1|●|●|●|●|●|●|●|●|●|(% style="width:33px" %)●|●|●
1776 |Parameter 2|●|●|●|●|●|●|●|●|●|(% style="width:33px" %)●|●|●
1777
1778 **{{id name="_Toc13079"/}}Features**
1779
1780 Set the communication protocol when used for run. The instruction above actually is to set a specific value for the parameter modification flag.
1781
1782 The calculation formula is: (parameter setting value + the offset of the start special device corresponding to the serial port + 10)*2
1783
1784 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. .
1785
1786 In Modbus master protocol, the trigger of setting parameters is to change the value after an instruction is completed.
1787
1788 In Modbus slave protocol, the trigger of setting parameters is that to switch as long as it is not processing the received data.
1789
1790 For details, please refer to "PROTOCOL instruction description"
1791
1792 **3) Host computer settings**
1793
1794 The PLC parameter setting of host computer can set the corresponding serial port parameters.
1795
1796 (% style="text-align:center" %)
1797 [[image:10_html_4208a2ce93bb23e7.png||class="img-thumbnail"]]
1798
1799 Specialized protocol station number cannot be 0.
1800
1801 The station number under ModbusRTU and ModbusASCII protocol is 0: the protocol sets the master station.
1802
1803 The station number under ModbusRTU and ModbusASCII protocol is not 0: the protocol sets the slave station.
1804
1805 The serial port parameters are filled in according to the content in the form.
1806
1807 **✎Note: **RTU protocol cannot set data bit of 7-bit.
1808
1809 **4)Priority description of serial port parameters**
1810
1811 The priority of serial port parameter settings are listed as blow. The serial port parameters are saved by power failure currently.
1812
1813 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.
1814
1815 **{{id name="_Toc33979615"/}}(4) Basic ladder program**
1816
1817 (% style="text-align:center" %)
1818 [[image:10_html_a7e64b4f4526b73e.png||class="img-thumbnail"]]
1819
1820 (((
1821 Serial port parameter setting
1822
1823 Baud rate 115200, data bit 8, parity bit none, stop bit 1
1824
1825 Communication protocol setting: ModbusRTU master station protocol
1826
1827 Sending interval: 5ms
1828
1829 Receiving timeout: 100ms
1830
1831 Timeout retry times: 3 times
1832
1833 Station number 01H, function code 03H, slave address 10, length 05
1834
1835
1836 )))
1837
1838 **{{id name="_Toc33979616"/}}10.7.2.3 Send and receive process**
1839
1840 **{{id name="_Toc33979617"/}}(1) Modbus master station**
1841
1842 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.
1843
1844 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.
1845
1846 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.
1847
1848 Modbus master function list
1849
1850 (% class="table-bordered" %)
1851 |**Function code**|**Function name**|**Details**
1852 |0x01|Coil readout|Coil readout (multiple points optional)
1853 |0x02|Input readout|Input and read (multiple points optional)
1854 |0x03|Holding register readout|Holding register readout(multiple points optional)
1855 |0x04|Input register readout|Input register readout (multiple points optional)
1856 |0x05|1 coil write|Coil writing (only 1 point)
1857 |0x06|1 register write|Holding register write (only 1 point)
1858 |0x0F|Batch coil write|Multi-point coil writing
1859 |0x10|Batch register write|Multi-point holding register write
1860
1861 (((
1862 Serial port parameter setting
1863
1864 Baud rate 115200, data bit 8, no parity bit, stop bit 1
1865
1866 Example:
1867 )))
1868
1869 (% style="text-align:center" %)
1870 [[image:10_html_a7e64b4f4526b73e.png||class="img-thumbnail"]]
1871
1872 (((
1873 Communication protocol setting: ModbusRTU master station protocol
1874
1875 Sending interval: 5ms
1876
1877 Receiving timeout: 100ms
1878
1879 Timeout retry times: 3 times
1880
1881 Station number 01H, function code 03H, slave address 10, length 05
1882
1883
1884 )))
1885
1886 As shown in the ladder program shown:
1887
1888 When M1 is turned ON, PLC will send data (hexadecimal) from COM2 of PLC: 01 03 00 0A 00 05 A5 C8
1889
1890 * 01: Slave address, the high 8 bits of (s);
1891 * 03: Modbus instruction code, the lower 8 bits of (s). It is to read the slave register;
1892 * 00 0A: The address of the slave register to be read, the value of (m);
1893 * 00 05: The number of registers to be read, the value of (d),
1894 * A5 C8: CRC check code.
1895
1896 **✎Note: **
1897
1898 When using 1 coil to write (0x05), the value used for writing 1 is 0xFF00, and the value used for writing 0 is 0x0000.
1899
1900 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.
1901
1902 **{{id name="_Toc33979618"/}}(2) Modbus slave**
1903
1904 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.
1905
1906 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.
1907
1908 **{{id name="_Toc33979619"/}}1) instruction code 0x01 (01): read coil**
1909
1910 (% class="table-bordered" %)
1911 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
1912 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
1913 |2|0x01 (instruction code)|1 byte|Read coil
1914 |3|Coil start address|2 bytes|High bit in front, low bit in back, see coil addressing
1915 |4|Number of coils|2 bytes|High bit in front, low bit in back (N)
1916 |5|CRC check|2 bytes|Low bit in front, high bit in back
1917
1918 Response frame format: slave address + 0x01 + number of bytes + coil status + CRC check
1919
1920 (% class="table-bordered" %)
1921 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
1922 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
1923 |2|0x01 (instruction code)|1 byte|Read coil
1924 |3|Number of bytes|1 byte|Value: [(N+7)/8]
1925 |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
1926 |5|CRC check|2 bytes|High bit first, then low bit
1927
1928 Error response: refer to error response frame.
1929
1930 **{{id name="_Toc33979620"/}}2) instruction code 0x03 (03): read register**
1931
1932 Request frame format: slave address + 0x03 + register start address + number of registers + CRC check.
1933
1934 (% class="table-bordered" %)
1935 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
1936 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
1937 |2|0x03 (instruction code)|1 byte|Read register
1938 |3|Register start address|2 bytes|High bit in front, low bit in back, see register addressing
1939 |4|Number of registers|2 bytes|High bit in front, low bit in back (N)
1940 |5|CRC check|2 bytes|High bit in front, low bit in back
1941
1942 Response frame format: slave address + 0x03 + number of bytes + register value + CRC check.
1943
1944 (% class="table-bordered" %)
1945 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
1946 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
1947 |2|0x03 (instruction code)|1 byte|Read register
1948 |3|Number of bytes|1 byte|Value: N*2
1949 |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
1950 |5|CRC check|2 bytes|High bit in front, low bit in back
1951
1952 Error response: See error response frame.
1953
1954 **{{id name="_Toc216324734"/}}3)** {{id name="_Toc267753989"/}}{{id name="_Toc33979621"/}}**instruction code 0x05 (05): write single coil**
1955
1956 Request frame format: slave address + 0x05 + coil address + coil status + CRC check.
1957
1958 (% class="table-bordered" %)
1959 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
1960 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
1961 |2|0x05 (instruction code)|1 byte|Write single coil
1962 |3|Coil address|2 bytes|High bit in front, low bit in back, see coil addressing
1963 |4|Coil state|2 bytes|High bit in front, low bit in back. Non-zero is valid
1964 |5|CRC check|2 bytes|High bit in front, low bit in back
1965
1966 Response frame format: slave address + 0x05 + coil address + coil status + CRC check.
1967
1968 (% class="table-bordered" %)
1969 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
1970 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
1971 |2|0x05 (instruction code)|1 byte|Write single coil
1972 |3|Coil address|2 bytes|High bit in front, low bit in back, see coil addressing
1973 |4|Coil state|2 bytes|High bit in front, low bit in back. Non-zero is valid
1974 |5|CRC check|2 bytes|High bit in front, low bit in back
1975
1976 {{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.
1977
1978 **4) instruction code 0x06 (06): write a single register**
1979
1980 Request frame format: slave address + 0x06 + register address + register value + CRC check.
1981
1982 (% class="table-bordered" %)
1983 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
1984 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
1985 |2|0x06 (instruction code)|1 byte|Write single coil
1986 |3|Register|2 bytes|High bit in front, low bit in back, see coil addressing
1987 |4|Register value|2 bytes|High bit in front, low bit in back. Non-zero is valid
1988 |5|CRC check|2 bytes|High bit in front, low bit in back
1989
1990 Response frame format: slave address + 0x06 + register address + register value + CRC check.
1991
1992 (% class="table-bordered" %)
1993 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
1994 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
1995 |2|0x06 (instruction code)|1 byte|Write single coil
1996 |3|Register|2 bytes|High bit in front, low bit in back, see coil addressing
1997 |4|Register value|2 bytes|High bit in front, low bit in back. Non-zero is valid
1998 |5|CRC check|2 bytes|High bit in front, low bit in back
1999
2000 Error response: See error response frame.{{id name="_Toc33979623"/}}{{id name="_Toc216324736"/}}{{id name="_Toc267753991"/}}
2001
2002 **5) instruction code 0x 0f (15): write multiple coils**
2003
2004 Request frame format: slave address + 0x 0f + coil start address + coil number + byte number + coil status + CRC check.
2005
2006 (% class="table-bordered" %)
2007 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
2008 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
2009 |2|0x 0f (instruction code)|1 byte|Write multiple single coils
2010 |3|Coil start address|2 bytes|High bit in front, low bit in back, see coil addressing
2011 |4|Number of coils|2 bytes|High bit in front, low bit in back. The maximum of N is 1968
2012 |5|Number of bytes|1 byte|Value: [(N+7)/8]
2013 |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
2014 |7|CRC check|2 bytes|High bit in front, low bit in back
2015
2016 Response frame format: slave address + 0x 0f + coil start address + coil number + CRC check
2017
2018 (% class="table-bordered" %)
2019 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
2020 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
2021 |2|0x 0f (instruction code)|1 byte|Write multiple single coils
2022 |3|Coil start address|2 bytes|High bit in front, low bit in back, see coil addressing
2023 |4|Number of coils|2 bytes|High bit in front, low bit in back
2024 |5|CRC check|2 bytes|High bit in front, low bit in back
2025
2026 Error response: See error response frame.
2027
2028 **{{id name="_Toc33979624"/}}6)** {{id name="_Toc216324737"/}}{{id name="_Toc267753992"/}}**3.2.6 instruction code 0x10 (16): write multiple registers**
2029
2030 Request frame format: slave address + 0x10 + register start address + register number + byte number + register value + CRC check.
2031
2032 (% class="table-bordered" %)
2033 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
2034 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
2035 |2|0x10(instruction code)|1 byte|Write multiple registers
2036 |3|Register start address|2 bytes|High bit in front, low bit in back, see register addressing
2037 |4|Number of registers|2 bytes|High bit in front, low bit in back. The maximum of N is 120
2038 |5|Number of bytes|1 byte|Value: N*2
2039 |6|Register value|N*2 (N*4)|
2040 |7|CRC check|2 bytes|High bit in front, low bit in back
2041
2042 Response frame format: slave address + 0x10 + register start address + register number + CRC check.
2043
2044 (% class="table-bordered" %)
2045 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
2046 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
2047 |2|0x10 (instruction code)|1 byte|Write multiple registers
2048 |3|Register start address|2 bytes|High bit in front, low bit in back, see register addressing
2049 |4|Number of registers|2 bytes|High bit in front, low bit in back. The maximum of N is 120
2050 |5|CRC check|2 bytes|High bit in front, low bit in back
2051
2052 Error response: See error response frame.{{id name="_Toc33979625"/}}{{id name="_Toc216324738"/}}{{id name="_Toc267753993"/}}
2053
2054 **7) Error response frame**
2055
2056 Error response: slave address + (instruction code + 0x80) + Error code + CRC check.
2057
2058 (% class="table-bordered" %)
2059 |**Serial number**|**Data (byte) meaning**|**Number of bytes**|**Instruction**
2060 |1|Slave address|1 byte|Value 1 to 247, set by SD2544, SD2594
2061 |2|Instruction code+0x80|1 byte|Error instruction code
2062 |3|Code|1 byte|1 to 4
2063 |4|CRC check|2 bytes|High bit in front, low bit in back
2064
2065 (% class="table-bordered" %)
2066 |**Serial number**|**Error code**|**Instruction**
2067 |1|01|Unsupported function code
2068 |2|02|Wrong address or function code
2069 |3|03|Wrong length
2070 |4|04|Imperfect instruction
2071 |5|05|Address not allowed
2072
2073 **{{id name="_Toc33979626"/}}8) Slave address table**
2074
2075 (% class="table-bordered" %)
2076 |(% colspan="5" %)**Word address**
2077 |**Address type**|**Occupy**|**Address range**|**Decimal address**|**Total reserved address size**
2078 |T0 to T511|512 WORD|0x0000-0x01ff|0|1536
2079 |C0 to C255|256 WORD|0x0600-0x06ff|1536|1024
2080 |LC0 to LC255|512 WORD|0x0A00-0x0BFF|2560|1024
2081 |HSC0 to HSC15|32 WORD|0x0E00-0x0E1F|3584|512
2082 |D0 to D7999|8000 WORD|0x1000-0x2F3F|4096|16384
2083 |SD0 to SD4095|4096 WORD|0x5000-0x5FFF|20480|12288
2084 |R0 to R30000|30000 WORD|0x8000-0xF52F|32768|30000
2085
2086 (% class="table-bordered" %)
2087 |(% colspan="5" %)**Bit address**
2088 |**Address type**|**Occupy**|**Address range**|**Decimal address**|**Total reserved address size**
2089 |T0 to T511|512 bit|0x0000-0x01ff| |1536
2090 |C0 to C255|256 bit|0x0600-0x06ff|1536|1024
2091 |LC0 to LC255|256 bit|0x0A00-0x0AFF|2560|1024
2092 |HSC0 to HSC15|16 bit|0x0E00-0x0E0F|3584|512
2093 |M0 to M8000|8000 bit|0x1000-0x2F3F|4096|16384
2094 |SM0 to SM4095|4096 bit|0x5000-0x5FFF|20480|12288
2095 |Reserved| |0x8000-0xBFFF| |16383
2096 |S0 to S4095|4096 bit|0xC000-0xCFFF|49152|8192
2097 |X0 to X1023|1024 bit|0xE000-0xE3FF|57344|4096
2098 |Y0 to Y1023|1024 bit|0xF000-0xF3FF|61440|4096
2099
2100 **Error message**
2101
2102 Currently the Error code will be displayed on SD7 and SD0 and SD2611 and SD2612.
2103
2104 The Error codes that appear in the Modbus protocol are mainly as follows.
2105
2106 (% class="table-bordered" %)
2107 |(% style="width:101px" %)**Error code**|(% style="width:980px" %)**Content**
2108 |(% 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)
2109 |(% 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.
2110 |(% 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."
2111 |(% 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.
2112 |(% 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.
2113 |(% 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.
2114 |(% style="width:101px" %)3185H|(% style="width:980px" %)COM2 send buffer overflow. Contact a technician if this error occurs
2115 |(% 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
2116 |(% 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)
2117 |(% 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.
2118 |(% 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)"
2119 |(% 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)
2120 |(% 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)
2121 |(% 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)
2122 |(% style="width:101px" %)318DH|(% style="width:980px" %)COM2 slave confirms. Slave station return information: slave station confirmation (please refer to Modbus abnormal 05)
2123 |(% 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)
2124 |(% style="width:101px" %)318FH|(% style="width:980px" %)COM2 sending timed out. Contact a technician if this error occurs
2125 |(% style="width:101px" %)3190H|(% style="width:980px" %)COM2 receiving data exceeds the buffer limit.
2126 |(% 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)
2127 |(% 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)
2128
2129 After resetting the protocol or communication parameters, the error will be cleared.
2130
2131 In addition, the communication completion/communication error/communication timeout flag will be set after the executed instruction.
2132
2133 == {{id name="_10.7 WECON MODBUS protocol description"/}}**PLCLINK/Fast interconnect** ==
2134
2135 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).
2136
2137 The topological diagram is shown in the figure below.
2138
2139 (% style="text-align:center" %)
2140 [[image:image-20220614170612-1.jpeg]]
2141
2142 When using the PLCLINK function:
2143
2144 * Master station configuration: Select COM2 port and set the protocol to PLCLINK protocol.
2145 * Slave configuration: Select COM1 or COM2 and set the protocol to dedicated protocol.
2146
2147 (% class="wikigeneratedid" id="H28129Createatable" %)
2148 **(1) Create a table**
2149
2150 In [Project manager]-[Extended function]-[PLCLINK], right click [PLCLINK], and click it to create a table.
2151
2152 (% style="text-align:center" %)
2153 [[image:10_html_347d7923523ad9af.png||class="img-thumbnail"]]
2154
2155 Click it and a prompt box as below would pop up.
2156
2157 (% style="text-align:center" %)
2158 [[image:10_html_dbbb9b1ddaa56dce.png||class="img-thumbnail"]]
2159
2160 Click "Yes" will automatically change the protocol to PLCLINK, click "No" will not change the protocol.
2161
2162 The number of PLCLINK protocol is H60.
2163
2164 (% class="table-bordered" %)
2165 |**0H**|Wecon Modbus slave station
2166 |**2H**|ModbusRTU slave station
2167 |**3H**|ModbusASCII slave station
2168 |**10H**|user-defined protocol
2169 |**20H**|ModbusRTU main station
2170 |**30H**|ModbusASCII main station
2171 |**60H**|PLCLINK protocol
2172
2173 Click "Yes" will generate an empty table MAIN.
2174
2175 (% style="text-align:center" %)
2176 [[image:10_html_39ce9cf6a41c3901.png||class="img-thumbnail"]]
2177
2178 Double click MAIN will pop up the POLCLINK table as below.
2179
2180 (% style="text-align:center" %)
2181 [[image:10_html_14072bc2a32c267.png||class="img-thumbnail"]]
2182
2183 Currently only one PLCLINK table can be created. Creating a new table after creating one is disallowed.
2184
2185 (% style="text-align:center" %)
2186 [[image:10_html_f4bec5285beb7949.png||class="img-thumbnail"]]
2187
2188 (2) Write the table
2189
2190 Write station number in
2191
2192 After writing the station number in the new instruction station number in the table, click the new instruction to add the communication instruction.
2193
2194 The range of station number is 1 to 31. The maximum number of communication instruction is 255.
2195
2196 (% style="text-align:center" %)
2197 [[image:10_html_21d3b9789058efb3.png||class="img-thumbnail"]]
2198
2199 (% style="text-align:center" %)
2200 [[image:10_html_20232344eaa6cb2a.png||class="img-thumbnail"]]
2201
2202 Currently the station number is only selected by drop-down box.
2203
2204 (% style="text-align:center" %)
2205 [[image:10_html_f09857f93ae04f0a.png||class="img-thumbnail"]]
2206
2207 The devices of main station and slave station are selected by drop-down box.
2208
2209 (% style="text-align:center" %)
2210 [[image:10_html_99c7d435825defd1.png||class="img-thumbnail"]]
2211
2212 (% style="text-align:center" %)
2213 [[image:10_html_f62cce6501331b8d.png||class="img-thumbnail"]]
2214
2215 The transfer direction are read and write, and also selected by drop-down box.
2216
2217 (% style="text-align:center" %)
2218 [[image:10_html_7b3de12a134b4e95.png||class="img-thumbnail"]]
2219
2220 The device address range limitations are as below.
2221
2222 1. The device address could not exceed the current device range
2223 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.
2224 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.
2225 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.
2226
2227 {{id name="OLE_LINK104"/}}The number limitations of slave station device are as below.
2228
2229 1. The number of bit device ranges from 8 to 2,032.
2230 1. {{id name="OLE_LINK105"/}}The number of word device ranges from 1 to 126.
2231 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.
2232 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.
2233
2234 (3) Download
2235
2236 {{id name="OLE_LINK107"/}}Currently PLCLINK could only be downloaded with the program and could not downloaded separately.
2237
2238 (% style="text-align:center" %)
2239 [[image:10_html_a586bd0ca75cd8f.png||class="img-thumbnail"]]
2240
2241 Click on PLCLINK in monitoring mode to re-write part of the table into PLC, but the start device could not be modified.
2242
2243 (% style="text-align:center" %)
2244 [[image:10_html_92ca328b83e6ef12.png||class="img-thumbnail"]]
2245
2246 In monitoring mode, monitoring read and monitoring write could not be executed if the ladder program comparison is incorrect.
2247
2248 (4) Automatic check
2249
2250 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.
2251
2252 (% style="text-align:center" %)
2253 [[image:10_html_d6ff78427b75140d.png||class="img-thumbnail"]]
2254
2255 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.
2256
2257 (% class="table-bordered" %)
2258 |**S1+12**|(((
2259 Auto check mode
2260
2261 (Reserved)
2262 )))|(((
2263 {{id name="OLE_LINK109"/}}0: No check; 1: Automatic check mode; 2: Automatic check in progress.
2264
2265 {{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.
2266 )))
2267
2268 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.
2269
2270 (% class="table-bordered" %)
2271 |**S1+13**|Corresponding station number communication switch 1|(((
2272 The switch control of station 1 to 15
2273
2274 {{id name="OLE_LINK112"/}}Bit0: ON: Station number 0 (broadcast) normal communication
2275
2276 OFF: Station number 0 (broadcast) communication prohibited (broadcast prohibited)
2277
2278 Bit1: ON: Station number 1 normal communication; OFF: Station 1 communication prohibited
2279
2280 Bit2: ON: Station number 2 normal communication; OFF: Station 2 communication prohibited
2281 )))
2282 |**S1+14**|Corresponding station number communication switch 2|The switch control of station 16 to 31
2283
2284 Click [station number enable] to set the station enable according to the corresponding situations.
2285
2286 (% style="text-align:center" %)
2287 [[image:10_html_beda0fdc84802959.png||class="img-thumbnail"]]
2288
2289 (% style="text-align:center" %)
2290 [[image:10_html_f84703130b23d8f6.png||class="img-thumbnail"]]
2291
2292 **✎Note: **When in the automatic check state, forcibly turn off the automatic check state (write 0 in S1+12), an error may occur.
2293
2294 {{id name="OLE_LINK113"/}}(5) Main station parameter configuration
2295
2296 (% style="text-align:center" %)
2297 [[image:10_html_434fac0fa8c16597.png||class="img-thumbnail"]]
2298
2299 The protocol must be PLCLINK protocol, and the data bit can not be 7-bit data bit. Other parameters can be selected as required.
2300
2301 (6) Slave station configuration
2302
2303 For PLCLINK communication ports, select the dedicated protocol from the station protocol.
2304
2305 (% style="text-align:center" %)
2306 [[image:10_html_2641eb7c39f4f4aa.png||class="img-thumbnail"]]
2307
2308 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.
2309
2310 {{id name="OLE_LINK115"/}}(7) Close PLCLINK
2311
2312 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.
2313
2314 (% class="table-bordered" %)
2315 |**S1+11**|Operation state|(((
2316 Bit0=1,Port is occupied. This function obtains the right of data transaction transmission.
2317
2318 Bit2=1,One cycle has been executed.
2319
2320 {{id name="OLE_LINK114"/}}Bit4,Communication transmission output indication
2321
2322 Bit5,Communication error output indication (Exceeds the number of retry times)
2323
2324 Bit6,Communication completion output indication
2325
2326 Bit8,PLCLINK suspension (0: Normal operation, 1: Operation paused)
2327 )))
2328
2329 (8) Table contents
2330
2331 {{id name="OLE_LINK119"/}}Currently the communication table is downloaded to the device to operate. The details of the table are as follows.
2332
2333 (% class="table-bordered" %)
2334 |(% rowspan="2" %)**Address offset**|(% colspan="2" %){{id name="OLE_LINK116"/}}**Brief description**|(% rowspan="2" %)**Detailed description**
2335 |**High byte**|**Low byte**
2336 |S1+0|(% colspan="2" %)Header|{{id name="OLE_LINK117"/}}Header =70h, correct PLCLINK table. (modification prohibited)
2337 |S1+1|(% colspan="2" %)Number of communication instructions|1 to 255 (modification prohibited)
2338 |S1+2|(% colspan="2" %)Version|{{id name="OLE_LINK121"/}}{{id name="OLE_LINK118"/}}V1.100 (modification prohibited)
2339 |S1+3|(% colspan="2" %){{id name="OLE_LINK120"/}}The start address of communication table|modification prohibited
2340 |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))
2341 |S1+5|(% colspan="2" %)Which instruction currently is running|Display the current running command (read only)
2342 |S1+6|Station NO.1|Read/write direction|(% rowspan="5" %)The instruction content of current communication
2343 |S1+7|(% colspan="2" %)The data start address of station NO.1
2344 |S1+8|Station NO.2|Address type distinction
2345 |S1+9|(% colspan="2" %)The data start address of station NO.2
2346 |S1+10|(% colspan="2" %)Data length
2347 |S1+11|(% colspan="2" %)Operation state|(((
2348 Bit0=1,Port is occupied. This function obtains the right of data transaction transmission.
2349
2350 Bit2=1, One cycle has been executed.
2351
2352 Bit4, Communication transmission output indication
2353
2354 Bit5, Communication error output indication (Exceeds the number of retry times)
2355
2356 Bit6, Communication completion output indication
2357
2358 Bit8, PLCLINK suspension (0: Normal operation, 1: Operation paused)
2359 )))
2360 |S1+12|(% colspan="2" %)Auto check mode (Reserved)|(((
2361 0: No check; 1: Automatic check mode; 2: Automatic check in progress.
2362
2363 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.
2364 )))
2365 |S1+13|(% colspan="2" %)Corresponding station number communication switch 1|(((
2366 The switch control of station 1 to 15
2367
2368 Bit0: ON: Station NO. 0 (broadcast) normal communication
2369
2370 OFF: Station NO.0 (broadcast) communication prohibited (broadcast prohibited)
2371
2372 Bit1: ON: Station NO.1 normal communication;
2373
2374 OFF: Station NO.1 communication prohibited
2375
2376 Bit2: ON: Station NO.2 normal communication;
2377
2378 OFF: Station NO.2 communication prohibited
2379 )))
2380 |S1+14|(% colspan="2" %)Corresponding station number communication switch 2|The switch control of station 16 to 31
2381 |S1+15|(% colspan="2" %)Reserved|
2382 |S1+16|(% colspan="2" %)Reserved|
2383 |S1+17|(% colspan="2" %)Reserved|
2384 |S1+18|(% colspan="2" %)Reserved|
2385 |S1+19|(% colspan="2" %)Reserved|
2386 |S1+20|(% colspan="2" %)Reserved|
2387 |S1+21|Station NO.1|Read/write direction|(((
2388 • Station NO. 1 to 32, FF(FF represents main station)
2389
2390 • Function code:
2391
2392 ~=01H, read
2393
2394 ~=02H, write
2395 )))
2396 |S1+22|(% colspan="2" %)The data start address of station NO.1|• Valid word. Define operating the start address of slave station data
2397 |S1+23|Station NO.2|Address type distinction|(((
2398 •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
2399
2400 •Distinguish the type of the starting device for storing data in the main station.
2401
2402 Main station address type distinction. 0: word address; 1: bit address
2403 )))
2404 |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.
2405 |S1+25|(% colspan="2" %)Data length|• Valid word. Range 1 to 126(bit data), 1 to 2,032(bit data)
2406 |S1+26|Station NO.1|Read/write direction|(% rowspan="5" %)(((
2407 The second data transmission description.
2408
2409 Main station address type distinction.
2410 )))
2411 |S1+27|(% colspan="2" %)The data start address of station NO.1
2412 |S1+28|Station NO.2|Address type distinction
2413 |S1+29|(% colspan="2" %)The data start address of station NO.2
2414 |S1+30|(% colspan="2" %)Data length
2415 |•|(% colspan="2" %) | 
2416 |•|(% colspan="2" %) | 
2417 |S1+20+ n×5|(% colspan="2" %)Reserved|• n is the total number of data transmission commands.
2418
2419 **{{id name="_Toc27709"/}}✎Note: **
2420
2421 1. It is forbidden to modify S0 to S4.
2422 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.
2423
2424 **{{id name="_Toc18822"/}}Error code**
2425
2426 (% class="table-bordered" %)
2427 |(% style="width:105px" %)**Error code**|(% style="width:976px" %)**Contents**
2428 |(% style="width:105px" %)31C0H|(% style="width:976px" %){{id name="OLE_LINK129"/}}Abnormal PLCLINK header. Re-download the program.
2429 |(% style="width:105px" %)31C1H|(% style="width:976px" %)PLCLINK function is not supported by COM port currently.
2430 |(% style="width:105px" %)31C2H|(% style="width:976px" %)PLCLINK table version is incompatible. Re-download the program.
2431 |(% style="width:105px" %)31C3H|(% style="width:976px" %)The number of PLCLINK command exceeds the range. The value ranges from 1 to 255 Currently.
2432 |(% 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.
2433 |(% style="width:105px" %)31C5H|(% style="width:976px" %)PLCLINK table exceeds the range of device. Check the corresponding device range of table.
2434 |(% 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.
2435 |(% 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.
2436 |(% 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.
2437 |(% 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.
2438 |(% 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.
2439 |(% style="width:105px" %)3186H|(% style="width:976px" %){{id name="OLE_LINK135"/}}COM2 function code error. Check whether the function code is supported by PLC.
2440 |(% style="width:105px" %)3187H|(% style="width:976px" %)COM2 address error.
2441 |(% 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.
2442 |(% 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)
2443 |(% 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)
2444 |(% 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)
2445 |(% 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)
2446 |(% style="width:105px" %)318DH|(% style="width:976px" %)COM2 slave station confirmation. Slave station returns message: Slave station confirmation.(Please refer to Modbus abnormal 05)
2447 |(% 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.
2448 |(% style="width:105px" %)3190H|(% style="width:976px" %)The data received by COM2 exceeds the cache limit.
2449
2450 **{{id name="_Toc25970"/}}Example**
2451
2452 Create a PLCLINK table and automatically switch the Com2 protocol to PLCLINK.
2453
2454 (% style="text-align:center" %)
2455 [[image:10_html_c4962fb2076781b9.png||class="img-thumbnail"]]
2456
2457 {{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.
2458
2459 (% style="text-align:center" %)
2460 [[image:10_html_3244c013d7d800c3.png||class="img-thumbnail"]]
2461
2462 {{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.
2463
2464 (% style="text-align:center" %)
2465 [[image:10_html_ae5ef70ce179ad5e.png||class="img-thumbnail"]]
2466
2467 **{{id name="_Toc27083"/}}The situation of connecting more than one**
2468
2469 When adding commands, the station number that corresponding more slave station number can add more station number communication connections
2470
2471 (% style="text-align:center" %)
2472 [[image:10_html_98f836562979721.png||class="img-thumbnail"]]
2473
2474 == {{id name="_Toc7760"/}}**Wecon Modbus protocol description** ==
2475
2476 The current Wecon Modbus protocol description (special protocol) is modified based on the ModbusRTU protocol.
2477
2478 Therefore, 7-bit data bits cannot be used in the serial port parameter part.
2479
2480 The protocol of COM0 and COM1 can only use WECON Modbus protocol at present and cannot be changed.
2481
2482 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.
2483
2484 The extended function is mainly used to communicate with PLCEDITOR.