07 Communication
PLC COM2 Modbus RTU
Protocol Setting (D8126)
Protocol | Description | Value of D8126 |
---|---|---|
WECON PLC Protocol | Using WECON PLC Protocol | 01H |
MODBUS RTU Master | PLC is slave device | 02H |
MODBUS ASCII Master | PLC is slave device | 03H |
User-defined Protocol | Using User-defined Protocol | 10H |
MODBUS RTU Slave | PLC is master device | 20H |
MODBUS ASCII Slave | PLC is master device | 30H |
Communication format (D8120)
Item | parameter | Bit value of D8120 | |||||||
b7 | b6 | b5 | b4 | b3 | b2 | b1 | b0 | ||
Baud rate (Bps) | 115200 | 1 | 1 | 0 | 0 | - | - | - | - |
57600 | 1 | 0 | 1 | 1 | - | - | - | - | |
38400 | 1 | 0 | 1 | 0 | - | - | - | - | |
19200 | 1 | 0 | 0 | 1 | - | - | - | - | |
9600 | 1 | 0 | 0 | 0 | - | - | - | - | |
4800 | 0 | 1 | 1 | 1 | - | - | - | - | |
Stop bit | 1 bit | - | - | - | - | 0 | - | - | - |
2 bit | - | - | - | - | 1 | - | - | - | |
Parity | None | - | - | - | - | - | 0 | 0 | - |
Odd | - | - | - | - | - | 0 | 1 | - | |
Even | - | - | - | - | - | 1 | 1 | - | |
Data bit | 7 bit | - | - | - | - | - | - | - | 0 |
8 bit | - | - | - | - | - | - | - | 1 | |
Example: the communication format is 9600.1.8.None, b7b6b5b4=1000, b3=0, b2b1=00, b 0=1. D8120=81H ( (10000001)2=81H, 81H means hexadecimal number) |
WECON PLC - MODBUS (Slave) addresses rules
PLC Bit Address | ||
PLC Address | MODBUS Address | |
Hex | Decimal | |
M0 ~ M3071 | 0 ~ 0xBFF | 0 ~ 3071 |
M8000 ~ M8256 | 0x1F40 ~ 0x2040 | 8000 ~ 8256 |
S0 ~ S999 | 0xE000 ~ 0xE3E7 | 57344 ~ 58343 |
T0 ~ T256 | 0xF000 ~ 0xF100 | 61440 ~ 61696 |
C0 ~ C255 | 0xF400 ~ 0xF4FF | 62464 ~ 62719 |
X0 ~ X377 | 0xF800 ~ 0xF8FF | 63488 ~ 63743 |
Y0 ~ Y377 | 0xFC00 ~ 0xFCFF | 64512 ~ 64767 |
PLC Word Address | ||
PLC Address | MODBUS Address | |
Hex | Decimal | |
D0 ~ D8255 | 0 ~ 0x203F | 0 ~ 8255 |
T0 ~ T255 | 0xF000 ~ 0xF0FF | 61440 ~ 61695 |
C0 ~ C199 | 0xF400 ~ 0xF4C7 | 62464 ~ 62663 |
C200 ~ C255 | 0xF700 ~ 0xF7FF | 63232 ~ 63487 |
MODBUS function code introduction
Function code 0x01(01): read coil (bit address)
Frame format: Station number of slave&0x01 + start address + number of coils + CRC
No. | Data | Number of byte | Instruction |
1 | Station number of slave | 1 byte | Value range 1~247, set by D8121 |
2 | 0x01(function code) | 1 byte | Read coil |
3 | Start address | 2 bytes | |
4 | Number of coils | 2 bytes | |
5 | CRC | 2 bytes |
Function code 0x03(03): read register (word address)
Frame format: Station number of slave&0x03 + start address+ number of registers + CRC
No. | Data | Number of byte | Instruction |
1 | Station number of slave | 1 byte | Value range 1~247, set by D8121 |
2 | 0x03 (function code) | 1 byte | Read register |
3 | Start address | 2 bytes | |
4 | Number of registers | 2 bytes | |
5 | CRC | 2 bytes |
Function code 0x05(05): write single coil
Frame format: Station number of slave&0x05 + address + state of coil + CRC
No. | Data | Number of byte | Instruction |
1 | Station number of slave | 1 byte | Value range 1~247, set by D8121 |
2 | 0x05 (function code) | 1 byte | Write single coil |
3 | address | 2 bytes | |
4 | State of coil | 2 bytes | |
5 | CRC | 2 bytes |
Function code 0x06 (06): Write single register
Frame format: Station number of slave&0x06 + address + value + CRC
No. | Data | Number of byte | Instruction |
1 | Station number of slave | 1 byte | Value range 1~247, set by D8121 |
2 | 0x06 (function code) | 1 byte | Write single register |
3 | address | 2 bytes | |
4 | Value of register | 2 bytes | |
5 | CRC | 2 bytes |
Function code 0x0f(15): Write continuous coils
Frame format: Station number of slave&0x0f + start address + number of coils + length + state of coil + CRC
No. | Data | Number of byte | Instruction |
1 | Station number of slave | 1 byte | Value range 1~247, set by D8121 |
2 | 0x0f (function code) | 1 byte | Write contunuous coils |
3 | Start address | 2 bytes | |
4 | Number of coil | 2 bytes | |
5 | Length | 1 bytes | |
6 | State of coils | [(N+7)/8] bytes | |
7 | CRC | 2 bytes |
Function code 0x10 (10): Write continuous registers
Frame format: Station number of slave&0x10 + start address + number of registers + length + value of register + CRC
No. | Data | Number of byte | Instruction |
1 | Station number of slave | 1 byte | Value range 1~247, set by D8121 |
2 | 0x10 (function code) | 1 byte | Write contunuous registers |
3 | Start address | 2 bytes | |
4 | Number of registers | 2 bytes | |
5 | Length | 1 bytes | |
6 | Value of register | N*2 bytes | |
7 | CRC | 2 bytes |
Example
Read bit address from device
(When reading the bit address, a return value of 256 indicates that the coil is in the ON state, while a return value of 0 indicates that the coil is in the OFF state.)
Read word address from device
Write single coil
Tip: (When writing a single coil or a continuous coil, write HFF00 to turn the coil on, and write H0000 to turn off the coil.)
Write single register
Write continuous coils
Write continuous registers
PLC is slave devic
WECON PLC Protocol (COM2)
N:N network
LX3VP COM2 N:N Application
LX3VP COM2 N:N Connection
PLC built-in N:N connection protocol provides an effective way to exchange data among multiple PLC (Max. 8 devices). Technically, it only requires the twisted pair RS485 cable to connect with each PLC COM2 (in parallel).
COM2 N:N Instructions
User should put data to specified register unit. Exchanging the data among PLCs, This function only requires putting data in preset register block, all the data in this register block would share with other PLCs. There are five modes for choice, according to data volume and communication speed. See the preset register block from table below.
Station Number | Mode 0 | Mode 1 | Mode 2 | ||||
Bit (M) | Word(D) | Bit (M) | Word(D) | Bit (M) | Word(D) | ||
0 | 4 | 32 | 4 | 64 | 8 | ||
Master | NO. 0 | -- | 0-3 | 1000-1031 | 0-3 | 1000-1063 | 0-7 |
Slave | NO. 1 | -- | 32-35 | 1064-1095 | 32-35 | 1064-1127 | 32-39 |
NO. 2 | -- | 64-67 | 1128-1159 | 64-67 | 1128-1191 | 64-71 | |
NO. 3 | -- | 96-99 | 1192-1223 | 96-99 | 1192-1255 | 96-103 | |
NO. 4 | -- | 128-131 | 1256-1287 | 128-131 | 1256-1319 | 128-135 | |
NO. 5 | -- | 160-163 | 1320-1351 | 160-163 | 1320-1383 | 160-167 | |
NO. 6 | -- | 192-195 | 1384-1415 | 192-195 | 1384-1447 | 192-199 | |
NO. 7 | -- | 224-227 | 1448-1479 | 224-227 | 1448-1511 | 224-231 | |
Station Number | Mode 3 | Mode 4 | |||||
Bit (M) | Word(D) | Bit (M) | Word(D) | ||||
64 | 16 | 64 | 32 | ||||
Master | NO. 0 | 1000-1063 | 0-15 | 1000-1063 | 0-31 | ||
Slave | NO. 1 | 1064-1127 | 32-47 | 1064-1127 | 32-63 | ||
NO. 2 | 1128-1191 | 64-79 | 1128-1191 | 64-95 | |||
NO. 3 | 1192-1255 | 96-111 | 1192-1255 | 96-127 | |||
NO. 4 | 1256-1319 | 128-143 | 1256-1319 | 128-159 | |||
NO. 5 | 1320-1383 | 160-175 | 1320-1383 | 160-191 | |||
NO. 6 | 1384-1447 | 192-207 | 1384-1447 | 192-223 | |||
NO. 7 | 1448-1511 | 224-239 | 1448-1511 | 224-255 |
Communication between each PLC (up to 8 PLC), please see the connection construction below (For 3 PLC interconnection).
Special devices in N: N network
Register | Description |
---|---|
D8120 | Communication format settings |
D8126 | COM2 communication protocol settings, 40h means N:N Master Device, 04h means N:N Slave device |
D8176 | Station number, from 0 to 7, 0 means master device |
D8177 | Total station number, from 1 to 7, only required for master device. |
D8178 | Register block setting, from 0 to 5, only required for master device. |
D8179 | Retry count settings, only required for master device. |
D8180 | Timeout setting, unit: 10ms,only required for master device. |
D8201 | Current connection scould time |
D8202 | Maximum connection scould time |
D8203 | Master error counter |
D8204~D8210 | Slave error counter |
D8211 | Master N:N error code |
D8212~D8218 | Slave N:N error code |
M8183 | Master data transfer sequence error |
M8183~M8190 | Communication error flag: M8183 - No.0 (Master); M8184 - No. 1 (Slave 1) ...... |
M8191 | Processing sending data |
Communications format
Item | Parameters | b15(RS2) | b14-b8 | b7 | b6 | b5 | b4 | b3 | b2 | b1 | b0 |
---|---|---|---|---|---|---|---|---|---|---|---|
Bit mode | 8 bit | 0 | Retention | - | - | - | - | - | - | - | - |
16-bit | 1 | - | - | - | - | - | - | - | - | ||
Baud rate (Bps) | 115200 | - | 1 | 1 | 0 | 0 | - | - | - | - | |
57600 | - | 1 | 0 | 1 | 1 | - | - | - | - | ||
38400 | - | 1 | 0 | 1 | 0 | - | - | - | - | ||
19200 | - | 1 | 0 | 0 | 1 | - | - | - | - | ||
9600 | - | 1 | 0 | 0 | 0 | - | - | - | - | ||
4800 | - | 0 | 1 | 1 | 1 | - | - | - | - | ||
Stop bit | 1 bit | - | - | - | - | - | 0 | - | - | - | |
2 bit | - | - | - | - | - | 1 | - | - | - | ||
Parity | None | - | - | - | - | - | - | 0 | 0 | - | |
Odd | - | - | - | - | - | - | 0 | 1 | - | ||
Even | - | - | - | - | - | - | 1 | 1 | - | ||
Data bit | 7 bit | - | - | - | - | - | - | - | - | 0 | |
8 bit | - | - | - | - | - | - | - | - | 1 |
Communication error code (D8211~D8218)
Error code | Description |
---|---|
1 | The monitoring period has elapsed, and the slave station has not responded to requests from the master station yet. |
2 | The other slave stations have responded to requests sent by the master station. |
3 | The count values in the parameter data do not match those responded by the slave stations. |
4 | The response messages from the slave stations are incorrect. |
17 | The monitoring period has elapsed,the master station has not sent a request to the next slave station yet. |
20 | The messages from the master station are incorrect. |
33 | The slave station is unresponsive. |
34 | The other slave stations have responded to requests sent by the master station. |
35 | The count values in the parameter data do not match those responded by the slave stations. |
49 | The slave station received requests from the master station before receiving the parameters. |
Program example
LX3VP COM2 port communication parameters: 9600, 1, 8, NONE. Register block mode: 3
PLC as master
PLC as slave
RS485-BD and ETH-BD communiaction
Please kindly check the link as below.
http://docs.we-con.com.cn/wiki/bdmodule/view/Main/Communication/2RS485-BD-3V/
http://docs.we-con.com.cn/wiki/bdmodule/view/Main/Communication/LX3VP-ETH-BD/