LX5V-2RS485-BD
1 Features
- LX5V-2RS485-BD is used for serial communication connection and installed on the top of PLC host.
- LX5V-2RS485-BD supports Modbus RTU, Modbus ASCII, user-defined protocol and dedicated protocol (Wecon Modbus slave station protocol, that is, PLC local protocol).
- Data transfer using user-defined protocol, through RS485 converter, data communication between various devices with RS232C unit, such as personal computers, barcode readers and printers. In this application, data is sent and received through the data register specified by RS2 instruction.
- Using dedicated protocol for data transfer, connect PLC Editor2 PC with LX5V-2RS485-BD to complete the uploading and downloading of the program.
2 Appearance and terminal
Indicator light | Color | Description |
---|---|---|
PWR | White | Power light: It is always ON when the power supply connection is normal. |
TX1 | Yellow | Serial port 3/serial port 5 sends. |
RX1 | Green | Serial port 3/serial port 5 receives. |
TX2 | Yellow | Serial port 4/serial port 6 sends. |
RX2 | Green | Serial port 4/serial port 6 receives. |
PLC with small points has a card slot, and the installation position is shown in the following figure, where (A1+, B1-) is COM3 and (A2+, B2-) is COM4.
PLC with large points has two card slots. (A1+, B1-) of BD module on the left side is COM3, and (A2+, B2-) is COM4. (A1+, B1-) of BD module on the right is COM5, [A2+, B2-] is COM6.
3 Serial communication function
Serial port | Communication protocol | Communication instruction | Communication interface |
---|---|---|---|
COM3 | Modbus RTU protocol; Modbus ASCII protocol; User-defined protocol Dedicated protocol (supports program upload and download and HMI monitoring). | RS2 instruction | RS485 |
COM4 | |||
COM5 | |||
COM6 |
4 Parameter configuration
- Open the host computer and create a new project, double-click “Project Manager” → “Extended Function” → "BD Module Configuration" Note to enter “BD settings” interface;
- Select "LX5V-2RS485" in the device bar on the right side of the BD module configuration interface and double-click to add it to the corresponding slot position of PLC (slot 1 or 2, the software will select slot 1 by default. You could right-click it to move to slot 2);
- After adding BD module to the machine slot, double-click or right-click to select configuration parameters to enter LX5V-2RS485-BD configuration parameters interface, as shown in the following figure. Parameters such as baud rate, data bit, stop bit, check bit and station number are configured in this interface.
Supported host computer versions: Wecon PLC Editor 2 2.1.204 and above, as shown in the following figure:
Supported slave computer versions: 2.061 and above, as shown in the following figure:
The parameter configuration interface is as follows:
Functional description of each configuration item:
- Whether to set: Indicates whether the configuration is effective. True is effective, and False is not.
- Communication settings:
- Baud rate: Indicates the baud rate of serial communication and the number of bits transmitted per second. The maximum baud rate supported is 115200bps.
- Data bit: Indicates the number of data bits of serial communication, and the value range is 7 to 8 digits.
- Stop bit: Indicates the number of stop bits in serial communication, and the value range is 1 to 2 digits.
- Parity bit: Indicates whether to add check bits during serial communication, and check types. Odd check and even check are commonly used.
- Timeout (10ms): Configuration for the master station, indicating the maximum waiting time between the request and the reply. The unit is 10ms, and the configuration here is 10, which means 10*10ms=100ms.
- Sending interval (0.1 ms): Configuration for the master station, indicating the time when the communication is completed and the next request is sent.
- Agreement: Currently supported protocols are: user-defined protocol, dedicated protocol, Modbus RTU, Modbus ASCII.
- User-defined protocol: Users need to organize request frames by themselves, and process response frames after receiving response data.
- Dedicated protocol: WECON Modbus protocol (PLC local protocol) is used for program upload and download, HMI monitoring protocol.
- Agreement related:
- Station NO. (0 is the main station): The value range is 0 to 255. Non-0 indicates the slave station number, and 0 indicates the master station.
- Whether to enable the starter: Effective under user-defined protocol. When enabled, a user-defined starter of one-byte is sent first before sending user data.
- Whether to enable the terminator: Effective under user-defined protocol. When enabled, a user-defined terminator of one-byte is sent again after the user data is sent.
- Terminator: Effective under user-defined protocol.
- Inter-character timeout (0.1 ms): Mainly used to judge whether a complete response frame is received. After receiving a byte, if there is no new byte is received beyond the time-out interval between characters, it indicates that the data of the previous frame has been received.
- Bit mode: It is divided into 8-bit and 16-bit modes, which are mainly used to define the storage mode of data received by user-defined protocol. Assume that the user-defined protocol receives two bytes of data, 0x12 and 0x13, and stores them in the device starting with D100.
The storage mode of 16-bit mode is as follows:
(High 8 bits) | (Low 8 bits) | |
---|---|---|
D100 | 0x13 | 0x12 |
D101 | No data | No data |
The storage mode of 8-bit mode is as follows:
(High 8 bits) | (Low 8 bits) | |
---|---|---|
D100 | 0x00 | 0x12 |
D101 | 0x00 | 0x13 |
5 RS2 instruction
In the case of user-defined protocol: The instruction is a communication receiving and sending instruction. The starting data of the specified (S) is taken out (M) and sent, and the data received by the serial port is stored in (D), and store (N), sent by the communication port specified by (N1).
In the case of Modbus master protocol: The instruction is a setting interface for sending protocol frames by the master station. According to the station number function code (S), slave station address (M), and length (D) set by the instruction, and the function code to determine whether N data is needed to automatically combine to send and receive protocol frames. If it is a read type function code, the data will be written to (N) and sent by the communication port specified by (N1).
-[RS2 (S) (M) (D) (N) (N1)]
Content, range and data type
In the case of user-defined protocol
Parameter | Content | Range | Data type | Data type (label) |
---|---|---|---|---|
(S) | The starting address of the register area where the data to be sent is stored | - | Unsigned BIN16 bits | ANY16 |
(M) | The length (in bytes) of the data to be sent | 0 to 528 | Unsigned BIN16 bits | ANY16 |
(D) | The start number of device that stores written data | - | Unsigned BIN16 bits | ANY16 |
(N) | Number of data written in bytes | 0 to 528 | Unsigned BIN16 bits | ANY16 |
(N1) | Specify communication port | - | Unsigned BIN16 bits | ANY16 |
Modbus protocol
Parameter | Content | Range | Data type | Data type (label) |
---|---|---|---|---|
(S) | The high byte stores the station number of the slave station, and the low byte stores Modbus function codes. | - | Unsigned BIN16 bits | ANY16 |
(M) | The slave address provided by the slave, reads or writes data from this address of the slave. | - | Unsigned BIN16 bits | ANY16 |
(D) | Length. The length read or written by Modbus, and the unit is determined by the function code. | - | Unsigned BIN16 bits | ANY16 |
(N) | Start address for reading or writing data | - | Unsigned BIN16 bits | ANY16 |
(N1) | Specify communication port | - | Unsigned BIN16 bits | ANY16 |
Device used
Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||
T | C | D | R | K | H | [D] | XXP | ||
RS2 | (S) | ● | ● | ● | ● | ● | ● | ||
(M) | ● | ● | ● | ● | ● | ● | |||
(D) | ● | ● | ● | ● | ● | ● | |||
(N) | ● | ● | ● | ● | ● | ● | |||
(N1) | ● | ● |
Function
The parameter (N1) is the specified serial port, K2 for COM3 (BD1), K3 for COM4 (BD1), K4 for COM5 (BD2), and K5 for COM6 (BD2).
User-defined protocol
When the communication protocol is set to user-defined protocol, in the case of the contact before the RS2 instruction is set on, the “sending control on" is also set ON, and the sending length (M) is not 0, the data of (S) will be sent out by (M) bytes, and then enter the wait receiving mode. When the data is received, (N) bytes of data will be stored in (D). After receiving (N) pieces of data, the "Accept control/Receive prompt" will be set on.
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.
Example:
When M1 is ON, the sending and receiving data of communication after instruction execution are stored as follows:
Modbus protocol
When the protocol is set to Modbus master station protocol (whether RTU or ASCII), and the contact point before the RS2 instruction is set ON, the RS2 instruction will judge whether the data of (N) is needed to send the combined data frame according to station number function code (S), slave station address (M), the length (D) and function code.
Example:
(S) | The high byte stores the station number of the slave station, and the low byte stores the Modbus function code. |
---|---|
(M) | Slave station address The address provided by the slave station will read or write data from the address of slave station. |
(D) | Length. The length read or written by Modbus, and the unit is determined by the function code. |
(N) | The starting address for reading or writing data. |
(N1) | Specify communication port. |
✎Note:
- The RS2 instruction allows parameters to be represented by K and H constants, but with different restrictions on different protocols.
- When the protocol is user-defined protocol, S and D cannot be constants, otherwise an error (3X89H) will be reported.
- When the protocol is Modbus protocol, N cannot be a constant, otherwise an error (3X89H) will be reported.
- When the protocol is RTU protocol, only 8 bits of data can be selected.
- If the serial port parameters are set differently, it may be in normal communication. However, it is recommended that to set consistent serial port parameters to avoid other failures.
- At present, RS2 instructions cannot be used in interrupts and events.
Error code
Error code | Content |
---|---|
4085H | (S), (M), (D) and (N) read address out of range of the device. |
4084H | Parameter value is out of the specified range. |
COM3 | |
3280H | COM3 data reception error. There may be interference on the communication cable, it is recommended to connect GND. |
3281H | COM3 data reception timed out. Check the wiring, whether the serial port parameter settings correspond to master and slave, and whether there is interference. Check whether the response from the station is too late. It is recommended to increase the “sending interval". |
3282H | COM3 CRC validation error. There may be interference on the communication cable, it is recommended to connect GND. |
3283H | COM3 LRC validation error. There may be interference on the communication cable, it is recommended to connect GND. |
3284H | COM3 station number is incorrectly configured. Check the slave station number setting, and check whether there is any problem with the receiving and sending mechanism from slave. |
3285H | COM3 send buffer overflow. If this error appears, please contact your technician. |
3286H | COM3 function code error. Check whether the set function code is supported by PLC. |
3287H | COM3 address error. Check whether the slave station has this address. (Please refer to Modbus exception 02). |
3288H | COM3 length error. Check whether the communication length exceeds the length range specified by Modbus protocol or user-defined protocol. |
3289H | COM3 data error. Check the parameters of the instruction for errors. Check whether the set value is supported by the slave station. (Please refer to Modbus exception 03). |
328AH | COM3 slave station is busy. Message returned from slave station: Slave station is busy. (Please refer to Modbus exception 06). |
328BH | COM3 slave does not support function codes. Check whether this function code is supported by the slave station. (Please refer to Modbus exception 01). |
328CH | COM3 slave failure. Message returned from slave station: Slave station failed, please check whether slave station failed (Please refer to Modbus exception 04). |
328DH | COM3 slave confirmation. Message returned from slave station: slave station confirmation. (Please refer to Modbus exception 05). |
328EH | COM 3 does not currently support this instruction or function. When set to slave protocol, the communication instructions related to master station or master station functions cannot be used. Please change the protocol or close the contact before the corresponding instruction or close the corresponding communication function. |
328FH | COM3 sending timed out. If this error appears, please contact your technician. |
32A0H | COM3 unavailable gateway Message returned from the station: unavailable gateway. (Please refer to Modbus exception 0A). |
32A1H | COM3 indicates that no response was obtained from the target device. Message returned from the station: The device is not in the network. (Please refer to Modbus Exception 0B). |
COM4 | |
3380H | COM4 data reception error. There may be interference on the communication cable, it is recommended to connect GND. |
3381H | COM4 data reception timed out. Check the wiring, whether the serial port parameter settings correspond to master and slave, and whether there is interference. Check whether the response from the station is too late. It is recommended to increase the “sending interval". |
3382H | COM4 CRC validation error. There may be interference on the communication cable, it is recommended to connect GND. |
3383H | COM4 LRC validation error. There may be interference on the communication cable, it is recommended to connect GND. |
3384H | COM4 station number is incorrectly configured. Check the slave station number setting, and check whether there is any problem with the receiving and sending mechanism from slave. |
3385H | COM4 send buffer overflow. If this error appears, please contact your technician. |
3386H | COM4 function code error. Check whether the set function code is supported by PLC. |
3387H | COM4 address error. Check whether the slave station has this address. (Please refer to Modbus exception 02). |
3388H | COM4 length error. Check whether the communication length exceeds the length range specified by Modbus protocol or user-defined protocol. |
3389H | COM4 data error. Check the parameters of the instruction for errors. Check whether the set value is supported by the slave station. (Please refer to Modbus exception 03). |
338AH | COM4 slave station is busy. Message returned from slave station: Slave station is busy. (Please refer to Modbus exception 06). |
338BH | COM4 slave does not support function codes. Check whether this function code is supported by the slave station. (Please refer to Modbus exception 01). |
338CH | COM4 slave failure. Message returned from slave station: Slave station failed, please check whether slave station failed. (Please refer to Modbus exception 04). |
338DH | COM4 slave confirmation Message returned from slave station: slave station confirmation. (Please refer to Modbus exception 05). |
338EH | COM4 does not currently support this instruction or function. When set to slave protocol, the communication instructions related to master station or master station functions cannot be used. Please change the protocol or close the contact before the corresponding instruction or close the corresponding communication function. |
338FH | COM4 send timed out. If this error appears, please contact your technician. |
33A0H | COM4 unavailable gateway Message returned from the station: unavailable gateway. (Please refer to Modbus exception 0A). |
33A1H | COM4 indicates that no response was obtained from the target device. Message returned from the station: The device is not in the network. (Please refer to Modbus Exception 0B). |
COM5 | |
---|---|
3480H | COM5 data reception error. There may be interference on the communication cable, it is recommended to connect GND. |
3481H | COM5 data reception timed out. Check the wiring, whether the serial port parameter settings correspond to master and slave, and whether there is interference. Check whether the response from the station is too late. It is recommended to increase the “sending interval". |
3482H | COM5 CRC validation error. There may be interference on the communication cable, it is recommended to connect GND. |
3483H | COM5 LRC validation error. There may be interference on the communication cable, it is recommended to connect GND. |
3484H | COM5 station number is incorrectly configured. Check the slave station number setting, and check whether there is any problem with the receiving and sending mechanism from slave. |
3485H | COM5 send buffer overflow. If this error appears, please contact your technician. |
3486H | COM5 function code error. Check whether the set function code is supported by PLC. |
3487H | COM5 address error. Check whether the slave station has this address. (Please refer to Modbus exception 02). |
3488H | COM5 length error. Check whether the communication length exceeds the length range specified by Modbus protocol or user-defined protocol. |
3489H | COM5 data error. Check the parameters of the instruction for errors. Check whether the set value is supported by the slave station. (Please refer to Modbus exception 03). |
348AH | COM5 slave station is busy. Message returned from slave station: Slave station is busy. (Please refer to Modbus exception 06). |
348BH | COM5 slave does not support function codes. Check whether this function code is supported by the slave station. (Please refer to Modbus exception 01). |
348CH | COM5 slave failure. Message returned from slave station: Slave station failed, please check whether slave station failed. (Please refer to Modbus exception 04). |
348DH | COM5 slave station confirmation Message returned from slave station: slave station confirmation. (Please refer to Modbus exception 05). |
348EH | COM5 does not currently support this instruction or function. When set to slave protocol, the communication instructions related to master station or master station functions cannot be used. Please change the protocol or close the contact before the corresponding instruction or close the corresponding communication function. |
348FH | COM5 send timed out. If this error appears, please contact your technician. |
34A0H | COM5 unavailable gateway Message returned from the station: unavailable gateway. (Please refer to Modbus exception 0A). |
34A1H | COM5 indicates that no response was obtained from the target device. Message returned from the station: The device is not in the network. (Please refer to Modbus Exception 0B). |
COM6 | |
3580H | COM6 data reception error. There may be interference on the communication cable, it is recommended to connect GND. |
3581H | COM6 data reception timed out. Check the wiring, whether the serial port parameter settings correspond to master and slave, and whether there is interference. Check whether the response from the station is too late. It is recommended to increase the “sending interval". |
3582H | COM6 CRC validation error. There may be interference on the communication cable, it is recommended to connect GND. |
3583H | COM6 LRC validation error. There may be interference on the communication cable, it is recommended to connect GND. |
3584H | COM6 station number is incorrectly configured. Check the slave station number setting, and check whether there is any problem with the receiving and sending mechanism from slave. |
3585H | COM6 send buffer overflow. If this error appears, please contact your technician. |
3586H | COM6 function code error. Check whether the set function code is supported by PLC. |
3587H | COM6 address error. Check whether the slave station has this address. (Please refer to Modbus exception 02). |
3588H | COM6 length error. Check whether the communication length exceeds the length range specified by Modbus protocol or user-defined protocol. |
3589H | COM6 data error. Check the parameters of the instruction for errors. Check whether the set value is supported by the slave station. (Please refer to Modbus exception 03). |
358AH | COM6 slave station is busy. Message returned from slave station: Slave station is busy. (Please refer to Modbus exception 06). |
358BH | COM6 slave does not support function codes. Check whether this function code is supported by the slave station. (Please refer to Modbus exception 01). |
358CH | COM6 slave failure. Message returned from slave station: Slave station failed, please check whether slave station failed. (Please refer to Modbus exception 04). |
358DH | COM6 slave station acknowledges. Message returned from slave station: slave station confirmation. (Please refer to Modbus exception 05). |
358EH | COM6 does not currently support this instruction or function. When set to slave protocol, the communication instructions related to master station or master station functions cannot be used. Please change the protocol or close the contact before the corresponding instruction or close the corresponding communication function. |
358FH | COM6 send timed out. If this error appears, please contact your technician. |
35A0H | COM6 unavailable gateway Message returned from the station: unavailable gateway. (Please refer to Modbus exception 0A). |
35A1H | COM6 indicates that no response was obtained from the target device. Message returned from the station: The device is not in the network. (Please refer to Modbus Exception 0B). |
6 Address mapping
When the BD module configures the serial port protocol as Modbus slave station protocol, the address mapping relationship accessed by the master station is as follows:
Word address | ||||
---|---|---|---|---|
Address type | Occupation | Address range | Decimal address | Total reserved address size |
T0 to T511 | 512 WORD | 0x0000 to 0x01ff | 0 | 1536 |
C0 to C255 | 256 WORD | 0x0600 to 0x06ff | 1536 | 1024 |
LC0 to LC255 | 512 WORD | 0x0A000 to 0x0BFF | 2560 | 1024 |
HSC0 to HSC15 | 128 WORD | 0x0E00 to 0x0E1F | 3584 | 512 |
D0 to D7999 | 8000 WORD | 0x1000 to 0x2F3F | 4096 | 16384 |
SD0 to SD4095 | 4096 WORD | 0x5000 to 0x5FFF | 20480 | 12288 |
R0 to R30000 | 30000 WORD | 0x8000 to 0xF52F | 32768 | 30000 |
Bit address | ||||
---|---|---|---|---|
Address type | Occupation | Address range | Decimal address | Total reserved address size |
T0 to T511 | 512 bits | 0x0000 to 0x01ff | 0 | 1536 |
C0 to C255 | 256 bits | 0x0600 to 0x06ff | 1536 | 1024 |
LC0 to LC255 | 256 bits | 0x0A00 to 0x0AFF | 2560 | 1024 |
HSC0 to HSC15 | 64 bits | 0x0E00 to 0x0E0F | 3584 | 512 |
M0 to M8000 | 8192 bits | 0x1000 to 0x2F3F | 4096 | 16384 |
SM0 to SM4095 | 4096 bits | 0x5000 to 0x5FFF | 20480 | 12288 |
Reserved | 0x8000 to 0xBFFF | 16383 | ||
S0 to S4095 | 4096 bits | 0xC000 to 0xCFFF | 49152 | 8192 |
X0 to X1023 | 1024 bits | 0xE000 to 0xE3FF | 57344 | 4096 |
Y0 to Y1023 | 1024 bits | 0xF000 to 0xF3FF | 61440 | 4096 |
When using the Modbus master station to access the slave station, the RS2 instruction specifies the following address:
Example 1: Read 10 registers starting from slave station (station NO.1) D0 and store them in 10 devices starting from local D0:
The function code of this instruction is 3, which indicates reading register, and the address H1000 in it is the starting address of "D0 to D7999" by inquiring the "word address table", which corresponds to the address of D0.
Example 2: Read 10 bit devices starting from slave station (station NO.1) M0 and store them in local D0 device (because D0 can store the value of 16 bit devices, zero padding will be performed):
The function code of the instruction is 1, which indicates read coil, and the address H1000 in it is the starting address of “M0 to M8000" by inquiring the "bit address table", which corresponds to the address of M0. If slave stations M0 and M1 are 1, and the rest are 0, the value in D0 is H0300 (not H0003).
7 Special devices for BD module
BD1:
SD label | Content | SD label | Content |
---|---|---|---|
SM2000 | COM3 sending control on | SD2000 | Display 0x1062 after 485 BD is recognized after power-on. |
SM2001 | COM3 send control/send prompt | SD2001 | Display 485BD version information after 485 BD is recognized after power-on. |
SM 2002 | COM3 reception control on | SD 2002 | BD1 last error |
SM 2003 | COM3 accept control/receive prompt | SD 2003 | BD1 current error |
SM2004 | COM3 communication complete flag | SD2004 | BD1 error times |
SM 2005 | COM4 sending control on | SD 2005 | BD1 error communication port. |
SM 2006 | COM4 send control/send prompt | SD2006 | BD1 communication timeout (1ms). |
SM 2007 | COM4 reception control on | ||
SM2008 | COM4 accept control/receive prompt | ||
SM2009 | COM4 communication complete flag |
BD2:
SD label | Content | SD label | Content |
---|---|---|---|
SM2020 | COM5 sending control on | SD2020 | Display 0x1062 after 485 BD is recognized after power-on. |
SM2021 | COM5 send control/send prompt | SD2021 | Display 485 BD version information after 485 BD is recognized after power-on. |
SM 2022 | COM5 reception control on | SD2022 | BD2 last error |
SM2023 | COM5 accept control/receive prompt | SD2023 | BD2 current error |
SM2024 | COM5 communication complete flag | SD2024 | BD2 error times |
SM2025 | COM6 sending control on | SD2025 | BD2 error communication port. |
SM2026 | COM6 send control/send prompt | SD2026 | BD2 communication timeout (1ms). |
SM2027 | COM6 reception control on | ||
SM2028 | COM6 accept control/receive prompt | ||
SM2029 | COM6 communication complete flag |
8 Examples
Modbus RTU slave station
Configure COM3 port as Modbus RTU slave. COM3 parameters are configured as follows:
Configure the station number to 1 and click OK, and the download program will take effect. (Ensure that the baud rate, data bit, stop bit and parity bit configuration are consistent with the master station)
Modbus RTU master station
Configure COM4 port as the Modbus RTU master station, and read the 125 word devices starting from the station address once every 100ms.
COM4 parameters are configured as follows:
The station number is configured as 0 to indicate the master station protocol.
The ladder diagram is configured as follows:
Dedicated protocol
Configure COM3 port as a dedicated protocol, and use this serial port to upload and download programs.
COM3 parameters are configured as follows:
PLC Editor2 uses this serial port communication: PC uses USB to RS485 converter to connect with BD module at this time.
User-defined protocol
Configure COM3 port as user-defined protocol, and simulate Modbus RTU instruction. A read instruction is sent to the slave station every 100ms, to read 125 word devices starting from slave station address 0, and store the response data in D100 device, and judge whether the value of the word device at address 0 is 100. If yes, set M10 and reset M20; If not, set M20 and reset M10.
COM3 parameters are configured as follows:
The ladder diagram is configured as follows: