10 Communication

Last modified by Devin Chen on 2024/04/09 10:21

Communication

Protocol

PROTOCOL(P)

Set (s) protocol for (N) communication port.

-[PROTOCOL (S) (N)]

Content, range and data type

ParameterContentRangeData typeData type (label)
(S)Protocol number to be set-Unsigned BIN 16 bitANY16
(N)Which communication port to set, 0 means COM1, 1 means COM2 *10, 1Unsigned BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset

modification

Pulse

extension

KnYKnMKnSTCDRSDKH[D]XXP
PROTOCOLParameter 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.

✎Note: Whether it is by self-calculation and then modifying the setting value of the identifier (COM1 SD2543, COM2 SD2593) to the protocol, or using this instruction to set, it is possible to modify the protocol when the PLC is in the RUN state.

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 NumberContent
0 HWecon Modbus slave
2 HModbusRTU slave
3 HModbusASCII slave
10 HUser-defined protocol
20 HModbusRTU master station
30 HModbusASCII master

Related software components

DevicesContent
SD2542COM1 protocol settings
SD2543COM1 protocol modification sign
SD2592COM2 protocol settings
SD2593COM2 protocol modification sign

✎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.

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 codeContent
4085HThe read address of (s) and (N) exceeds the device range
4084H(N) is not 1

Example

10_html_2947ba20da1d1c90.png

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.

10_html_38333ed8624e86d1.png

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.

10_html_54692bd97d6e3bfd.png

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

ParameterContentRangeData typeData type (label)
(s)Serial port parameters to be set-Unsigned BIN 16 bitANY16
(N)Which communication port to set, 0 means COM1, 1 means COM20, 1Unsigned BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset

modification

Pulse

extension

KnYKnMKnSTCDRSDKH[D]XXP
ECAMCUTParameter 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.

✎Note: Whether it is by self-calculation and then to the serial port parameter to modify the flag (COM1 SD2541, COM2 SD2591) setting value, or use this instruction to set, it is possible to modify the serial port parameter when the PLC is in the RUN state.

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 numberB0B1、B2B3B4、B5、B6、B7、B8、B9B10B11
NameData lengthParityStop BitBaud Rate(bps)STXETX
Content0 off7bit

b2,b1

(0,0):None

(0,1):Odd parity(ODD)

(1,1):Even parity(EVEN)

1bit
48000111
96001000
192001001
384001010
576001011
1152001100
1875001101
2304001110
4608001111
92160010000
Turn off STX functionTurn off ETX function
1 on8bit2bitEnable STX function, the specific value is set by D8124Turn on the ETX function, the specific value is set by D8125

Related software components

DevicesContent
SD2540COM1 serial port parameter setting
SD2541COM1 serial port parameter modification identification
SD2590COM2 serial port parameter setting
SD2591COM2 serial port parameter modification sign

✎Note: The setting of communication parameters will affect the overall communication. The processing in the PLC is to be modified when there is no communication or after a round of communication is completed. This point needs attention.

STX function and ETX function are only useful in the case of custom protocol.

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 codeContent
4085HThe read address of (s) and (N) exceeds the device range
4084H(N) is not 0 or 1

Example

10_html_4a65cac3b7fac971.png

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

10_html_6c71076e92745b55.png

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.

10_html_b19182554f11878c.png

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

ParameterContentRangeData typeData type (label)
(s)Station number to be set0 to 255Unsigned BIN 16 bitANY16
(N)Which communication port to set 0 means COM1, 1 means COM20, 1Unsigned BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset

modification

Pulse

extension

KnYKnMKnSTCDRSDKH[D]XXP
ECAMCUTParameter 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

DevicesContent
SD2544COM1 station number setting
SD2545COM1 station number modification sign
SD2594COM2 station number setting
SD2595COM2 station number modification sign

Error code

Error codeContent
4085HThe 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

10_html_687577f8e28f9089.png

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

10_html_b474623d8ed5305f.png

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.

10_html_309b7cb63c6f5d1b.png

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:

ParameterContentRangeData typeData type (label)
(s)The start address of register area that stores the data to be sent-Unsigned BIN 16 bitANY16
(m)The length of data to be sent (bytes)0 to 523Unsigned BIN 16 bitANY16
(d)The device start number that stores the written data-Unsigned BIN 16 itANY16
(N)Number of data written (bytes)0 to 523Unsigned BIN 16 bitANY16

In the case of Modbus protocol:

