欢迎图片

07 Communication

Last modified by Devin Chen on 2024/08/19 14:28

PLC COM2 Modbus RTU

Protocol Setting (D8126)

ProtocolDescriptionValue of D8126
WECON PLC ProtocolUsing WECON PLC Protocol01H
MODBUS RTU MasterPLC is slave device02H
MODBUS ASCII MasterPLC is slave device03H
User-defined ProtocolUsing User-defined Protocol10H
MODBUS RTU SlavePLC is master device20H
MODBUS ASCII SlavePLC is master device30H

Communication format (D8120)

ItemparameterBit value of D8120
b7b6b5b4b3b2b1b0

 

Baud rate

(Bps)

1152001100----
576001011----
384001010----
192001001----
96001000----
48000111----
Stop bit1 bit----0---
2 bit----1---

 

Parity

None-----00-
Odd-----01-
Even-----11-
Data bit7 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)

✎Note: If use Data bit=7.Parity can not choose None.

WECON PLC - MODBUS (Slave) addresses rules

   PLC Bit Address
PLC AddressMODBUS Address
HexDecimal
M0 ~ M30710 ~ 0xBFF0 ~ 3071
M8000 ~ M82560x1F40 ~ 0x20408000 ~ 8256
S0 ~ S9990xE000 ~ 0xE3E757344 ~ 58343
T0 ~ T2560xF000 ~ 0xF10061440 ~ 61696
C0 ~ C2550xF400 ~ 0xF4FF62464 ~ 62719
X0 ~ X3770xF800 ~ 0xF8FF63488 ~ 63743
Y0 ~ Y3770xFC00 ~ 0xFCFF64512 ~ 64767
 PLC Word Address
PLC AddressMODBUS Address
HexDecimal
D0 ~ D82550 ~ 0x203F0 ~ 8255
T0 ~ T2550xF000 ~ 0xF0FF61440 ~ 61695
C0 ~ C1990xF400 ~ 0xF4C762464 ~ 62663
C200 ~ C2550xF700 ~ 0xF7FF63232 ~ 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.DataNumber of byteInstruction
1Station number of slave1 byteValue range 1~247, set by D8121
20x01(function code)1 byteRead coil
3Start address2 bytes 
4Number of coils2 bytes 
5CRC2 bytes 

Function code 0x03(03): read register (word address)

Frame format: Station number of slave&0x03 + start address+ number of registers + CRC

No.DataNumber of byteInstruction
1Station number of slave1 byteValue range 1~247, set by D8121
20x03 (function code)1 byteRead register
3Start address2 bytes 
4Number of registers2 bytes 
5CRC2 bytes 

Function code 0x05(05): write single coil

Frame format: Station number of slave&0x05 + address + state of coil + CRC

No.DataNumber of byteInstruction
1Station number of slave1 byteValue range 1~247, set by D8121
20x05 (function code)1 byteWrite single coil
3address2 bytes 
4State of coil2 bytes 
5CRC2 bytes 

Function code 0x06 (06): Write single register

Frame format: Station number of slave&0x06 + address + value + CRC

No.DataNumber of byteInstruction
1Station number of slave1 byteValue range 1~247, set by D8121
20x06 (function code)1 byteWrite single register
3address2 bytes 
4Value of register2 bytes 
5CRC2 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.DataNumber of byteInstruction
1Station number of slave1 byteValue range 1~247, set by D8121
20x0f (function code)1 byteWrite contunuous coils
3Start address2 bytes 
4Number of coil2 bytes 
5Length1 bytes 
6State of coils[(N+7)/8] bytes 
7CRC2 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.DataNumber of byteInstruction
1Station number of slave1 byteValue range 1~247, set by D8121
20x10 (function code)1 byteWrite contunuous registers
3Start address2 bytes 
4Number of registers2 bytes 
5Length1 bytes 
6Value of registerN*2 bytes 
7CRC2 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.)

1641781999957-637.png

Read word address from device

1641782024282-424.png

Write single coil

1641782057319-761.png

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

1641782078927-432.png

Write continuous coils

