Wiki source code of 10 Communication instruction

Version 5.1 by Stone Wu on 2022/06/15 09:41

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