ParameterContentRangeData 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 bitANY16
(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 bitANY16
(d)Length. The length of Modbus read or write. The unit is determined by function code.-Unsigned BIN 16 bitANY16
(N)Start address for reading or writing data-Unsigned BIN 16 bitANY16

Device used

InstructionParameterDevicesOffset modification

Pulse

extension

TCDRKH[D]XXP
RSParameter 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 numberB0B1、B2B3

B4、B5、B6、

B7、B8、B9

B10B11
NameData lengthParityStop BitBaud rate(bps)STXETX
Content

0

off

7-bit

b2, b1

(0,0): None

(0,1): Odd parity (ODD)

(1,1): Even parity (EVEN)

1-bit
9600001000
19200001001
38400001010
57600001011
115200001100
187500001101
230400001110
460800001111
921600010000
NoneNone

1

on

8-bit2-bitTurn on STX, the STX value is set in SD2600Turn on ETX, the ETX value is set in SD2601

Example

10_html_dbd00c955b74b44.png

When M1 is ON, the sending and receiving data of communication after executing instruction is stored as the following figure.

10_html_fa670961ae3e6f05.gif

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:

10_html_487e57593173359e.png

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.

10_html_9d0ddca3305d21b0.png

ParameterContent
(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

10_html_a7e64b4f4526b73e.png

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 codeContent
4085HThe read address of (s), (m), (d) and (N) exceed the device range.
3180HCOM2 data reception error. There may be interference on the communication line, it is recommended to connect the ground wire.
3181HCOM2 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."
3182HCOM2 CRC check error. There may be interference on the communication line, it is recommended to connect the ground wire.
3183HCOM2 LRC check error. There may be interference on the communication line, it is recommended to connect the ground wire.
3184HThe 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.
3185HCOM2 send buffer overflow. Contact a technician if this error occurs
3186HCOM2 function code is wrong. Check whether the set function code is a function code supported by PLC
3187HCOM2 address is wrong. Check whether the slave station has this address (please refer to Modbus Abnormal 02)
3188HThe 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.
3189HCOM2 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)"
318AHCOM2 slave station is busy. Slave station returns information: Slave station is busy (please refer to Modbus exception 06)
318BHCOM2 slave station does not support function codes. Check whether the slave station supports this function code (please refer to Modbus exception 01)
318CHCOM2 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)
318DHCOM2 slave station confirmation. Slave station return information: slave station confirmation (please refer to Modbus abnormal 05)
318EHCOM2 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.
318FHCOM2 sending timed out. Contact a technician if this error occurs
31A0HCOM2 is not available as a gateway. Slave station returns information: unavailable gateway (please refer to Modbus exception 0A)
31A1HCOM2 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

ParameterContentRangeData typeData type (label)
(s)The start address of register area that stores the data to be sent-Unsigned BIN 16 bitANY16
(m)The length of data to be sent (bytes)0 to 528Unsigned BIN 16 bitANY16
(d)The device start number that stores the written data-Unsigned BIN 16 bitANY16
(N)Number of data written (bytes)0 to 528Unsigned BIN 16 bitANY16
(n1)Specify the communication port Unsigned BIN 16 bitANY16

In Modbus protocol

ParameterContentRangeData typeData 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 bitANY16
(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 bitANY16
(d)Length. The length of Modbus read or write. The unit is determined by function code.-Unsigned BIN 16 bitANY16
(N)The start address of the data to be read or written-Unsigned BIN 16 bitANY16
(n1)Specify the communicatiom port Unsigned BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset modification

Pulse extension

TCDRSDKH[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 numberB0B1、B2B3

B4、B5、B6、

B7、B8、B9

B10B11
NameData lengthParityStop BitBaud rate(bps)STXETX
Content

0

off

7-bit

b2, b1

(0,0): none

(0,1): odd parity (ODD)

(1,1): even parity (EVEN)

1-bit
9600001000
19200001001
38400001010
57600001011
115200001100
187500001101
230400001110
460800001111
921600010000
NoneNone

1

on

8-bit2-bitTurn on STX, the STX value is set in the device of the corresponding communicationTurn on ETX, the ETX value is set in the device of the corresponding communication

Example

10_html_42196c0b440282c3.gif

When M1 is ON, the sending and receiving data of communication after executing instruction is stored as the following figure.

image-20220926140831-1.jpeg

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:

10_html_1917cca86a75115b.png

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.

10_html_d97afb4fe5346ca.gif

ParameterContent
(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

10_html_7400bc2aa339cd6d.png

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 codeContent
4085HThe read address of (s), (m), (d) and (N) exceed the device range.
4084HThe parameter value exceed the specified range
3080HCOM1 data reception error. There may be interference on the communication line, it is recommended to connect the ground wire.
3081HCOM1 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".
3082HCOM1 CRC check error. There may be interference on the communication line, it is recommended to connect the ground wire.
3083HCOM1 LRC check error. There may be interference on the communication line, it is recommended to connect the ground wire.
3084HThe 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.
3085HCOM1 send buffer overflow. Contact a technician if this error occurs.
3086HCOM1 function code is wrong. Check whether the set function code is a function code supported by PLC
3087HCOM1 address is wrong. Check whether the slave station has this address (please refer to Modbus Abnormal 02)
3088HThe 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.
3089HCOM1 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)"
308AHCOM1 slave station is busy. Slave station returns information: Slave station is busy (please refer to Modbus exception 06)
308BHCOM1 slave station does not support function codes. Check whether the slave station supports this function code (please refer to Modbus exception 01)
308CHCOM1 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)
308DHCOM1 slave station confirmation. Slave station return information: slave station confirmation (please refer to Modbus abnormal 05)
308EHCOM1 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.
308FHCOM1 sending timed out. Contact a technician if this error occurs.
30A0HCOM1 is not available as a gateway. Slave station returns information: unavailable gateway (please refer to Modbus exception 0A)
30A1HCOM1 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)
3181HCOM2 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".
3182HCOM2 CRC check error. There may be interference on the communication line, it is recommended to connect the ground wire.
3183HCOM2 LRC check error. There may be interference on the communication line, it is recommended to connect the ground wire.
3184HThe 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.
3185HCOM2 send buffer overflow. Contact a technician if this error occurs.
3186HCOM2 function code is wrong. Check whether the set function code is a function code supported by PLC.
3187HCOM2 address is wrong. Check whether the slave station has this address (please refer to Modbus Abnormal 02)
3188HThe 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.
3189HCOM2 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)"
318AHCOM2 slave station is busy. Slave station returns information: Slave station is busy (please refer to Modbus exception 06)
318BHCOM2 slave station does not support function codes. Check whether the slave station supports this function code (please refer to Modbus exception 01)
318CHCOM2 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)
318DHCOM2 slave station confirmation. Slave station return information: slave station confirmation (please refer to Modbus abnormal 05)
318EHCOM2 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.
318FHCOM2 sending timed out. Contact a technician if this error occurs.
31A0HCOM2 is not available as a gateway. Slave station returns information: unavailable gateway (please refer to Modbus exception 0A)
31A1HCOM2 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

