Wiki source code of LX5V-2RS485-BD

Last modified by Jim on 2023/05/29 16:00

Show last authors
1 = **1 Features** =
2
3 1. LX5V-2RS485-BD is used for serial communication connection and installed on the top of PLC host.
4 1. LX5V-2RS485-BD supports Modbus RTU, Modbus ASCII, user-defined protocol and dedicated protocol (Wecon Modbus slave station protocol, that is, PLC local protocol).
5 1. 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.
6 1. Using dedicated protocol for data transfer, connect PLC Editor2 PC with LX5V-2RS485-BD to complete the uploading and downloading of the program.
7
8 (% class="box infomessage" %)
9 (((
10 **✎Note:** This manual is only applicable when LX5V-2RS485-BD is used together with 5V series PLC.Please refer to the LX3V-RS485-BD Manual for the use of LX5V-2RS485-BD with 3V Series PLC.
11 )))
12
13 = **2 Appearance and terminal** =
14
15 (% style="text-align:center" %)
16 [[image:image-20220913154323-19.png||class="img-thumbnail"]]
17
18 |=**Indicator light**|=**Color**|=**Description**
19 |PWR|White|Power light: It is always ON when the power supply connection is normal.
20 |TX1|Yellow|Serial port 3/serial port 5 sends.
21 |RX1|Green|Serial port 3/serial port 5 receives.
22 |TX2|Yellow|Serial port 4/serial port 6 sends.
23 |RX2|Green|Serial port 4/serial port 6 receives.
24
25 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.
26
27 [[image:image-20220913154410-20.jpeg||class="img-thumbnail"]]
28
29 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.
30
31 (% style="text-align:center" %)
32 [[image:image-20220913154442-21.jpeg||class="img-thumbnail"]]
33
34 (% style="text-align:center" %)
35 [[image:image-20220913154452-22.jpeg||class="img-thumbnail"]]
36
37 (% style="text-align:center" %)
38 [[image:image-20220913154459-23.jpeg||class="img-thumbnail"]]
39
40 = **3 Serial communication function** =
41
42 |=(% scope="row" style="width: 146px;" %)**Serial port**|=(% style="width: 523px;" %)**Communication protocol**|=**Communication instruction**|=**Communication interface**
43 |=(% style="width: 146px;" %)COM3|(% rowspan="4" style="width:523px" %)(((
44 Modbus RTU protocol;
45
46 Modbus ASCII protocol;
47
48 User-defined protocol
49
50 Dedicated protocol (supports program upload and download and HMI monitoring).
51 )))|(% rowspan="4" %)RS2 instruction|(% rowspan="4" %)RS485
52 |=(% style="width: 146px;" %)COM4
53 |=(% style="width: 146px;" %)COM5
54 |=(% style="width: 146px;" %)COM6
55
56 = **4 Parameter configuration** =
57
58 * Open the host computer and create a new project, double-click “Project Manager” → “Extended Function” → "BD Module Configuration" Note to enter “BD settings” interface;
59 * 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);
60 * 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.
61
62 [[image:image-20220913154722-26.jpeg]]
63
64 (% class="box infomessage" %)
65 (((
66 **✎Note: This function is only supported in the following host computer and slave computer versions:**
67 )))
68
69 Supported host computer versions: Wecon PLC Editor 2 2.1.204 and above, as shown in the following figure:
70
71 (% style="text-align:center" %)
72 [[image:image-20220913154229-2.jpeg]]
73
74 Supported slave computer versions: 2.061 and above, as shown in the following figure:
75
76 [[image:image-20220913154229-3.jpeg]]
77
78 The parameter configuration interface is as follows:
79
80 (% style="text-align:center" %)
81 [[image:image-20220913154229-4.jpeg]]
82
83 **Functional description of each configuration item:**
84
85 * **Whether to set: **Indicates whether the configuration is effective. True is effective, and False is not.
86 * **Communication settings:**
87 ** **Baud rate: **Indicates the baud rate of serial communication and the number of bits transmitted per second. The maximum baud rate supported is 115200bps.
88 ** **Data bit: **Indicates the number of data bits of serial communication, and the value range is 7 to 8 digits.
89 ** **Stop bit: **Indicates the number of stop bits in serial communication, and the value range is 1 to 2 digits.
90 ** **Parity bit**: Indicates whether to add check bits during serial communication, and check types. Odd check and even check are commonly used.
91 ** **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.
92 ** **Sending interval (0.1 ms): **Configuration for the master station, indicating the time when the communication is completed and the next request is sent.
93 ** **Agreement: **Currently supported protocols are: user-defined protocol, dedicated protocol, Modbus RTU, Modbus ASCII.
94 *** **User-defined protocol:** Users need to organize request frames by themselves, and process response frames after receiving response data.
95 *** **Dedicated protocol: **WECON Modbus protocol (PLC local protocol) is used for program upload and download, HMI monitoring protocol.
96 * **Agreement related:**
97 ** **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.
98 ** **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.
99 ** **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.
100 * **Terminator: **Effective under user-defined protocol.
101 * **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.
102 * **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.
103
104 The storage mode of 16-bit mode is as follows:
105
106 |=(% scope="row" %) |=**(High 8 bits)**|=**(Low 8 bits)**
107 |=D100|0x13|0x12
108 |=D101|No data|No data
109
110 The storage mode of 8-bit mode is as follows:
111
112 |=(% scope="row" %) |=**(High 8 bits)**|=**(Low 8 bits)**
113 |=D100|0x00|0x12
114 |=D101|0x00|0x13
115
116 = **5 RS2 instruction** =
117
118 **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).
119
120 **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).
121
122 -[RS2 (S) (M) (D) (N) (N1)]
123
124 **Content, range and data type**
125
126 In the case of user-defined protocol
127
128 |=(% scope="row" %)**Parameter**|=(% style="width: 528px;" %)**Content**|=(% style="width: 98px;" %)**Range**|=(% style="width: 169px;" %)**Data type**|=(% style="width: 179px;" %)**Data type (label)**
129 |=(S)|(% style="width:528px" %)The starting address of the register area where the data to be sent is stored|(% style="width:98px" %)-|(% style="width:169px" %)Unsigned BIN16 bits|(% style="width:179px" %)ANY16
130 |=(M)|(% style="width:528px" %)The length (in bytes) of the data to be sent|(% style="width:98px" %)0 to 528|(% style="width:169px" %)Unsigned BIN16 bits|(% style="width:179px" %)ANY16
131 |=(D)|(% style="width:528px" %)The start number of device that stores written data|(% style="width:98px" %)-|(% style="width:169px" %)Unsigned BIN16 bits|(% style="width:179px" %)ANY16
132 |=(N)|(% style="width:528px" %)Number of data written in bytes|(% style="width:98px" %)0 to 528|(% style="width:169px" %)Unsigned BIN16 bits|(% style="width:179px" %)ANY16
133 |=(N1)|(% style="width:528px" %)Specify communication port|(% style="width:98px" %)-|(% style="width:169px" %)Unsigned BIN16 bits|(% style="width:179px" %)ANY16
134
135 Modbus protocol
136
137 |=(% scope="row" style="width: 98px;" %)**Parameter**|=(% style="width: 533px;" %)**Content**|=(% style="width: 97px;" %)**Range**|=(% style="width: 175px;" %)**Data type**|=(% style="width: 174px;" %)**Data type (label)**
138 |=(% style="width: 98px;" %)(S)|(% style="width:533px" %)The high byte stores the station number of the slave station, and the low byte stores Modbus function codes.|(% style="width:97px" %)-|(% style="width:175px" %)Unsigned BIN16 bits|(% style="width:174px" %)ANY16
139 |=(% style="width: 98px;" %)(M)|(% style="width:533px" %)The slave address provided by the slave, reads or writes data from this address of the slave.|(% style="width:97px" %)-|(% style="width:175px" %)Unsigned BIN16 bits|(% style="width:174px" %)ANY16
140 |=(% style="width: 98px;" %)(D)|(% style="width:533px" %)Length. The length read or written by Modbus, and the unit is determined by the function code.|(% style="width:97px" %)-|(% style="width:175px" %)Unsigned BIN16 bits|(% style="width:174px" %)ANY16
141 |=(% style="width: 98px;" %)(N)|(% style="width:533px" %)Start address for reading or writing data|(% style="width:97px" %)-|(% style="width:175px" %)Unsigned BIN16 bits|(% style="width:174px" %)ANY16
142 |=(% style="width: 98px;" %)(N1)|(% style="width:533px" %)Specify communication port|(% style="width:97px" %)-|(% style="width:175px" %)Unsigned BIN16 bits|(% style="width:174px" %)ANY16
143
144 **Device used**
145
146 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="6" %)**Devices**|(((
147 **Offset**
148
149 **modification**
150 )))|(((
151 **Pulse**
152
153 **extension**
154 )))
155 |T|C|D|R|K|H|[D]|XXP
156 |(% rowspan="5" %)RS2|(S)|●|●|●|●|●|●| |
157 |(M)|●|●|●|●|●|●| |
158 |(D)|●|●|●|●|●|●| |
159 |(N)|●|●|●|●|●|●| |
160 |(N1)| | | | |●|●| |
161
162 **Function**
163
164 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).
165
166 == User-defined protocol ==
167
168 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.
169
170 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.
171
172 **Example:**
173
174 (% style="text-align:center" %)
175 [[image:image-20220913154229-5.png||class="img-thumbnail"]]
176
177 When M1 is ON, the sending and receiving data of communication after instruction execution are stored as follows:
178
179 (% style="text-align:center" %)
180 [[image:image-20220913154229-6.jpeg||class="img-thumbnail"]]
181
182 == Modbus protocol ==
183
184 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.
185
186 **Example:**
187
188 (% style="text-align:center" %)
189 [[image:image-20220913154229-7.png||class="img-thumbnail"]]
190
191 |=(% scope="row" style="width: 97px;" %)**(S)**|(% style="width:978px" %)The high byte stores the station number of the slave station, and the low byte stores the Modbus function code.
192 |=(% style="width: 97px;" %)**(M)**|(% style="width:978px" %)Slave station address The address provided by the slave station will read or write data from the address of slave station.
193 |=(% style="width: 97px;" %)**(D)**|(% style="width:978px" %)Length. The length read or written by Modbus, and the unit is determined by the function code.
194 |=(% style="width: 97px;" %)**(N)**|(% style="width:978px" %)The starting address for reading or writing data.
195 |=(% style="width: 97px;" %)**(N1)**|(% style="width:978px" %)Specify communication port.
196
197 **✎Note:**
198
199 * The RS2 instruction allows parameters to be represented by K and H constants, but with different restrictions on different protocols.
200 * When the protocol is user-defined protocol, S and D cannot be constants, otherwise an error (3X89H) will be reported.
201 * When the protocol is Modbus protocol, N cannot be a constant, otherwise an error (3X89H) will be reported.
202 * When the protocol is RTU protocol, only 8 bits of data can be selected.
203 * 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.
204 * At present, RS2 instructions cannot be used in interrupts and events.
205
206 **Error code**
207
208 |=(% scope="row" style="width: 99px;" %)**Error code**|=(% style="width: 976px;" %)**Content**
209 |=(% style="width: 99px;" %)4085H|(% style="width:976px" %)(S), (M), (D) and (N) read address out of range of the device.
210 |=(% style="width: 99px;" %)4084H|(% style="width:976px" %)Parameter value is out of the specified range.
211 |=(% colspan="2" %)**COM3**
212 |=(% style="width: 99px;" %)3280H|(% style="width:976px" %)COM3 data reception error. There may be interference on the communication cable, it is recommended to connect GND.
213 |=(% style="width: 99px;" %)3281H|(% style="width:976px" %)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".
214 |=(% style="width: 99px;" %)3282H|(% style="width:976px" %)COM3 CRC validation error. There may be interference on the communication cable, it is recommended to connect GND.
215 |=(% style="width: 99px;" %)3283H|(% style="width:976px" %)COM3 LRC validation error. There may be interference on the communication cable, it is recommended to connect GND.
216 |=(% style="width: 99px;" %)3284H|(% style="width:976px" %)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.
217 |=(% style="width: 99px;" %)3285H|(% style="width:976px" %)COM3 send buffer overflow. If this error appears, please contact your technician.
218 |=(% style="width: 99px;" %)3286H|(% style="width:976px" %)COM3 function code error. Check whether the set function code is supported by PLC.
219 |=(% style="width: 99px;" %)3287H|(% style="width:976px" %)COM3 address error. Check whether the slave station has this address. (Please refer to Modbus exception 02).
220 |=(% style="width: 99px;" %)3288H|(% style="width:976px" %)COM3 length error. Check whether the communication length exceeds the length range specified by Modbus protocol or user-defined protocol.
221 |=(% style="width: 99px;" %)3289H|(% style="width:976px" %)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).
222 |=(% style="width: 99px;" %)328AH|(% style="width:976px" %)COM3 slave station is busy. Message returned from slave station: Slave station is busy. (Please refer to Modbus exception 06).
223 |=(% style="width: 99px;" %)328BH|(% style="width:976px" %)COM3 slave does not support function codes. Check whether this function code is supported by the slave station. (Please refer to Modbus exception 01).
224 |=(% style="width: 99px;" %)328CH|(% style="width:976px" %)COM3 slave failure. Message returned from slave station: Slave station failed, please check whether slave station failed (Please refer to Modbus exception 04).
225 |=(% style="width: 99px;" %)328DH|(% style="width:976px" %)COM3 slave confirmation. Message returned from slave station: slave station confirmation. (Please refer to Modbus exception 05).
226 |=(% style="width: 99px;" %)328EH|(% style="width:976px" %)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.
227 |=(% style="width: 99px;" %)328FH|(% style="width:976px" %)COM3 sending timed out. If this error appears, please contact your technician.
228 |=(% style="width: 99px;" %)32A0H|(% style="width:976px" %)COM3 unavailable gateway Message returned from the station: unavailable gateway. (Please refer to Modbus exception 0A).
229 |=(% style="width: 99px;" %)32A1H|(% style="width:976px" %)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).
230 |=(% colspan="2" %)**COM4**
231 |=(% style="width: 99px;" %)3380H|(% style="width:976px" %)COM4 data reception error. There may be interference on the communication cable, it is recommended to connect GND.
232 |=(% style="width: 99px;" %)3381H|(% style="width:976px" %)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".
233 |=(% style="width: 99px;" %)3382H|(% style="width:976px" %)COM4 CRC validation error. There may be interference on the communication cable, it is recommended to connect GND.
234 |=(% style="width: 99px;" %)3383H|(% style="width:976px" %)COM4 LRC validation error. There may be interference on the communication cable, it is recommended to connect GND.
235 |=(% style="width: 99px;" %)3384H|(% style="width:976px" %)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.
236 |=(% style="width: 99px;" %)3385H|(% style="width:976px" %)COM4 send buffer overflow. If this error appears, please contact your technician.
237 |=(% style="width: 99px;" %)3386H|(% style="width:976px" %)COM4 function code error. Check whether the set function code is supported by PLC.
238 |=(% style="width: 99px;" %)3387H|(% style="width:976px" %)COM4 address error. Check whether the slave station has this address. (Please refer to Modbus exception 02).
239 |=(% style="width: 99px;" %)3388H|(% style="width:976px" %)COM4 length error. Check whether the communication length exceeds the length range specified by Modbus protocol or user-defined protocol.
240 |=(% style="width: 99px;" %)3389H|(% style="width:976px" %)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).
241 |=(% style="width: 99px;" %)338AH|(% style="width:976px" %)COM4 slave station is busy. Message returned from slave station: Slave station is busy. (Please refer to Modbus exception 06).
242 |=(% style="width: 99px;" %)338BH|(% style="width:976px" %)COM4 slave does not support function codes. Check whether this function code is supported by the slave station. (Please refer to Modbus exception 01).
243 |=(% style="width: 99px;" %)338CH|(% style="width:976px" %)COM4 slave failure. Message returned from slave station: Slave station failed, please check whether slave station failed. (Please refer to Modbus exception 04).
244 |=(% style="width: 99px;" %)338DH|(% style="width:976px" %)COM4 slave confirmation Message returned from slave station: slave station confirmation. (Please refer to Modbus exception 05).
245 |=(% style="width: 99px;" %)338EH|(% style="width:976px" %)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.
246 |=(% style="width: 99px;" %)338FH|(% style="width:976px" %)COM4 send timed out. If this error appears, please contact your technician.
247 |=(% style="width: 99px;" %)33A0H|(% style="width:976px" %)COM4 unavailable gateway Message returned from the station: unavailable gateway. (Please refer to Modbus exception 0A).
248 |=(% style="width: 99px;" %)33A1H|(% style="width:976px" %)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).
249
250 |=(% colspan="2" scope="row" %)**COM5**
251 |=(% style="width: 99px;" %)3480H|(% style="width:976px" %)COM5 data reception error. There may be interference on the communication cable, it is recommended to connect GND.
252 |=(% style="width: 99px;" %)3481H|(% style="width:976px" %)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".
253 |=(% style="width: 99px;" %)3482H|(% style="width:976px" %)COM5 CRC validation error. There may be interference on the communication cable, it is recommended to connect GND.
254 |=(% style="width: 99px;" %)3483H|(% style="width:976px" %)COM5 LRC validation error. There may be interference on the communication cable, it is recommended to connect GND.
255 |=(% style="width: 99px;" %)3484H|(% style="width:976px" %)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.
256 |=(% style="width: 99px;" %)3485H|(% style="width:976px" %)COM5 send buffer overflow. If this error appears, please contact your technician.
257 |=(% style="width: 99px;" %)3486H|(% style="width:976px" %)COM5 function code error. Check whether the set function code is supported by PLC.
258 |=(% style="width: 99px;" %)3487H|(% style="width:976px" %)COM5 address error. Check whether the slave station has this address. (Please refer to Modbus exception 02).
259 |=(% style="width: 99px;" %)3488H|(% style="width:976px" %)COM5 length error. Check whether the communication length exceeds the length range specified by Modbus protocol or user-defined protocol.
260 |=(% style="width: 99px;" %)3489H|(% style="width:976px" %)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).
261 |=(% style="width: 99px;" %)348AH|(% style="width:976px" %)COM5 slave station is busy. Message returned from slave station: Slave station is busy. (Please refer to Modbus exception 06).
262 |=(% style="width: 99px;" %)348BH|(% style="width:976px" %)COM5 slave does not support function codes. Check whether this function code is supported by the slave station. (Please refer to Modbus exception 01).
263 |=(% style="width: 99px;" %)348CH|(% style="width:976px" %)COM5 slave failure. Message returned from slave station: Slave station failed, please check whether slave station failed. (Please refer to Modbus exception 04).
264 |=(% style="width: 99px;" %)348DH|(% style="width:976px" %)COM5 slave station confirmation Message returned from slave station: slave station confirmation. (Please refer to Modbus exception 05).
265 |=(% style="width: 99px;" %)348EH|(% style="width:976px" %)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.
266 |=(% style="width: 99px;" %)348FH|(% style="width:976px" %)COM5 send timed out. If this error appears, please contact your technician.
267 |=(% style="width: 99px;" %)34A0H|(% style="width:976px" %)COM5 unavailable gateway Message returned from the station: unavailable gateway. (Please refer to Modbus exception 0A).
268 |=(% style="width: 99px;" %)34A1H|(% style="width:976px" %)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).
269 |=(% colspan="2" %)COM6
270 |=(% style="width: 99px;" %)3580H|(% style="width:976px" %)COM6 data reception error. There may be interference on the communication cable, it is recommended to connect GND.
271 |=(% style="width: 99px;" %)3581H|(% style="width:976px" %)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".
272 |=(% style="width: 99px;" %)3582H|(% style="width:976px" %)COM6 CRC validation error. There may be interference on the communication cable, it is recommended to connect GND.
273 |=(% style="width: 99px;" %)3583H|(% style="width:976px" %)COM6 LRC validation error. There may be interference on the communication cable, it is recommended to connect GND.
274 |=(% style="width: 99px;" %)3584H|(% style="width:976px" %)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.
275 |=(% style="width: 99px;" %)3585H|(% style="width:976px" %)COM6 send buffer overflow. If this error appears, please contact your technician.
276 |=(% style="width: 99px;" %)3586H|(% style="width:976px" %)COM6 function code error. Check whether the set function code is supported by PLC.
277 |=(% style="width: 99px;" %)3587H|(% style="width:976px" %)COM6 address error. Check whether the slave station has this address. (Please refer to Modbus exception 02).
278 |=(% style="width: 99px;" %)3588H|(% style="width:976px" %)COM6 length error. Check whether the communication length exceeds the length range specified by Modbus protocol or user-defined protocol.
279 |=(% style="width: 99px;" %)3589H|(% style="width:976px" %)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).
280 |=(% style="width: 99px;" %)358AH|(% style="width:976px" %)COM6 slave station is busy. Message returned from slave station: Slave station is busy. (Please refer to Modbus exception 06).
281 |=(% style="width: 99px;" %)358BH|(% style="width:976px" %)COM6 slave does not support function codes. Check whether this function code is supported by the slave station. (Please refer to Modbus exception 01).
282 |=(% style="width: 99px;" %)358CH|(% style="width:976px" %)COM6 slave failure. Message returned from slave station: Slave station failed, please check whether slave station failed. (Please refer to Modbus exception 04).
283 |=(% style="width: 99px;" %)358DH|(% style="width:976px" %)COM6 slave station acknowledges. Message returned from slave station: slave station confirmation. (Please refer to Modbus exception 05).
284 |=(% style="width: 99px;" %)358EH|(% style="width:976px" %)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.
285 |=(% style="width: 99px;" %)358FH|(% style="width:976px" %)COM6 send timed out. If this error appears, please contact your technician.
286 |=(% style="width: 99px;" %)35A0H|(% style="width:976px" %)COM6 unavailable gateway Message returned from the station: unavailable gateway. (Please refer to Modbus exception 0A).
287 |=(% style="width: 99px;" %)35A1H|(% style="width:976px" %)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).
288
289 **6 Address mapping**
290
291 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:
292
293 |=(% colspan="5" %)**Word address**
294 |(% style="width:213px" %)**Address type**|(% style="width:212px" %)**Occupation**|(% style="width:226px" %)**Address range**|(% style="width:173px" %)**Decimal address**|(% style="width:252px" %)**Total reserved address size**
295 |(% style="width:213px" %)T0 to T511|(% style="width:212px" %)512 WORD|(% style="width:226px" %)0x0000 to 0x01ff|(% style="width:173px" %)0|(% style="width:252px" %)1536
296 |(% style="width:213px" %)C0 to C255|(% style="width:212px" %)256 WORD|(% style="width:226px" %)0x0600 to 0x06ff|(% style="width:173px" %)1536|(% style="width:252px" %)1024
297 |(% style="width:213px" %)LC0 to LC255|(% style="width:212px" %)512 WORD|(% style="width:226px" %)0x0A000 to 0x0BFF|(% style="width:173px" %)2560|(% style="width:252px" %)1024
298 |(% style="width:213px" %)HSC0 to HSC15|(% style="width:212px" %)128 WORD|(% style="width:226px" %)0x0E00 to 0x0E1F|(% style="width:173px" %)3584|(% style="width:252px" %)512
299 |(% style="width:213px" %)D0 to D7999|(% style="width:212px" %)8000 WORD|(% style="width:226px" %)0x1000 to 0x2F3F|(% style="width:173px" %)4096|(% style="width:252px" %)16384
300 |(% style="width:213px" %)SD0 to SD4095|(% style="width:212px" %)4096 WORD|(% style="width:226px" %)0x5000 to 0x5FFF|(% style="width:173px" %)20480|(% style="width:252px" %)12288
301 |(% style="width:213px" %)R0 to R30000|(% style="width:212px" %)30000 WORD|(% style="width:226px" %)0x8000 to 0xF52F|(% style="width:173px" %)32768|(% style="width:252px" %)30000
302
303 |=(% colspan="5" %)**Bit address**
304 |(% style="width:212px" %)**Address type**|(% style="width:214px" %)**Occupation**|(% style="width:229px" %)**Address range**|(% style="width:170px" %)**Decimal address**|(% style="width:251px" %)**Total reserved address size**
305 |(% style="width:212px" %)T0 to T511|(% style="width:214px" %)512 bits|(% style="width:229px" %)0x0000 to 0x01ff|(% style="width:170px" %)0|(% style="width:251px" %)1536
306 |(% style="width:212px" %)C0 to C255|(% style="width:214px" %)256 bits|(% style="width:229px" %)0x0600 to 0x06ff|(% style="width:170px" %)1536|(% style="width:251px" %)1024
307 |(% style="width:212px" %)LC0 to LC255|(% style="width:214px" %)256 bits|(% style="width:229px" %)0x0A00 to 0x0AFF|(% style="width:170px" %)2560|(% style="width:251px" %)1024
308 |(% style="width:212px" %)HSC0 to HSC15|(% style="width:214px" %)64 bits|(% style="width:229px" %)0x0E00 to 0x0E0F|(% style="width:170px" %)3584|(% style="width:251px" %)512
309 |(% style="width:212px" %)M0 to M8000|(% style="width:214px" %)8192 bits|(% style="width:229px" %)0x1000 to 0x2F3F|(% style="width:170px" %)4096|(% style="width:251px" %)16384
310 |(% style="width:212px" %)SM0 to SM4095|(% style="width:214px" %)4096 bits|(% style="width:229px" %)0x5000 to 0x5FFF|(% style="width:170px" %)20480|(% style="width:251px" %)12288
311 |(% style="width:212px" %)Reserved|(% style="width:214px" %) |(% style="width:229px" %)0x8000 to 0xBFFF|(% style="width:170px" %) |(% style="width:251px" %)16383
312 |(% style="width:212px" %)S0 to S4095|(% style="width:214px" %)4096 bits|(% style="width:229px" %)0xC000 to 0xCFFF|(% style="width:170px" %)49152|(% style="width:251px" %)8192
313 |(% style="width:212px" %)X0 to X1023|(% style="width:214px" %)1024 bits|(% style="width:229px" %)0xE000 to 0xE3FF|(% style="width:170px" %)57344|(% style="width:251px" %)4096
314 |(% style="width:212px" %)Y0 to Y1023|(% style="width:214px" %)1024 bits|(% style="width:229px" %)0xF000 to 0xF3FF|(% style="width:170px" %)61440|(% style="width:251px" %)4096
315
316 When using the Modbus master station to access the slave station, the RS2 instruction specifies the following address:
317
318 **Example 1:** Read 10 registers starting from slave station (station NO.1) D0 and store them in 10 devices starting from local D0:
319
320 (% style="text-align:center" %)
321 [[image:image-20220913154229-8.png||class="img-thumbnail"]]
322
323 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.
324
325 **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):
326
327 (% style="text-align:center" %)
328 [[image:image-20220913154229-9.png||class="img-thumbnail"]]
329
330 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).
331
332 = **7 Special devices for BD module** =
333
334 **BD1:**
335
336 |=(% scope="row" style="width: 111px;" %)**SD label**|=(% style="width: 317px;" %)**Content**|=(% style="width: 132px;" %)**SD label**|=(% style="width: 516px;" %)**Content**
337 |=(% style="width: 111px;" %)SM2000|(% style="width:317px" %)COM3 sending control on|(% style="width:132px" %)SD2000|(% style="width:516px" %)Display 0x1062 after 485 BD is recognized after power-on.
338 |=(% style="width: 111px;" %)SM2001|(% style="width:317px" %)COM3 send control/send prompt|(% style="width:132px" %)SD2001|(% style="width:516px" %)Display 485BD version information after 485 BD is recognized after power-on.
339 |=(% style="width: 111px;" %)SM 2002|(% style="width:317px" %)COM3 reception control on|(% style="width:132px" %)SD 2002|(% style="width:516px" %)BD1 last error
340 |=(% style="width: 111px;" %)SM 2003|(% style="width:317px" %)COM3 accept control/receive prompt|(% style="width:132px" %)SD 2003|(% style="width:516px" %)BD1 current error
341 |=(% style="width: 111px;" %)SM2004|(% style="width:317px" %)COM3 communication complete flag|(% style="width:132px" %)SD2004|(% style="width:516px" %)BD1 error times
342 |=(% style="width: 111px;" %)SM 2005|(% style="width:317px" %)COM4 sending control on|(% style="width:132px" %)SD 2005|(% style="width:516px" %)BD1 error communication port.
343 |=(% style="width: 111px;" %)SM 2006|(% style="width:317px" %)COM4 send control/send prompt|(% style="width:132px" %)SD2006|(% style="width:516px" %)BD1 communication timeout (1ms).
344 |=(% style="width: 111px;" %)SM 2007|(% style="width:317px" %)COM4 reception control on|(% style="width:132px" %) |(% style="width:516px" %)
345 |=(% style="width: 111px;" %)SM2008|(% style="width:317px" %)COM4 accept control/receive prompt|(% style="width:132px" %) |(% style="width:516px" %)
346 |=(% style="width: 111px;" %)SM2009|(% style="width:317px" %)COM4 communication complete flag|(% style="width:132px" %) |(% style="width:516px" %)
347
348 **BD2:**
349
350 |=(% scope="row" style="width: 113px;" %)**SD label**|=(% style="width: 314px;" %)**Content**|=(% style="width: 131px;" %)**SD label**|=(% style="width: 518px;" %)**Content**
351 |=(% style="width: 113px;" %)SM2020|(% style="width:314px" %)COM5 sending control on|(% style="width:131px" %)SD2020|(% style="width:518px" %)Display 0x1062 after 485 BD is recognized after power-on.
352 |=(% style="width: 113px;" %)SM2021|(% style="width:314px" %)COM5 send control/send prompt|(% style="width:131px" %)SD2021|(% style="width:518px" %)Display 485 BD version information after 485 BD is recognized after power-on.
353 |=(% style="width: 113px;" %)SM 2022|(% style="width:314px" %)COM5 reception control on|(% style="width:131px" %)SD2022|(% style="width:518px" %)BD2 last error
354 |=(% style="width: 113px;" %)SM2023|(% style="width:314px" %)COM5 accept control/receive prompt|(% style="width:131px" %)SD2023|(% style="width:518px" %)BD2 current error
355 |=(% style="width: 113px;" %)SM2024|(% style="width:314px" %)COM5 communication complete flag|(% style="width:131px" %)SD2024|(% style="width:518px" %)BD2 error times
356 |=(% style="width: 113px;" %)SM2025|(% style="width:314px" %)COM6 sending control on|(% style="width:131px" %)SD2025|(% style="width:518px" %)BD2 error communication port.
357 |=(% style="width: 113px;" %)SM2026|(% style="width:314px" %)COM6 send control/send prompt|(% style="width:131px" %)SD2026|(% style="width:518px" %)BD2 communication timeout (1ms).
358 |=(% style="width: 113px;" %)SM2027|(% style="width:314px" %)COM6 reception control on|(% style="width:131px" %) |(% style="width:518px" %)
359 |=(% style="width: 113px;" %)SM2028|(% style="width:314px" %)COM6 accept control/receive prompt|(% style="width:131px" %) |(% style="width:518px" %)
360 |=(% style="width: 113px;" %)SM2029|(% style="width:314px" %)COM6 communication complete flag|(% style="width:131px" %) |(% style="width:518px" %)
361
362 = **8 Examples** =
363
364 == Modbus RTU slave station ==
365
366 Configure COM3 port as Modbus RTU slave. COM3 parameters are configured as follows:
367
368 (% style="text-align:center" %)
369 [[image:image-20220913154229-10.jpeg]]
370
371 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)
372
373 == Modbus RTU master station ==
374
375 Configure COM4 port as the Modbus RTU master station, and read the 125 word devices starting from the station address once every 100ms.
376
377 COM4 parameters are configured as follows:
378
379 (% style="text-align:center" %)
380 [[image:image-20220913154229-11.jpeg]]
381
382 The station number is configured as 0 to indicate the master station protocol.
383
384 The ladder diagram is configured as follows:
385
386 (% style="text-align:center" %)
387 [[image:image-20220913154229-12.jpeg]]
388
389 == Dedicated protocol ==
390
391 Configure COM3 port as a dedicated protocol, and use this serial port to upload and download programs.
392
393 COM3 parameters are configured as follows:
394
395 (% style="text-align:center" %)
396 [[image:image-20220913154229-13.jpeg]]
397
398 PLC Editor2 uses this serial port communication: PC uses USB to RS485 converter to connect with BD module at this time.
399
400 (% style="text-align:center" %)
401 [[image:image-20220913154229-14.jpeg]]
402
403 (% style="text-align:center" %)
404 [[image:image-20220913154229-15.jpeg]]
405
406 == User-defined protocol ==
407
408 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.
409
410 COM3 parameters are configured as follows:
411
412 (% style="text-align:center" %)
413 [[image:image-20220913154229-16.jpeg||class="img-thumbnail"]]
414
415 The ladder diagram is configured as follows:
416
417 [[image:image-20220913154229-17.jpeg||class="img-thumbnail"]]
418
419 (% style="text-align:center" %)
420 [[image:image-20220913154229-18.jpeg||class="img-thumbnail"]]