1641782101687-540.png

Write continuous registers

1641782118748-978.png

PLC is slave devic

1641782203514-616.png

WECON PLC Protocol (COM2)

1641782240401-942.png

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

9.Communication example_html_8c43baa1ae891689.jpg

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 NumberMode 0Mode 1Mode 2
Bit (M)Word(D)Bit (M)Word(D)Bit (M)Word(D)
04324648
MasterNO. 0--0-31000-10310-31000-10630-7
SlaveNO. 1--32-351064-109532-351064-112732-39
NO. 2--64-671128-115964-671128-119164-71
NO. 3--96-991192-122396-991192-125596-103
NO. 4--128-1311256-1287128-1311256-1319128-135
NO. 5--160-1631320-1351160-1631320-1383160-167
NO. 6--192-1951384-1415192-1951384-1447192-199
NO. 7--224-2271448-1479224-2271448-1511224-231
Station NumberMode 3Mode 4  
Bit (M)Word(D)Bit (M)Word(D)  
64166432  
MasterNO. 01000-10630-151000-10630-31  
SlaveNO. 11064-112732-471064-112732-63  
NO. 21128-119164-791128-119164-95  
NO. 31192-125596-1111192-125596-127  
NO. 41256-1319128-1431256-1319128-159  
NO. 51320-1383160-1751320-1383160-191  
NO. 61384-1447192-2071384-1447192-223  
NO. 71448-1511224-2391448-1511224-255  

Communication between each PLC (up to 8 PLC), please see the connection construction below (For 3 PLC interconnection).

9.Communication example_html_b805bca9e1166337.jpg

Special devices in N: N network

RegisterDescription
D8120Communication format settings
D8126COM2 communication protocol settings, 40h means N:N Master Device, 04h means N:N Slave device
D8176Station number, from 0 to 7, 0 means master device
D8177Total station number, from 1 to 7, only required for master device.
D8178Register block setting, from 0 to 5, only required for master device.
D8179Retry count settings, only required for master device.
D8180Timeout setting, unit: 10ms,only required for master device.
D8201Current connection scould time
D8202Maximum connection scould time
D8203Master error counter
D8204~D8210Slave error counter
D8211Master N:N error code
D8212~D8218Slave N:N error code
M8183Master data transfer sequence error
M8183~M8190

Communication error flag:

M8183 - No.0 (Master);

M8184 - No. 1 (Slave 1)

......

M8191Processing sending data

Communications format

ItemParametersb15(RS2)b14-b8b7b6b5b4b3b2b1b0
Bit mode8 bit0Retention--------
16-bit1--------
Baud rate (Bps)115200-1100----
57600-1011----
38400-1010----
19200-1001----
9600-1000----
4800-0111----
Stop bit1 bit-----0---
2 bit-----1---
ParityNone------00-
Odd------01-
Even------11-
Data bit7 bit--------0
8 bit--------1

Communication error code (D8211~D8218)

Error codeDescription
1The monitoring period has elapsed, and the slave station has not responded to requests from the master station yet.
2The other slave stations have responded to requests sent by the master station.
3The count values in the parameter data do not match those responded by the slave stations.
4The response messages from the slave stations are incorrect.
17The monitoring period has elapsed,the master station has not sent a request to the next slave station yet.
20The messages from the master station are incorrect.
33The slave station is unresponsive.
34The other slave stations have responded to requests sent by the master station.
35The count values in the parameter data do not match those responded by the slave stations.
49The 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

9.Communication example_html_a3fdef81ab69639.jpg

PLC as slave

9.Communication example_html_cc8af72b56d9c539.jpg

Note: 

  • There are two modes of N:N protocol configuration. one is LX3VP built-in N:N protocol, the other one is LX3V N:N protocol (LX3V-2RS485-BD required).
  • In LX3VP series PLC, only one kind of N:N configuration available. Second mode would be disabled when LX3VP built-in N:N protocol configured.

RS485-BD and ETH-BD communiaction

Please kindly check the link as below.

Note: at present 5V PLC can not support RS485-BD and ETH-BD

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/