ParameterContentRangeData typeData type (label)
(s1)Module number, the first module is 0, the second module is 1, and so on0 to 32767Unsigned BIN 16 bitANY16
(s2)Start writing from which BFM in the module0 to 32767Unsigned BIN 16 bitANY16
(s3)Start number of the device storing the written data-32768 to 32767Signed BIN 16 bitANY16
(N)Number of data written0 to 512Unsigned BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset

modification

Pulse

extension

KnYKnMKnSTCDRSDKH[D]XXP
TOParameter 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).

10_html_603a54a4bdbc6b8f.gif

As the following Circuit program

10_html_9d053b1a8c234094.png

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

DevicesContent
SD2081Total number of modules
SD2082Number of IO expansion modules
SD2083Number of special expansion modules
SD2084The first missing expansion module. When the value is -1, it means not lost

Error code

Error codeContent
4085HThe 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
7080HCheck error when communicating between PLC and module
7081HExpansion module communication message is abnormal
7082HFROM/TO instruction error
7083HThe specified extension module was not found

Example

10_html_936412ccc04cc4cb.png

When M1 is turned on

The values of D200 and D201 will be passed to BFM2 and BFM3 of module #0 (the first)

10_html_555c0224c9a9e02d.png

10_html_ab29c2a6c272559.png

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

ParameterContentRangeData typeData type (label)
(s1)Module number, the first module is 0, the second module is 1, and so on0 to 32767Unsigned BIN 16 bitANY16
(s2)Start writing from which BFM in the module0 to 32767Unsigned BIN 16 bitANY16
(s3)Start number of the device storing the written data-2147483648 to 2147483647Signed BIN 32 bitANY32
(N)Number of data written0 to 256Unsigned BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset

modification

Pulse

extension

KnYKnMKnSTCDRSDLCHSCKH[D]XXP
DTOParameter 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).

10_html_86bfbd89b2652fbf.gif

As the following Circuit program

10_html_d3dfe7b80f649f8e.png

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

DevicesContent
SD2081Total number of modules
SD2082Number of IO expansion modules
SD2083Number of special expansion modules
SD2084The first missing expansion module. When the value is -1, it means not lost

Error code

Error codeContent
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
7080HCheck error when communicating between PLC and module
7081HExpansion module communication message is abnormal
7082HFROM/TO instruction error
7083HThe specified extension module was not found

Example

10_html_12ff08a3df52558c.png

When M1 is turned on

The values from D200 to D203 will be transferred to BFM1 to BFM4 of module #0 (first)

10_html_fe06c272cbdd1f7f.png

10_html_adeb00a341e12368.png

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

ParameterContentRangeData typeData type (label)
(s1)Module number, the first module is 0, the second module is 1, and so on0 to 32767Unsigned BIN 16 bitANY16
(s2)Start reading from which BFM in the module0 to 32767Unsigned BIN 16 bitANY16
(d)Start number of the device storing the read data-Signed BIN 16 bitANY16
(N)Number of read data0 to 512Unsigned BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset modification

Pulse extension

KnYKnMKnSTCDRSDKH[D]XXP
FROMParameter 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.

10_html_1b9d34e74f852368.gif

As the following Circuit program

