Wiki source code of 10 Communication Instruction
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | == **Communication Port Protocol Setting** == | ||
| 2 | |||
| 3 | ---- | ||
| 4 | |||
| 5 | === **Communication port protocol setting** === | ||
| 6 | |||
| 7 | ---- | ||
| 8 | |||
| 9 | PROTOCOL(P) | ||
| 10 | |||
| 11 | Set (s) protocol for (n) communication port. | ||
| 12 | |||
| 13 | -[PROTOCOL (s) (n)] | ||
| 14 | |||
| 15 | Content, range and data type | ||
| 16 | |||
| 17 | |=**Parameter**|=**Content**|=**Range**|=**Data type**|=**Data type (label)**|=**Custom variable type** | ||
| 18 | |(s)|Protocol number to be set|-|Unsigned BIN16 bits|ANY16|INT | ||
| 19 | |(n)|Which communication port to be set, 0 means COM1, 1 means COM2|0, 1|Unsigned BIN16 bits|ANY16|INT | ||
| 20 | |||
| 21 | Device used | ||
| 22 | |||
| 23 | |=**Instruction**|=**Parameter**|=(% colspan="24" %)**Devices**|=**Index modification**|=**Pulse expansion** | ||
| 24 | | | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 25 | |(% colspan="1" rowspan="2" %)PROTOCOL|Parameter 1| | | | | | | | | | | |●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 26 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 27 | |||
| 28 | Function | ||
| 29 | |||
| 30 | This command is mainly used to set the protocol during RUN, and can also be used in the first cycle of RUN. | ||
| 31 | |||
| 32 | The value of the protocol address (COM1 SD2542, COM2 SD2592) and the protocol modification sign (COM1 SD2543, COM2 SD2593) can be directly set according to the command parameters. | ||
| 33 | |||
| 34 | The specific calculation formula for setting the protocol modification sign (COM1 SD2543, COM2 SD2593) is: (parameter setting value + offset of the corresponding serial port's initial special device+ 10)*2 | ||
| 35 | |||
| 36 | For example, setting the protocol to 2, i.e. (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. | ||
| 37 | |||
| 38 | (% class="box infomessage" %) | ||
| 39 | ((( | ||
| 40 | **✎Note: ** | ||
| 41 | |||
| 42 | Whether the value is set by self-calculation and then modifying the identification (COM1 SD2543, COM2 SD2593) to the protocol, or by using this command, the protocol can be modified when the PLC is in the RUN state. | ||
| 43 | |||
| 44 | Protocol modification sign (COM1 SD2543 and COM2 SD2593): during the RUN process, when the protocol and modification sign are set correctly (the correctness will be judged at the End of the program), it will be deemed as the correct first cycle; then the protocol and modification sign (COM1 SD2543, COM2 SD2593) will be cleared upon completion of modification and the same value that is consequently set will not be processed. It mainly aims to avoid repeated settings for multiple times. | ||
| 45 | ))) | ||
| 46 | |||
| 47 | Protocol number | ||
| 48 | |||
| 49 | |=**Protocol number**|=**Content** | ||
| 50 | |0H|Wecon Modbus slave station | ||
| 51 | |2H|Modbus RTU slave station | ||
| 52 | |3H|Modbus ASCII slave station | ||
| 53 | |10H|User-defined protocol | ||
| 54 | |20H|Modbus RTU master | ||
| 55 | |30H|Modbus ASCII master | ||
| 56 | |||
| 57 | Related devices | ||
| 58 | |||
| 59 | |=**Devices**|=**Content** | ||
| 60 | |SD2542|COM1 protocol settings | ||
| 61 | |SD2543|COM1 protocol modification sign | ||
| 62 | |SD2592|COM2 protocol settings | ||
| 63 | |SD2593|COM2 protocol modification sign | ||
| 64 | |||
| 65 | Precautions | ||
| 66 | |||
| 67 | The setting of communication parameters will affect the overall communication. The parameters in PLC are modified when there is no communication or after a round of communication is completed. Attention shall be paid to this point. | ||
| 68 | |||
| 69 | 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. | ||
| 70 | |||
| 71 | Error code | ||
| 72 | |||
| 73 | |=**Error code**|=**Content** | ||
| 74 | |4085H|The read address (s) (n) exceeds the device range. | ||
| 75 | |4084H|(n) is not 1. | ||
| 76 | |||
| 77 | Example | ||
| 78 | |||
| 79 | (% style="text-align:center" %) | ||
| 80 | [[image:1709191890650-622.png]] | ||
| 81 | |||
| 82 | As shown in above example, M1 turns from OFF to ON during RUN process. | ||
| 83 | |||
| 84 | SD2594 will be set to 32 (20H), SD2595 will be set to 90 and then it will be cleared. At this time, it has been set successfully. | ||
| 85 | |||
| 86 | (% style="text-align:center" %) | ||
| 87 | [[image:1709191945171-155.png]] | ||
| 88 | |||
| 89 | If M1 turns from OFF to ON again, | ||
| 90 | |||
| 91 | SD2592 will be set to 32 (20H), SD2595 will be set to 90, which will not be cleared. | ||
| 92 | |||
| 93 | (% style="text-align:center" %) | ||
| 94 | [[image:1709191962952-895.png]] | ||
| 95 | |||
| 96 | == **Modbus Serial Port Parameter Setting** == | ||
| 97 | |||
| 98 | ---- | ||
| 99 | |||
| 100 | === **PORTPARA/Modbus serial port parameter setting** === | ||
| 101 | |||
| 102 | ---- | ||
| 103 | |||
| 104 | PORTPARA(P) | ||
| 105 | |||
| 106 | Set (s) serial port parameters for (n) communication port. | ||
| 107 | |||
| 108 | -[PORTPARA (s) (n)] | ||
| 109 | |||
| 110 | Content, range and data type | ||
| 111 | |||
| 112 | |=**Parameter**|=**Content**|=**Range**|=**Data type**|=**Data type (label)**|=**Custom variable type** | ||
| 113 | |(s)|Serial port parameters to be set|-|Unsigned BIN16 bits|ANY16|INT | ||
| 114 | |(n)|Which communication port to be set, 0 means COM1, 1 means COM2|0, 1|Unsigned BIN16 bits|ANY16|INT | ||
| 115 | |||
| 116 | Device used | ||
| 117 | |||
| 118 | |=**Instruction**|=**Parameter**|=(% colspan="24" %)**Devices**|=**Index modification**|=**Pulse expansion** | ||
| 119 | | | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 120 | |(% colspan="1" rowspan="2" %)PORTPARA|Parameter 1| | | | | | | | | | | |●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 121 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 122 | |||
| 123 | Function | ||
| 124 | |||
| 125 | This command is mainly used to set serial port parameters during RUN, and can also be used in the first cycle of RUN. | ||
| 126 | |||
| 127 | The value of serial port parameter address (COM1 SD2540, COM2 SD2590) and the serial parameter modification sign (COM1 SD2541, COM2 SD2591) can be set directly according to the command parameters. | ||
| 128 | |||
| 129 | The specific calculation formula for setting the serial port parameter modification sign (COM1 SD2541, COM2 SD2591) is: (parameter setting value + offset of the corresponding serial port's initial special device + 10)*2 | ||
| 130 | |||
| 131 | For example, setting the COM1 serial port parameter to 193 (HC1), i.e. (193 +2541-2540 +10)*2 which is (193 +1+10) *2=408. At this time, SD2540 is set to be 193(HC1) and SD2541 is set to be 408. | ||
| 132 | |||
| 133 | (% class="box infomessage" %) | ||
| 134 | ((( | ||
| 135 | **✎**Note: | ||
| 136 | |||
| 137 | Whether the value is set by self-calculation and then modifying the sign (COM1 SD2541, COM2 SD2591) to the serial port parameters, or by using this command, the serial port parameters can be modified when the PLC is in the RUN state. | ||
| 138 | |||
| 139 | Serial port parameter modification sign (COM1 SD2541 and COM2 SD2591): during the RUN process, when the serial port parameter and modification sign are set correctly (the correctness will be judged at the End of the program), it will be deemed as the correct first cycle; then the serial port parameter and modification sign (COM1 SD2541, COM2 SD2591) will be cleared upon completion of modification and the same value that is consequently set will not be processed. It mainly aims to avoid repeated settings for multiple times. | ||
| 140 | ))) | ||
| 141 | |||
| 142 | Serial port parameter setting table | ||
| 143 | |||
| 144 | |=**Bit number**|=**Name**|=(% colspan="2" %)**Content** | ||
| 145 | | | |**0 (bit OFF)**|**1 (bit ON)** | ||
| 146 | |b0|Data length|7 digits|8 digits | ||
| 147 | |((( | ||
| 148 | b1 | ||
| 149 | |||
| 150 | b2 | ||
| 151 | )))|Parity check|(% colspan="2" %)((( | ||
| 152 | b2, b1 | ||
| 153 | |||
| 154 | (0, 0): None | ||
| 155 | |||
| 156 | (0,1): Odd parity (ODD) | ||
| 157 | |||
| 158 | (1,1): Even parity (EVEN) | ||
| 159 | ))) | ||
| 160 | |b3|Stop bit|1 bit|2 bit | ||
| 161 | |((( | ||
| 162 | b4 | ||
| 163 | |||
| 164 | b5 | ||
| 165 | |||
| 166 | b6 | ||
| 167 | |||
| 168 | b7 | ||
| 169 | |||
| 170 | b8 | ||
| 171 | |||
| 172 | b9 | ||
| 173 | )))|Baud rate(bps)|((( | ||
| 174 | .b9,b8,b7,b6,b5,b4 | ||
| 175 | |||
| 176 | ( 0, 0, 0, 1, 1, 1): 4800 | ||
| 177 | |||
| 178 | ( 0, 0, 1, 0, 0, 0): 9600 | ||
| 179 | |||
| 180 | ( 0, 0, 1, 0, 0, 1): 19200 | ||
| 181 | |||
| 182 | ( 0, 0, 1, 0, 1, 0): 38400 | ||
| 183 | |||
| 184 | ( 0, 0, 1, 0, 1, 1): 57600 | ||
| 185 | )))|((( | ||
| 186 | .b9,b8,b7,b6,b5,b4 | ||
| 187 | |||
| 188 | ( 0, 0, 1, 1, 0, 0): 115200 | ||
| 189 | |||
| 190 | ( 0, 0, 1, 1, 0, 1): 187500 | ||
| 191 | |||
| 192 | ( 0, 0, 1, 1, 1, 0): 230400 | ||
| 193 | |||
| 194 | ( 0, 0, 1, 1, 1, 1): 460800 | ||
| 195 | |||
| 196 | ( 0, 1, 0, 0, 0, 0): 921600 | ||
| 197 | ))) | ||
| 198 | |b10|STX|Disable STX function|Enable STX function, the specific value is set by D8124 | ||
| 199 | |b11|ETX|Disable ETX function|Enable the ETX function, the specific value is set by D8125 | ||
| 200 | |b12|~-~-|~-~-|~-~- | ||
| 201 | |b13|~-~-|~-~-|~-~- | ||
| 202 | |b14|~-~-|~-~-|~-~- | ||
| 203 | |b15|~-~-|~-~-|~-~- | ||
| 204 | |||
| 205 | Related devices | ||
| 206 | |||
| 207 | |=**Devices**|=**Content** | ||
| 208 | |SD2540|COM1 serial port parameter setting | ||
| 209 | |SD2541|COM1 serial port parameter modification sign | ||
| 210 | |SD2590|COM2 serial port parameter setting | ||
| 211 | |SD2591|COM2 serial port parameter modification sign | ||
| 212 | |||
| 213 | Precautions | ||
| 214 | |||
| 215 | The setting of communication parameters will affect the overall communication. The parameters in PLC are modified when there is no communication or after a round of communication is completed. Attention shall be paid to this point. | ||
| 216 | |||
| 217 | STX function and ETX function are only useful in the case of user-defined protocol. | ||
| 218 | |||
| 219 | If the set protocol does not match the provided protocol number, the serial port parameter modification sign (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. | ||
| 220 | |||
| 221 | Error code | ||
| 222 | |||
| 223 | |=**Error code**|=**Content** | ||
| 224 | |4085H|The read address (s) and (n) exceeds the device range. | ||
| 225 | |4084H|(n) is not 0 or 1. | ||
| 226 | |||
| 227 | Example | ||
| 228 | |||
| 229 | (% style="text-align:center" %) | ||
| 230 | [[image:1709192341229-210.png]] | ||
| 231 | |||
| 232 | As shown in the above example, | ||
| 233 | |||
| 234 | M1 turns from OFF to ON during RUN process. | ||
| 235 | |||
| 236 | 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. | ||
| 237 | |||
| 238 | (% style="text-align:center" %) | ||
| 239 | [[image:1709192357577-580.png]] | ||
| 240 | |||
| 241 | If M1 turns from OFF to ON again, | ||
| 242 | |||
| 243 | SD2540 will be set to 129 (H81), SD2541 will be set to 280, which will not be cleared. | ||
| 244 | |||
| 245 | (% style="text-align:center" %) | ||
| 246 | [[image:1709192373970-129.png]] | ||
| 247 | |||
| 248 | == **Modbus Station Number Setting** == | ||
| 249 | |||
| 250 | ---- | ||
| 251 | |||
| 252 | === **STATION/Modbus station number setting** === | ||
| 253 | |||
| 254 | ---- | ||
| 255 | |||
| 256 | STATION (P) | ||
| 257 | |||
| 258 | Under the Modbus slave station protocol. Set the station number (s) for the (n) communication port. | ||
| 259 | |||
| 260 | -[STATION (s) (n)] | ||
| 261 | |||
| 262 | Content, range and data type | ||
| 263 | |||
| 264 | |=**Parameter**|=**Content**|=**Range**|=**Data type**|=**Data type (label)**|=**Custom variable type** | ||
| 265 | |(s)|Station number to be set|0~~255|Unsigned BIN16 bits|ANY16|INT | ||
| 266 | |(n)|Which communication port to set, 0 means COM1, 1 means COM2|0, 1|Unsigned BIN16 bits|ANY16|INT | ||
| 267 | |||
| 268 | Device used | ||
| 269 | |||
| 270 | |=**Instruction**|=**Parameter**|=(% colspan="24" %)**Devices**|=**Index modification**|=**Pulse expansion** | ||
| 271 | | | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 272 | |(% colspan="1" rowspan="2" %)STATION|Parameter 1| | | | | | | | | | | |●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 273 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 274 | |||
| 275 | Function | ||
| 276 | |||
| 277 | This command is mainly used to set the station number during RUN, and can also be used in the first cycle of RUN. | ||
| 278 | |||
| 279 | * ((( | ||
| 280 | The value of the station number address (COM1 SD2544, COM2 SD2594) and the station number modification sign (COM1 SD2545, COM2 SD2595) can be directly set according to the command parameters. | ||
| 281 | ))) | ||
| 282 | * ((( | ||
| 283 | The specific calculation formula for setting the station number modification sign (COM1 SD2545, COM2 SD2595) is: (parameter setting value + offset of the corresponding serial port's initial special device + 10) *2 | ||
| 284 | ))) | ||
| 285 | |||
| 286 | For example, setting COM2 station number to 1, i.e. (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. | ||
| 287 | |||
| 288 | Note: Whether the value is set by self-calculation and then modifying the sign (COM1 SD2545, COM2 SD2595) to the station number, or by using this command, the station number can be modified when the PLC is in the RUN state. | ||
| 289 | |||
| 290 | Station number modification sign (COM1 SD2545 and COM2 SD2595): During RUN, when the station number and modification sign are set correctly (the correctness will be judged at the End of the program), it will be deemed as the correct first cycle; then the protocol and modification sign (COM1 SD2545, COM2 SD2595) will be cleared upon completion of modification and the same value that is consequently set will not be processed. It mainly aims to avoid repeated settings for multiple times. | ||
| 291 | |||
| 292 | Related devices | ||
| 293 | |||
| 294 | |=**Devices**|=**Content** | ||
| 295 | |SD2544|COM1 station number settings | ||
| 296 | |SD2545|COM1 station number modification sign | ||
| 297 | |SD2594|COM2 station number settings | ||
| 298 | |SD2595|COM2 station number modification sign | ||
| 299 | |||
| 300 | Error code | ||
| 301 | |||
| 302 | |**Error code**|**Content** | ||
| 303 | |4085H|The read address (s) (n) exceeds the device range. | ||
| 304 | |(% colspan="1" rowspan="2" %)4084H|(s) not within the range of 0~~255. | ||
| 305 | |(n) is not 0 or 1. | ||
| 306 | |||
| 307 | Precautions | ||
| 308 | |||
| 309 | The setting of communication parameters will affect the overall communication. The parameters in PLC are modified when there is no communication or after a round of communication is completed. Attention shall be paid to this point. | ||
| 310 | |||
| 311 | Example | ||
| 312 | |||
| 313 | (% style="text-align:center" %) | ||
| 314 | [[image:1709192619027-553.png]] | ||
| 315 | |||
| 316 | As shown in the above example, | ||
| 317 | |||
| 318 | M1 turns from OFF to ON during RUN process. | ||
| 319 | |||
| 320 | 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. | ||
| 321 | |||
| 322 | (% style="text-align:center" %) | ||
| 323 | [[image:1709192635876-596.png]] | ||
| 324 | |||
| 325 | If M1 turns from OFF to ON again, | ||
| 326 | |||
| 327 | SD2594 will be set to 2, SD2595 will be set to 34 but will not be cleared. | ||
| 328 | |||
| 329 | (% style="text-align:center" %) | ||
| 330 | [[image:1709192654323-459.png]] | ||
| 331 | |||
| 332 | == **RS Instruction** == | ||
| 333 | |||
| 334 | ---- | ||
| 335 | |||
| 336 | === **RS/External communication command** === | ||
| 337 | |||
| 338 | ---- | ||
| 339 | |||
| 340 | RS | ||
| 341 | |||
| 342 | In Modbus master station protocol: the command is the setting interface for the master station to send protocol frames. According to the station number function code (s), slave station address (m), length (d) set by the command and the function code, it can be determined whether n data is required to automatically combine the transmission and reception of protocol frames. If it is a read type function code, the data will be written into (n). | ||
| 343 | |||
| 344 | -[RS (s) (m) (d) (n)] | ||
| 345 | |||
| 346 | Content, range and data type | ||
| 347 | |||
| 348 | |=**Parameter**|=**Content**|=**Range**|=**Data type**|=**Data type (label)**|=**Custom variable type** | ||
| 349 | |(s)|The starting address of the register area where the data to be sent is stored.|-|Unsigned BIN16 bits|ANY16|~-~- | ||
| 350 | |(m)|The length (in bytes) of the data to be sent.|0~~523|Unsigned BIN16 bits|ANY16|~-~- | ||
| 351 | |(d)|The starting number of the device that stores written data.|-|Unsigned BIN16 bits|ANY16|~-~- | ||
| 352 | |(n)|Volume of data written (in bytes).|0~~523|Unsigned BIN16 bits|ANY16|~-~- | ||
| 353 | |||
| 354 | In Modbus protocol: | ||
| 355 | |||
| 356 | |=**Parameter**|=**Content**|=**Range**|=**Data type**|=**Data type (label)** | ||
| 357 | |(s)|The high byte stores the station number of the slave station, and the low byte stores the Modbus function code.|-|Unsigned BIN16 bits|ANY16 | ||
| 358 | |(m)|Slave station address. The address provided by the slave station will read or write data from the address of slave station.|-|Unsigned BIN16 bits|ANY16 | ||
| 359 | |(d)|Length, the data length read or written by Modbus, and the unit are determined by the function code.|-|Unsigned BIN16 bits|ANY16 | ||
| 360 | |(n)|The starting address for data to be read or written.|-|Unsigned BIN16 bits|ANY16 | ||
| 361 | |||
| 362 | Device used | ||
| 363 | |||
| 364 | |=**Instruction**|=**Parameter**|=(% colspan="24" %)**Devices**|=**Index modification**|=**Pulse expansion** | ||
| 365 | | | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 366 | |(% colspan="1" rowspan="4" %)RS|Parameter 1| | | | | | | | | | | | | | |●|●|●|●| | | |●|●| | | | ||
| 367 | |Parameter 2| | | | | | | | | | | | | | |●|●|●|●| | | |●|●| | | | ||
| 368 | |Parameter 3| | | | | | | | | | | | | | |●|●|●|●| | | |●|●| | | | ||
| 369 | |Parameter 4| | | | | | | | | | | | | | |●|●|●|●| | | |●|●| | | | ||
| 370 | |||
| 371 | User-defined protocol | ||
| 372 | |||
| 373 | When the communication protocol is set as a user-defined protocol. When the contact in front of RS command is turned on and SM2591 is also turned on at the same time, if the sending length (m) is not 0, (m) bytes of the data of (s) will be sent out, and then it will enter 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. | ||
| 374 | |||
| 375 | 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. | ||
| 376 | |||
| 377 | To enable the start character (STX) and the end character (ETX) modes of RS command, the status of the 10th and 11th bits of the special address SD2600 must be set. See the table below for detailed settings: | ||
| 378 | |||
| 379 | |=**Bit number**|=**Name**|=(% colspan="2" %)**Content** | ||
| 380 | | | |**0 (bit OFF)**|**1 (bit ON)** | ||
| 381 | |b0|Data length|7 digits|8 digits | ||
| 382 | |((( | ||
| 383 | b1 | ||
| 384 | |||
| 385 | b2 | ||
| 386 | )))|Parity check|(% colspan="2" %)((( | ||
| 387 | b2, b1 | ||
| 388 | |||
| 389 | (0, 0): None | ||
| 390 | |||
| 391 | (0,1): Odd parity (ODD) | ||
| 392 | |||
| 393 | (1,1): Even parity (EVEN) | ||
| 394 | ))) | ||
| 395 | |b3|Stop bit|1 bit|2 bit | ||
| 396 | |((( | ||
| 397 | b4 | ||
| 398 | |||
| 399 | b5 | ||
| 400 | |||
| 401 | b6 | ||
| 402 | |||
| 403 | b7 | ||
| 404 | |||
| 405 | b8 | ||
| 406 | |||
| 407 | b9 | ||
| 408 | )))|Baud rate (bps)|((( | ||
| 409 | .b9,b8,b7,b6,b5,b4 | ||
| 410 | |||
| 411 | ( 0, 0, 0, 1, 1, 1): 4800 | ||
| 412 | |||
| 413 | ( 0, 0, 1, 0, 0, 0): 9600 | ||
| 414 | |||
| 415 | ( 0, 0, 1, 0, 0, 1): 19200 | ||
| 416 | |||
| 417 | ( 0, 0, 1, 0, 1, 0): 38400 | ||
| 418 | |||
| 419 | ( 0, 0, 1, 0, 1, 1): 57600 | ||
| 420 | )))|((( | ||
| 421 | .b9,b8,b7,b6,b5,b4 | ||
| 422 | |||
| 423 | ( 0, 0, 1, 1, 0, 0): 115200 | ||
| 424 | |||
| 425 | ( 0, 0, 1, 1, 0, 1): 187500 | ||
| 426 | |||
| 427 | ( 0, 0, 1, 1, 1, 0): 230400 | ||
| 428 | |||
| 429 | ( 0, 0, 1, 1, 1, 1): 460800 | ||
| 430 | |||
| 431 | ( 0, 1, 0, 0, 0, 0): 921600 | ||
| 432 | ))) | ||
| 433 | |b10|STX|Disable STX function|Enable STX function, the specific value is set by D8124 | ||
| 434 | |b11|ETX|Disable ETX function|Enable the ETX function, the specific value is set by D8125 | ||
| 435 | |b12|~-~-|~-~-|~-~- | ||
| 436 | |b13|~-~-|~-~-|~-~- | ||
| 437 | |b14|~-~-|~-~-|~-~- | ||
| 438 | |b15|~-~-|~-~-|~-~- | ||
| 439 | |||
| 440 | Example | ||
| 441 | |||
| 442 | (% style="text-align:center" %) | ||
| 443 | [[image:1709192957243-806.png]] | ||
| 444 | |||
| 445 | When M1 is ON, the sent and received data of communication are stored as follows after the command is executed: | ||
| 446 | |||
| 447 | [[image:1709192977624-617.png||style="float:left"]] | ||
| 448 | |||
| 449 | As shown in the figure, the sent data are 01H, 02H, 03H, 04H and 05H in turn The number of dark backgrounds used is the sent data length (m). | ||
| 450 | |||
| 451 | |||
| 452 | As shown in the figure, the received data are 21H, 22H, 23H and 24H in turn The number of dark backgrounds used is the received data length (n). | ||
| 453 | |||
| 454 | |||
| 455 | |||
| 456 | Some configuration and preparation of serial communication are needed for actual programming in order to achieve communication as expected. For instance, sending and receiving mode of serial port, baud rate, number of bits, parity, software protocol settings, timeout judgment conditions, and data preparation for the transceiver buffer, sending and receiving sign processing shall be set. A relatively complete RS communication setting program is shown as follows: | ||
| 457 | |||
| 458 | [[image:1709193063665-172.png||height="199" style="float:left" width="294"]] | ||
| 459 | |||
| 460 | Set the protocol to a user-defined protocol, | ||
| 461 | |||
| 462 | Sending interval: 5ms, | ||
| 463 | |||
| 464 | Reception timeout: 100ms, | ||
| 465 | |||
| 466 | Retries: 3 times, | ||
| 467 | |||
| 468 | Character interval timeout: 30ms, | ||
| 469 | |||
| 470 | Sending starting address D200 of user-defined protocol: sending length 8, | ||
| 471 | |||
| 472 | Directly trigger sending upon being. | ||
| 473 | |||
| 474 | For detailed user-defined protocol instructions, please refer to “9.5.1 User-defined Protocol Description”. | ||
| 475 | |||
| 476 | |||
| 477 | **Modbus protocol** | ||
| 478 | |||
| 479 | When the protocol is set to Modbus master station protocol (whether it is RTU or ASCII), When the contact in front of the RS command is set ON. RS2 command will judge whether the data of (N) is needed to send the combined data frame according to station number function code (s), slave station address (m), the length (d) and function code. | ||
| 480 | |||
| 481 | (% style="text-align:center" %) | ||
| 482 | [[image:1709193191809-462.png]] | ||
| 483 | |||
| 484 | After receiving, directly close the command and reset the command receiving sign. | ||
| 485 | |||
| 486 | |=**Parameter**|=**Content** | ||
| 487 | |(s)|The high byte stores the station number of slave station, and the low byte stores the function code of Modbus. | ||
| 488 | |(m)|Slave station address. The address provided by the slave station will read or write data from the address of slave station. | ||
| 489 | |(d)|Length: the length read or written by Modbus. The unit is determined by function code. | ||
| 490 | |(n)|((( | ||
| 491 | The starting address for data to be read or written. | ||
| 492 | ))) | ||
| 493 | |||
| 494 | [[image:1709193250935-338.png||height="138" style="float:left" width="296"]] | ||
| 495 | |||
| 496 | Communication protocol setting: | ||
| 497 | |||
| 498 | Sending interval: 5ms | ||
| 499 | |||
| 500 | Reception timeout: 100ms | ||
| 501 | |||
| 502 | Timeout retry times: 3 times | ||
| 503 | |||
| 504 | Station number 01H, function code 03H, slave station | ||
| 505 | |||
| 506 | As shown in above ladder diagram: | ||
| 507 | |||
| 508 | When M1 is turned ON, PLC will send data (hexadecimal) from COM2 of PLC: 01 03 00 0A 00 05 A5 C8 | ||
| 509 | |||
| 510 | 01: represents slave address, the high 8 bits of (s); | ||
| 511 | |||
| 512 | 03: Modbus command code, the low 8 bits of (s), which means to read the slave register; | ||
| 513 | |||
| 514 | 00 0A: the address of slave register to be read, the value of (m); | ||
| 515 | |||
| 516 | 00 05: the number of registers to be read, the value of (d), | ||
| 517 | |||
| 518 | A5 C8: CRC parity code. | ||
| 519 | |||
| 520 | For detailed user-defined protocol instructions, please refer to “9.5.2 Modbus Protocol Description”. | ||
| 521 | |||
| 522 | |||
| 523 | Precautions | ||
| 524 | |||
| 525 | 1. Although the RS command currently allows all the parameters of the command to use constants such as K and H, different protocols have different restrictions. | ||
| 526 | 1. When the protocol is a user-defined protocol, S and D cannot be constants, otherwise it will report (3189H) error. | ||
| 527 | 1. When the protocol is Modbus protocol, n cannot be a constant, otherwise it will report (3189H) error. | ||
| 528 | 1. The combination of RTU protocol and 7-bit data bits cannot be set. | ||
| 529 | 1. If the serial port parameter settings are different, it may still be able to communicate. At present, it is normal. | ||
| 530 | 1. Currently, the RS comand cannot be used in interrupts and events. | ||
| 531 | |||
| 532 | Error code | ||
| 533 | |||
| 534 | |=(% style="width: 113px;" %)**Error code**|=(% style="width: 897px;" %)**Content** | ||
| 535 | |(% style="width:113px" %)4085H|(% style="width:897px" %)(s), (m), (d) and (n) read address exceeds the range of the device. | ||
| 536 | |(% style="width:113px" %)3180H|(% style="width:897px" %)COM2 data reception error. There may be interference on the communication cable, it is recommended to connect GND. | ||
| 537 | |(% style="width:113px" %)3181H|(% style="width:897px" %)COM2 data reception timeout. Check the wiring, whether the serial port parameter settings correspond to master and slave, and whether there is interference. Check whether it is caused by the late response from the slave station. It is recommended to increase the sending interval SD2546. | ||
| 538 | |(% style="width:113px" %)3182H|(% style="width:897px" %)COM2 CRC parity error. There may be interference on the communication cable, it is recommended to connect GND. | ||
| 539 | |(% style="width:113px" %)3183H|(% style="width:897px" %)COM2 LRC parity error. There may be interference on the communication cable, it is recommended to connect GND. | ||
| 540 | |(% style="width:113px" %)3184H|(% style="width:897px" %)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 slave station. | ||
| 541 | |(% style="width:113px" %)3185H|(% style="width:897px" %)COM2 send buffer overflow If this error message appears, please contact technical personnel | ||
| 542 | |(% style="width:113px" %)3186H|(% style="width:897px" %)COM2 function code is wrong. Check whether the set function code is a function code supported by PLC. | ||
| 543 | |(% style="width:113px" %)3187H|(% style="width:897px" %)COM2 address is wrong. Check whether the slave station has this address. (Please refer to Modbus exception 02). | ||
| 544 | |(% style="width:113px" %)3188H|(% style="width:897px" %)The length of COM2 is wrong. Check whether the communication length exceeds the length range specified by Modbus protocol or user-defined protocol. | ||
| 545 | |(% style="width:113px" %)3189H|(% style="width:897px" %)COM2 data error. Check whether parameters of the command are wrong. Check whether the set value is supported by the slave station. (Please refer to Modbus exception 03). | ||
| 546 | |(% style="width:113px" %)318AH|(% style="width:897px" %)COM2 slave station is busy. Message returned from slave station: Slave station is busy. (Please refer to Modbus exception 06). | ||
| 547 | |(% style="width:113px" %)318BH|(% style="width:897px" %)COM2 slave station does not support function codes. Check whether this function code is supported by the slave station. (Please refer to Modbus exception 01). | ||
| 548 | |(% style="width:113px" %)318CH|(% style="width:897px" %)COM2 slave station is faulty. Message returned from slave station: Slave station failed, please check whether slave station failed. (Please refer to Modbus exception 04). | ||
| 549 | |(% style="width:113px" %)318DH|(% style="width:897px" %)COM2 slave station confirmation. Message returned from slave station: slave station confirmation. (Please refer to Modbus exception 05). | ||
| 550 | |(% style="width:113px" %)318EH|(% style="width:897px" %)At present, COM2 does not support this command or function. When the slave protocol is set, the communication commands related to master station or master station functions cannot be used. Please change the protocol or close the contact before the corresponding command or close the corresponding communication function. | ||
| 551 | |(% style="width:113px" %)318FH|(% style="width:897px" %)COM2 sending timeout. If this error message appears, please contact technical personnel. | ||
| 552 | |(% style="width:113px" %)31A0H|(% style="width:897px" %)No available gateway for COM2 Message returned from the slave station: no available gateway. (Please refer to Modbus exception 0A). | ||
| 553 | |(% style="width:113px" %)31A1H|(% style="width:897px" %)COM2 indicates that no response was obtained from the target device. Message returned from the slave station: The device is not networked. (Please refer to Modbus Exception 0B). | ||
| 554 | |||
| 555 | == **Instructions for Use of RS Instruction Protocol** == | ||
| 556 | |||
| 557 | ---- | ||
| 558 | |||
| 559 | === **User-defined Protocol Description** === | ||
| 560 | |||
| 561 | ---- | ||
| 562 | |||
| 563 | Introduction | ||
| 564 | |||
| 565 | The function of user-defined protocol: it can directly transmit data with equipment without any processing or the customer can set corresponding protocol to communicate with other equipment. | ||
| 566 | |||
| 567 | At present, the user-defined protocol of 6V PLC is configured and sent by COM2, and the command used is RS command. Protocol and serial port parameters need to be configured through devices. | ||
| 568 | |||
| 569 | The current user-defined protocol is generally similar to 3V. | ||
| 570 | |||
| 571 | Basic Configuration | ||
| 572 | |||
| 573 | (1)Instruction | ||
| 574 | |||
| 575 | The RS command itself is used in the same way as the previous RS command at 3V, and R devices can be used. | ||
| 576 | |||
| 577 | -[RS (s) (m) (d) (n)] | ||
| 578 | |||
| 579 | Content, range and data type | ||
| 580 | |||
| 581 | |=**Parameter**|=**Content**|=**Range**|=**Data type**|=**Data type (label)**|=**Custom Variable Type** | ||
| 582 | |(s)|The starting address of the register area where the data to be sent is stored|-|Unsigned BIN16 bits|ANY16|~-~- | ||
| 583 | |(m)|The length (in bytes) of the data to be sent|0~~528|Unsigned BIN16 bits|ANY16|~-~- | ||
| 584 | |(d)|The start number of device that stores written data|-|Unsigned BIN16 bits|ANY16|~-~- | ||
| 585 | |(n)|Volume of data written|0~~528|Unsigned BIN16 bits|ANY16|~-~- | ||
| 586 | |||
| 587 | Device used | ||
| 588 | |||
| 589 | |=**Instruction**|=**Parameter**|=(% colspan="24" %)**Devices**|=**Index modification**|=**Pulse expansion** | ||
| 590 | | | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 591 | |(% colspan="1" rowspan="4" %)RS|Parameter 1| | | | | | | | | | | | | | |●|●|●|●| | | |●|●| | | | ||
| 592 | |Parameter 2| | | | | | | | | | | | | | |●|●|●|●| | | |●|●| | | | ||
| 593 | |Parameter 3| | | | | | | | | | | | | | |●|●|●|●| | | |●|●| | | | ||
| 594 | |Parameter 4| | | | | | | | | | | | | | |●|●|●|●| | | |●|●| | | | ||
| 595 | |||
| 596 | (% class="box infomessage" %) | ||
| 597 | ((( | ||
| 598 | **✎**Note: | ||
| 599 | |||
| 600 | Although the RS command currently allows all the parameters of the command to use constants such as K and H, different protocols have different restrictions. | ||
| 601 | |||
| 602 | When the protocol is user-defined protocol, S and D cannot be constants, otherwise an error will be reported. | ||
| 603 | ))) | ||
| 604 | |||
| 605 | (2)Special device setting | ||
| 606 | |||
| 607 | Special address table | ||
| 608 | |||
| 609 | |=(% colspan="2" %)**COM2 special D device (SD)**|=(% colspan="2" %)**COM2 special M device (SM)** | ||
| 610 | |2590|Communication port settings|2590|Sending control on | ||
| 611 | |2591|COM1 serial port parameter modification sign|2591|Send control/send prompt | ||
| 612 | |2592|Protocol settings|2592|Reception control on | ||
| 613 | |2593|Protocol modification sign|2593|Accept control/receive prompt | ||
| 614 | |2594|Station number settings|2594|8-bit mode (for user-defined protocol) | ||
| 615 | |2595|Station number modification sign|2595| | ||
| 616 | |2596|((( | ||
| 617 | Sending interval (0.1ms) 0~~32767 | ||
| 618 | |||
| 619 | Set 0 to 10 (1ms) | ||
| 620 | )))|2596| | ||
| 621 | |2597|((( | ||
| 622 | Communication timeout setting (10ms) 0~~32767 | ||
| 623 | |||
| 624 | Set 0 to 10 (100ms) | ||
| 625 | )))|2597| | ||
| 626 | |2598|Timeout retry times 0~~32767|2598| | ||
| 627 | |2599|((( | ||
| 628 | Character interval timeout setting (for custom protocol) (0.1ms) | ||
| 629 | |||
| 630 | 0 to 32767 | ||
| 631 | |||
| 632 | Set 0 to 10 (1ms) | ||
| 633 | )))|2599| | ||
| 634 | |2600|STX value|2600| | ||
| 635 | |2601|ETX value|2601| | ||
| 636 | |...| |...| | ||
| 637 | |2610|Volume of data received|2610|Communication completion sign | ||
| 638 | |2611|Last error|2611|Receiving sign | ||
| 639 | |2612|Current error|2612|Retry | ||
| 640 | |2613|Error steps|2613|Communication error | ||
| 641 | |2614|Error station number|2614|Communication timeout | ||
| 642 | |2615|Cumulative error times|2615| | ||
| 643 | |||
| 644 | The contents that will be used or set by the user-defined protocol have been marked with “underline” and “in bold”. | ||
| 645 | |||
| 646 | In addition, the devices to be used as judgment conditions have been marked “in bold” in the table. | ||
| 647 | |||
| 648 | (% class="box infomessage" %) | ||
| 649 | ((( | ||
| 650 | **✎**Note: | ||
| 651 | |||
| 652 | at present, COM1 doesn’t support user-defined protocol. | ||
| 653 | ))) | ||
| 654 | |||
| 655 | Communication port settings SD2590 | ||
| 656 | |||
| 657 | |=**Bit number**|=**Name**|=(% colspan="2" %)**Content** | ||
| 658 | | | |**0 (bit OFF)**|**1 (bit ON)** | ||
| 659 | |b0|Data length|7 digits|8 digits | ||
| 660 | |((( | ||
| 661 | b1 | ||
| 662 | |||
| 663 | b2 | ||
| 664 | )))|Parity check|(% colspan="2" %)((( | ||
| 665 | b2, b1 | ||
| 666 | |||
| 667 | (0, 0): None | ||
| 668 | |||
| 669 | (0,1): Odd parity (ODD) | ||
| 670 | |||
| 671 | (1,1): Even parity (EVEN) | ||
| 672 | ))) | ||
| 673 | |b3|Stop bit|1 bit|2 bit | ||
| 674 | |((( | ||
| 675 | b4 | ||
| 676 | |||
| 677 | b5 | ||
| 678 | |||
| 679 | b6 | ||
| 680 | |||
| 681 | b7 | ||
| 682 | |||
| 683 | b8 | ||
| 684 | |||
| 685 | b9 | ||
| 686 | )))|Baud rate (bps)|((( | ||
| 687 | .b9,b8,b7,b6,b5,b4 | ||
| 688 | |||
| 689 | ( 0, 0, 0, 1, 1, 1): 4800 | ||
| 690 | |||
| 691 | ( 0, 0, 1, 0, 0, 0): 9600 | ||
| 692 | |||
| 693 | ( 0, 0, 1, 0, 0, 1): 19200 | ||
| 694 | |||
| 695 | ( 0, 0, 1, 0, 1, 0): 38400 | ||
| 696 | |||
| 697 | ( 0, 0, 1, 0, 1, 1): 57600 | ||
| 698 | )))|((( | ||
| 699 | .b9,b8,b7,b6,b5,b4 | ||
| 700 | |||
| 701 | ( 0, 0, 1, 1, 0, 0): 115200 | ||
| 702 | |||
| 703 | ( 0, 0, 1, 1, 0, 1): 187500 | ||
| 704 | |||
| 705 | ( 0, 0, 1, 1, 1, 0): 230400 | ||
| 706 | |||
| 707 | ( 0, 0, 1, 1, 1, 1): 460800 | ||
| 708 | |||
| 709 | ( 0, 1, 0, 0, 0, 0): 921600 | ||
| 710 | ))) | ||
| 711 | |b10|STX|Disable STX function|Enable STX function, the specific value is set by D8124 | ||
| 712 | |b11|ETX|Disable ETX function|Enable the ETX function, the specific value is set by D8125 | ||
| 713 | |||
| 714 | According to the bit setting provided in the above table, the serial port parameter is set to SD2590. At present, the setting is basically the same as 3V. As a higher baud rate can be set, the bits used for enabling STX and ETX need to be moved back by two bits. | ||
| 715 | |||
| 716 | For instance, set serial port parameters: baud rate: 115200, stop bit: 1, data bit: 8, parity bit: none, enable STX. | ||
| 717 | |||
| 718 | Then set the value H4C1 (K1217) on SD2590. At present, the parameters directly set to SD2590 are only valid in the first cycle of PLC RUN, and if they need to be modified during RUN, they can be set by PORTPARAM command. | ||
| 719 | |||
| 720 | |||
| 721 | Protocol settings SD2592 | ||
| 722 | |||
| 723 | |=(% colspan="2" %)**Protocol settings**|=(% colspan="2" %)**Protocol settings** | ||
| 724 | |0 H|Wecon Modbus slave station|10 H|User-defined protocol | ||
| 725 | |2 H|Modbus RTU slave station|20 H|Modbus RTU master station | ||
| 726 | |3 H|Modbus ASCII slave station|30 H|Modbus ASCII master station | ||
| 727 | |||
| 728 | The corresponding protocol can be set by setting the corresponding value in SD2592. | ||
| 729 | |||
| 730 | At present, the parameters directly set to SD2590 are only valid in the first cycle of PLC RUN. | ||
| 731 | |||
| 732 | If the parameters need to be modified during RUN, they can be set by PROTOCOL command. | ||
| 733 | |||
| 734 | |||
| 735 | Sending interval SD2596 | ||
| 736 | |||
| 737 | The main function of sending interval is: to determine how long does it take to wait to send the next command when one command is completed. When 0 is set, it will not wait for sending at specified interval, but it will be affected by scanning period. | ||
| 738 | |||
| 739 | The unit of transmission interval is 0.1 ms, i.e. the interval time is 10ms when the value is set to be 100. | ||
| 740 | |||
| 741 | |||
| 742 | Communication timeout SD2597 and timeout retry SD2598 | ||
| 743 | |||
| 744 | |||
| 745 | (% style="text-align:center" %) | ||
| 746 | [[image:1709194693483-466.png]] | ||
| 747 | |||
| 748 | The main function of communication timeout is: to determine when the retry is required or an error needs to be reported when the data is not received after being sent by PLC. When 0 is set, it is 100ms by default. | ||
| 749 | |||
| 750 | The unit of transmission interval is 10ms, i.e. the timeout judgment time is 100ms when the value is set to be 10. | ||
| 751 | |||
| 752 | When receiving timeout occurs, it will judge whether there are retries and the current retry times. If the retry times are greater than or equal to SD2598, an error will be reported. | ||
| 753 | |||
| 754 | If SD2598 is set to 0, no retry is required. | ||
| 755 | |||
| 756 | When it is set to 1, send the data once and then send it again after timeout. | ||
| 757 | |||
| 758 | |||
| 759 | Character interval timeout SD2599 | ||
| 760 | |||
| 761 | At present, this setting is available for user-defined protocol. | ||
| 762 | |||
| 763 | The main function of character interval timeout is: after receiving at least one character before there is no communication timeout, judge whether the interval time between the following two characters exceed the time limit, report an error if it exceeds the time limit, and end communication. | ||
| 764 | |||
| 765 | (% style="text-align:center" %) | ||
| 766 | [[image:1709194729585-457.png]] | ||
| 767 | |||
| 768 | This setting is mainly designed after considering that some devices may send data slowly or there are other specific sending requirements. No retry is required in case of character interval timeout. | ||
| 769 | |||
| 770 | |||
| 771 | **Serial port parameter setting command** | ||
| 772 | |||
| 773 | Upper computer interface settings | ||
| 774 | |||
| 775 | (% style="text-align:center" %) | ||
| 776 | [[image:1709194773560-219.png]] | ||
| 777 | |||
| 778 | Through the PLC parameter setting in the upper computer interface, if the protocol is switched to “no protocol”, it means the user-defined protocol. | ||
| 779 | |||
| 780 | Serial port parameters mainly include baud rate, data bits and other serial port parameters. | ||
| 781 | |||
| 782 | Start/end characters can be sent when start characters are enabled. Start/end characters will be distinguished when they are received. See the instructions in the sending and receiving process for details. | ||
| 783 | |||
| 784 | It is important to note that the characters here are actually decimal values. | ||
| 785 | |||
| 786 | PORTPARA command | ||
| 787 | |||
| 788 | -[PORTPARA (s) (n)] | ||
| 789 | |||
| 790 | Content, range and data type | ||
| 791 | |||
| 792 | |=**Parameter**|=**Content**|=**Range**|=**Data type**|=**Data type (label)**|=**Custom variable type** | ||
| 793 | |(s)|Serial port parameters to be set|0 to 256|Unsigned BIN16 bits|ANY16|~-~- | ||
| 794 | |(n)|Which communication port to set, 0 means COM1, 1 means COM2|0, 1|Unsigned BIN16 bits|ANY16|INT | ||
| 795 | |||
| 796 | Device used | ||
| 797 | |||
| 798 | |=**Instruction**|=**Parameter**|=(% colspan="24" %)**Devices**|=**Index modification**|=**Pulse expansion** | ||
| 799 | | | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 800 | |(% colspan="1" rowspan="2" %)PROTOCOL|Parameter 1| | | | | | | | | | | |●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 801 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 802 | |||
| 803 | Function | ||
| 804 | |||
| 805 | It is used to set the communication protocol at the time of RUN, and the above command is actually used to set a specific value for the parameter modification sign. | ||
| 806 | |||
| 807 | ●The specific calculation formula is: (parameter setting value + offset of the corresponding serial port's initial special device + 10)*2 | ||
| 808 | |||
| 809 | For example, setting the protocol to Modbus RTU master station (H20), i.e. (0x20 +2593-2590 +10) * 2, which is (32 +3 +10) *2=90, which mainly aims to avoid random modification of serial port parameters during operation. | ||
| 810 | |||
| 811 | For user-defined protocol, if the set parameters are triggered, the value will be changed only after the command is completely completed. | ||
| 812 | |||
| 813 | For Modbus master station protocol, if the set parameters are triggered, the value will be changed only after the command is completely completed. | ||
| 814 | |||
| 815 | For Modbus slave station protocol, if the set parameters are triggered, switching can be performed when the received data is not being processed. | ||
| 816 | |||
| 817 | For details, please refer to “PROTOCOL Instruction Description”. | ||
| 818 | |||
| 819 | |||
| 820 | Priority description of serial port parameters | ||
| 821 | |||
| 822 | The priority of serial port parameter setting is listed below. At present, serial port parameters are saved at the time of power failure. | ||
| 823 | |||
| 824 | Serial port parameter setting command setting = using ladder diagram MOV command to set corresponding SD device > upper computer downloading parameters > previous data saved at the time of power outage. | ||
| 825 | |||
| 826 | |||
| 827 | **Basic ladder diagram** | ||
| 828 | |||
| 829 | [[image:1709195811192-573.png||height="294" style="float:left" width="419"]] | ||
| 830 | |||
| 831 | Setting serial port parameters: | ||
| 832 | |||
| 833 | Baud rate: 115200, stop bit: 1, data bit: 8, parity | ||
| 834 | |||
| 835 | Set the protocol to a user-defined protocol | ||
| 836 | |||
| 837 | Sending interval: 5ms | ||
| 838 | |||
| 839 | Reception timeout: 100ms | ||
| 840 | |||
| 841 | Retries: 3 times | ||
| 842 | |||
| 843 | Character interval timeout: 30ms | ||
| 844 | |||
| 845 | Sending starting address D200 of user-defined protocol: sending length 8 | ||
| 846 | |||
| 847 | Directly trigger sending upon being | ||
| 848 | |||
| 849 | After receiving, directly close the command and reset the command receiving sign. | ||
| 850 | |||
| 851 | 1.Sending and receiving mechanism | ||
| 852 | |||
| 853 | |||
| 854 | (1)No start character (STX) and end character (ETX) | ||
| 855 | |||
| 856 | 16-bit (SM2594 is OFF) | ||
| 857 | |||
| 858 | Devices will be divided into high and low directly and then the data in the low address will be sent first, followed by the data in the high address. | ||
| 859 | |||
| 860 | (% style="text-align:center" %) | ||
| 861 | [[image:1709197260367-911.png]] | ||
| 862 | |||
| 863 | [[image:1709197271332-974.png||height="183" style="float:left" width="161"]] | ||
| 864 | |||
| 865 | For instance, the sent data are 01, 02, 03, 04 and 05 | ||
| 866 | |||
| 867 | |||
| 868 | |||
| 869 | When X1 is ON, the sent and received data of communication are stored as follows after the command is executed. | ||
| 870 | |||
| 871 | For instance, the received data are 11, 12, 13 and 14 | ||
| 872 | |||
| 873 | |||
| 874 | 8-bit (SM2594 is ON) | ||
| 875 | |||
| 876 | Get the value of the low address of the device directly and send it | ||
| 877 | |||
| 878 | (% style="text-align:center" %) | ||
| 879 | [[image:1709197320390-469.png]] | ||
| 880 | |||
| 881 | (% style="text-align:center" %) | ||
| 882 | [[image:1709197331830-332.png]] | ||
| 883 | |||
| 884 | As shown in above ladder diagram and under above data transmission, the sent data should be: 70 E1 31 62 6C. | ||
| 885 | |||
| 886 | (% style="text-align:center" %) | ||
| 887 | [[image:1709197349815-564.png]] | ||
| 888 | |||
| 889 | The received data will also be stored at low address. | ||
| 890 | |||
| 891 | (2)Opening and setting the start character STX | ||
| 892 | |||
| 893 | The value of the start character SD2600 is valid only when it is at low bit. | ||
| 894 | |||
| 895 | When STX is opened, the data will start with the start character STX at the time of sending, and the data starting with STX will be received, but no STX will be shown. | ||
| 896 | |||
| 897 | When the data starting with STX is received in the half way,the reception process will restart. | ||
| 898 | |||
| 899 | If the first character is not received, it will be judged as time out in case of the timeout of the first character; if the first character is received, no matter what kind of data is received, the character timeout will be counted since the last character is received. | ||
| 900 | |||
| 901 | (% style="text-align:center" %) | ||
| 902 | [[image:1709197411454-969.png]] | ||
| 903 | |||
| 904 | |||
| 905 | (% style="text-align:center" %) | ||
| 906 | [[image:1709197419797-167.png]] | ||
| 907 | |||
| 908 | As shown in above ladder diagram and under above data transmission, the sent data should be FE 70 7D E1 00 31. | ||
| 909 | |||
| 910 | If FE 51 26 34 15 is sent to PLC, the following data will be received. | ||
| 911 | |||
| 912 | If FE 25 63 FE 51 26 34 15 is sent to PLC, the following data will be received. | ||
| 913 | |||
| 914 | (% style="text-align:center" %) | ||
| 915 | [[image:1709197434533-834.png]] | ||
| 916 | |||
| 917 | |||
| 918 | 2.Opening and setting the end character ETX | ||
| 919 | |||
| 920 | The value of the end character SD2601 is valid only when it is at low bit. | ||
| 921 | |||
| 922 | When ETX is opened, the data will end with ETX at the end of sending. | ||
| 923 | |||
| 924 | SM2610 and SM2593 are immediately ON when an ETX is received, no matter whether sufficient length of data is received. | ||
| 925 | |||
| 926 | (% style="text-align:center" %) | ||
| 927 | [[image:1709197515381-874.png]] | ||
| 928 | |||
| 929 | (% style="text-align:center" %) | ||
| 930 | [[image:1709197524487-888.png]] | ||
| 931 | |||
| 932 | |||
| 933 | As shown in above ladder diagram and under above data transmission, the result is 70 7D E1 00 31 FD. | ||
| 934 | |||
| 935 | As shown in above ladder diagram, if 01 06 FD is sent, the following data will be received. If FD is sent directly, it will be judged as “end” directly. | ||
| 936 | |||
| 937 | (% style="text-align:center" %) | ||
| 938 | [[image:1709197546086-345.png]] | ||
| 939 | |||
| 940 | |||
| 941 | Both start character (STX) and end character (ETX) are opened | ||
| 942 | |||
| 943 | When both start character and end character are opened, it is generally deemed as the combination of above single open state. | ||
| 944 | |||
| 945 | However, if only ETX data is received when both characters are opened, it will not end immediately, but it will change to judge the character interval time, without starting to receive data. | ||
| 946 | |||
| 947 | |||
| 948 | **Receiving after sending (similar to Modbus master station mechanism)** | ||
| 949 | |||
| 950 | 1.** **OFF (default) state of sending control switch (SM2590) and receiving control switch (SM2592) | ||
| 951 | |||
| 952 | When the contact point of RS command is set ON, SM2591 will be sent immediately when it is set ON, and SM2591 will be automatically set OFF after sending. | ||
| 953 | |||
| 954 | After sending, judge the state of SM2593. If it is ON, it will stop in this command all the time and wait until it is set OFF and then receive data; if it is OFF, it will start receiving data. | ||
| 955 | |||
| 956 | After the first character timeout time (SD2597), if no character is received, it is judged as timeout; if retry time is set, retry it. If the communication cannot be achieved after retry, an error will be reported and SM2593 and SM2614 are set to be on. | ||
| 957 | |||
| 958 | After receiving the first character, judge whether the interval between characters exceeds the time set by SD2599, otherwise an error will be reported. (Please refer to “Character Interval Timeout” for details.) | ||
| 959 | |||
| 960 | If there are two or more commands, after SM2591 is set to be ON, RS command for setting the first ON will be sent, and then if this RS command is completed^^* 1^^and set to be ON, SM2591 will switch to the next RS command in the ladder diagram sequence^^* 2^^. | ||
| 961 | |||
| 962 | If there are two or more commands, another data will be sent when the data is half received, and the original command is continued to be executed for receiving until it is completed. | ||
| 963 | |||
| 964 | (% class="box infomessage" %) | ||
| 965 | ((( | ||
| 966 | **✎**Note * 1: Completion refers to receiving data or reporting errors. | ||
| 967 | |||
| 968 | **✎**Note * 2: If there is no other RS command opened after the ladder diagram sequence, it will return to execute the first RS command opened in the ladder diagram sequence. | ||
| 969 | ))) | ||
| 970 | |||
| 971 | 2.Sending mode when the sending control switch (SM2590) is ON | ||
| 972 | |||
| 973 | When the sending control switch (SM2590) is ON, there is no need to control SM2591 to be set as ON. | ||
| 974 | |||
| 975 | At this time, as long as the contact of RS command is triggered, it can be sent, and SM2591 is automatically set as ON. | ||
| 976 | |||
| 977 | 3.Receiving mode when the receiving control switch (SM2592) is ON | ||
| 978 | |||
| 979 | When the receiving control switch (SM2592) is ON, SM2593 is automatically turned to OFF when the command is executed. | ||
| 980 | |||
| 981 | When receiving, the status of SM2593 will not be judged again, and SM2593 will still be set as ON after receiving. | ||
| 982 | |||
| 983 | 4.ON state of sending control switch (SM2590) and receiving control switch (SM2592) | ||
| 984 | |||
| 985 | Under above circumstance, the data can be sent only by triggering the contact in front of the RS command, which will automatically turn to the waiting for receiving state, and when the reception is completed, it will turn to the next opened RS command. | ||
| 986 | |||
| 987 | |||
| 988 | (3)Send only | ||
| 989 | |||
| 990 | (% style="text-align:center" %) | ||
| 991 | [[image:1709197775117-634.png]] | ||
| 992 | |||
| 993 | When the sending length is set to a non-0 value, the receiving length is set to 0. This is send-only mode. | ||
| 994 | |||
| 995 | 1.OFF state of sending control switch (SM2590) | ||
| 996 | |||
| 997 | When SM2591 is set as ON, it sends data and does not receive data. | ||
| 998 | |||
| 999 | If there are two or more commands, after SM2591 is set to be ON, RS command for setting the first ON will be sent, and then if this RS command is completed and set to be ON, SM2591 will switch to the next RS command in the ladder diagram. | ||
| 1000 | |||
| 1001 | 2.ON state of sending control switch (SM2590) | ||
| 1002 | |||
| 1003 | The data will be sent when RS command is triggered. | ||
| 1004 | |||
| 1005 | When several commands are triggered, the data will be set in circular manner, and during the circular sending, the data will be sent at intervals according to the set sending intervals. | ||
| 1006 | |||
| 1007 | |||
| 1008 | (4)Receive-only | ||
| 1009 | |||
| 1010 | (% style="text-align:center" %) | ||
| 1011 | [[image:1709197838060-527.png]] | ||
| 1012 | |||
| 1013 | When the sending length is set to a non-0 value, the receiving length is set to 0. This is send-only mode. | ||
| 1014 | |||
| 1015 | 1.OFF state of sending control switch (SM2590) | ||
| 1016 | |||
| 1017 | When SM2591 is set as ON, it sends data and does not receive data. | ||
| 1018 | |||
| 1019 | If there are two or more commands, after SM2591 is set to be ON, RS command for setting the first ON will be sent, and then if this RS command is completed and set to be ON, SM2591 will switch to the next RS command in the ladder diagram. | ||
| 1020 | |||
| 1021 | 2.ON state of sending control switch (SM2590) | ||
| 1022 | |||
| 1023 | The data will be sent when RS command is triggered. | ||
| 1024 | |||
| 1025 | When several commands are triggered, the data will be set in circular manner, and during the circular sending, the data will be sent at intervals according to the set sending intervals. | ||
| 1026 | |||
| 1027 | (5)Sending after receiving by the receive-only and send-only mode (similar to Modbus slave station mechanism) | ||
| 1028 | |||
| 1029 | [[image:1709715782626-666.png||height="247" style="float:left" width="233"]] | ||
| 1030 | |||
| 1031 | |||
| 1032 | Receive-only: when it is judged as completing reception, the command to be triggered will be judged according to the received contents; meanwhile, the received data will be saved. | ||
| 1033 | |||
| 1034 | |||
| 1035 | |||
| 1036 | Send-only: the sent contents are different after M2 is triggered and M3 is triggered. After the trigger is over, they will return to trigger the receive-only part of M1. | ||
| 1037 | |||
| 1038 | |||
| 1039 | A. 9.5.1.4 Error information | ||
| 1040 | |||
| 1041 | The current error code will be displayed in theSD7, SD0 and SD2611 and SD2612. | ||
| 1042 | |||
| 1043 | The error codes that will occur in user-defined protocols are mainly shown as follows: | ||
| 1044 | |||
| 1045 | |=(% style="width: 108px;" %)**Error code**|=(% style="width: 902px;" %)**Content** | ||
| 1046 | |(% style="width:108px" %)3181H|(% style="width:902px" %)Data reception timeout | ||
| 1047 | |(% style="width:108px" %)3188H|(% style="width:902px" %)Length error | ||
| 1048 | |(% style="width:108px" %)3189H|(% style="width:902px" %)COM2 data error. “Check whether the parameters of the command are wrong. Check whether the set value is supported by the slave station. (Please refer to Modbus exception 03).” | ||
| 1049 | |(% style="width:108px" %)318EH|(% style="width:902px" %)At present, COM2 does not support this command or function. When the slave protocol is set, the communication commands related to master station or master station functions cannot be used. Please change the protocol or close the contact before the corresponding command or close the corresponding communication function. | ||
| 1050 | |(% style="width:108px" %)318FH|(% style="width:902px" %)COM2 sending timeout. If this error message appears, please contact technical personnel. | ||
| 1051 | |(% style="width:108px" %)3190H|(% style="width:902px" %)COM2 receives data beyond the cache limit. | ||
| 1052 | |||
| 1053 | After resetting the protocol or communication parameters, the reported errors will be cleared. | ||
| 1054 | |||
| 1055 | In addition, in case of communication completion/communication error/communication timeout, the sign bit will be set after executing the command. | ||
| 1056 | |||
| 1057 | B.9.5.1.5 Difference with Mitsubishi | ||
| 1058 | |||
| 1059 | Currently known difference: | ||
| 1060 | |||
| 1061 | ⑴ For STX and ETX, Mitsubishi can set a maximum of 4 bytes, but we only have one byte. | ||
| 1062 | |||
| 1063 | ⑵Support accumulation, parity, CR and LF. | ||
| 1064 | |||
| 1065 | ⑶Mitsubishi's command control is to execute the command on a fixed basis when the command is triggered first. It will not be switched to other commands midway unless the contact of this command is closed. | ||
| 1066 | |||
| 1067 | |||
| 1068 | === **Modbus Protocol Description** === | ||
| 1069 | |||
| 1070 | ---- | ||
| 1071 | |||
| 1072 | [[image:file:///C:\Users\ADMINI~~1\AppData\Local\Temp\ksohtml10940\wps1.png]]Introduction | ||
| 1073 | |||
| 1074 | The current Modbus master station protocol is generally similar to LX3V. The address is modified in the slave station part. | ||
| 1075 | |||
| 1076 | Basic Configuration | ||
| 1077 | |||
| 1078 | (1) Instruction | ||
| 1079 | |||
| 1080 | The RS command itself is used in the same way as the previous RS command at 3V. R device can be used. | ||
| 1081 | |||
| 1082 | -[RS (s) (m) (d) (n)] | ||
| 1083 | |||
| 1084 | Content, range and data type | ||
| 1085 | |||
| 1086 | |=**Parameter**|=**Content**|=**Range**|=**Data type**|=**Data type (label)** | ||
| 1087 | |(s)|The high byte stores the station number of slave station, and the low byte stores the function code of Modbus.|-|Unsigned BIN16 bits|ANY16 | ||
| 1088 | |(m)|Slave station address. The address provided by the slave station will read or write data from the address of slave station.|-|Unsigned BIN16 bits|ANY16 | ||
| 1089 | |(d)|Length: the length read or written by Modbus. The unit is determined by function code.|-|Unsigned BIN16 bits|ANY16 | ||
| 1090 | |(n)|The starting address for data to be read or written.|-|Unsigned BIN16 bits|ANY16 | ||
| 1091 | |||
| 1092 | Device used | ||
| 1093 | |||
| 1094 | |=**Instruction**|=**Parameter**|=(% colspan="24" %)**Devices**|=**Index modification**|=**Pulse expansion** | ||
| 1095 | | | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 1096 | |(% colspan="1" rowspan="4" %)RS|Parameter 1| | | | | | | | | | | | | | |●|●|●|●| | | |●|●| | | | ||
| 1097 | |Parameter 2| | | | | | | | | | | | | | |●|●|●|●| | | |●|●| | | | ||
| 1098 | |Parameter 3| | | | | | | | | | | | | | |●|●|●|●| | | |●|●| | | | ||
| 1099 | |Parameter 4| | | | | | | | | | | | | | |●|●|●|●| | | | | | | | | ||
| 1100 | |||
| 1101 | (% class="box infomessage" %) | ||
| 1102 | ((( | ||
| 1103 | **✎Note:** | ||
| 1104 | |||
| 1105 | Although the RS command currently allows all the parameters of the command to use constants such as K and H, | ||
| 1106 | |||
| 1107 | different protocols have different restrictions. When the protocol is Modbus master station protocol, n cannot be a constant, otherwise it will report an error. | ||
| 1108 | ))) | ||
| 1109 | |||
| 1110 | (2) Special device setting | ||
| 1111 | |||
| 1112 | Special address table | ||
| 1113 | |||
| 1114 | |=(% colspan="2" %)**COM1 special D device (SD)** | ||
| 1115 | |2540|Communication port settings | ||
| 1116 | |2541|COM1 serial port parameter modification sign | ||
| 1117 | |2542| | ||
| 1118 | |2543| | ||
| 1119 | |2544|Station number settings | ||
| 1120 | |2545|Station number modification sign | ||
| 1121 | |||
| 1122 | (% class="box infomessage" %) | ||
| 1123 | ((( | ||
| 1124 | **✎Note:** COM1 doesn’t support modification of protocol. | ||
| 1125 | ))) | ||
| 1126 | |||
| 1127 | |=(% colspan="2" style="width: 502px;" %)**COM2 special D device (SD)**|=(% colspan="2" style="width: 508px;" %)**COM2 special M device (SM)** | ||
| 1128 | |2590|(% style="width:440px" %)Communication port settings|(% style="width:65px" %)2590|(% style="width:443px" %)Sending control on | ||
| 1129 | |2591|(% style="width:440px" %)COM1 serial port parameter modification sign|(% style="width:65px" %)2591|(% style="width:443px" %)Send control/send prompt | ||
| 1130 | |2592|(% style="width:440px" %)Protocol settings|(% style="width:65px" %)2592|(% style="width:443px" %)Reception control on | ||
| 1131 | |2593|(% style="width:440px" %)Protocol modification sign|(% style="width:65px" %)2593|(% style="width:443px" %)Accept control/receive prompt | ||
| 1132 | |2594|(% style="width:440px" %)Station number settings|(% style="width:65px" %)2594|(% style="width:443px" %)8-bit mode (for user-defined protocol) | ||
| 1133 | |2595|(% style="width:440px" %)Station number modification sign|(% style="width:65px" %)2595|(% style="width:443px" %) | ||
| 1134 | |2596|(% style="width:440px" %)((( | ||
| 1135 | Sending interval (0.1ms) 0-32767 | ||
| 1136 | |||
| 1137 | Set 0 to 10 (1ms) | ||
| 1138 | )))|(% style="width:65px" %)2596|(% style="width:443px" %) | ||
| 1139 | |2597|(% style="width:440px" %)((( | ||
| 1140 | Communication timeout setting (10ms) 0-32767 | ||
| 1141 | |||
| 1142 | Set 0 to 10 (100ms) | ||
| 1143 | )))|(% style="width:65px" %)2597|(% style="width:443px" %) | ||
| 1144 | |2598|(% style="width:440px" %)Timeout retry times 0-32767|(% style="width:65px" %)2598|(% style="width:443px" %) | ||
| 1145 | |2599|(% style="width:440px" %)((( | ||
| 1146 | Character interval timeout setting (for custom protocol) (0.1ms) | ||
| 1147 | |||
| 1148 | 0 to 32767 | ||
| 1149 | |||
| 1150 | Set 0 to 10 (1ms) | ||
| 1151 | )))|(% style="width:65px" %)2599|(% style="width:443px" %) | ||
| 1152 | |2600|(% style="width:440px" %)STX value|(% style="width:65px" %)2600|(% style="width:443px" %) | ||
| 1153 | |2601|(% style="width:440px" %)ETX value|(% style="width:65px" %)2601|(% style="width:443px" %) | ||
| 1154 | |...|(% style="width:440px" %) |(% style="width:65px" %)..|(% style="width:443px" %) | ||
| 1155 | |2610|(% style="width:440px" %)Volume of data received|(% style="width:65px" %)2610|(% style="width:443px" %)Communication completion sign | ||
| 1156 | |2611|(% style="width:440px" %)Last error|(% style="width:65px" %)2611|(% style="width:443px" %)Receiving sign | ||
| 1157 | |2612|(% style="width:440px" %)Current error|(% style="width:65px" %)2612|(% style="width:443px" %)Retry | ||
| 1158 | |2613|(% style="width:440px" %)Error steps|(% style="width:65px" %)2613|(% style="width:443px" %)Communication error | ||
| 1159 | |2614|(% style="width:440px" %)Error station number|(% style="width:65px" %)2614|(% style="width:443px" %)Communication timeout | ||
| 1160 | |2615|(% style="width:440px" %)Cumulative error times|(% style="width:65px" %)2615|(% style="width:443px" %) | ||
| 1161 | |||
| 1162 | The contents that will be used or set by the Modbus protocol have been marked with “underline” and “in bold”. | ||
| 1163 | |||
| 1164 | In addition, the devices to be used as judgment conditions have been marked “in bold” in the table. | ||
| 1165 | |||
| 1166 | 1.Communication port settings SD2590 | ||
| 1167 | |||
| 1168 | |=**Bit number**|=**Name**|=(% colspan="2" %)**Content** | ||
| 1169 | | | |**0 (bit OFF)**|**1 (bit ON)** | ||
| 1170 | |b0|Data length|7 digits|8 digits | ||
| 1171 | |((( | ||
| 1172 | b1 | ||
| 1173 | |||
| 1174 | b2 | ||
| 1175 | )))|Parity check|(% colspan="2" %)((( | ||
| 1176 | b2, b1 | ||
| 1177 | |||
| 1178 | (0, 0): None | ||
| 1179 | |||
| 1180 | (0,1): Odd parity (ODD) | ||
| 1181 | |||
| 1182 | (1,1): Even parity (EVEN) | ||
| 1183 | ))) | ||
| 1184 | |b3|Stop bit|1 bit|2 bit | ||
| 1185 | |((( | ||
| 1186 | b4 | ||
| 1187 | |||
| 1188 | b5 | ||
| 1189 | |||
| 1190 | b6 | ||
| 1191 | |||
| 1192 | b7 | ||
| 1193 | |||
| 1194 | b8 | ||
| 1195 | |||
| 1196 | b9 | ||
| 1197 | )))|Baud rate (bps)|((( | ||
| 1198 | .b9,b8,b7,b6,b5,b4 | ||
| 1199 | |||
| 1200 | ( 0, 0, 0, 1, 1, 1): 4800 | ||
| 1201 | |||
| 1202 | ( 0, 0, 1, 0, 0, 0): 9600 | ||
| 1203 | |||
| 1204 | ( 0, 0, 1, 0, 0, 1): 19200 | ||
| 1205 | |||
| 1206 | ( 0, 0, 1, 0, 1, 0): 38400 | ||
| 1207 | |||
| 1208 | ( 0, 0, 1, 0, 1, 1): 57600 | ||
| 1209 | )))|((( | ||
| 1210 | .b9,b8,b7,b6,b5,b4 | ||
| 1211 | |||
| 1212 | ( 0, 0, 1, 1, 0, 0): 115200 | ||
| 1213 | |||
| 1214 | ( 0, 0, 1, 1, 0, 1): 187500 | ||
| 1215 | |||
| 1216 | ( 0, 0, 1, 1, 1, 0): 230400 | ||
| 1217 | |||
| 1218 | ( 0, 0, 1, 1, 1, 1): 460800 | ||
| 1219 | |||
| 1220 | ( 0, 1, 0, 0, 0, 0): 921600 | ||
| 1221 | ))) | ||
| 1222 | |||
| 1223 | According to the bit setting provided in the above table, the serial port parameter is set to SD2590. | ||
| 1224 | |||
| 1225 | At present, the setting is basically the same as 3V. As a higher baud rate can be set, the bits used for enabling STX and ETX need to be moved back by two bits. | ||
| 1226 | |||
| 1227 | For instance, set serial port parameters: baud rate: 115200, stop bit: 1, data bit: 8, parity bit: none. | ||
| 1228 | |||
| 1229 | Then set the value HC1 (K1217) on SD2590. | ||
| 1230 | |||
| 1231 | At present, the parameters directly set to SD2590 are only valid in the first cycle of PLC RUN. | ||
| 1232 | |||
| 1233 | If the parameters need to be modified during RUN, they can be set by PORTPARAM command. | ||
| 1234 | |||
| 1235 | 2.Protocol settings SD2592 | ||
| 1236 | |||
| 1237 | |=(% colspan="4" %)**Protocol settings** | ||
| 1238 | |0H|Wecon Modbus slave station|10H|User-defined protocol | ||
| 1239 | |2H|Modbus RTU slave station|20H|Modbus RTU master station | ||
| 1240 | |3H|Modbus ASCII slave station|30H|Modbus ASCII master station | ||
| 1241 | |||
| 1242 | The corresponding protocol can be set by setting the corresponding value in SD2592. | ||
| 1243 | |||
| 1244 | At present, the parameters directly set to SD2590 are only valid in the first cycle of PLC RUN. | ||
| 1245 | |||
| 1246 | If the parameters need to be modified during RUN, they can be set by PROTOCOL command. | ||
| 1247 | |||
| 1248 | At present, COM1 cannot support the protocol other than W Modbus slave protocol. | ||
| 1249 | |||
| 1250 | 3.Sending interval SD2596 | ||
| 1251 | |||
| 1252 | The main function of sending interval is: to determine how long does it take to wait to send the next command when one command is completed. When 0 is set, it will not wait for sending at specified interval, but it will be affected by scanning period. | ||
| 1253 | |||
| 1254 | The unit of transmission interval is 0.1 ms, i.e. the interval time is 10ms when the value is set to be 100. | ||
| 1255 | |||
| 1256 | 4.Communication timeout SD2597 and timeout retry SD2598 | ||
| 1257 | |||
| 1258 | (% style="text-align:center" %) | ||
| 1259 | [[image:1709716850100-900.png]] | ||
| 1260 | |||
| 1261 | The main function of communication timeout is: to determine when the retry is required or an error needs to be reported when the data is not received after being sent by PLC. When 0 is set, it is 100ms by default. | ||
| 1262 | |||
| 1263 | The unit of transmission interval is 10ms, i.e. the timeout judgment time is 100ms when the value is set to be 10. | ||
| 1264 | |||
| 1265 | When receiving timeout occurs, it will judge whether there are retries and the current retry times. If the retry times are greater than or equal to SD2598, an error will be reported. | ||
| 1266 | |||
| 1267 | If SD2598 is set to 0, no retry is required. | ||
| 1268 | |||
| 1269 | When it is set to 1, send the data once and then send it again after timeout. | ||
| 1270 | |||
| 1271 | (3) Serial port parameter setting | ||
| 1272 | |||
| 1273 | 1.PORTPARA command | ||
| 1274 | |||
| 1275 | -[PORTPARA (s) (n)] | ||
| 1276 | |||
| 1277 | Content, range and data type | ||
| 1278 | |||
| 1279 | |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**|**Custom variable type** | ||
| 1280 | |(s)|Serial port parameters to be set 0~~256|-|Unsigned BIN16 bits|ANY16|INT | ||
| 1281 | |(n)|Which communication port to be set, 0 means COM1, 1 means COM2|((( | ||
| 1282 | -2147483648~~ | ||
| 1283 | |||
| 1284 | 2147483647 | ||
| 1285 | )))|Unsigned BIN16 bits|ANY16|INT | ||
| 1286 | |||
| 1287 | Device used | ||
| 1288 | |||
| 1289 | |=**Instruction**|=**Parameter**|=(% colspan="24" %)**Devices**|=**Index modification**|=**Pulse expansion** | ||
| 1290 | | | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 1291 | |(% colspan="1" rowspan="2" %)PORTPARA|Parameter 1| | | | | | | | | | | |●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 1292 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 1293 | |||
| 1294 | Function | ||
| 1295 | |||
| 1296 | Used to set communication parameters at the time of RUN. | ||
| 1297 | |||
| 1298 | For details, please refer to “PORTPARA Instruction Description”. | ||
| 1299 | |||
| 1300 | 2.PROTOCOL command | ||
| 1301 | |||
| 1302 | -[PROTOCOL (s) (n)] | ||
| 1303 | |||
| 1304 | Content, range and data type | ||
| 1305 | |||
| 1306 | |=**Parameter**|=**Content**|=**Range**|=**Data type**|=**Data type (label)**|=**Custom variable type** | ||
| 1307 | |(s)|Protocol number to be set|0 to 65535|Unsigned BIN16 bits|ANY16|INT | ||
| 1308 | |(n)|Which communication port to be set, 0 means COM1, 1 means COM2|1|Unsigned BIN16 bits|ANY16|INT | ||
| 1309 | |||
| 1310 | Device used | ||
| 1311 | |||
| 1312 | |=**Instruction**|=**Parameter**|=(% colspan="24" %)**Devices**|=**Index modification**|=**Pulse expansion** | ||
| 1313 | | | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 1314 | |(% colspan="1" rowspan="2" %)PROTOCOL|Parameter 1| | | | | | | | | | | |●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 1315 | |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | |●|●| |●|● | ||
| 1316 | |||
| 1317 | Function | ||
| 1318 | |||
| 1319 | It is used to set the communication protocol at the time of RUN, and the above command is actually used to set a specific value for the parameter modification sign. | ||
| 1320 | |||
| 1321 | The specific calculation formula is: (parameter setting value + offset of the corresponding serial port's initial special device + 10)*2 | ||
| 1322 | |||
| 1323 | For example, setting the protocol to Modbus RTU master station (H20), i.e. (0x20 +2593-2590 +10) * 2, which is (32 +3 +10) *2=90, which mainly aims to avoid random modification of serial port parameters during operation. | ||
| 1324 | |||
| 1325 | For Modbus master station protocol, if the set parameters are triggered, the value will be changed only after the command is completely completed. | ||
| 1326 | |||
| 1327 | For Modbus slave station protocol, if the set parameters are triggered, switching can be performed when the received data is not being processed. | ||
| 1328 | |||
| 1329 | For details, please refer to “PROTOCOL Instruction Description”. | ||
| 1330 | |||
| 1331 | 3.Upper computer settings | ||
| 1332 | |||
| 1333 | The PLC parameter setting of the upper computer can set the corresponding serial port parameters. | ||
| 1334 | |||
| 1335 | (% style="text-align:center" %) | ||
| 1336 | [[image:1709717121639-464.png]] | ||
| 1337 | |||
| 1338 | Specific protocol station number cannot be 0 | ||
| 1339 | |||
| 1340 | Station number under Modbus RTU and Modbus ASCII protocol is 0: Protocol sets the master station. | ||
| 1341 | |||
| 1342 | Station number under Modbus RTU and Modbus ASCII protocol is non-0: Protocol sets the slave station. | ||
| 1343 | |||
| 1344 | Serial port parameters are filled in according to the contents in the table. | ||
| 1345 | |||
| 1346 | Note: RTU protocol cannot set 7-bit data bits. | ||
| 1347 | |||
| 1348 | 4.Priority description of serial port parameters | ||
| 1349 | |||
| 1350 | The priority of serial port parameter settings is listed below. | ||
| 1351 | |||
| 1352 | At present, serial port parameters are saved at the time of power failure. | ||
| 1353 | |||
| 1354 | Serial port parameter setting command setting = using ladder diagram MOV command to set corresponding SD device > upper computer downloading parameters > previous data saved at the time of power outage. | ||
| 1355 | |||
| 1356 | (4) Basic ladder diagram | ||
| 1357 | |||
| 1358 | [[image:1709717196041-407.png||height="190" style="float:left" width="409"]] | ||
| 1359 | |||
| 1360 | Serial port parameter setting | ||
| 1361 | |||
| 1362 | Baud rate: 115200, data bit: 8, parity bit: none, stop bit: 1 | ||
| 1363 | |||
| 1364 | Communication protocol setting: ModbusRTU master station protocol | ||
| 1365 | |||
| 1366 | Sending interval: 5ms | ||
| 1367 | |||
| 1368 | Reception timeout: 100ms | ||
| 1369 | |||
| 1370 | Timeout retry times: 3 times | ||
| 1371 | |||
| 1372 | Station number 01H, function code 03H, slave station address 10, length 05 | ||
| 1373 | |||
| 1374 | 1.Sending and receiving process | ||
| 1375 | |||
| 1376 | Modbus master station | ||
| 1377 | |||
| 1378 | When programming, in front of each RS (Modbus mode) command, each operand unit should be assigned with a certain value according to the address of the communication operation object, operation type, operation register address, data number, sending or receiving unit. Once the execution starts, the system program will automatically calculate CRC parity, organize communication frames, and complete the operation of sending data and receiving response. | ||
| 1379 | |||
| 1380 | If Modbus-ASC protocol is used for communication (SD2592 is set to H30), the HEX-ASC format for sending and receiving data is automatically changed by PLC system program, and the method of using RS (Modbus mode) command by users is exactly the same as that of using Modbus-RTU protocol. | ||
| 1381 | |||
| 1382 | In the plc program, if multiple RS (Modbus Mode) commands are driven, when the system program is executed, the next RS command will be processed in the same way after the links of “sending, waiting for response, receiving, checking, analyzing and storing" of one RS command are completed, until all RS commands are executed and started again. Users don't need to care about the timing and process of its execution, which simplifies PLC programming design. This is the advantage of Modbus command. | ||
| 1383 | |||
| 1384 | List of Modbus Master Station Function | ||
| 1385 | |||
| 1386 | |=**Function code**|=**Function name**|=**Details** | ||
| 1387 | |0x01|Coil state readout|Coil state readout (several points) | ||
| 1388 | |0x02|Input readout|Input readout (several) | ||
| 1389 | |0x03|Holding register readout|Holding register readout (several points) | ||
| 1390 | |0x04|Input register readout|Input register readout (several points) | ||
| 1391 | |0x05|1 Coil written|Coil written (only one point) | ||
| 1392 | |0x06|1 Register written|Holding register written (only one point) | ||
| 1393 | |0x0F|Batch coil written|Multi-point coil written | ||
| 1394 | |0x10|Batch register written|Multi-point holding register written | ||
| 1395 | |||
| 1396 | [[image:file:///C:\Users\ADMINI~~1\AppData\Local\Temp\ksohtml13328\wps1.png]]For instance: | ||
| 1397 | |||
| 1398 | [[image:1709789901403-566.png||height="186" style="float:left" width="399"]] Serial port parameter setting | ||
| 1399 | |||
| 1400 | Baud rate: 115200, data bit: 8, parity bit: none, stop bit: 1 | ||
| 1401 | |||
| 1402 | Communication protocol setting: ModbusRTU master station protocol | ||
| 1403 | |||
| 1404 | Sending interval: 5ms | ||
| 1405 | |||
| 1406 | Reception timeout: 100ms | ||
| 1407 | |||
| 1408 | Timeout retry times: 3 times | ||
| 1409 | |||
| 1410 | Station number 01H, function code 03H, slave station | ||
| 1411 | |||
| 1412 | As shown in above ladder diagram: | ||
| 1413 | |||
| 1414 | When M1 is turned ON, PLC will send data (hexadecimal) from COM2 of PLC: 01 03 00 0A 00 05 A5 C8 | ||
| 1415 | |||
| 1416 | 01: represents slave address, the high 8 bits of (s); | ||
| 1417 | |||
| 1418 | 03: Modbus command code, the low 8 bits of (s), which means to read the slave register; | ||
| 1419 | |||
| 1420 | 00 0A: the address of slave register to be read, the value of (m); | ||
| 1421 | |||
| 1422 | 00 05: The number of registers to be read, the value of (d), | ||
| 1423 | |||
| 1424 | A5 C8: CRC parity code | ||
| 1425 | |||
| 1426 | (% class="box infomessage" %) | ||
| 1427 | ((( | ||
| 1428 | **✎Notes** | ||
| 1429 | |||
| 1430 | With 1 coil written (0x05), if 1 is written, the used value is 0xFF00; if 0 is written, the used value is 0x0000. | ||
| 1431 | |||
| 1432 | With batch coil written (0x0F), pay attention to the high and low bytes switching. For example, when writing 1 length, the fourth parameter value is 1 (0x0001), which means sending 0, and only when 256 (0x0100) is written can 1 be written as the target address. | ||
| 1433 | ))) | ||
| 1434 | |||
| 1435 | 2.Modbus slave station | ||
| 1436 | |||
| 1437 | When plc is used as Modbus slave station, it supports communication operation commands such as 0x01, 0x03, 0x05, 0x06, 0x0f and 0x10 of Modbus; through these commands, the coils that can read and write PLC have variables such as M, S, T, C, X (read-only) SM, Y, LC, HSC, etc. Register variables include D, T, C, R, SD, LC and HSC. | ||
| 1438 | |||
| 1439 | When the Modbus communication host accesses (reads or rewrites) the internal variables of PLC slave, it must follow the following definition of communication command frame and variable address index method, so as to carry out normal communication operation. | ||
| 1440 | |||
| 1441 | **①**Instruction code 0x01 (01): read coil | ||
| 1442 | |||
| 1443 | |=**No.**|=**Data (byte) meaning**|=**Number of bytes**|=**Description** | ||
| 1444 | |1|Slave address|1 byte|Take value 1~~247, which is set by SD2544 and SD2594 | ||
| 1445 | |2|0x01 (command code)|1 byte|Read coil | ||
| 1446 | |3|Start address of coil|2 bytes|High bit in the front and low bit in the rear, see the addressing of the coil | ||
| 1447 | |4|Coil number|2 bytes|High bit in the front and low bit in the rear (N) | ||
| 1448 | |5|CRC parity|2 bytes|High bit in the front and low bit in the rear | ||
| 1449 | |||
| 1450 | Response frame format: slave address + 0x01 + bytes + coil status + CRC parity | ||
| 1451 | |||
| 1452 | |=(% style="width: 58px;" %)**No.**|=(% style="width: 139px;" %)**Data (byte) meaning**|=(% style="width: 124px;" %)**Number of bytes**|=(% style="width: 690px;" %)**Description** | ||
| 1453 | |(% style="width:58px" %)1|(% style="width:139px" %)Slave address|(% style="width:124px" %)1 byte|(% style="width:690px" %)Take value 1~~247, which is set by SD2544 and SD2594 | ||
| 1454 | |(% style="width:58px" %)2|(% style="width:139px" %)0x01 (command code)|(% style="width:124px" %)1 byte|(% style="width:690px" %)Read coil | ||
| 1455 | |(% style="width:58px" %)3|(% style="width:139px" %)Number of bytes|(% style="width:124px" %)1 byte|(% style="width:690px" %)Value: [(N+7)/8] | ||
| 1456 | |(% style="width:58px" %)4|(% style="width:139px" %)Coil state|(% style="width:124px" %)[(N+7)/8] bytes|(% style="width:690px" %)Every 8 coils are combined into one byte. If the last coil is less than 8 bits, the undefined part is filled with 0. The first 8 coils are in the first byte, and the coil with the smallest address is in the lowest bit. And so forth. | ||
| 1457 | |(% style="width:58px" %)5|(% style="width:139px" %)CRC parity|(% style="width:124px" %)2 bytes|(% style="width:690px" %)High bit in the front and low bit in the rear | ||
| 1458 | |||
| 1459 | Error response: see error response frame | ||
| 1460 | |||
| 1461 | ② Instruction code 0x03 (03): read register | ||
| 1462 | |||
| 1463 | Request frame format: slave address+ 0x03 + register start address + register number + CRC parity. | ||
| 1464 | |||
| 1465 | |=**No.**|=**Data (byte) meaning**|=**Number of bytes**|=**Description** | ||
| 1466 | |1|Slave address|1 byte|Take value 1~~247, which is set by SD2544 and SD2594 | ||
| 1467 | |2|0x03 (command code)|1 byte|Read register | ||
| 1468 | |3|Register start address|2 bytes|High bit in the front and low bit in the rear, see the addressing of the register | ||
| 1469 | |4|Register number|2 bytes|High bit in the front and low bit in the rear (N) | ||
| 1470 | |5|CRC parity|2 bytes|High bit in the front and low bit in the rear | ||
| 1471 | |||
| 1472 | |=**No.**|=**Data (byte) meaning**|=**Number of bytes**|=**Description** | ||
| 1473 | |1|Slave address|1 byte|Take value 1~~247, which is set by SD2544 and SD2594 | ||
| 1474 | |2|0x03 (command code)|1 byte|Read register | ||
| 1475 | |3|Number of bytes|1 byte|Value: N*2 | ||
| 1476 | |4|Register value|N*2 bytes|Every two bytes represents a register value, with high bit in the front and low bit in the rear. Register with small address comes first | ||
| 1477 | |5|CRC parity|2 bytes|High bit in the front and low bit in the rear | ||
| 1478 | |||
| 1479 | Response frame format: slave address+0x03+bytes+register value +CRC parity. | ||
| 1480 | |||
| 1481 | Error response: see error response frame | ||
| 1482 | |||
| 1483 | ③ Instruction code 0x05 (05): write single coil | ||
| 1484 | |||
| 1485 | Response frame format: slave address + 0x05+ bytes + coil address + CRC parity | ||
| 1486 | |||
| 1487 | |=**No.**|=**Data (byte) meaning**|=**Number of bytes**|=**Description** | ||
| 1488 | |1|Slave address|1 byte|Take value 1~~247, which is set by SD2544 and SD2594 | ||
| 1489 | |2|0x05 (command code)|1 byte|Write single coil | ||
| 1490 | |3|Coil address|2 bytes|High bit in the front and low bit in the rear, see the addressing of the coil | ||
| 1491 | |4|Coil state|2 bytes|High bit in the front and low bit in the rear. If the value is not 0, it is valid. | ||
| 1492 | |5|CRC parity|2 bytes|High bit in the front and low bit in the rear | ||
| 1493 | |||
| 1494 | Response frame format: slave address+0x05+coil address+ coil state+ CRC parity. | ||
| 1495 | |||
| 1496 | |=**No.**|=**Data (byte) meaning**|=**Number of bytes**|=**Description** | ||
| 1497 | |1|Slave address|1 byte|Take value 1~~247, which is set by SD2544 and SD2594. | ||
| 1498 | |2|0x05 (command code)|1 byte|Write single coil | ||
| 1499 | |3|Coil address|2 bytes|High bit in the front and low bit in the rear, see the addressing of the coil | ||
| 1500 | |4|Coil state|2 bytes|High bit in the front and low bit in the rear. If the value is not 0, it is valid. | ||
| 1501 | |5|CRC parity|2 bytes|High bit in the front and low bit in the rear | ||
| 1502 | |||
| 1503 | Error response: see error response frame | ||
| 1504 | |||
| 1505 | Wherein the coil state 0xFF00 means being set as ON and 0x0000 means being set as OFF. | ||
| 1506 | |||
| 1507 | ④ Instruction code 0x06 (06): write single register | ||
| 1508 | |||
| 1509 | Request frame format: slave address+ 0x06 + register address + register value + CRC parity. | ||
| 1510 | |||
| 1511 | |=**No.**|=**Data (byte) meaning**|=**Number of bytes**|=**Description** | ||
| 1512 | |1|Slave address|1 byte|Take value 1~~247, which is set by SD2544 and SD2594 | ||
| 1513 | |2|0x06 (command code)|1 byte|Write single register | ||
| 1514 | |3|Register address|2 bytes|High bit in the front and low bit in the rear, see the addressing of the register | ||
| 1515 | |4|Register value|2 bytes|High bit in the front and low bit in the rear. If the value is not 0, it is valid. | ||
| 1516 | |5|CRC parity|2 bytes|High bit in the front and low bit in the rear | ||
| 1517 | |||
| 1518 | Response frame format: slave address+0x06+register address+ register value+ CRC parity. | ||
| 1519 | |||
| 1520 | |=**No.**|=**Data (byte) meaning**|=**Number of bytes**|=**Description** | ||
| 1521 | |1|Slave address|1 byte|Take value 1~~247, which is set by SD2544 and SD2594 | ||
| 1522 | |2|0x06 (command code)|1 byte|Write single register | ||
| 1523 | |3|Register address|2 bytes|High bit in the front and low bit in the rear, see the addressing of the register | ||
| 1524 | |4|Register value|2 bytes|High bit in the front and low bit in the rear. If the value is not 0, it is valid. | ||
| 1525 | |5|CRC parity|2 bytes|High bit in the front and low bit in the rear | ||
| 1526 | |||
| 1527 | Error response: see error response frame. | ||
| 1528 | |||
| 1529 | ⑤ Instruction code 0x0f (15): write multiple coils | ||
| 1530 | |||
| 1531 | Request frame format: slave address + 0x 0f+ coil start address + coil number+ number of bytes+ coil state+ CRC parity. | ||
| 1532 | |||
| 1533 | |=**No.**|=**Data (byte) meaning**|=**Number of bytes**|=**Description** | ||
| 1534 | |1|Slave address|1 byte|Take value 1~~247, which is set by SD2544 and SD2594 | ||
| 1535 | |2|0x 0f (command code)|1 byte|Write multiple coils | ||
| 1536 | |3|Start address of coil|2 bytes|High bit in the front and low bit in the rear, see the addressing of the coil | ||
| 1537 | |4|Coil number|2 bytes|High bit in the front and low bit in the rear. N, maximum value: 1968 | ||
| 1538 | |5|Number of bytes|1 byte|Value: [(N+7)/8] | ||
| 1539 | |6|Coil state|[(N+7)/8] bytes|Every 8 coils are combined into one byte. If the last coil is less than 8 bits, the undefined part is filled with 0. The first 8 coils are in the first byte, and the coil with the smallest address is in the lowest bit. And so forth. | ||
| 1540 | |7|CRC parity|2 bytes|High bit in the front and low bit in the rear | ||
| 1541 | |||
| 1542 | Response frame format: slave address+ 0x 0f +coil start address+ coil number+ CRC parity | ||
| 1543 | |||
| 1544 | |=**No.**|=**Data (byte) meaning**|=**Number of bytes**|=**Description** | ||
| 1545 | |1|Slave address|1 byte|Take value 1~~247, which is set by SD2544 and SD2594 | ||
| 1546 | |2|0x 0f (command code)|1 byte|Write multiple coils | ||
| 1547 | |3|Start address of coil|2 bytes|High bit in the front and low bit in the rear, see the addressing of the coil | ||
| 1548 | |4|Coil number|2 bytes|High bit in the front and low bit in the rear. | ||
| 1549 | |5|CRC parity|2 bytes|High bit in the front and low bit in the rear | ||
| 1550 | |||
| 1551 | Error response: see error response frame | ||
| 1552 | |||
| 1553 | ⑥ Instruction code 0x10 (16): write multiple registers | ||
| 1554 | |||
| 1555 | Request frame format: slave address+ 0x10 + register start address + register number +number of bytes+ register value+ CRC parity. | ||
| 1556 | |||
| 1557 | |=**No.**|=**Data (byte) meaning**|=**Number of bytes**|=**Description** | ||
| 1558 | |1|Slave address|1 byte|Take value 1~~247, which is set by SD2544 and SD2594 | ||
| 1559 | |2|0x10 (command code)|1 byte|Write multiple registers | ||
| 1560 | |3|Register start address|2 bytes|High bit in the front and low bit in the rear, see the addressing of the register | ||
| 1561 | |4|Register number|2 bytes|High bit in the front and low bit in the rear. N, maximum value: 120 | ||
| 1562 | |5|Number of bytes|1 byte|Value: N*2 | ||
| 1563 | |6|Register value|N*2 (N*4)| | ||
| 1564 | |7|CRC parity|2 bytes|High bit in the front and low bit in the rear | ||
| 1565 | |||
| 1566 | Response frame format: slave address+0x10+ register start address+ register number + CRC parity. | ||
| 1567 | |||
| 1568 | |=**No.**|=**Data (byte) meaning**|=**Number of bytes**|=**Description** | ||
| 1569 | |1|Slave address|1 byte|Take value 1~~247, which is set by SD2544 and SD2594 | ||
| 1570 | |2|0x10 (command code)|1 byte|Write multiple registers | ||
| 1571 | |3|Register start address|2 bytes|High bit in the front and low bit in the rear, see the addressing of the register | ||
| 1572 | |4|Register number|2 bytes|High bit in the front and low bit in the rear. N, maximum value: 120 | ||
| 1573 | |5|CRC parity|2 bytes|High bit in the front and low bit in the rear | ||
| 1574 | |||
| 1575 | Error response: see error response frame | ||
| 1576 | |||
| 1577 | ⑦ Error response frame | ||
| 1578 | |||
| 1579 | Error response: slave address + (command code + 0x80) + error code + CRC parity. | ||
| 1580 | |||
| 1581 | |=**No.**|=**Data (byte) meaning**|=**Number of bytes**|=**Description** | ||
| 1582 | |1|Slave address|1 byte|Take value 1~~247, which is set by SD2544 and SD2594 | ||
| 1583 | |2|Instruction code+0x80|1 byte|Error command code | ||
| 1584 | |3|Error code|1 byte|1 to 4 | ||
| 1585 | |4|CRC parity|2 bytes|High bit in the front and low bit in the rear | ||
| 1586 | |||
| 1587 | |=(% style="width: 88px;" %)**No.**|=(% style="width: 276px;" %)**Error code**|=**Description** | ||
| 1588 | |(% style="width:88px" %)1|(% style="width:276px" %)01|Not supported function codes | ||
| 1589 | |(% style="width:88px" %)2|(% style="width:276px" %)02|Wrong address or function code | ||
| 1590 | |(% style="width:88px" %)3|(% style="width:276px" %)03|Wrong length | ||
| 1591 | |(% style="width:88px" %)4|(% style="width:276px" %)04|Incomplete command | ||
| 1592 | |(% style="width:88px" %)5|(% style="width:276px" %)05|Address not allowed | ||
| 1593 | |||
| 1594 | **⑧Slave station address table** | ||
| 1595 | |||
| 1596 | |=(% colspan="5" %)**Word address** | ||
| 1597 | |**Address type**|**Occupation**|**Address range**|**Decimal address**|**Total reserved address size** | ||
| 1598 | |T0 to T511|512 WORD|0x0000 to 0x01ff|0|1536 | ||
| 1599 | |C0~~C255|256 WORD|0x0600 to 0x06ff|1536|1024 | ||
| 1600 | |LC0 to LC255|512 WORD|0x0A000 to 0x0BFF|2560|1024 | ||
| 1601 | |HSC0 to HSC15|128 WORD|0x0E00 to 0x0E1F|3584|512 | ||
| 1602 | |D0~~D7999|8000 WORD|0x1000 to 0x2F3F|4096|16384 | ||
| 1603 | |SD0 to SD4095|4096 WORD|0x5000 to 0x5FFF|20480|12288 | ||
| 1604 | |R0~~R30000|30000 WORD|0x8000 to 0xF52F|32768|30000 | ||
| 1605 | |||
| 1606 | |=(% colspan="5" %)**Bit address** | ||
| 1607 | |**Address type**|**Occupation**|**Address range**|**Decimal address**|**Total reserved address size** | ||
| 1608 | |T0 to T511|512 bit|0x0000 to 0x01ff|0|1536 | ||
| 1609 | |C0~~C255|256 bit-|0x0600 to 0x06ff|1536|1024 | ||
| 1610 | |LC0 to LC255|256 bit-|0x0A00 to 0x0AFF|2560|1024 | ||
| 1611 | |HSC0 to HSC15|64 bit|0x0E00 to 0x0E0F|3584|512 | ||
| 1612 | |M0 to M8000|8192 bit|0x1000 to 0x2F3F|4096|16384 | ||
| 1613 | |SM0~~SM4095|4096 bit|0x5000 to 0x5FFF|20480|12288 | ||
| 1614 | |Reserved| |0x8000 to 0xBFFF| |16383 | ||
| 1615 | |S0 to S4095|4096 bit|0xC000 to 0xCFFF|49152|8192 | ||
| 1616 | |X0 to X1777|1024 bit-|0xE000 to 0xE3FF|57344|4096 | ||
| 1617 | |Y0~~Y1777|1024 bit-|0xF000 to 0xF3FF|61440|4096 | ||
| 1618 | |||
| 1619 | Error information | ||
| 1620 | |||
| 1621 | The current error code will be displayed in the SD7, SD0, SD2611 and SD2612. | ||
| 1622 | |||
| 1623 | The error codes that will occur in Modbus protocols are mainly shown as follows: | ||
| 1624 | |||
| 1625 | |=**Error code**|=**Content** | ||
| 1626 | |4085H|(s), (m), (d) and (n) read address exceeds the range of the device (this error is displayed in SD7 and SD0 only). | ||
| 1627 | |3180H|COM2 data reception error. There may be interference on the communication cable, it is recommended to connect GND. | ||
| 1628 | |3181H|COM2 data reception timeout. Check the wiring, whether the serial port parameter settings correspond to master and slave, and whether there is interference. Check whether it is caused by the late response from slave station. It is recommended to increase the sending interval SD2546. | ||
| 1629 | |3182H|COM2 CRC parity error. There may be interference on the communication cable, it is recommended to connect GND. | ||
| 1630 | |3183H|COM2 LRC parity error. There may be interference on the communication cable, it is recommended to connect GND. | ||
| 1631 | |3184H|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 slave station. | ||
| 1632 | |3185H|COM2 send buffer overflow If this error message appears, please contact technical personnel. | ||
| 1633 | |3186H|COM2 function code is wrong. Check whether the set function code is a function code supported by PLC. | ||
| 1634 | |3187H|COM2 address is wrong. Check whether the slave station has this address. (Please refer to Modbus exception 02). | ||
| 1635 | |3188H|The length of COM2 is wrong. Check whether the communication length exceeds the length range specified by Modbus protocol or user-defined protocol. | ||
| 1636 | |3189H|((( | ||
| 1637 | COM2 data error. Check whether parameters of the command are wrong. Check whether the set value is supported by the slave station. | ||
| 1638 | |||
| 1639 | (Please refer to Modbus exception 03). | ||
| 1640 | ))) | ||
| 1641 | |318AH|COM2 slave station is busy. Message returned from slave station: Slave station is busy. (Please refer to Modbus exception 06). | ||
| 1642 | |318BH|COM2 slave station does not support function codes. Check whether this function code is supported by the slave station. (Please refer to Modbus exception 01). | ||
| 1643 | |318CH|COM2 slave station is faulty. Message returned from slave station: Slave station failed, please check whether slave station failed. (Please refer to Modbus exception 04). | ||
| 1644 | |318DH|COM2 slave station confirmation. Message returned from slave station: slave station confirmation. (Please refer to Modbus exception 05). | ||
| 1645 | |318EH|At present, COM2 does not support this command or function. When the slave protocol is set, the communication commands related to master station or master station functions cannot be used. Please change the protocol or close the contact before the corresponding command or close the corresponding communication function. | ||
| 1646 | |318FH|COM2 sending timeout. If this error message appears, please contact technical personnel. | ||
| 1647 | |3190H|COM2 receives data beyond the cache limit. | ||
| 1648 | |31A0H|No available gateway for COM2 Message returned from the slave station: no available gateway. (Please refer to Modbus exception 0A). | ||
| 1649 | |31A1H|COM2 indicates that no response was obtained from the target device. Message returned from the slave station: The device is not networked. (Please refer to Modbus Exception 0B). | ||
| 1650 | |||
| 1651 | After resetting the protocol or communication parameters, the reported errors will be cleared. | ||
| 1652 | |||
| 1653 | In addition, in case of communication completion/communication error/communication timeout, the sign bit will be set after executing the command. | ||
| 1654 | |||
| 1655 | |||
| 1656 | == **WECON Modbus Protocol Description** == | ||
| 1657 | |||
| 1658 | ---- | ||
| 1659 | |||
| 1660 | At present, WECON Modbus protocol description (special protocol) is modified based on Modbus RTU protocol. | ||
| 1661 | |||
| 1662 | Therefore, 7-bit data bits cannot be used in serial port parameters. | ||
| 1663 | |||
| 1664 | This protocol is fully compatible with Modbus RTU protocol, and the address is the same as the default address of Modbus RTU protocol of LX6V PLC. | ||
| 1665 | |||
| 1666 | The extended function is mainly used to communicate with PLC Editor 2. | ||
| 1667 | |||
| 1668 | == [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps2.png]][[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps3.png]]**10.7 Communication function block** == | ||
| 1669 | |||
| 1670 | === [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps4.png]]**1. SERIAL_MODBUS_WR** === | ||
| 1671 | |||
| 1672 | SERIAL_MODBUS_WR - Modbus master serial communication | ||
| 1673 | |||
| 1674 | [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps5.jpg]] | ||
| 1675 | |||
| 1676 | This function block is the setting function block for sending protocol frames by the Modbus master station (whether RTU or ASCII). When the contact in front of Enable is turned ON, according to the communication port, station number, function code, slave station address, quantity and mapped data address set by the function block, the data frame is combined and sent. | ||
| 1677 | |||
| 1678 | **Device used** | ||
| 1679 | |||
| 1680 | |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Device**|((( | ||
| 1681 | **Offset** | ||
| 1682 | |||
| 1683 | **Modification** | ||
| 1684 | )))|((( | ||
| 1685 | **Pulse** | ||
| 1686 | |||
| 1687 | **Expansion** | ||
| 1688 | ))) | ||
| 1689 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 1690 | |(% rowspan="15" %)((( | ||
| 1691 | SERIAL | ||
| 1692 | |||
| 1693 | MODBUS_WR | ||
| 1694 | )))|Enable|●|●|●|●|●| | | | | | | | | | | | |●|●| | | | | | | | ||
| 1695 | |CommunicationPort| | | | | | | | | | | | |●|●|●|●|●| | | | | | | | | | ||
| 1696 | |SlaveID| | | | | | | | | | | | |●|●|●|●|●| | | | | | | | | | ||
| 1697 | |FunctionCode| | | | | | | | | | | | |●|●|●|●|●| | | | | | | | | | ||
| 1698 | |SlaveAddress| | | | | | | | | | | | |●|●|●|●|●| | | | | | | | | | ||
| 1699 | |Count| | | | | | | | | | | | |●|●|●|●|●| | | | | | | | | | ||
| 1700 | |Data| | | | | | | | | | | | | | |●|●| | | | | | | | | | | ||
| 1701 | |Done| |●|●|●|●| | | | | | | | | | | | | |●| | | | | | | | ||
| 1702 | |Busy| |●|●|●|●| | | | | | | | | | | | | |●| | | | | | | | ||
| 1703 | |InVelocity| |●|●|●|●| | | | | | | | | | | | | |●| | | | | | | | ||
| 1704 | |Busy| |●|●|●|●| | | | | | | | | | | | | |●| | | | | | | | ||
| 1705 | |Active| | | | | | | | | | | | | | |●|●| | | | | | | | | | | ||
| 1706 | |CommandAborted|●|●|●|●|●| | | | | | | | | | | | |●|●| | | | | | | | ||
| 1707 | |Error| | | | | | | | | | | | |●|●|●|●|●| | | | | | | | | | ||
| 1708 | |ErrorID| | | | | | | | | | | | |●|●|●|●|●| | | | | | | | | | ||
| 1709 | |||
| 1710 | **Variable Type Used** | ||
| 1711 | |||
| 1712 | |**Instruction**|((( | ||
| 1713 | **Pin** | ||
| 1714 | |||
| 1715 | **Type** | ||
| 1716 | )))|**Parameter**|((( | ||
| 1717 | **Variable** | ||
| 1718 | |||
| 1719 | **Type** | ||
| 1720 | )))|((( | ||
| 1721 | **Can you** | ||
| 1722 | |||
| 1723 | **Is empty** | ||
| 1724 | )))|**Range**|**Description** | ||
| 1725 | |(% rowspan="12" %)((( | ||
| 1726 | SERIAL | ||
| 1727 | |||
| 1728 | MODBUS_WR | ||
| 1729 | )))|(% rowspan="7" %)Input|Enable|BOOL|No|TRUE/FALSE|Enable sending Modbus master serial communication data | ||
| 1730 | |CommunicationPort|UINT|No|[0,1]|((( | ||
| 1731 | Communication port | ||
| 1732 | |||
| 1733 | 0: Serial port 1 | ||
| 1734 | |||
| 1735 | 1: Serial port 2 | ||
| 1736 | ))) | ||
| 1737 | |SlaveID|UINT|No|[0,255]|Station number of slave station | ||
| 1738 | |FunctionCode|UINT|No|1/2/3/4/5/6/15/16|Function code | ||
| 1739 | |SlaveAddress|UINT|No|[0,65535]|The slave address ( the address provided by the slave station) will read or write data from this address of the slave station. | ||
| 1740 | |Count|UINT|No|-|((( | ||
| 1741 | Number | ||
| 1742 | |||
| 1743 | The number of Modbus reads or writes, and the unit is determined by the function code. | ||
| 1744 | ))) | ||
| 1745 | |Data|ANY|No|-|The starting address for reading or writing data | ||
| 1746 | |(% rowspan="5" %)Output|Done|BOOL|Yes|TRUE/FALSE|Instruction completed | ||
| 1747 | |Busy|BOOL|Yes|TRUE/FALSE|Serial port busy | ||
| 1748 | |Active|BOOL|Yes|TRUE/FALSE|Instruction working | ||
| 1749 | |Error|BOOL|Yes|TRUE/FALSE|Error | ||
| 1750 | |ErrorID|DWORD|Yes|Refer to ErrorID for details|Error code | ||
| 1751 | |||
| 1752 | **Function** | ||
| 1753 | |||
| 1754 | Enable the MB_SERIAL function block to send the specified Modbus master serial communication data for reading from or writing to a slave station. | ||
| 1755 | |||
| 1756 | **Notice** | ||
| 1757 | |||
| 1758 | (1) If and only if the function block Enable is enabled, update the current serial communication instruction sending status; | ||
| 1759 | |||
| 1760 | (2) If two or more serial port instructions use the same serial port in the scanning program, the corresponding serial port instructions will wait for the execution of the previous serial port instruction to be completed according to the instruction order, and then execute their own communication instructions; | ||
| 1761 | |||
| 1762 | (3) If two or more serial port instructions use different serial ports in the scanning program, the corresponding serial port instructions will be executed in sequence according to the instruction order without affecting each other; | ||
| 1763 | |||
| 1764 | (4) Busy means that the serial port is busing and Active means that the current instruction is being executed. | ||
| 1765 | |||
| 1766 | **Modbus protocol** | ||
| 1767 | |||
| 1768 | When the protocol is set to Modbus master protocol (whether RTU or ASCII). When the contact in front of the MB_SERIAL function block is ON, the MB_SERIAL function block will send a combined data frame at the designated communication port according to the station number, function code, slave station address, quantity, and data starting address. | ||
| 1769 | |||
| 1770 | **Error code** | ||
| 1771 | |||
| 1772 | |**Error code**|**Content** | ||
| 1773 | |4084H|CommunicationPort input error (0: Serial port 1, 1: Serial port 2). | ||
| 1774 | |408FH|The firmware does not support this instruction, and needs to be upgraded. | ||
| 1775 | |4096H|The settings of Count and Data are outside the range of variables. | ||
| 1776 | |3180H|COM2 reception error There may be interference on the communication cable, it is recommended to connect GND. | ||
| 1777 | |3181H|COM2 data reception timeout. Check the wiring, whether the serial port parameter settings correspond to master and slave, and whether there is interference. Check whether it is caused by the late response from the slave station. It is recommended to increase the sending interval SD2546. | ||
| 1778 | |3182H|COM2 CRC parity error. There may be interference on the communication cable, it is recommended to connect GND. | ||
| 1779 | |3183H|COM2 LRC parity error. There may be interference on the communication cable, it is recommended to connect GND. | ||
| 1780 | |3184H|The COM2 station number is configuration error Check the slave station number setting, and check whether there is any problem with the receiving and sending mechanism from slave station. | ||
| 1781 | |3185H|COM2 send buffer overflow If this error message appears, please contact technical personnel. | ||
| 1782 | |3186H|COM2 function code is error. Check whether the set function code is a function code supported by PLC. | ||
| 1783 | |3187H|COM2 address error. Check whether the slave station has this address. (Please refer to Modbus exception 02) | ||
| 1784 | |3188H|The length of COM2 is wrong. Check whether the communication length exceeds the length range specified by Modbus protocol or user-defined protocol. | ||
| 1785 | |3189H|COM2 data error. Check whether parameters of the command are wrong. Check whether the set value is supported by the slave station. (Please refer to Modbus exception 03). | ||
| 1786 | |318AH|COM2 slave station is busy. Slave station return information: Slave station is busy (Please refer to Modbus exception 06). | ||
| 1787 | |318BH|COM2 slave station does not support function codes. Check whether this function code is supported by the slave station. (Please refer to Modbus exception 01) | ||
| 1788 | |318CH|COM2 slave failure. Slave station return information: Slave station failure, please check whether the slave station fails. (Please refer to Modbus exception 04) | ||
| 1789 | |318DH|COM2 slave station confirmation. Slave station return information: Slave confirmation (Please refer to Modbus exception 05) | ||
| 1790 | |318EH|At present, COM2 does not support this command or function. When the slave protocol is set, the communication commands related to master station or master station functions cannot be used. Please change the protocol or close the contact in front of the corresponding command or close the corresponding communication function. | ||
| 1791 | |318FH|COM2 sending timeout. If this error message appears, please contact technical personnel. | ||
| 1792 | |31A0H|No available gateway for COM2 Slave station return information: Unavailable gateway (Please refer to Modbus exception 0A) | ||
| 1793 | |31A1H|COM2 indicates that no response was obtained from the target device. Slave station return information: The device is not in the network. (Please refer to Modbus exception 0B) | ||
| 1794 | |||
| 1795 | |||
| 1796 | **Example** | ||
| 1797 | |||
| 1798 | **Application example** | ||
| 1799 | |||
| 1800 | Set the COM2 communication parameters through the SD device. | ||
| 1801 | |||
| 1802 | [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps6.jpg]] | ||
| 1803 | |||
| 1804 | Enable the function block and its Enable pin, send Modbus serial port master data and wait for the slave respond. Done indicates that the current instruction has been executed, Busy indicates that the serial port is busy, and Active indicates that the current instruction is running (waiting for data to be returned from the slave station). | ||
| 1805 | |||
| 1806 | [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps7.jpg]] | ||
| 1807 | |||
| 1808 | |||
| 1809 | 1. **SERIAL_WR** | ||
| 1810 | |||
| 1811 | [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps8.png]]SERIAL_WR - Custom protocol serial communication | ||
| 1812 | |||
| 1813 | [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps9.jpg]] | ||
| 1814 | |||
| 1815 | This function block is a setting function block for user defined protocol serial port to send protocol frames. When the contact in front of Enable is turned ON. According to the communication port, sending data mapping address, sending data length, receiving data mapping address, and receiving data length set by the function block, the data frame is sent and waits for the data of the specified length to be returned. | ||
| 1816 | |||
| 1817 | **Device used** | ||
| 1818 | |||
| 1819 | |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="22" %)**Device**|((( | ||
| 1820 | **Offset** | ||
| 1821 | |||
| 1822 | **Modification** | ||
| 1823 | )))|((( | ||
| 1824 | **Pulse** | ||
| 1825 | |||
| 1826 | **Expansion** | ||
| 1827 | ))) | ||
| 1828 | |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP** | ||
| 1829 | |(% rowspan="11" %)SERIAL_WR|Enable|●|●|●|●|●| | | | | | | | | | | | | | | | | | | | ||
| 1830 | |CommunicationPort| | | | | | | | | | | | |●|●|●|●|●| | | | | | | | ||
| 1831 | |SendData| | | | | | | | | | | | | | |●|●| | | | | | | | | ||
| 1832 | |SendDataLength| | | | | | | | | | | | |●|●|●|●|●| | | | | | | | ||
| 1833 | |ReceiveData| | | | | | | | | | | | | | |●|●| | | | | | | | | ||
| 1834 | |ReceiveDataLength| | | | | | | | | | | | |●|●|●|●|●| | | | | | | | ||
| 1835 | |Done| |●|●|●|●| | | | | | | | | | | | | | | | | | | | ||
| 1836 | |Busy| |●|●|●|●| | | | | | | | | | | | | | | | | | | | ||
| 1837 | |Active| |●|●|●|●| | | | | | | | | | | | | | | | | | | | ||
| 1838 | |Error| |●|●|●|●| | | | | | | | | | | | | | | | | | | | ||
| 1839 | |ErrorID| | | | | | | | | | | | | | |●|●| | | | | | | | | ||
| 1840 | |||
| 1841 | **Variable Type Used** | ||
| 1842 | |||
| 1843 | |**Instruction**|**Pin Type**|**Parameter**|**Variable Type**|**Can it be empty**|**Range**|**Description** | ||
| 1844 | |(% rowspan="11" %)SERIAL_WR|(% rowspan="6" %)Input|Enable|BOOL|No|TRUE/FALSE|Enable sending protocol-less serial communication data | ||
| 1845 | |CommunicationPort|UINT|No|[0,1]|Communication port, 0: Serial port 1, 1: Serial port 2 | ||
| 1846 | |SendData|ANY|No|-|Starting address for sending data | ||
| 1847 | |SendDataLength|UINT|No|[0,523]|Send data length, in bytes | ||
| 1848 | |ReceiveData|ANY|No|-|Starting address for receiving data | ||
| 1849 | |ReceiveDataLength|UINT|No|[0,523]|Length of received data, in bytes | ||
| 1850 | |(% rowspan="5" %)Output|Done|BOOL|Yes|TRUE/FALSE|Instruction completed | ||
| 1851 | |Busy|BOOL|Yes|TRUE/FALSE|Serial port busy | ||
| 1852 | |Active|BOOL|Yes|TRUE/FALSE|Instruction working | ||
| 1853 | |Error|BOOL|Yes|TRUE/FALSE|Error | ||
| 1854 | |ErrorID|DWORD|Yes|Refer to ErrorID for details|Error code | ||
| 1855 | |||
| 1856 | **Function** | ||
| 1857 | |||
| 1858 | * Enable the PROTOCOLLESS_SERIAL function block, which can send the serial communication data of the specified custom protocol master station and wait for the data return of the slave station. | ||
| 1859 | |||
| 1860 | **Notice** | ||
| 1861 | |||
| 1862 | * If and only if the function block Enable is enabled, updating the current serial communication instruction sending state; | ||
| 1863 | * If two or more serial communication instructions are used simultaneously in the scanning program, the corresponding communication instructions are sequentially executed according to the instruction sequence; | ||
| 1864 | * Busy indicates that the serial port is busy, and Active indicates that the current instruction is being executed. | ||
| 1865 | |||
| 1866 | **User-defined protocol** | ||
| 1867 | |||
| 1868 | When the protocol is set to a custom protocol. When the contact in front of the PROTOCOLLESS_SERIAL function block is ON,The PROTOCOLLESS_ SERIAL function block will send the data starting address and sending data length in the specified communication port to send the combined data frame, and wait for the data of the received data length to be filled in the received data starting address. | ||
| 1869 | |||
| 1870 | * When the length of the transmitted data is set to 0, the mapping address of the transmitted data may not be filled in. At this time, the PROTOCOLLESS_SERIAL function block only receives data; | ||
| 1871 | * When the received data length is set to 0, the received data mapping address may not be filled in. At this time, the PROTOCOLLESS_SERIAL function block only sends data. | ||
| 1872 | |||
| 1873 | **Error code** | ||
| 1874 | |||
| 1875 | |**Error code**|**Content** | ||
| 1876 | |4084H|CommunicationPort input error (0: Serial port 1, 1: Serial port 2). | ||
| 1877 | |5:|The setting of SendDataLength and SendData or ReceiveDataLength and ReceiveData is outside the scope of the variable. | ||
| 1878 | |3181H|Data reception timeout | ||
| 1879 | |318EH|((( | ||
| 1880 | At present, COM2 does not support this command or function. | ||
| 1881 | |||
| 1882 | When set to the slave protocol, the communication instructions related to the master station or the master station function cannot be used. | ||
| 1883 | |||
| 1884 | Please change the protocol or close the contact in front of the corresponding command or close the corresponding communication function. | ||
| 1885 | ))) | ||
| 1886 | |318FH|((( | ||
| 1887 | COM2 data reception timeout. | ||
| 1888 | |||
| 1889 | * Check wiring; | ||
| 1890 | * Check whether the serial port parameter settings are master-slave corresponding; | ||
| 1891 | * Check whether there is any interference; | ||
| 1892 | * Check whether it is caused by the late response from the slave station. | ||
| 1893 | |||
| 1894 | It is recommended to increase the sending interval SD2546. | ||
| 1895 | ))) | ||
| 1896 | |3190H|COM2 receives data beyond the cache limit. | ||
| 1897 | |||
| 1898 | |||
| 1899 | **Example** | ||
| 1900 | |||
| 1901 | **Application example** | ||
| 1902 | |||
| 1903 | * Set the COM2 communication parameters through the SD device. | ||
| 1904 | |||
| 1905 | [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps10.jpg]] | ||
| 1906 | |||
| 1907 | Enables the function block and the Enable pin of the function block, sends custom protocol data and waits for the slave to respond. Done indicates that the current instruction has been executed, Busy indicates that the serial port is busy, and Active indicates that the current instruction is running (waiting for data to be returned from the slave station). |