10 Communication
Communication
Protocol
PROTOCOL(P)
Set (s) protocol for (N) communication port.
-[PROTOCOL (S) (N)]
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(S) | Protocol number to be set | - | Unsigned BIN 16 bit | ANY16 |
(N) | Which communication port to set, 0 means COM1, 1 means COM2 *1 | 0, 1 | Unsigned BIN 16 bit | ANY16 |
Device used
Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||
KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
PROTOCOL | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Features
This instruction is mainly used to set the protocol during run, and can also be used in the first cycle of run.
The value of the protocol address (COM1 SD2542, COM2 SD2592) and the protocol modification flag (COM1 SD2543, COM2 SD2593) can be directly set according to the command parameters.
The specific calculation formula for setting the protocol modification flag (COM1 SD2543, COM2 SD2593) is: (parameter setting value + offset of the corresponding serial port's initial special soft component + 10)*2
For example, setting the protocol to 2 is (2 +2593-2590 +10)*2, which is (2+3+10) *2=30. At this time, SD2592 will be set to 1, and SD2593 will be set to 32.
Regarding the protocol modification flags (COM1 SD2543, COM2 SD2593): During the RUN process, the first cycle of setting the protocol and modifying the flags is correct (judging at END) to the correct first cycle. When the modification is completed, the protocol modification flags (COM1 SD2543, COM2 SD2593) is cleared, and then set the same value will not be processed. Mainly to avoid repeated settings multiple times.
Protocol Number
Protocol Number | Content |
0 H | Wecon Modbus slave |
2 H | ModbusRTU slave |
3 H | ModbusASCII slave |
10 H | User-defined protocol |
20 H | ModbusRTU master station |
30 H | ModbusASCII master |
Related software components
Devices | Content |
SD2542 | COM1 protocol settings |
SD2543 | COM1 protocol modification sign |
SD2592 | COM2 protocol settings |
SD2593 | COM2 protocol modification sign |
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.
Error code
Error code | Content |
4085H | The read address of (s) and (N) exceeds the device range |
4084H | (N) is not 1 |
Example
Example above
M1 changes from OFF to ON during the run
SD2592 will be set to 32 (20H), SD2593 will be set to 90 and then it will be cleared. At this time, it means that the setting is successful.
If you turn M1 from OFF to ON again
SD2592 will be set to 32 (20H), SD2593 will be set to 90 but will not be cleared.
Modbus serial port parameter settings
PORTPARA/Modbus serial port parameter setting
PORTPARA(P)
Set (s) serial port parameters for (N) communication port.
-[PORTPARA (s) (N)]
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(s) | Serial port parameters to be set | - | Unsigned BIN 16 bit | ANY16 |
(N) | Which communication port to set, 0 means COM1, 1 means COM2 | 0, 1 | Unsigned BIN 16 bit | ANY16 |
Device used
Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||
KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
ECAMCUT | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Features
This instruction is mainly used to set serial port parameters during run, and can also be used in the first cycle of run.
Can directly set the serial port parameter address (COM1 SD2540, COM2 SD2590) and the value of the serial parameter modification flag (COM1 SD2541, COM2 SD2591) according to the command parameters.
The specific calculation formula for setting the serial port parameter modification flags (COM1 SD2541, COM2 SD2591) is: (parameter setting value + offset of the corresponding serial port's initial special soft component + 10)*2
For example, setting the COM1 serial port parameter to 193 (HC1) is (193 +2541-2540 +10)*2 which is (193 +1+10) *2=408. At this time, 193 (HC1) will be set for SD2540 and 408 for SD2541.
About serial port parameter modification flags (COM1 SD2541, COM2 SD2591): During RUN, when the serial port parameters are set and the modified flag is correct (judging at END) to the correct first cycle, the serial port parameter modification flag (COM1 SD2541, COM2, SD2591) are cleared, and then set the same value will not be processed. Mainly to avoid repeated settings multiple times.
Serial port parameter setting table
Bit number | B0 | B1、B2 | B3 | B4、B5、B6、B7、B8、B9 | B10 | B11 | |||||||||||||||||||||
Name | Data length | Parity | Stop Bit | Baud Rate(bps) | STX | ETX | |||||||||||||||||||||
Content | 0 off | 7bit | b2,b1 (0,0):None (0,1):Odd parity(ODD) (1,1):Even parity(EVEN) | 1bit |
| Turn off STX function | Turn off ETX function | ||||||||||||||||||||
1 on | 8bit | 2bit | Enable STX function, the specific value is set by D8124 | Turn on the ETX function, the specific value is set by D8125 |
Related software components
Devices | Content |
SD2540 | COM1 serial port parameter setting |
SD2541 | COM1 serial port parameter modification identification |
SD2590 | COM2 serial port parameter setting |
SD2591 | COM2 serial port parameter modification sign |
If the set protocol does not match the provided protocol number, the serial port parameter modification flags (COM1 SD2541, COM2 SD2591) will not be cleared after setting. At this time, the protocol will not be set successfully, and it will run according to the original protocol.
Error code
Error code | Content |
4085H | The read address of (s) and (N) exceeds the device range |
4084H | (N) is not 0 or 1 |
Example
Example above
M1 changes from OFF->ON during run
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
If you turn M1 from OFF->ON again
SD2540 will be set to 129 (H81), SD2541 will be set to 280 but will be cleared.
Modbus station number setting
STATION/Modbus station number setting
STATION(P)
Under the Modbus slave station protocol. Set the station number (s) for the (N) communication port.
-[STATION (s) (N)]
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(s) | Station number to be set | 0 to 255 | Unsigned BIN 16 bit | ANY16 |
(N) | Which communication port to set 0 means COM1, 1 means COM2 | 0, 1 | Unsigned BIN 16 bit | ANY16 |
Device used
Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||
KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
ECAMCUT | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Features
●This instruction is mainly used to set the station number during run, and it can also be used in the first cycle of run.
●The value of the station number address (COM1 SD2544, COM2 SD2594) and the station number modification flag (COM1 SD2545, COM2 SD2595) can be directly set according to the command parameters.
●The specific calculation formula for setting the station number modification flag (COM1 SD2545, COM2 SD2595) is: (parameter setting value + offset of the corresponding serial port's initial special device + 10)*2
●For example, setting the COM2 station number to 1 is (1 +2595-2590 +10)*2, which is (1 +5+10) *2=32. At this time, SD2594 will be set to 1, and SD2595 will be set to 32.
✎Note: Whether it is by self-calculation and then modifying the ID (COM1 SD2545, COM2 SD2595) setting value to the station number, or setting with this instruction, the station number can be modified when the PLC is in the RUN state.
●Regarding station number modification identification (COM1 SD2545, COM2 SD2595): During RUN, when the station number is set and the modification identification is correct (judgment at END) to the correct first cycle, the station number will be modified when the modification is completed (COM1 SD2545, COM2 SD2595) are cleared, and then set the same value will not be processed. Mainly to avoid repeated settings multiple times.
Related software components
Devices | Content |
SD2544 | COM1 station number setting |
SD2545 | COM1 station number modification sign |
SD2594 | COM2 station number setting |
SD2595 | COM2 station number modification sign |
Error code
Error code | Content |
4085H | The read address of (s) and (N) exceeds the device range |
4084H | (s) not in the range of 0 to 255 |
(N) is not 0 or 1 |
✎Note:
The setting of communication parameters will affect the overall communication. The processing in the PLC is to modify it when there is no communication or after a round of communication is completed. This point needs attention.
Example
Example above
M1 changes from OFF->ON during run
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
If you turn M1 from OFF->ON again
SD2594 will be set to 2, SD2595 will be set to 34 but will not be cleared.
RS instruction
RS/External communication instruction
RS
In the case of Modbus master station protocol: This instruction is the setting interface for the master station to send protocol frames. The function code (s), slave address (m), length (d) of the station number set according to the instruction, and the function code determines whether the data of n is required to be automatically combined to send and receive protocol frames. If it is a read type function code, the data will be written into (N).
-[RS (s) (m) (d) (N)]
Content, range and data type
In the case of user-defined protocol:
Parameter | Content | Range | Data type | Data type (label) |
(s) | The start address of register area that stores the data to be sent | - | Unsigned BIN 16 bit | ANY16 |
(m) | The length of data to be sent (bytes) | 0 to 523 | Unsigned BIN 16 bit | ANY16 |
(d) | The device start number that stores the written data | - | Unsigned BIN 16 it | ANY16 |
(N) | Number of data written (bytes) | 0 to 523 | Unsigned BIN 16 bit | ANY16 |
In the case of Modbus protocol:
Parameter | Content | Range | Data type | Data type (label) |
(s) | The high byte stores the station number of slave station, and the low byte stores function code of Modbus | - | Unsigned BIN 16 bit | ANY16 |
(m) | Slave address. The address provided by the slave station will read or write data from this address of the slave station | - | Unsigned BIN 16 bit | ANY16 |
(d) | Length. The length of Modbus read or write. The unit is determined by function code. | - | Unsigned BIN 16 bit | ANY16 |
(N) | Start address for reading or writing data | - | Unsigned BIN 16 bit | ANY16 |
Device used
Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||
T | C | D | R | K | H | [D] | XXP | ||
RS | Parameter 1 | ● | ● | ● | ● | ● | ● | ||
Parameter 2 | ● | ● | ● | ● | ● | ● | |||
Parameter 3 | ● | ● | ● | ● | ● | ● | |||
Parameter 4 | ● | ● | ● | ● | ● | ● |
(1) Custom protocol
When the communication protocol is set as a custom protocol. When the contact in before RS instruction is turned on and SM2591 is also turned on at the same time, if the sending length (m) is not 0, the data of (s) will be sent (m) bytes out, and then it will be in the mode of waiting for reception. When the data is received, (N) bytes of data will be stored in (d). SM2593 will be turned ON after receiving (N) data.
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.
To enable the start character (STX) and the end character (ETX) modes of RS instruction, the status of the 10th and 11th bits of the special address SD2600 must be set. See the table below for detailed settings:
Bit number | B0 | B1、B2 | B3 | B4、B5、B6、 B7、B8、B9 | B10 | B11 | |||||||||||||||||||
Name | Data length | Parity | Stop Bit | Baud rate(bps) | STX | ETX | |||||||||||||||||||
Content | 0 off | 7-bit | b2, b1 (0,0): None (0,1): Odd parity (ODD) (1,1): Even parity (EVEN) | 1-bit |
| None | None | ||||||||||||||||||
1 on | 8-bit | 2-bit | Turn on STX, the STX value is set in SD2600 | Turn on ETX, the ETX value is set in SD2601 |
Example
When M1 is ON, the sending and receiving data of communication after executing instruction is stored as the following figure.
Some configuration and preparation of serial communication are needed for actual programming to communicate as expected, such as setting the transceiver mode of serial port, baud rate, number of bits, parity, software protocol settings, timeout judgment conditions, and data preparation for the transceiver buffer, send and receive flag processing, etc.,
A relatively complete RS communication setup program is shown as follows:
Serial port parameters settings:
Baud rate 112500, stop bit 1, data bit 8, parity bit none
Set the protocol as a custom protocol
Sending interval: 5ms
Receiving timeout: 100ms
Number of repetitions: 3 times
Timeout between characters: 30ms
Custom protocol, send start address D200, sending length 8, receive start address D300, receiving length 8,
Receive start address D300 Receive length 6
Send directly after trigger
After receiving, close the instruction directly and reset the instruction receiving flag
For detailed user-defined protocol instructions, please refer to "10.7.1 Custom protocol description"
(2) Modbus protocol
When the protocol is set to Modbus master protocol (whether it is RTU or ASCII). When the contact before RS instruction is turned ON, the RS instruction will send the combined data frame according to the station number function code (s), slave station address (m), length (d) and judge whether the data of (N) is needed according to the function code.
Parameter | Content |
(s) | The high byte stores the station number of slave station, and the low byte stores the function code of Modbus |
(m) | Slave address. The address provided by the slave station will read or write data from this address of the slave station |
(d) | Length, the length of Modbus read or write. The unit is determined by the function code. |
(N) | Start address for reading or writing data |
Serial port parameter setting
Baud rate 115200, data bit 8, parity bit none, stop bit 1
Communication protocol setting: ModbusRTU master station protocol
Sending interval: 5ms
Receiving timeout: 100ms
Timeout retry times: 3 times
Station number 01H, function code 03H, slave address 10, length 05
As the ladder program shown above:
When M1 is turned ON, PLC will send data (hexadecimal) from COM2 of PLC: 01 03 00 0A 00 05 A5 C8
01: represents slave address, the upper 8 bits of (s);
03: Modbus instruction code, the lower 8 bits of (s), meaning to read the slave register;
00 0A: The address of slave register to be read, the value of (m);
00 05: The number of registers to be read, the value of (d),
A5 C8: CRC check code.
For detailed custom protocol instructions, please refer to "10.7.2 Modbus protocol description"
✎Note:
Although the RS instruction currently allows all the parameters of the instruction to use constants such as K and H, there are different restrictions depending on the protocol.
When the protocol is a custom protocol, S and D cannot be constants, otherwise it will report (3189H) error.
When the protocol is Modbus protocol, n cannot be a constant, otherwise it will report (3189H) error.
The combination of RTU protocol and 7-bit data bits cannot be set.
If the serial port parameter settings are different, it may still be able to communicate. At present, it is normal to set one.
Currently, the RS instruction cannot be used in interrupts and events.
Error code
Error code | Content |
4085H | The read address of (s), (m), (d) and (N) exceed the device range. |
3180H | COM2 data reception error. There may be interference on the communication line, it is recommended to connect the ground wire. |
3181H | COM2 data reception timed out. "Check the wiring, check whether the serial port parameter settings are compatible with master and slave, check whether there is interference. Check whether the slave station is too late to respond. For this reason, you can try to increase the sending interval SD2546." |
3182H | COM2 CRC check error. There may be interference on the communication line, it is recommended to connect the ground wire. |
3183H | COM2 LRC check error. There may be interference on the communication line, it is recommended to connect the ground wire. |
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 of slave station. |
3185H | COM2 send buffer overflow. Contact a technician if this error occurs |
3186H | COM2 function code is wrong. Check whether the set function code is a function code supported by PLC |
3187H | COM2 address is wrong. Check whether the slave station has this address (please refer to Modbus Abnormal 02) |
3188H | The length of COM2 is wrong. Check whether the communication length exceeds the length range specified by the Modbus protocol, or whether it exceeds the specified length range of the custom protocol. |
3189H | COM2 data error. "Check whether there are errors in the parameters of the instruction. Check whether the slave station supports the setting of this value. (Please refer to Modbus Abnormal 03)" |
318AH | COM2 slave station is busy. Slave station returns information: Slave station is busy (please refer to Modbus exception 06) |
318BH | COM2 slave station does not support function codes. Check whether the slave station supports this function code (please refer to Modbus exception 01) |
318CH | COM2 slave station is faulty. Slave station returns information: Slave station is faulty, please check whether the slave station is faulty (please refer to Modbus Abnormal 04) |
318DH | COM2 slave station confirmation. Slave station return information: slave station confirmation (please refer to Modbus abnormal 05) |
318EH | COM2 current protocol does not support this instruction or function. The related conmunication instruction of master station or the function of maste station cannot be used when it is set to slave station protocol, please change the protocol or close the contact before the corresponding instruction or diable the corresponding communication function. |
318FH | COM2 sending timed out. Contact a technician if this error occurs |
31A0H | COM2 is not available as a gateway. Slave station returns information: unavailable gateway (please refer to Modbus exception 0A) |
31A1H | COM2 indicates that no response was obtained from the target device. Slave station returns information: the device is not in the network (please refer to Modbus exception 0B) |
RS2 instruction
RS2/External communication instruction
RS2
In custom protocol: This instruction is a communication send and receive instruction. It takes out (M) of the initial data specified (s) and send it, and stores (N) of the data received through the serial port in (d) and sent by (n1) automatic communication port.
In Modbus master station protocol: This instruction is the setting interface for the master station to send protocol frames. According to the station number function code (s), slave address (m), length (d) set by the instruction, and the function code to determine whether n data is required to automatically combined sending and receiving protocol frames. If it is a read type function code, the data would be written to (N) and sent by (n1) custom communication port.
-[RS2 (s) (m) (d) (N) (n1)]
Content, range and data type
In custom protocol
Parameter | Content | Range | Data type | Data type (label) |
---|---|---|---|---|
(s) | The start address of register area that stores the data to be sent | - | Unsigned BIN 16 bit | ANY16 |
(m) | The length of data to be sent (bytes) | 0 to 528 | Unsigned BIN 16 bit | ANY16 |
(d) | The device start number that stores the written data | - | Unsigned BIN 16 bit | ANY16 |
(N) | Number of data written (bytes) | 0 to 528 | Unsigned BIN 16 bit | ANY16 |
(n1) | Specify the communication port | Unsigned BIN 16 bit | ANY16 |
In Modbus protocol
Parameter | Content | Range | Data type | Data type (label) |
---|---|---|---|---|
(s) | The high byte stores the station number of slave station, and the low byte stores function code of Modbus | - | Unsigned BIN 16 bit | ANY16 |
(m) | Slave address. The address provided by the slave station will read or write data from this address of the slave station | - | Unsigned BIN 16 bit | ANY16 |
(d) | Length. The length of Modbus read or write. The unit is determined by function code. | - | Unsigned BIN 16 bit | ANY16 |
(N) | The start address of the data to be read or written | - | Unsigned BIN 16 bit | ANY16 |
(n1) | Specify the communicatiom port | Unsigned BIN 16 bit | ANY16 |
Device used
Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||
---|---|---|---|---|---|---|---|---|---|---|
T | C | D | R | SD | K | H | [D] | XXP | ||
RS2 | (s) | ● | ● | ● | ● | ● | ● | ● | - | - |
(m) | ● | ● | ● | ● | ● | ● | ● | - | - | |
(d) | ● | ● | ● | ● | ● | ● | ● | - | - | |
(N) | ● | ● | ● | ● | ● | ● | ● | - | - | |
(n1) | ● | ● |
Features
Parameter (n1) is the specified port. Curently, k0 indicates COM1, and k1 indicates COM2.
(1) Custom protocol
When the communication protocol is set as a custom protocol. When the contact in before RS2 instruction is turned on and “sending control enable” is also turned on at the same time, and the sending length (m) is not 0, the data of (s) will be sent (m) bytes out, and then it will be in the mode of waiting for reception. When the data is received, (N) bytes of data will be stored in (d). “reception control or reception notice” will be turned ON after receiving (N) data.
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.
To enable the start character (STX) and the end character (ETX) modes of RS2 instruction, the status of the 10th and 11th bits of the special address “communication port setting” must be set. See the table below for detailed settings:
Bit number | B0 | B1、B2 | B3 | B4、B5、B6、 B7、B8、B9 | B10 | B11 | |||||||||||||||||||
Name | Data length | Parity | Stop Bit | Baud rate(bps) | STX | ETX | |||||||||||||||||||
Content | 0 off | 7-bit | b2, b1 (0,0): none (0,1): odd parity (ODD) (1,1): even parity (EVEN) | 1-bit |
| None | None | ||||||||||||||||||
1 on | 8-bit | 2-bit | Turn on STX, the STX value is set in the device of the corresponding communication | Turn on ETX, the ETX value is set in the device of the corresponding communication |
Example
When M1 is ON, the sending and receiving data of communication after executing instruction is stored as the following figure.
Some configuration and preparation of serial communication are needed for actual programming to communicate as expected, such as setting the transceiver mode of serial port, baud rate, number of bits, parity, software protocol settings, timeout judgment conditions, and data preparation for the transceiver buffer, send and receive flag processing, etc.,
A relatively complete RS communication setup program is shown as follows:
Set the protocol to a custom protocol.
Set serial port parameter: baud rate 115200 stop bit 1, data bit 8, no parity bit
For detailed custom protocol instructions, please refer to "10.7.1 Custom protocol description"
(2) Modbus protocol
When the protocol is set to Modbus master protocol (whether it is RTU or ASCII). When the contact before RS2 instruction is turned ON, the RS2 instruction will send the combined data frame according to the station number function code (s), slave station address (m), length (d) and judge whether the data of (N) is needed according to the function code.
Parameter | Content |
---|---|
(s) | The high byte stores the station number of slave station, and the low byte stores function code of Modbus |
(m) | Slave address. The address provided by the slave station will read or write data from this address of the slave station |
(d) | Length. The length of Modbus read or write. The unit is determined by function code. |
(N) | The start address of the data to be read or written |
(n1) | Specify the communicatiom port |
As the ladder program shown above:
When M1 is turned ON, PLC will send data (hexadecimal) from COM2 of PLC: 01 03 00 0A 00 05 A5 C8
- 01: represents slave address, the high 8 bits of (s);
- 03: Modbus command code, the low 8 bits of (s), which means to read the slave register;
- 00 0A: The address of slave register to be read, the value of (m);
- 00 05: The number of registers to be read, the value of (d),
- A5 C8: CRC check code.
For detailed custom protocol instructions, please refer to "10.7.2 Modbus protocol description"
✎Note:
- The RS2 instruction allows parameters to be represented by K and H constants, but there are different restrictions depending on the protocol.
- When the protocol is a custom protocol, S and D cannot be constants, otherwise it will report (3X89H) error.
- When the protocol is Modbus protocol, n cannot be a constant, otherwise it will report (3X89H) error.
- When the protocol is set to the RTU protocol, only 8 bits of data can be selected
- If the serial port parameter settings are different, it may still be able to communicate. However, it is recommended that the serial port parameters be the same to avoid other faults.
- Currently, the RS2 instruction cannot be used in interrupts and events.
Error code
Error code | Content |
---|---|
4085H | The read address of (s), (m), (d) and (N) exceed the device range. |
4084H | The parameter value exceed the specified range |
3080H | COM1 data reception error. There may be interference on the communication line, it is recommended to connect the ground wire. |
3081H | COM1 data reception timed out. "Check the wiring, check whether the serial port parameter settings are compatible with master and slave, check whether there is interference. Check whether the slave station is too late to respond. For this reason, you can try to increase “the sending interval". |
3082H | COM1 CRC check error. There may be interference on the communication line, it is recommended to connect the ground wire. |
3083H | COM1 LRC check error. There may be interference on the communication line, it is recommended to connect the ground wire. |
3084H | The COM1 station number is incorrectly configured. Check the slave station number setting, and check whether there is any problem with the receiving and sending mechanism of slave station. |
3085H | COM1 send buffer overflow. Contact a technician if this error occurs. |
3086H | COM1 function code is wrong. Check whether the set function code is a function code supported by PLC |
3087H | COM1 address is wrong. Check whether the slave station has this address (please refer to Modbus Abnormal 02) |
3088H | The length of COM1 is wrong. Check whether the communication length exceeds the length range specified by the Modbus protocol, or whether it exceeds the specified length range of the custom protocol. |
3089H | COM1 data error. "Check whether there are errors in the parameters of the instruction. Check whether the slave station supports the setting of this value. (Please refer to Modbus Abnormal 03)" |
308AH | COM1 slave station is busy. Slave station returns information: Slave station is busy (please refer to Modbus exception 06) |
308BH | COM1 slave station does not support function codes. Check whether the slave station supports this function code (please refer to Modbus exception 01) |
308CH | COM1 slave station is faulty. Slave station returns information: Slave station is faulty, please check whether the slave station is faulty (please refer to Modbus Abnormal 04) |
308DH | COM1 slave station confirmation. Slave station return information: slave station confirmation (please refer to Modbus abnormal 05) |
308EH | COM1 current protocol does not support this instruction or function. The related conmunication instruction of master station or the function of maste station cannot be used when it is set to slave station protocol, please change the protocol or close the contact before the corresponding instruction or diable the corresponding communication function. |
308FH | COM1 sending timed out. Contact a technician if this error occurs. |
30A0H | COM1 is not available as a gateway. Slave station returns information: unavailable gateway (please refer to Modbus exception 0A) |
30A1H | COM1 indicates that no response was obtained from the target device. Slave station returns information: the device is not in the network (please refer to Modbus exception 0B) |
3181H | COM2 data reception timed out. "Check the wiring, check whether the serial port parameter settings are compatible with master and slave, check whether there is interference. Check whether the slave station is too late to respond. For this reason, you can try to increase the “sending interval". |
3182H | COM2 CRC check error. There may be interference on the communication line, it is recommended to connect the ground wire. |
3183H | COM2 LRC check error. There may be interference on the communication line, it is recommended to connect the ground wire. |
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 of slave station. |
3185H | COM2 send buffer overflow. Contact a technician if this error occurs. |
3186H | COM2 function code is wrong. Check whether the set function code is a function code supported by PLC. |
3187H | COM2 address is wrong. Check whether the slave station has this address (please refer to Modbus Abnormal 02) |
3188H | The length of COM2 is wrong. Check whether the communication length exceeds the length range specified by the Modbus protocol, or whether it exceeds the specified length range of the custom protocol. |
3189H | COM2 data error. "Check whether there are errors in the parameters of the instruction. Check whether the slave station supports the setting of this value. (Please refer to Modbus Abnormal 03)" |
318AH | COM2 slave station is busy. Slave station returns information: Slave station is busy (please refer to Modbus exception 06) |
318BH | COM2 slave station does not support function codes. Check whether the slave station supports this function code (please refer to Modbus exception 01) |
318CH | COM2 slave station is faulty. Slave station returns information: Slave station is faulty, please check whether the slave station is faulty (please refer to Modbus Abnormal 04) |
318DH | COM2 slave station confirmation. Slave station return information: slave station confirmation (please refer to Modbus abnormal 05) |
318EH | COM2 current protocol does not support this instruction or function. The related conmunication instruction of master station or the function of maste station cannot be used when it is set to slave station protocol, please change the protocol or close the contact before the corresponding instruction or diable the corresponding communication function. |
318FH | COM2 sending timed out. Contact a technician if this error occurs. |
31A0H | COM2 is not available as a gateway. Slave station returns information: unavailable gateway (please refer to Modbus exception 0A) |
31A1H | COM2 indicates that no response was obtained from the target device. Slave station returns information: the device is not in the network (please refer to Modbus exception 0B) |
Expansion module communication
Single word data writing from TO/PLC to the module (16-bit specification)
TO(P)
Write the data at the start (N) point of the device specified in (s3) to the buffer memory in the intelligent function module specified in (s1) after the address specified in (s2).
-[TO (s1) (s2) (s3) (N)]
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(s1) | Module number, the first module is 0, the second module is 1, and so on | 0 to 32767 | Unsigned BIN 16 bit | ANY16 |
(s2) | Start writing from which BFM in the module | 0 to 32767 | Unsigned BIN 16 bit | ANY16 |
(s3) | Start number of the device storing the written data | -32768 to 32767 | Signed BIN 16 bit | ANY16 |
(N) | Number of data written | 0 to 512 | Unsigned BIN 16 bit | ANY16 |
Device used
Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||
KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
TO | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |
Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |
Parameter 4 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Features
Write the data at the start (N) point of the device specified in (s3) to the buffer memory in the intelligent function module specified in (s1) after the address specified in (s2).
As the following Circuit program
Indicates that when X1 is ON, write the data in the PLC's D220 register to the buffer register (BFM) #24 in the #1 (second) special module. When X1 is OFF, no operation is performed.
Currently LX5VPLC supports 16 special expansion modules at the same time.
The special devices used are as follows
Devices | Content |
SD2081 | Total number of modules |
SD2082 | Number of IO expansion modules |
SD2083 | Number of special expansion modules |
SD2084 | The first missing expansion module. When the value is -1, it means not lost |
Error code
Error code | Content |
4085H | The read addresses of (s1), (s2), (s3) and (N) exceed the device range |
4084H | (s1) and (s2) is not in the range of 0 to 32767 or (N) is not in the range of 0 to 512 |
7080H | Check error when communicating between PLC and module |
7081H | Expansion module communication message is abnormal |
7082H | FROM/TO instruction error |
7083H | The specified extension module was not found |
Example
When M1 is turned on
The values of D200 and D201 will be passed to BFM2 and BFM3 of module #0 (the first)
Double word data write from DTO/PLC to the module (32-bit specification)
DTO(P)
Write the data of (N)×2 points from the device specified in (s3) to the buffer memory in the intelligent function module specified in (s1) and beyond the address specified in (s2).
-[DTO (s1) (s2) (s3) (N)]
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(s1) | Module number, the first module is 0, the second module is 1, and so on | 0 to 32767 | Unsigned BIN 16 bit | ANY16 |
(s2) | Start writing from which BFM in the module | 0 to 32767 | Unsigned BIN 16 bit | ANY16 |
(s3) | Start number of the device storing the written data | -2147483648 to 2147483647 | Signed BIN 32 bit | ANY32 |
(N) | Number of data written | 0 to 256 | Unsigned BIN 16 bit | ANY16 |
Device used
Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||||
KnY | KnM | KnS | T | C | D | R | SD | LC | HSC | K | H | [D] | XXP | ||
DTO | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||
Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |||
Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |
Parameter 4 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Features
Write the data of (N)×2 points from the device specified in (s3) to the buffer memory in the intelligent function module specified in (s1) and beyond the address specified in (s2).
As the following Circuit program
Indicates that when M1 is ON, write the data in the PLC's D200 and D201 registers to the buffer registers (BFM) #1 and #2 in the #0 (first) special module. When X1 is OFF, no operation is performed.
Currently LX5V PLC supports 16 special expansion modules at the same time.
The special devices used are as follows
Devices | Content |
SD2081 | Total number of modules |
SD2082 | Number of IO expansion modules |
SD2083 | Number of special expansion modules |
SD2084 | The first missing expansion module. When the value is -1, it means not lost |
Error code
Error code | Content |
4085H | (s1) (s2) (s3) (N) The read address exceeds the device range |
4084H | (s1) (s2) is not in the range of 0 to 32767 or (N) is not in the range of 0 to 256 |
7080H | Check error when communicating between PLC and module |
7081H | Expansion module communication message is abnormal |
7082H | FROM/TO instruction error |
7083H | The specified extension module was not found |
Example
When M1 is turned on
The values from D200 to D203 will be transferred to BFM1 to BFM4 of module #0 (first)
FROM/Read single word data from the module (16-bit specification)
FROM(P)
Read (N) word data from the buffer memory specified in (s2) in the module specified in (s1), and store it in the device specified in (d) and later.
Ladder
-[FROM (s1) (s2) (d) (N)]
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(s1) | Module number, the first module is 0, the second module is 1, and so on | 0 to 32767 | Unsigned BIN 16 bit | ANY16 |
(s2) | Start reading from which BFM in the module | 0 to 32767 | Unsigned BIN 16 bit | ANY16 |
(d) | Start number of the device storing the read data | - | Signed BIN 16 bit | ANY16 |
(N) | Number of read data | 0 to 512 | Unsigned BIN 16 bit | ANY16 |
Device used
Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
FROM | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |
Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |||
Parameter 4 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Features
Read (N) word data from the buffer memory specified in (s2) in the intelligent function module specified in (s1) and store it in the device specified in (d) and later.
As the following Circuit program
It means that when M1 is ON, the data in the buffer registers (BFM) #10 and #11 in the special module #0 (the first) will be written into the D200 and D201 registers of the PLC. When M1 is OFF, no operation is performed.
Currently LX5V PLC supports 16 special expansion modules at the same time.
The special soft components used are as follows:
Devices | Content |
---|---|
SD2081 | Total number of modules |
SD2082 | Number of IO expansion modules |
SD2083 | Number of special expansion modules |
SD2084 | The first missing expansion module. When the value is -1, it means not lost |
Error code
Error code | Content |
---|---|
4085H | (s1) (s2) (N) The read address exceeds the device range |
4086H | (d) The write address exceeds the device range |
4084H | (s1) (s2) is not in the range of 0 to 32767 or (N) is not in the range of 0 to 512 |
7080H | Check error when communicating between PLC and module |
7081H | Expansion module communication message is abnormal |
7082H | FROM/TO instruction error |
7083H | The specified extension module was not found |
Example
When M1 is turned on
The values of BFM3, BFM4, and BFM5 of the #0 (first) module will be transferred to D200, D201, D202
DFROM/single word data read from the module (32-bit specification)
DFROM(P)
Read (N)*2 words of data from the buffer memory specified in (s2) in the module specified in (s1), and store it in the device specified in (d) and later.
-[DFROM (s1) (s2) (d) (N)]
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
---|---|---|---|---|
(s1) | Module number, the first module is 0, the second module is 1, and so on | 0 to 32767 | Unsigned BIN 16 bit | ANY16 |
(s2) | Start reading from which BFM in the module | 0 to 32767 | Unsigned BIN 16 bit | ANY16 |
(d) | Start number of the device storing the read data | - | Signed BIN 32 bit | ANY32 |
(N) | Number of read data | 0 to 256 | Unsigned BIN 16 bit | ANY16 |
Device used
Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
KnY | KnM | KnS | T | C | D | R | SD | LC | HSC | K | H | [D] | XXP | ||
DFROM | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||
Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |||
Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |||
Parameter 4 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Features
Read (N)×2 words of data from the buffer memory specified in (s2) in the intelligent function module specified in (s1), and store it in the device specified in (d) and later.
As the following Circuit program
It means that when M1 is ON, the data in the buffer register (BFM) #10 to #13 in the special module #0 (the first) will be written to the D200 to D203 registers of the PLC. When M1 is OFF, no operation is performed.
Currently LX5V PLC supports 16 special expansion modules at the same time.
The special soft components used are as follows:
Devices | Content |
---|---|
SD2081 | Total number of modules |
SD2082 | Number of IO expansion modules |
SD2083 | Number of special expansion modules |
SD2084 | The first missing expansion module. When the value is -1, it means not lost |
Error code
Error code | Content |
---|---|
4085H | (s1) (s2) (N) The read address exceeds the device range |
4086H | (d) The write address exceeds the device range |
4084H | (s1) (s2) is not in the range of 0 to 32767 or (N) is not in the range of 0 to 256 |
7080H | Check error when communicating between PLC and module |
7081H | Expansion module communication message is abnormal |
7082H | FROM/TO instruction error |
7083H | The specified extension module was not found |
Example
When M1 is turned on
The value of BFM3 to BFM8 of module #0 (first) will be transferred to D200 to D205
RS and RS2 instructions corresponding protocol description
Custom protocol description
Introduction
The function of custom protocol is that it can directly transmit data with the device without any processing or communicate with other devices with the corresponding protocol set by the customer.
At present, the custom protocol of 5V PLC is configured and sent by COM2, and the instruction used is RS instruction, and it need to configure the protocol and serial port parameters through the Devices.
The current custom protocol is generally close to 3V series.
Basic configuration
(1) Instructions
The RS instruction itself has the same usage as the previous RS instruction at 3V, and it can use R device.
-[RS (s) (m) (d) (N)]
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(s) | The start address of the register area where the data to be sent is stored | - | Unsigned BIN 16 bit | ANY16 |
(m) | Is the length of the data to be sent (number of bytes) | 0 to 528 | Unsigned BIN 16 bit | ANY16 |
(d) | Start number of the device storing the written data | - | Unsigned BIN 16 bit | ANY16 |
(N) | Number of data written | 0 to 528 | Unsigned BIN 16 bit | ANY16 |
Device used
Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||
T | C | D | R | K | H | [D] | XXP | ||
RS | Parameter 1 | ● | ● | ● | ● | ● | ● | ||
Parameter 2 | ● | ● | ● | ● | ● | ● | |||
Parameter 3 | ● | ● | ● | ● | ● | ● | |||
Parameter 4 | ● | ● | ● | ● | ● | ● |
✎Note: Although the RS instruction currently allows all the parameters of the instruction to use constants such as K and H, there are different restrictions according to the different protocol. When the protocol is a custom protocol, S and D cannot be constants, otherwise it will report an error.
(2) Special device settings
Special address table
COM2 special D device (SD) | COM2 special M Device (SM) | ||
2590 | Communication port setting | 2590 | Send control on |
2591 | Serial parameter modification identification | 2591 | Send control/send reminder |
2592 | Protocol settings | 2592 | Receive control on |
2593 | Protocol modification logo | 2593 | Accept control/receive prompt |
2594 | Station number setting | 2594 | 8-bit mode (for custom protocol) |
2595 | Station number modification logo | 2595 | |
2596 | Sending interval (0.1ms) 0-32767 It is 10 (1ms) when set to 0 | 2596 | |
2597 | Communication timeout setting (10ms) 0-32767 It is 10(100ms) when set to 0 | 2597 | |
2598 | Timeout retry times 0-32767 | 2598 | |
2599 | Character interval timeout setting (for custom protocol) (0.1ms) 0-32767 . It is 10 (1ms) when set to 0 | 2599 | |
2600 | STX value | 2600 | |
2601 | ETX value | 2601 | |
... | ... | ||
2610 | The amount of data received | 2610 | Communication complete flag |
2611 | Last error | 2611 | Receiving flag |
2612 | Current error | 2612 | Retry occurred |
2613 | Error steps | 2613 | Communication error |
2614 | Error station number | 2614 | Communication timeout |
2615 | Cumulative number of errors | 2615 |
The contents that the custom protocol will be used and set has been marked with underline and bold.
In addition, the devices to be used as judgment conditions have also been marked in bold in the table.
✎Note: COM1 currently does not support custom protocols.
1) Communication port setting SD2590
Bit number | B0 | B1、B2 | B3 | B4、B5、B6、 B7、B8、B9 | B10 | B11 | |||||||||||||||||||||
Name | Data length | Parity | Stop Bit | Baud rate(bps) | STX | ETX | |||||||||||||||||||||
Content | 0 off | 7 bit | b2,b1 (0,0): None (0,1): Odd parity (ODD) (1,1): Even parity (EVEN) | 1 bit |
| None | None | ||||||||||||||||||||
1 on | 8 bit | 2 bit | Turn on ETX, the ETX value is set in SD2600 | Turn on ETX, the ETX value is set in SD2601 |
Set the serial port parameters to SD2590 according to the bit settings provided in the table above. The setting is roughly the same as 3V. It is mainly because the baud rate can be set to a higher baud rate, the bit used need backward two bits when STX and ETX start.
For example: To set the serial port parameters: baud rate 115200, stop bit 1, data bit 8, no parity bit, turn on STX, you need to set the value H4C1 (K1217) on SD2590. The parameters directly set to SD2590 are only valid in the first cycle of PLC RUN.
If you need to modify it during RUN, you can use the PORTPARAM instruction to set it.
2) Protocol setting SD2592
Protocol settings | Protocol settings | ||
0 H | Wecon Modbus slave station | 10 H | Cunstom protocol |
2 H | ModbusRTU slave station | 20 H | ModbusRTU master station |
3 H | ModbusASCII slave station | 30 H | ModbusASCII master station |
The corresponding protocol can be set by setting the corresponding value in SD2592.
The parameters directly set to SD2592 are only valid in the first cycle of PLC RUN.
If you need to modify it during RUN, you can use the PROTOCOL instruction to set it.
3) Sending interval SD2596
The main function of sending interval is: how long to wait for sending the next instruction after one instruction is completed. If the value is set to 0, there is basically no waiting for sending interval, but it will be affected by the scan cycle.
The unit of the sending interval is 0.1ms, that is, the interval time is 10ms when the setting is 100.
4) Communication timeout SD2597 and timeout retry SD2598
The main function of communication timeout is: How long does it take to wait for no data to be received after the PLC sends retry or occurs an error. When 0 is set, the default is 100ms.
The unit of communication timeout is 10ms, that is, the timeout judgment time is 10ms when the setting is 100.
When a receiving timeout occurs, it will determine whether there are retry times and the current retry times. If the retry times are greater than or equal to SD2598, an error will be reported.
If SD2598 is set to 0, it will not try again.
If it is set to 1, send once again after sending a timeout.
5) Character interval timeout SD2599
Currently this setting is only available for custom protocols.
The main function of the character interval timeout is: after receiving at least one character before the communication timeout, judge whether the interval time between the following two characters has exceeded. if it is, report an error and end the communication.
This setting is mainly designed considering that some devices may send slow or have other specific sending requirements.
The character interval timeout will not retry.
(3) Serial port parameter setting instructions
1) Host computer interface settings
Through the PLC parameter setting in the upper computer interface, If protocol is set to none, it is a custom protocol.
The serial port parameter content mainly sets the serial port parameters such as baud rate and data bit.
After the start character is enabled, the start/end character can be sent. The start/end character will also be distinguished when receiving. See the description in the sending and receiving process for details.
✎Note: The characters here are decimal values.
2) PORTPARA instruction
-[PORTPARA (s) (N)]
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(s) | Serial port parameters to be set | 0 to 256 | Unsigned BIN 16 bit | ANY16 |
(N) | Which communication port to set (0 means COM1, 1 means COM2) | 0, 1 | Unsigned BIN 16 bit | ANY16 |
Device used
Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||
KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
PROTPARA | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Function: To set communication parameters when running.
Please refer to "PORTPARA instruction description" for details.
3) PROTOCOL instruction
-[PROTOCOL (s) (N)]
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(s) | Protocol number to be set | 0 to 65535 | Unsigned BIN 16 bit | ANY16 |
(N) | Which communication port to set (0 means COM1, 1 means COM2 *1) | 1 | Unsigned BIN 16 bit | ANY16 |
Device used
Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||
KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
PORTOCOL | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |
Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Features:
It is used to set the communication protocol when running. The above instruction actually sets a specific value for the parameter modification flag. The specific calculation formula is: (parameter setting value + the offset of the start special device corresponding to the serial port + 10)*2
For example, setting the protocol to Modbusrtu master station (H20) is (0x20 +2593-2590 +10)*2, that is (32 +3+10) *2=90. This is to prevent the serial port parameters from being modified at will.
The trigger of setting parameters in custom protocol will not change the value until an instruction is completed.
The trigger of setting parameters in Modbus master station protocol won’t change the value until an instruction is completed.
The trigger of setting parameters in the Modbus slave protocol can be switched as long as it is not processing the received data. Please refer to "PROTOCOL instruction description" for details.
4) Priority description of serial port parameters
The priority of serial port parameter settings are listed as blow. The serial port parameters are saved by power failure currently.
Serial port parameter set instruction setting = Ladder program MOV instruction set the corresponding SD device > the download parameters of host computer > Previous power-off save data.
(4) Ladder program
- Set serial port parameters:
- Baud rate 112500, stop bit 1, data bit 8, no parity bit none
- Set protocol to custom protocol
- Sending interval: 5ms
- Receiving timeout: 100ms
- Number of repetitions: 3 times
- Characters interval timeout: 30ms
- Custom protocol sending start address D200, sending length 8.
- Receiving start address D300, receiving length 6
- Send directly after trigger
- After receiving is completed, close the instruction directly and reset the instruction receiving flag
Sending and receiving process
(1) Sending and receiving mechanism
1) No start character (STX) and end character (ETX)
①16-bit (SM2594 is OFF)
The devices will be divided into high and low directly, and send data from the low address first and then the high address in order.
②8-bit (SM2594 is ON)
Get the value of the low address of device directly and send it
The data sent in the case of the ladder program and the data above should be 70 E1 31 62 6C.
Receiving will also be stored in the lower address
2) Open and set the start character STX
The value of the start character SD2600 is only valid in the low bit
When STX is enabled, the send will start with STX. When receiving, the send will start with STX, but STX will not be displayed.
If it receives the STX during the receiving, the receiving will restart.
If the first character is not received, the timeout period is judged by the first character timeout. When a character is received, no matter what data is received, the inter-character timeout will be counted from the last character received.
For example, the result of the above ladder program and the above data sending is FE 70 7D E1 00 31.
Sending FE 51 26 34 15 to the PLC at this time will receive the following data. And if you send FE 25 63 FE 51 26 34 15 you will also receive the following data.
3) Open and set the end character ETX situation
The value of ending character SD2601 is only valid in the low bit.
When ETX is enabled, the send will end with ETX.
When ETX is received, SM2610 and SM2593 are immediately turned ON, regardless of whether sufficient length is received.
For example, the result of the above Circuit program and the above data transmission is 70 7D E1 00 31 FD.
If the above Circuit program sends 01 06 FD to him, the following data will be received. If the FD is sent directly, it will be judged as the end directly.
4) Both the start character STX and the end character ETX are turned on
When both are opened, it is basically a combination of the above single opened states. But if only ETX data is received when both start, it will not end immediately. It will judge the character interval time and does not start receiving data.
(2) Receiving after sending (similar to Modbus master station mechanism)
1) Send control switch (SM2590) and receive control switch (SM2592) OFF (default)
When the contact of RS instruction is on, turn SM2591 on and send it immediately. SM2591 will be automatically OFF immediately after sending.
After sending, SM2593 is ON, it will always stop at this instruction, and wait for it to be OFF and then receive data. If it is OFF, it will start to receive data.
After the first character timeout period (SD2597), if no character is received, it is judged as a timeout. If there are retry times, it will retry. But after retrying, the communication still does not report an error, and SM2593 and SM2614 are turned on.
After receiving the first character, it will judge whether that the interval between characters exceeds the time set by SD2599. If it it doesn’t. it will report an error.(For the details, please refer to [the timeout of the interval character].)
When there are two or more instructions, the first RS instruction which is set ON will be sent after SM2591 is ON. Later, if this RS instruction is completed*1, then turn ON, SM2591 will switch to the next RS instruction*2 in the ladder sequence.
When there are two or more instructions, switch to another one during the data reception and it continue to stay back in the original instruction to until the reception is complete.
✎Note:
✎Completion refers to receiving data or reporting an error.
✎If there is no other open RS instruction after the ladder sequence, it will return to the first RS instruction that was opened in the ladder sequence for execution.
2) The sending way when the sending control switch (SM2590) is ON
When the sending control switch (SM2590) is ON, there is no need to set SM2591 ON. At this time, as long as the contact of the RS instruction is triggered, it can be sent, and SM2591 is automatically turned ON.
3) The receiving way when the receiving control switch (SM2592) is ON
When the receiving control switch (SM2592) is ON, SM2593 will be OFF automatically when the instruction is executed. It will no longer judge the status of SM2593 when receiving, and SM2593 will still be turned ON after receiving.
4) Sending control switch (SM2590) and receiving control switch (SM2592) ON
In this case, you only need to trigger the contact before the RS instruction to send data, then it will automatically switch to the waiting status. When the reception is completed, it will turn to the next RS instruction that is turned on.
(3) Send-only
When the sending length is set to a value other than 0, and the receiving length is set to 0, it is send-only mode.
1) The sending control switch (SM2590) is OFF
When SM2591 is turned ON, the data will be sent without receiving.
When there are two or more instructions, the first RS instruction which is turned ON will be sent after SM2591 is turned ON. After this RS instruction is completed, then turn ON SM2591 will switch to the next RS instruction in the ladder program.
2) The Sending control switch (SM2590) is ON
The RS instruction will be sent when triggered. Multiple instructions are triggered and sent in a loop. During the sending cycle, the interval will be sent according to the set sending interval.
(4) Receive-only
When the sending length is 0 and the receiving length is not 0, it is only receiving.
1) SM2592 receiving control switch OFF
SM2593 will be turned ON when receiving, and the ladder program control must be turned OFF to continue receiving. SM2593 will not turn ON without receiving data.
When multiple instructions are enabled to receive only at the same time, it will start to receive from the smallest number of steps in the ladder diagram. Time out or received data will be forwarded to the second to continue receiving.
2) SM2592 receiving control switch ON
It can receive normally and will not be controlled by the flag bit. The SM2593 receiving identifier serves as the receiving prompt identifier,and SM2593 will not turn ON without receiving data.
If multiple RS receive only instructions are turned on at the same time, the receiving position is uncertain due to the timeout judgment and switching to the next one.
(5) Use receive-only and send-only methods to send after receiving (similar to Modbus slave mechanism)
Receive-only: When it is determined that the reception is complete, it will determine the instruction to be triggered according to the received content, and save the received data at the same time.
Send-only: The content sent by triggered M2 is different from that of triggered M3. After the trigger is over, they will return to trigger the receive-only of M1.
10.7.1.4 Error message
Currently The Error code will be displayed on SD7, SD0, SD 2611 and SD2612.
The Error codes that will appear in the custom protocol are mainly as follows.
Error code | Content |
3181H | Data receiving timeout |
3188H | Wrong length |
3189H | COM2 data error. "Check whether there are errors in the parameters of instruction. Check whether the slave station supports the setting of this value. (Please refer to Modbus exception 03)" |
318EH | Current protocol does not support this instruction (This error is only displayed on SD7 and SD0) |
318FH | COM2 sending timed out. Contact a technician if this error occurs |
3190H | COM2 receiving data exceeds the buffer limit. |
After resetting the protocol or communication parameters, the error will be cleared.
In addition, the communication completion/communication error/communication timeout flag will be set after the executed instruction.
10.7.1.5 The difference with Mitsubishi
The current differences:
- STX and ETX: Mitsubishi can set up to 4 bytes, we only have one byte.
- Add sum check and CR, LF.
- The instruction control of Mitsubishi is that the first instruction triggered is fixed to execute this instruction. It will not be switched to other instructions midway, unless the contact of this instruction is closed.
Modbus protocol description
Introduction
The Modbus master station protocol is generally close to LX3V. The address was modified in the slave station.
Basic configuration
(1) Introduction
The RS instruction has the same usage as the previous RS instruction of 3V, and can use R device.
-[RS (s) (m) (d) (N)]
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(s) | The high byte stores the station number of slave station, and the low byte stores the Modbus function code. | - | Unsigned BIN 16 bit | ANY16 |
(m) | Slave address. The address provided by slave station will read or write data from this address of the slave station | - | Unsigned BIN 16 bit | ANY16 |
(d) | Length. The length of Modbus read or write. The unit is determined by function code. | - | Unsigned BIN 16 bit | ANY16 |
(N) | Start address for reading or writing data | - | Unsigned BIN 16 bit | ANY16 |
Device used
Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||
T | C | D | R | K | H | [D] | XXP | ||
RS | Parameter 1 | ● | ● | ● | ● | ● | ● | ||
Parameter 2 | ● | ● | ● | ● | ● | ● | |||
Parameter 3 | ● | ● | ● | ● | ● | ● | |||
Parameter 4 | ● | ● | ● | ● |
✎Note: Although the RS instruction currently allows all the parameters of the instruction to use constants such as K and H, there are different restrictions according to the different protocols. When the protocol is Modbus master station protocol, n cannot be a constant, otherwise an error will be reported.
(2) Special device setting
Special address table
COM 1 special D device (SD) | |
2540 | Communication port settings |
2541 | Serial parameter modification identification |
2542 | |
2543 | |
2544 | Station number setting |
2545 | Station number modification logo |
✎Note: COM1 does not support modifying the protocol.
COM2 special D device (SD) | COM2 special M Device (SM) | ||
2590 | Communication port setting | 2590 | Send control start |
2591 | Serial parameter modification identifier | 2591 | Send control/send reminder |
2592 | Protocol setting | 2592 | Receive control start |
2593 | Protocol modification identifier | 2593 | Receive control/receive prompt |
2594 | Station number setting | 2594 | 8-bit mode (for custom protocol) |
2595 | Station number modification identifier | 2595 | |
2596 | Sending interval (0.1ms) 0-32767. It is 10 when set to 0 (1ms) | 2596 | |
2597 | Communication timeout setting (10ms) 0-32767 It is 10 when set to 0 (100ms) | 2597 | |
2598 | Timeout retry times 0-32767 | 2598 | |
2599 | Character interval timeout setting (for custom protocol) (0.1ms) 0-32767. It is 10 when set to 0 (1ms) | 2599 | |
2600 | STX value | 2600 | |
2601 | ETX value | 2601 | |
... | ... | ||
2610 | The amount of data received | 2610 | Communication complete flag |
2611 | Last error | 2611 | Receiving flag |
2612 | Current error | 2612 | Retry occurred |
2613 | Error steps | 2613 | Communication error |
2614 | Error station number | 2614 | Communication timeout |
2615 | Cumulative number of errors | 2615 |
The contents that the custom protocol will be used and set has been marked with underline and bold. In addition, the devices to be used as judgment conditions have also been marked in bold in the table.
1) Communication port setting SD2590
Bit number | B0 | B1、B2 | B3 | B4、B5、B6、B7、B8、B9 | |||||||||||||||||||||
Name | Data length | Parity | Stop Bit | Baud rate(bps) | |||||||||||||||||||||
Content | 0 off | 7 bit | b2,b1 (0,0): None (0,1): Odd parity (ODD) (1,1): Even parity (EVEN) | 1 bit |
| ||||||||||||||||||||
1 on | 8 bit | 2 bit |
Set the serial port parameters to SD2590 according to the bit settings provided in the table above. The setting is roughly the same as 3V. It is mainly because the baud rate can be set to a higher baud rate, the bit used need backward two bits when STX and ETX start.
For example: To set the serial port parameters: baud rate 115200, stop bit 1, data bit 8, no parity bit, you need to set the value H4C1 (K1217) on SD2590. The parameters directly set to SD2590 are only valid in the first cycle of PLC RUN. If you need to modify it during RUN, you can use the PORTPARAM instruction to set it.
2) Protocol setting SD2592
Protocol settings | |||
0 H | Wecon Modbus slave station | 10 H | Custom protocol |
2 H | ModbusRTU slave station | 20 H | ModbusRTU master station |
3 H | ModbusASCII slave station | 30 H | ModbusASCII master station |
The corresponding protocol can be set by setting the corresponding value in SD2592. The parameters directly set to SD2592 are only valid in the first cycle of PLC RUN. If you need to modify it during RUN, you can use the PROTOCOL instruction to set it. COM1 cannot use protocols other than Wecon Modbus slave station Currently.
3) Sending interval SD2596
The main function of sending interval is: how long to wait for sending the next instruction after one instruction is completed. If it is set to 0, there is basically no waiting for interval sending, but it will be affected by the scan cycle. The unit of the sending interval is 0.1ms, that is, the interval is 10ms when set to 100.
4) Communication timeout SD2597 and timeout retry SD2598
The main function of communication timeout is: How long does it take to wait for no data to be received and then retry or report an error after the PLC sends. When it is set to 0, the default value is 100ms.
The unit of communication timeout is 10ms, that is, the timeout determine time is 100ms when set to 10.
When a receiving timeout occurs, it will determine whether there are retry times and the current retry times. If the retry times are greater than or equal to SD2598, an error will be reported.
If SD2598 is set to 0, it will not retry.
If it is set to 1, send once and then send once again after timeout.
Serial port parameter setting
PORTPARA instruction
-[PORTPARA (s) (N)]
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(s1) | The start number of the device that stores the number of digits of converted value | - | Signed BIN 16 bit | ANY16_S_ARRAY |
(s2) | Converted BIN data | -2147483648 to 2147483647 | Signed BIN 32 bit | ANY32_S |
Device used
Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||
KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
PORTPARA | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Features
Set communication parameters when used for run. Please refer to "PORTPARA instruction description" for details.
PROTOCOL instruction
-[PROTOCOL (s) (N)]
Content, range and data type
Parameter | Content | Range | Data type | Data type (label) |
(s) | Protocol number to be set | 0 to 65535 | Unsigned BIN 16 bit | ANY16 |
(N) | Which communication port to set (0 means COM1, 1 means COM2 *1) | 1 | Unsigned BIN 16 bit | ANY16 |
Device used
Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||
KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
PROTOCOL | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Features
Set the communication protocol when used for run. The instruction above actually is to set a specific value for the parameter modification flag.
The calculation formula is: (parameter setting value + the offset of the start special device corresponding to the serial port + 10)*2
For example, setting the protocol to ModbusRTU master station (H20) is (0x20 +2593-2590 +10)*2, which is (32 +3+10) *2=90. This is to prevent the serial port parameters from being modified at will. .
In Modbus master protocol, the trigger of setting parameters is to change the value after an instruction is completed.
In Modbus slave protocol, the trigger of setting parameters is that to switch as long as it is not processing the received data.
For details, please refer to "PROTOCOL instruction description"
3) Host computer settings
The PLC parameter setting of host computer can set the corresponding serial port parameters.
Specialized protocol station number cannot be 0.
The station number under ModbusRTU and ModbusASCII protocol is 0: the protocol sets the master station.
The station number under ModbusRTU and ModbusASCII protocol is not 0: the protocol sets the slave station.
The serial port parameters are filled in according to the content in the form.
✎Note: RTU protocol cannot set data bit of 7-bit.
4)Priority description of serial port parameters
The priority of serial port parameter settings are listed as blow. The serial port parameters are saved by power failure currently.
Serial port parameter set instruction setting = Ladder program MOV instruction set the corresponding SD device > the download parameters of host computer > Previous power-off save data.
(4) Basic ladder program
Serial port parameter setting
Baud rate 115200, data bit 8, parity bit none, stop bit 1
Communication protocol setting: ModbusRTU master station protocol
Sending interval: 5ms
Receiving timeout: 100ms
Timeout retry times: 3 times
Station number 01H, function code 03H, slave address 10, length 05
10.7.2.3 Send and receive process
(1) Modbus master station
When programming, before each RS (Modbus mode) instruction, the assignment of each operand unit, such as the communication operation object address, operation type, operation register address, data number, sending or receiving unit, etc., is completed, once the execution starts, the system program will automatically calculate the CRC check, organize the communication frame, and complete the operation of sending data and receiving response.
If you use Modbus-ASC protocol communication (set SD2592 as H30), the HEX-ASC format conversion of sending and receiving data is automatically completed by the PLC system program. The RS (Modbus mode) instruction method and the Modbus-RTU protocol method are exactly the same.
In the plc program, if multiple RS (Modbus mode) instructions are driven, the system program will still execute the "sending, waiting for answer, receiving, verification, analysis and storage" of an RS instruction, and then perform the same process for the next RS instruction until all RS instructions are executed and then restarted. You don not need to care about the timing and process of its execution, which simplifies the PLC programming design. This is the advantage of Modbus instruction.
Modbus master function list
Function code | Function name | Details |
0x01 | Coil readout | Coil readout (multiple points optional) |
0x02 | Input readout | Input and read (multiple points optional) |
0x03 | Holding register readout | Holding register readout(multiple points optional) |
0x04 | Input register readout | Input register readout (multiple points optional) |
0x05 | 1 coil write | Coil writing (only 1 point) |
0x06 | 1 register write | Holding register write (only 1 point) |
0x0F | Batch coil write | Multi-point coil writing |
0x10 | Batch register write | Multi-point holding register write |
Serial port parameter setting
Baud rate 115200, data bit 8, no parity bit, stop bit 1
Example:
Communication protocol setting: ModbusRTU master station protocol
Sending interval: 5ms
Receiving timeout: 100ms
Timeout retry times: 3 times
Station number 01H, function code 03H, slave address 10, length 05
As shown in the ladder program shown:
When M1 is turned ON, PLC will send data (hexadecimal) from COM2 of PLC: 01 03 00 0A 00 05 A5 C8
- 01: Slave address, the high 8 bits of (s);
- 03: Modbus instruction code, the lower 8 bits of (s). It is to read the slave register;
- 00 0A: The address of the slave register to be read, the value of (m);
- 00 05: The number of registers to be read, the value of (d),
- A5 C8: CRC check code.
✎Note:
When using 1 coil to write (0x05), the value used for writing 1 is 0xFF00, and the value used for writing 0 is 0x0000.
When using batch coil write (0x0F), pay attention to the high and low byte exchange. For example, when writing 1 length, the fourth parameter value is 1 (0x0001), which means 0 is sent. You need to write 256 (0x0100) to write 1 to the target address.
(2) Modbus slave
When the PLC series is used as a Modbus slave, it supports Modbus communication operation instructions such as 0x01, 0x03, 0x05, 0x06, 0x 0f, 0x10. The coils of the PLC that can be read and written include M, S, T, C, X (only Read) SM, Y, LC, HSC and other variables through these instructions. Register variables include D, T, C, R, SD, LC, HSC.
When the Modbus communication master accesses (reads or rewrites) the internal variables of the PLC slave, it must follow the following communication instruction frame definition and the variable address index method in order to carry out normal communication operations.
1) instruction code 0x01 (01): read coil
Serial number | Data (byte) meaning | Number of bytes | Instruction |
1 | Slave address | 1 byte | Value 1 to 247, set by SD2544, SD2594 |
2 | 0x01 (instruction code) | 1 byte | Read coil |
3 | Coil start address | 2 bytes | High bit in front, low bit in back, see coil addressing |
4 | Number of coils | 2 bytes | High bit in front, low bit in back (N) |
5 | CRC check | 2 bytes | Low bit in front, high bit in back |
Response frame format: slave address + 0x01 + number of bytes + coil status + CRC check
Serial number | Data (byte) meaning | Number of bytes | Instruction |
1 | Slave address | 1 byte | Value 1 to 247, set by SD2544, SD2594 |
2 | 0x01 (instruction code) | 1 byte | Read coil |
3 | Number of bytes | 1 byte | Value: [(N+7)/8] |
4 | Coil state | [(N+7)/8] bytes | Every 8 coils are combined into one byte. If the last one is less than 8 bits, fill in 0 in the undefined part. The first 8 coils are in the first byte, and the coil with the smallest address is in the lowest bit. And so on |
5 | CRC check | 2 bytes | High bit first, then low bit |
Error response: refer to error response frame.
2) instruction code 0x03 (03): read register
Request frame format: slave address + 0x03 + register start address + number of registers + CRC check.
Serial number | Data (byte) meaning | Number of bytes | Instruction |
1 | Slave address | 1 byte | Value 1 to 247, set by SD2544, SD2594 |
2 | 0x03 (instruction code) | 1 byte | Read register |
3 | Register start address | 2 bytes | High bit in front, low bit in back, see register addressing |
4 | Number of registers | 2 bytes | High bit in front, low bit in back (N) |
5 | CRC check | 2 bytes | High bit in front, low bit in back |
Response frame format: slave address + 0x03 + number of bytes + register value + CRC check.
Serial number | Data (byte) meaning | Number of bytes | Instruction |
1 | Slave address | 1 byte | Value 1 to 247, set by SD2544, SD2594 |
2 | 0x03 (instruction code) | 1 byte | Read register |
3 | Number of bytes | 1 byte | Value: N*2 |
4 | Register value | N*2 bytes | Every two bytes represent a register value, with high bit in front, low bit in back. The smallest register address comes first |
5 | CRC check | 2 bytes | High bit in front, low bit in back |
Error response: See error response frame.
3) instruction code 0x05 (05): write single coil
Request frame format: slave address + 0x05 + coil address + coil status + CRC check.
Serial number | Data (byte) meaning | Number of bytes | Instruction |
1 | Slave address | 1 byte | Value 1 to 247, set by SD2544, SD2594 |
2 | 0x05 (instruction code) | 1 byte | Write single coil |
3 | Coil address | 2 bytes | High bit in front, low bit in back, see coil addressing |
4 | Coil state | 2 bytes | High bit in front, low bit in back. Non-zero is valid |
5 | CRC check | 2 bytes | High bit in front, low bit in back |
Response frame format: slave address + 0x05 + coil address + coil status + CRC check.
Serial number | Data (byte) meaning | Number of bytes | Instruction |
1 | Slave address | 1 byte | Value 1 to 247, set by SD2544, SD2594 |
2 | 0x05 (instruction code) | 1 byte | Write single coil |
3 | Coil address | 2 bytes | High bit in front, low bit in back, see coil addressing |
4 | Coil state | 2 bytes | High bit in front, low bit in back. Non-zero is valid |
5 | CRC check | 2 bytes | High bit in front, low bit in back |
Error response: see error response frame. The coil status 0xFF00 means ON, and 0x0000 means OFF.
4) instruction code 0x06 (06): write a single register
Request frame format: slave address + 0x06 + register address + register value + CRC check.
Serial number | Data (byte) meaning | Number of bytes | Instruction |
1 | Slave address | 1 byte | Value 1 to 247, set by SD2544, SD2594 |
2 | 0x06 (instruction code) | 1 byte | Write single coil |
3 | Register | 2 bytes | High bit in front, low bit in back, see coil addressing |
4 | Register value | 2 bytes | High bit in front, low bit in back. Non-zero is valid |
5 | CRC check | 2 bytes | High bit in front, low bit in back |
Response frame format: slave address + 0x06 + register address + register value + CRC check.
Serial number | Data (byte) meaning | Number of bytes | Instruction |
1 | Slave address | 1 byte | Value 1 to 247, set by SD2544, SD2594 |
2 | 0x06 (instruction code) | 1 byte | Write single coil |
3 | Register | 2 bytes | High bit in front, low bit in back, see coil addressing |
4 | Register value | 2 bytes | High bit in front, low bit in back. Non-zero is valid |
5 | CRC check | 2 bytes | High bit in front, low bit in back |
Error response: See error response frame.
5) instruction code 0x 0f (15): write multiple coils
Request frame format: slave address + 0x 0f + coil start address + coil number + byte number + coil status + CRC check.
Serial number | Data (byte) meaning | Number of bytes | Instruction |
1 | Slave address | 1 byte | Value 1 to 247, set by SD2544, SD2594 |
2 | 0x 0f (instruction code) | 1 byte | Write multiple single coils |
3 | Coil start address | 2 bytes | High bit in front, low bit in back, see coil addressing |
4 | Number of coils | 2 bytes | High bit in front, low bit in back. The maximum of N is 1968 |
5 | Number of bytes | 1 byte | Value: [(N+7)/8] |
6 | Coil state | [(N+7)/8] bytes | Every 8 coils are combined into one byte. If the last one is less than 8 bits, fill in 0 in the undefined part. The first 8 coils are in the first byte, and the coil with the smallest address is in the lowest bit. And so on |
7 | CRC check | 2 bytes | High bit in front, low bit in back |
Response frame format: slave address + 0x 0f + coil start address + coil number + CRC check
Serial number | Data (byte) meaning | Number of bytes | Instruction |
1 | Slave address | 1 byte | Value 1 to 247, set by SD2544, SD2594 |
2 | 0x 0f (instruction code) | 1 byte | Write multiple single coils |
3 | Coil start address | 2 bytes | High bit in front, low bit in back, see coil addressing |
4 | Number of coils | 2 bytes | High bit in front, low bit in back |
5 | CRC check | 2 bytes | High bit in front, low bit in back |
Error response: See error response frame.
6) 3.2.6 instruction code 0x10 (16): write multiple registers
Request frame format: slave address + 0x10 + register start address + register number + byte number + register value + CRC check.
Serial number | Data (byte) meaning | Number of bytes | Instruction |
1 | Slave address | 1 byte | Value 1 to 247, set by SD2544, SD2594 |
2 | 0x10(instruction code) | 1 byte | Write multiple registers |
3 | Register start address | 2 bytes | High bit in front, low bit in back, see register addressing |
4 | Number of registers | 2 bytes | High bit in front, low bit in back. The maximum of N is 120 |
5 | Number of bytes | 1 byte | Value: N*2 |
6 | Register value | N*2 (N*4) | |
7 | CRC check | 2 bytes | High bit in front, low bit in back |
Response frame format: slave address + 0x10 + register start address + register number + CRC check.
Serial number | Data (byte) meaning | Number of bytes | Instruction |
1 | Slave address | 1 byte | Value 1 to 247, set by SD2544, SD2594 |
2 | 0x10 (instruction code) | 1 byte | Write multiple registers |
3 | Register start address | 2 bytes | High bit in front, low bit in back, see register addressing |
4 | Number of registers | 2 bytes | High bit in front, low bit in back. The maximum of N is 120 |
5 | CRC check | 2 bytes | High bit in front, low bit in back |
Error response: See error response frame.
7) Error response frame
Error response: slave address + (instruction code + 0x80) + Error code + CRC check.
Serial number | Data (byte) meaning | Number of bytes | Instruction |
1 | Slave address | 1 byte | Value 1 to 247, set by SD2544, SD2594 |
2 | Instruction code+0x80 | 1 byte | Error instruction code |
3 | Code | 1 byte | 1 to 4 |
4 | CRC check | 2 bytes | High bit in front, low bit in back |
Serial number | Error code | Instruction |
1 | 01 | Unsupported function code |
2 | 02 | Wrong address or function code |
3 | 03 | Wrong length |
4 | 04 | Imperfect instruction |
5 | 05 | Address not allowed |
8) Slave address table
Word address | ||||
Address type | Occupy | Address range | Decimal address | Total reserved address size |
T0 to T511 | 512 WORD | 0x0000-0x01ff | 0 | 1536 |
C0 to C255 | 256 WORD | 0x0600-0x06ff | 1536 | 1024 |
LC0 to LC255 | 512 WORD | 0x0A00-0x0BFF | 2560 | 1024 |
HSC0 to HSC15 | 32 WORD | 0x0E00-0x0E1F | 3584 | 512 |
D0 to D7999 | 8000 WORD | 0x1000-0x2F3F | 4096 | 16384 |
SD0 to SD4095 | 4096 WORD | 0x5000-0x5FFF | 20480 | 12288 |
R0 to R29999 | 30000 WORD | 0x8000-0xF52F | 32768 | 30000 |
Bit address | ||||
Address type | Occupy | Address range | Decimal address | Total reserved address size |
T0 to T511 | 512 bit | 0x0000-0x01ff | 1536 | |
C0 to C255 | 256 bit | 0x0600-0x06ff | 1536 | 1024 |
LC0 to LC255 | 256 bit | 0x0A00-0x0AFF | 2560 | 1024 |
HSC0 to HSC15 | 16 bit | 0x0E00-0x0E0F | 3584 | 512 |
M0 to M7999 | 8000 bit | 0x1000-0x2F3F | 4096 | 16384 |
SM0 to SM4095 | 4096 bit | 0x5000-0x5FFF | 20480 | 12288 |
Reserved | 0x8000-0xBFFF | 16383 | ||
S0 to S4095 | 4096 bit | 0xC000-0xCFFF | 49152 | 8192 |
X0 to X1777 | 1024 bit | 0xE000-0xE3FF | 57344 | 4096 |
Y0 to Y1777 | 1024 bit | 0xF000-0xF3FF | 61440 | 4096 |
Error message
Currently the Error code will be displayed on SD7 and SD0 and SD2611 and SD2612.
The Error codes that appear in the Modbus protocol are mainly as follows.
Error code | Content |
4085H | (s)(m)(d)(N) The read address is out of the device range (this error is only displayed on SD7 and SD0) |
3180H | COM2 data reception error. There may be interference on the communication line, it is recommended to connect the ground wire. |
3181H | COM2 data reception timed out. "Check the wiring, check whether the serial port parameter settings are compatible with master and slave, check whether there is interference. Check whether the slave station is too late to respond. For this reason, you can try to increase the sending interval SD2546." |
3182H | COM2 CRC check error. There may be interference on the communication line, it is recommended to connect the ground wire. |
3183H | COM2 LRC check error. There may be interference on the communication line, it is recommended to connect the ground wire. |
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 the station. |
3185H | COM2 send buffer overflow. Contact a technician if this error occurs |
3186H | COM2 function code is wrong. Check whether the set function code is a function code supported by PLC |
3187H | COM2 address is wrong. Check whether the slave station has this address (please refer to Modbus Abnormal 02) |
3188H | The length of COM2 is wrong. Check whether the communication length exceeds the length range specified by the Modbus protocol, or whether it exceeds the specified length range of the custom protocol. |
3189H | COM2 data error. "Check whether there are errors in the parameters of the instruction. Check whether the slave station supports the setting of this value. (Please refer to Modbus Abnormal 03)" |
318AH | COM2 slave is busy. Slave station returns information: Slave station is busy (please refer to Modbus exception 06) |
318BH | The COM2 slave station does not support function codes. Check whether the slave station supports this function code (please refer to Modbus exception 01) |
318CH | The COM2 slave is faulty. Slave station returns information: Slave station is faulty, please check whether the slave station is faulty (please refer to Modbus Abnormal 04) |
318DH | COM2 slave confirms. Slave station return information: slave station confirmation (please refer to Modbus abnormal 05) |
318EH | COM2 current protocol does not support this instruction. RS instruction cannot be used when it is set to slave station protocol, please change the protocol or close the contact before RS instruction (this error is only displayed on SD7 and SD0) |
318FH | COM2 sending timed out. Contact a technician if this error occurs |
3190H | COM2 receiving data exceeds the buffer limit. |
31A0H | COM2 is not available as a gateway. Returned information from the station: unavailable gateway (please refer to Modbus exception 0A) |
31A1H | COM2 indicates that no response was obtained from the target device. Slave station returns information: the device is not in the network (please refer to Modbus exception 0B) |
After resetting the protocol or communication parameters, the error will be cleared.
In addition, the communication completion/communication error/communication timeout flag will be set after the executed instruction.
PLCLINK/Fast interconnect
PLCLINK function is used to simplify the fast connection between PLCs. The fast communication of the LX5V series PLC could be achieved only using the configuration parameters without using the communication instruction(RS).
The topological diagram is shown in the figure below.
When using the PLCLINK function:
- Master station configuration: Select COM2 port and set the protocol to PLCLINK protocol.
- Slave configuration: Select COM1 or COM2 and set the protocol to dedicated protocol.
(1) Create a table
In [Project manager]-[Extended function]-[PLCLINK], right click [PLCLINK], and click it to create a table.
Click it and a prompt box as below would pop up.
Click "Yes" will automatically change the protocol to PLCLINK, click "No" will not change the protocol.
The number of PLCLINK protocol is H60.
0H | Wecon Modbus slave station |
2H | ModbusRTU slave station |
3H | ModbusASCII slave station |
10H | user-defined protocol |
20H | ModbusRTU main station |
30H | ModbusASCII main station |
60H | PLCLINK protocol |
Click "Yes" will generate an empty table MAIN.
Double click MAIN will pop up the POLCLINK table as below.
Currently only one PLCLINK table can be created. Creating a new table after creating one is disallowed.
(2) Write the table
After writing the station number in the new instruction station number in the table, click the new instruction to add the communication instruction.
The range of station number is 1 to 31. The maximum number of communication instruction is 255.
Currently the station number is only selected by drop-down box.
The devices of main station and slave station are selected by drop-down box.
The transfer direction are read and write, and also selected by drop-down box.
The device address range limitations are as below.
- The device address could not exceed the current device range
- In the device of bit written, the mantissa of points of X and Y must be zero, such as X0, X10, X20, Y0, Y10, Y20 and so on. The software PLC Editor 2 will adjust automatically.
- The Points of bit device other than X and Y must be a multiple of 8,such as M0, M8, N16, T(bit) 16, C(bit) 24 and so on. The software PLC Editor 2 will adjust automatically.
- Bit device must communicate with bit device , and word device must communicate with word device. Double word device can only communicate with double word device. This is to avoid length perception differences.
The number limitations of slave station device are as below.
- The number of bit device ranges from 8 to 2,032.
- The number of word device ranges from 1 to 126.
- The number of double word device ranges from 1 to 63. HSC can only use a maximum of 16 due to the number limitation.
- The number of bit device must be a multiple of 8, such as 8, 16, 24, 32 and so on. The software PLC Editor 2 will adjust automatically.display the corresponding device address and range.
(3) Download
Currently PLCLINK could only be downloaded with the program and could not downloaded separately.
Click on PLCLINK in monitoring mode to re-write part of the table into PLC, but the start device could not be modified.
In monitoring mode, monitoring read and monitoring write could not be executed if the ladder program comparison is incorrect.
(4) Automatic check
Click “Check” in monitoring mode, the PLC that can communicate will be automatically searched and enabled. Stations that could not communicate will be closed. The Stations without instructions will not be checked. The PLCLINK table will be updated after the automatic check of the upper computer is finished.
Write 1 to in the table for addresses whose start address is offset 12 (for example, R200 is R212). The corresponding function is as below.
S1+12 | Auto check mode (Reserved) | 0: No check; 1: Automatic check mode; 2: Automatic check in progress. When enabled, all the station numbers will send data to determine whether the station number exists. The corresponding communication switch will be turned on if it exists. If not, the corresponding communication switch will be turned off. |
No error will be reported during auto check after the auto check is enabled. After the check is complete, the corresponding station number will be automatically enabled and disabled.
S1+13 | Corresponding station number communication switch 1 | The switch control of station 1 to 15 Bit0: ON: Station number 0 (broadcast) normal communication OFF: Station number 0 (broadcast) communication prohibited (broadcast prohibited) Bit1: ON: Station number 1 normal communication; OFF: Station 1 communication prohibited Bit2: ON: Station number 2 normal communication; OFF: Station 2 communication prohibited |
S1+14 | Corresponding station number communication switch 2 | The switch control of station 16 to 31 |
Click [station number enable] to set the station enable according to the corresponding situations.
✎Note: When in the automatic check state, forcibly turn off the automatic check state (write 0 in S1+12), an error may occur.
(5) Master station parameter configuration
The protocol must be PLCLINK protocol, and the data bit can not be 7-bit data bit. Other parameters can be selected as required.
(6) Slave station configuration
For PLCLINK communication ports, select the dedicated protocol from the station protocol.
The settings of Baud rate, data bit, stop bit, parity bit must be consistent with main station. The parameters above are consistent if not modified. The station number needs to be configured separately. The slave station number ranges from 1 to 31.
(7) Close PLCLINK
In S1+11, The pause and start of PLCLINK are controlled by bit 8. If bit 8 is ON, PLCLINK would be closed. No error is reported when switching protocol after this function is disabled.
S1+11 | Operation state | Bit0=1,Port is occupied. This function obtains the right of data transaction transmission. Bit2=1,One cycle has been executed. Bit4,Communication transmission output indication Bit5,Communication error output indication (Exceeds the number of retry times) Bit6,Communication completion output indication Bit8,PLCLINK suspension (0: Normal operation, 1: Operation paused) |
(8) Table contents
Currently the communication table is downloaded to the device to operate. The details of the table are as follows.
Address offset | Brief description | Detailed description | |
High byte | Low byte | ||
S1+0 | Header | Header =70h, correct PLCLINK table. (modification prohibited) | |
S1+1 | Number of communication instructions | 1 to 255 (modification prohibited) | |
S1+2 | Version | V1.100 (modification prohibited) | |
S1+3 | The start address of communication table | modification prohibited | |
S1+4 | Check bit of the number of header and communication | Simple check calculation for table header, number of communication instructions, version, and the start address of communication table ((modification prohibited)) | |
S1+5 | Which instruction currently is running | Display the current running command (read only) | |
S1+6 | Station NO.1 | Read/write direction | The instruction content of current communication |
S1+7 | The data start address of station NO.1 | ||
S1+8 | Station NO.2 | Address type distinction | |
S1+9 | The data start address of station NO.2 | ||
S1+10 | Data length | ||
S1+11 | Operation state | Bit0=1,Port is occupied. This function obtains the right of data transaction transmission. Bit2=1, One cycle has been executed. Bit4, Communication transmission output indication Bit5, Communication error output indication (Exceeds the number of retry times) Bit6, Communication completion output indication Bit8, PLCLINK suspension (0: Normal operation, 1: Operation paused) | |
S1+12 | Auto check mode (Reserved) | 0: No check; 1: Automatic check mode; 2: Automatic check in progress. When enabled, all the station numbers will send data to determine whether the station number exists. The corresponding communication switch will be turned on if it exists. If not, the corresponding communication switch will be turned off. | |
S1+13 | Corresponding station number communication switch 1 | The switch control of station 1 to 15 Bit0: ON: Station NO. 0 (broadcast) normal communication OFF: Station NO.0 (broadcast) communication prohibited (broadcast prohibited) Bit1: ON: Station NO.1 normal communication; OFF: Station NO.1 communication prohibited Bit2: ON: Station NO.2 normal communication; OFF: Station NO.2 communication prohibited | |
S1+14 | Corresponding station number communication switch 2 | The switch control of station 16 to 31 | |
S1+15 | Reserved | ||
S1+16 | Reserved | ||
S1+17 | Reserved | ||
S1+18 | Reserved | ||
S1+19 | Reserved | ||
S1+20 | Reserved | ||
S1+21 | Station NO.1 | Read/write direction | • Station NO. 1 to 32, FF(FF represents main station) • Function code: =01H, read =02H, write |
S1+22 | The data start address of station NO.1 | • Valid word. Define operating the start address of slave station data | |
S1+23 | Station NO.2 | Address type distinction | •Station NO.0 to 32 (If it is 0, broadcast to all the slave stations on behalf of master station, and slave stations do not respond •Distinguish the type of the starting device for storing data in the main station. Main station address type distinction. 0: word address; 1: bit address |
S1+24 | The data start address of station NO.2 | • Valid word. Define operating the start device of slave station data. Define the corresponding address by MUDBUS address of 5V. | |
S1+25 | Data length | • Valid word. Range 1 to 126(bit data), 1 to 2,032(bit data) | |
S1+26 | Station NO.1 | Read/write direction | The second data transmission description. Main station address type distinction. |
S1+27 | The data start address of station NO.1 | ||
S1+28 | Station NO.2 | Address type distinction | |
S1+29 | The data start address of station NO.2 | ||
S1+30 | Data length | ||
• | |||
• | |||
S1+20+ n×5 | Reserved | • n is the total number of data transmission commands. |
✎Note:
- It is forbidden to modify S0 to S4.
- It is not recommended to change the value except the function enable or station number enable. Otherwise, the operation or upload may be abnormal.
Error code
Error code | Contents |
31C0H | Abnormal PLCLINK header. Re-download the program. |
31C1H | PLCLINK function is not supported by COM port currently. |
31C2H | PLCLINK table version is incompatible. Re-download the program. |
31C3H | The number of PLCLINK command exceeds the range. The value ranges from 1 to 255 Currently. |
31C4H | The station number of PLCLINK table exceeds the range. Check the station number in the table. |
31C5H | PLCLINK table exceeds the range of device. Check the corresponding device range of table. |
31C6H | The device used by PLCLINK table command exceeds the range. Check the device used for each command in the table. |
3180H | COM2 data reception error. There may be interference on the communication line. It is recommended to connect the ground wire. |
3181H | COM2 data reception time. Check wiring, whether the parameters of the serial port setting is master-slave correspondence, whether there is interference, whether it is caused by the delay of the slave station. For this reason, try to increase the sending interval SD2546. |
3182H | COM2 CRC check error. There may be interference on the communication line. It is recommended to connect the ground wire. |
3184H | COM2 station number error. Check the setting of slave station number. Check whether there is a problem with the slave receiving and sending mechanism. |
3186H | COM2 function code error. Check whether the function code is supported by PLC. |
3187H | COM2 address error. |
3188H | COM2 length error. Check whether the communication length exceeds the length range specified by Modbus or user-defined protocol. |
3189H | COM2 data error. Check whether the parameter of instruction is wrong. Check whether the setting of the value is supported by slave station. (Please refer to Modbus abnormal 03) |
318AH | COM2 slave station is busy. Slave station returns message: Slave station is busy. (Please refer to Modbus abnormal 06) |
318BH | COM2 slave station does not support function codes. Check whether the function code is supported by slave station. (Please refer to Modbus abnormal 01) |
318CH | COM2 slave station fault. Slave station returns message: Slave station is fault. Check whether the slave station is faulty. (Please refer to Modbus abnormal 04) |
318DH | COM2 slave station confirmation. Slave station returns message: Slave station confirmation.(Please refer to Modbus abnormal 05) |
318EH | COM2 does not support this instruction or function. When slave station protocol is set, the corresponding communication instruction or function of main station could not be used. Please change the protocol or close the contacts before the corresponding instruction, or the corresponding communication function. |
3190H | The data received by COM2 exceeds the cache limit. |
Example
Create a PLCLINK table and automatically switch the Com2 protocol to PLCLINK.
Open PLCLINK table, write the master station D10 to the slave station D10 device number 10, and read the slave station D10 to the master station D20 device number 10.
Connect Com2 of master station PLC to COM1 of slave station, and set the slave station number to 1. After downloading, set the value of main station D10 to 1 and D11 to 8192 . Then, D20 will change to 1 and and D21 will change to 8192.
The situation of connecting more than one
When adding commands, the station number that corresponding more slave station number can add more station number communication connections
Wecon Modbus protocol description
The current Wecon Modbus protocol description (special protocol) is modified based on the ModbusRTU protocol.
Therefore, 7-bit data bits cannot be used in the serial port parameter part.
The protocol of COM0 and COM1 can only use WECON Modbus protocol at present and cannot be changed.
This protocol is fully compatible with Modbus RTU protocol, and the address is also the same as the default address of LX5V PLC's Modbus RTU protocol.
The extended function is mainly used to communicate with PLCEDITOR.