10_html_ad9897d46ca8f957.png

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:

DevicesContent
SD2081Total number of modules
SD2082Number of IO expansion modules
SD2083Number of special expansion modules
SD2084The first missing expansion module. When the value is -1, it means not lost

Error code

Error codeContent
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
7080HCheck error when communicating between PLC and module
7081HExpansion module communication message is abnormal
7082HFROM/TO instruction error
7083HThe specified extension module was not found

Example

10_html_a9071734dc5cfce5.png

When M1 is turned on

The values of BFM3, BFM4, and BFM5 of the #0 (first) module will be transferred to D200, D201, D202

10_html_f1df0562ea9002cf.png

10_html_73bb66d1890735ff.png

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

ParameterContentRangeData typeData type (label)
(s1)Module number, the first module is 0, the second module is 1, and so on0 to 32767Unsigned BIN 16 bitANY16
(s2)Start reading from which BFM in the module0 to 32767Unsigned BIN 16 bitANY16
(d)Start number of the device storing the read data-Signed BIN 32 bitANY32
(N)Number of read data0 to 256Unsigned BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset

modification

Pulse

extension

KnYKnMKnSTCDRSDLCHSCKH[D]XXP
DFROMParameter 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.

10_html_ea4017a0483ddbbe.gif

As the following Circuit program

10_html_6d0c9e8bc37fe95.png

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:

DevicesContent
SD2081Total number of modules
SD2082Number of IO expansion modules
SD2083Number of special expansion modules
SD2084The first missing expansion module. When the value is -1, it means not lost

Error code

Error codeContent
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
7080HCheck error when communicating between PLC and module
7081HExpansion module communication message is abnormal
7082HFROM/TO instruction error
7083HThe specified extension module was not found

Example

10_html_7389fb305b495d09.png

When M1 is turned on

The value of BFM3 to BFM8 of module #0 (first) will be transferred to D200 to D205

10_html_2f6f4ddff10c30ec.png

10_html_8a1de3e41b64afe1.png

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

ParameterContentRangeData typeData type (label)
(s)The start address of the register area where the data to be sent is stored-Unsigned BIN 16 bitANY16
(m)Is the length of the data to be sent (number of bytes)0 to 528Unsigned BIN 16 bitANY16
(d)Start number of the device storing the written data-Unsigned BIN 16 bitANY16
(N)Number of data written0 to 528Unsigned BIN 16 bitANY16

Device used

InstructionParameterDevicesOffset modification

Pulse

extension

TCDRKH[D]XXP
RSParameter 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)
2590Communication port setting2590Send control on
2591Serial parameter modification identification2591Send control/send reminder
2592Protocol settings2592Receive control on
2593Protocol modification logo2593Accept control/receive prompt
2594Station number setting25948-bit mode (for custom protocol)
2595Station number modification logo2595 
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 
2598Timeout retry times  0-327672598 
2599

Character interval timeout setting (for custom protocol) (0.1ms)

0-32767 . It is 10 (1ms) when set to 0

2599 
2600STX value2600 
2601ETX value2601 
... ... 
2610The amount of data received2610Communication complete flag
2611Last error2611Receiving flag
2612Current error2612Retry occurred
2613Error steps2613Communication error
2614Error station number2614Communication timeout
2615Cumulative number of errors2615 

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 numberB0B1、B2B3

B4、B5、B6、

B7、B8、B9

B10B11
NameData lengthParityStop BitBaud rate(bps)STXETX
Content0 off7 bit

b2,b1

(0,0): None

(0,1): Odd parity (ODD)

(1,1): Even parity (EVEN)

1 bit
48000111
96001000
192001001
384001010
576001011
1152001100
1875001101
2304001110
4608001111
92160010000
NoneNone
1 on8 bit2 bitTurn on ETX, the ETX value is set in SD2600Turn 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 settingsProtocol settings
0 HWecon Modbus slave station10 HCunstom protocol
2 HModbusRTU slave station20 HModbusRTU master station
3 HModbusASCII slave station30 HModbusASCII 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

10_html_53f716718aad2197.png

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.

10_html_3725d523c70bd43d.png

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

10_html_3f08ef293fcbfcf1.png

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

ParameterContentRangeData type

Data type

(label)

(s)Serial port parameters to be set0 to 256Unsigned BIN 16 bitANY16
(N)Which communication port to set (0 means COM1, 1 means COM2)0, 1Unsigned BIN 16 bitANY16

Device used

InstructionParameterDevicesOffset modification

Pulse

extension

KnYKnMKnSTCDRSDKH[D]XXP
PROTPARAParameter 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

ParameterContentRangeData     typeData type (label)
(s)Protocol number to be set0 to 65535Unsigned BIN 16 bitANY16
(N)Which communication port to set (0 means COM1, 1 means COM2 *1)1Unsigned BIN 16 bitANY16

Device used

InstructionParameterDevices

Offset

modification

Pulse

extension

KnYKnMKnSTCDRSDKH[D]XXP
PORTOCOLParameter 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

10_html_487e57593173359e.png

  • 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.

10_html_5891dcc3161d6651.png

image-20220926145824-1.jpeg

②8-bit (SM2594 is ON)

Get the value of the low address of device directly and send it

10_html_1d76c606ba1b2ba8.png

10_html_a46b2be94cb51e78.png

The data sent in the case of the ladder program and the data above should be 70 E1 31 62 6C.

10_html_1920f501fdbca9b8.png

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.

10_html_bd054fd74ccaddc.png

10_html_a46b2be94cb51e78.png

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.

10_html_f2dbc2f6fb276e3f.png

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.

10_html_17fa71d20bec1531.png

10_html_a46b2be94cb51e78.png

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.

10_html_72c7fdeee574504.png

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

10_html_ee6092e0d3a61be2.png

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

10_html_46075eaee9d78457.png

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)

10_html_a70fbc189fa39660.png

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 codeContent
3181HData receiving timeout
3188HWrong length
3189HCOM2 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)

318FHCOM2 sending timed out. Contact a technician if this error occurs
3190HCOM2 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:

  1. STX and ETX: Mitsubishi can set up to 4 bytes, we only have one byte.
  2. Add sum check and CR, LF.
  3. 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

ParameterContentRangeData typeData 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 bitANY16
(m)Slave address. The address provided by slave station will read or write data from this address of the slave station-Unsigned BIN 16 bitANY16
(d)Length. The length of Modbus read or write. The unit is determined by function code.-Unsigned BIN 16 bitANY16
(N)Start address for reading or writing data-Unsigned BIN 16 bitANY16

Device used

InstructionParameterDevicesOffset modification

Pulse

extension

TCDRKH[D]XXP
RSParameter 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)
2540Communication port settings
2541Serial parameter modification identification
2542 
2543 
2544Station number setting
2545Station number modification logo

✎Note: COM1 does not support modifying the protocol.

COM2 special D device (SD)COM2 special M Device (SM)
2590Communication port setting2590Send control start
2591Serial parameter modification identifier2591Send control/send reminder
2592Protocol setting2592Receive control start
2593Protocol modification identifier2593Receive control/receive prompt
2594Station number setting25948-bit mode (for custom protocol)
2595Station number modification identifier2595 
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 
2598Timeout retry times 0-327672598 
2599Character interval timeout setting (for custom protocol) (0.1ms) 0-32767. It is 10 when set to 0 (1ms)2599 
2600STX value2600 
2601ETX value2601 
... ... 
2610The amount of data received2610Communication complete flag
2611Last error2611Receiving flag
2612Current error2612Retry occurred
2613Error steps2613Communication error
2614Error station number2614Communication timeout
2615Cumulative number of errors2615 

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 numberB0B1、B2B3B4、B5、B6、B7、B8、B9
NameData lengthParityStop BitBaud rate(bps)
Content0 off7 bit

b2,b1

(0,0): None

(0,1): Odd parity (ODD)

(1,1): Even parity (EVEN)

1 bit
48000111
96001000
192001001
384001010
576001011
1152001100
1875001101
2304001110
4608001111
92160010000
1 on8 bit2 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 HWecon Modbus slave station10 HCustom protocol
2 HModbusRTU slave station20 HModbusRTU master station
3 HModbusASCII slave station30 HModbusASCII 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

10_html_8c204d3cecb508d7.png

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

ParameterContentRangeData typeData type (label)
(s1)The start number of the device that stores the number of digits of converted value-Signed BIN 16 bitANY16_S_ARRAY
(s2)Converted BIN data-2147483648 to 2147483647Signed BIN 32 bitANY32_S

Device used

InstructionParameterDevices

Offset

modification

Pulse

extension

KnYKnMKnSTCDRSDKH[D]XXP
PORTPARAParameter 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

ParameterContentRangeData typeData type (label)
(s)Protocol number to be set0 to 65535Unsigned BIN 16 bitANY16
(N)Which communication port to set (0 means COM1, 1 means COM2 *1)1Unsigned BIN 16 bitANY16

Device used

InstructionParameterDevicesOffset modification

Pulse

extension

KnYKnMKnSTCDRSDKH[D]XXP
PROTOCOLParameter 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.

10_html_4208a2ce93bb23e7.png

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

10_html_a7e64b4f4526b73e.png

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 codeFunction nameDetails
0x01Coil readoutCoil readout (multiple points optional)
0x02Input readoutInput and read (multiple points optional)
0x03Holding register readoutHolding register readout(multiple points optional)
0x04Input register readoutInput register readout (multiple points optional)
0x051 coil writeCoil writing (only 1 point)
0x061 register writeHolding register write (only 1 point)
0x0FBatch coil writeMulti-point coil writing
0x10Batch register writeMulti-point holding register write

Serial port parameter setting

Baud rate 115200, data bit 8, no parity bit, stop bit 1

Example:

10_html_a7e64b4f4526b73e.png

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 numberData (byte) meaningNumber of bytesInstruction
1Slave address1 byteValue 1 to 247, set by SD2544, SD2594
20x01 (instruction code)1 byteRead coil
3Coil start address2 bytesHigh bit in front, low bit in back, see coil addressing
4Number of coils2 bytesHigh bit in front, low bit in back (N)
5CRC check2 bytesLow bit in front, high bit in back

Response frame format: slave address + 0x01 + number of bytes + coil status + CRC check

Serial numberData (byte) meaningNumber of bytesInstruction
1Slave address1 byteValue 1 to 247, set by SD2544, SD2594
20x01 (instruction code)1 byteRead coil
3Number of bytes1 byteValue: [(N+7)/8]
4Coil state[(N+7)/8] bytesEvery 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
5CRC check2 bytesHigh 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 numberData (byte) meaningNumber of bytesInstruction
1Slave address1 byteValue 1 to 247, set by SD2544, SD2594
20x03 (instruction code)1 byteRead register
3Register start address2 bytesHigh bit in front, low bit in back, see register addressing
4Number of registers2 bytesHigh bit in front, low bit in back (N)
5CRC check2 bytesHigh bit in front, low bit in back

Response frame format: slave address + 0x03 + number of bytes + register value + CRC check.

Serial numberData (byte) meaningNumber of bytesInstruction
1Slave address1 byteValue 1 to 247, set by SD2544, SD2594
20x03 (instruction code)1 byteRead register
3Number of bytes1 byteValue: N*2
4Register valueN*2 bytesEvery two bytes represent a register value, with high bit in front, low bit in back. The smallest register address comes first
5CRC check2 bytesHigh 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 numberData (byte) meaningNumber of bytesInstruction
1Slave address1 byteValue 1 to 247, set by SD2544, SD2594
20x05 (instruction code)1 byteWrite single coil
3Coil address2 bytesHigh bit in front, low bit in back, see coil addressing
4Coil state2 bytesHigh bit in front, low bit in back. Non-zero is valid
5CRC check2 bytesHigh bit in front, low bit in back

Response frame format: slave address + 0x05 + coil address + coil status + CRC check.

Serial numberData (byte) meaningNumber of bytesInstruction
1Slave address1 byteValue 1 to 247, set by SD2544, SD2594
20x05 (instruction code)1 byteWrite single coil
3Coil address2 bytesHigh bit in front, low bit in back, see coil addressing
4Coil state2 bytesHigh bit in front, low bit in back. Non-zero is valid
5CRC check2 bytesHigh 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 numberData (byte) meaningNumber of bytesInstruction
1Slave address1 byteValue 1 to 247, set by SD2544, SD2594
20x06 (instruction code)1 byteWrite single coil
3Register2 bytesHigh bit in front, low bit in back, see coil addressing
4Register value2 bytesHigh bit in front, low bit in back. Non-zero is valid
5CRC check2 bytesHigh bit in front, low bit in back

Response frame format: slave address + 0x06 + register address + register value + CRC check.

Serial numberData (byte) meaningNumber of bytesInstruction
1Slave address1 byteValue 1 to 247, set by SD2544, SD2594
20x06 (instruction code)1 byteWrite single coil
3Register2 bytesHigh bit in front, low bit in back, see coil addressing
4Register value2 bytesHigh bit in front, low bit in back. Non-zero is valid
5CRC check2 bytesHigh 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 numberData (byte) meaningNumber of bytesInstruction
1Slave address1 byteValue 1 to 247, set by SD2544, SD2594
20x 0f (instruction code)1 byteWrite multiple single coils
3Coil start address2 bytesHigh bit in front, low bit in back, see coil addressing
4Number of coils2 bytesHigh bit in front, low bit in back. The maximum of N is 1968
5Number of bytes1 byteValue: [(N+7)/8]
6Coil state[(N+7)/8] bytesEvery 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
7CRC check2 bytesHigh bit in front, low bit in back

Response frame format: slave address + 0x 0f + coil start address + coil number + CRC check

Serial numberData (byte) meaningNumber of bytesInstruction
1Slave address1 byteValue 1 to 247, set by SD2544, SD2594
20x 0f (instruction code)1 byteWrite multiple single coils
3Coil start address2 bytesHigh bit in front, low bit in back, see coil addressing
4Number of coils2 bytesHigh bit in front, low bit in back
5CRC check2 bytesHigh 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 numberData (byte) meaningNumber of bytesInstruction
1Slave address1 byteValue 1 to 247, set by SD2544, SD2594
20x10(instruction code)1 byteWrite multiple registers
3Register start address2 bytesHigh bit in front, low bit in back, see register addressing
4Number of registers2 bytesHigh bit in front, low bit in back. The maximum of N is 120
5Number of bytes1 byteValue: N*2
6Register valueN*2 (N*4) 
7CRC check2 bytesHigh bit in front, low bit in back

Response frame format: slave address + 0x10 + register start address + register number + CRC check.

Serial numberData (byte) meaningNumber of bytesInstruction
1Slave address1 byteValue 1 to 247, set by SD2544, SD2594
20x10 (instruction code)1 byteWrite multiple registers
3Register start address2 bytesHigh bit in front, low bit in back, see register addressing
4Number of registers2 bytesHigh bit in front, low bit in back. The maximum of N is 120
5CRC check2 bytesHigh 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 numberData (byte) meaningNumber of bytesInstruction
1Slave address1 byteValue 1 to 247, set by SD2544, SD2594
2Instruction code+0x801 byteError instruction code
3Code1 byte1 to 4
4CRC check2 bytesHigh bit in front, low bit in back
Serial numberError codeInstruction
101Unsupported function code
202Wrong address or function code
303Wrong length
404Imperfect instruction
505Address not allowed

8) Slave address table

Word address
Address typeOccupyAddress rangeDecimal addressTotal reserved address size
T0 to T511512 WORD0x0000-0x01ff01536
C0 to C255256 WORD0x0600-0x06ff15361024
LC0 to LC255512 WORD0x0A00-0x0BFF25601024
HSC0 to HSC1532 WORD0x0E00-0x0E1F3584512
D0 to D79998000 WORD0x1000-0x2F3F409616384
SD0 to SD40954096 WORD0x5000-0x5FFF2048012288
R0 to R2999930000 WORD0x8000-0xF52F3276830000
Bit address
Address typeOccupyAddress rangeDecimal addressTotal reserved address size
T0 to T511512 bit0x0000-0x01ff 1536
C0 to C255256 bit0x0600-0x06ff15361024
LC0 to LC255256 bit0x0A00-0x0AFF25601024
HSC0 to HSC1516 bit0x0E00-0x0E0F3584512
M0 to M79998000 bit0x1000-0x2F3F409616384
SM0 to SM40954096 bit0x5000-0x5FFF2048012288
Reserved 0x8000-0xBFFF 16383
S0 to S40954096 bit0xC000-0xCFFF491528192
X0 to X17771024 bit0xE000-0xE3FF573444096
Y0 to Y17771024 bit0xF000-0xF3FF614404096

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 codeContent
4085H(s)(m)(d)(N) The read address is out of the device range (this error is only displayed on SD7 and SD0)
3180HCOM2 data reception error. There may be interference on the communication line, it is recommended to connect the ground wire.
3181HCOM2 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."
3182HCOM2 CRC check error. There may be interference on the communication line, it is recommended to connect the ground wire.
3183HCOM2 LRC check error. There may be interference on the communication line, it is recommended to connect the ground wire.
3184HThe 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.
3185HCOM2 send buffer overflow. Contact a technician if this error occurs
3186HCOM2 function code is wrong. Check whether the set function code is a function code supported by PLC
3187HCOM2 address is wrong. Check whether the slave station has this address (please refer to Modbus Abnormal 02)
3188HThe 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.
3189HCOM2 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)"
318AHCOM2 slave is busy. Slave station returns information: Slave station is busy (please refer to Modbus exception 06)
318BHThe COM2 slave station does not support function codes. Check whether the slave station supports this function code (please refer to Modbus exception 01)
318CHThe 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)
318DHCOM2 slave confirms. Slave station return information: slave station confirmation (please refer to Modbus abnormal 05)
318EHCOM2 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)
318FHCOM2 sending timed out. Contact a technician if this error occurs
3190HCOM2 receiving data exceeds the buffer limit.
31A0HCOM2 is not available as a gateway. Returned information from the station: unavailable gateway (please refer to Modbus exception 0A)
31A1HCOM2 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.

image-20220614170612-1.jpeg

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.

10_html_347d7923523ad9af.png

Click it and a prompt box as below would pop up.

10_html_dbbb9b1ddaa56dce.png

Click "Yes" will automatically change the protocol to PLCLINK, click "No" will not change the protocol.

The number of PLCLINK protocol is H60.

0HWecon Modbus slave station
2HModbusRTU slave station
3HModbusASCII slave station
10Huser-defined protocol
20HModbusRTU main station
30HModbusASCII main station
60HPLCLINK protocol

Click "Yes" will generate an empty table MAIN.

10_html_39ce9cf6a41c3901.png

Double click MAIN will pop up the POLCLINK table as below.

10_html_14072bc2a32c267.png

Currently only one PLCLINK table can be created. Creating a new table after creating one is disallowed.

10_html_f4bec5285beb7949.png

(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.

10_html_21d3b9789058efb3.png

10_html_20232344eaa6cb2a.png

Currently the station number is only selected by drop-down box.

10_html_f09857f93ae04f0a.png

The devices of main station and slave station are selected by drop-down box.

10_html_99c7d435825defd1.png

10_html_f62cce6501331b8d.png

The transfer direction are read and write, and also selected by drop-down box.

10_html_7b3de12a134b4e95.png

The device address range limitations are as below.

  1. The device address could not exceed the current device range
  2. 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.
  3. 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.
  4. 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.

  1. The number of bit device ranges from 8 to 2,032.
  2. The number of word device ranges from 1 to 126.
  3. The number of double word device ranges from 1 to 63. HSC can only use a maximum of 16 due to the number limitation.
  4. 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.

10_html_a586bd0ca75cd8f.png

Click on PLCLINK in monitoring mode to re-write part of the table into PLC, but the start device could not be modified.

10_html_92ca328b83e6ef12.png

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.

10_html_d6ff78427b75140d.png

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+13Corresponding 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+14Corresponding station number communication switch 2The switch control of station 16 to 31

Click [station number enable] to set the station enable according to the corresponding situations.

10_html_beda0fdc84802959.png

10_html_f84703130b23d8f6.png

✎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

10_html_434fac0fa8c16597.png

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.

10_html_2641eb7c39f4f4aa.png

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+11Operation 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 offsetBrief descriptionDetailed description
High byteLow byte
S1+0HeaderHeader =70h, correct PLCLINK table. (modification prohibited)
S1+1Number of communication instructions1 to 255 (modification prohibited)
S1+2VersionV1.100 (modification prohibited)
S1+3The start address of communication tablemodification prohibited
S1+4Check bit of the number of header and communicationSimple check calculation for table header, number of communication instructions, version, and the start address of communication table ((modification prohibited))
S1+5Which instruction currently is runningDisplay the current running command (read only)
S1+6Station NO.1Read/write directionThe instruction content of current communication
S1+7The data start address of station NO.1
S1+8Station NO.2Address type distinction
S1+9The data start address of station NO.2
S1+10Data length
S1+11Operation 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+12Auto 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+13Corresponding 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+14Corresponding station number communication switch 2The switch control of station 16 to 31
S1+15Reserved 
S1+16Reserved 
S1+17Reserved 
S1+18Reserved 
S1+19Reserved 
S1+20Reserved 
S1+21Station NO.1Read/write direction

• Station NO. 1 to 32, FF(FF represents main station)

• Function code:

=01H, read

=02H, write

S1+22The data start address of station NO.1• Valid word. Define operating the start address of slave station data
S1+23Station NO.2Address 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+24The 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+25Data length• Valid word. Range 1 to 126(bit data), 1 to 2,032(bit data)
S1+26Station NO.1Read/write direction

The second data transmission description.

Main station address type distinction.

S1+27The data start address of station NO.1
S1+28Station NO.2Address type distinction
S1+29The data start address of station NO.2
S1+30Data length
  
  
S1+20+ n×5Reserved• n is the total number of data transmission commands.

✎Note: 

  1. It is forbidden to modify S0 to S4.
  2. 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 codeContents
31C0HAbnormal PLCLINK header. Re-download the program.
31C1HPLCLINK function is not supported by COM port currently.
31C2HPLCLINK table version is incompatible. Re-download the program.
31C3HThe number of PLCLINK command exceeds the range. The value ranges from 1 to 255 Currently.
31C4HThe station number of PLCLINK table exceeds the range. Check the station number in the table.
31C5HPLCLINK table exceeds the range of device. Check the corresponding device range of table.
31C6HThe device used by PLCLINK table command exceeds the range. Check the device used for each command in the table.
3180HCOM2 data reception error. There may be interference on the communication line. It is recommended to connect the ground wire.
3181HCOM2 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.
3182HCOM2 CRC check error. There may be interference on the communication line. It is recommended to connect the ground wire.
3184HCOM2 station number error. Check the setting of slave station number. Check whether there is a problem with the slave receiving and sending mechanism.
3186HCOM2 function code error. Check whether the function code is supported by PLC.
3187HCOM2 address error.
3188HCOM2 length error. Check whether the communication length exceeds the length range specified by Modbus or user-defined protocol.
3189HCOM2 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)
318AHCOM2 slave station is busy. Slave station returns message: Slave station is busy. (Please refer to Modbus abnormal 06)
318BHCOM2 slave station does not support function codes. Check whether the function code is supported by slave station. (Please refer to Modbus abnormal 01)
318CHCOM2 slave station fault. Slave station returns message: Slave station is fault. Check whether the slave station is faulty. (Please refer to Modbus abnormal 04)
318DHCOM2 slave station confirmation. Slave station returns message: Slave station confirmation.(Please refer to Modbus abnormal 05)
318EHCOM2 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.
3190HThe data received by COM2 exceeds the cache limit.

Example

Create a PLCLINK table and automatically switch the Com2 protocol to PLCLINK.

10_html_c4962fb2076781b9.png

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.

10_html_3244c013d7d800c3.png

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.

10_html_ae5ef70ce179ad5e.png

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

10_html_98f836562979721.png

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.