1 Communication
Wecon PLC
LX3V Serial Protocol
Supported series: Wecon LX2V/ LX2E/ LX3V/LX3VP/LX3VE/LX3VM
1)V-BOX setting
Item | Settings | Note |
Protocol | WECON LX2V/ LX2E/ LX3V/LX3VP/LX3VE/LX3VM | |
Connection | RS422/RS485 | |
Baud rate | 9600 | |
Data bit | 7 | |
Parity | EVEN | |
Stop bit | 1 | |
PLC station No. | 1 |
2)Address List
类型 | 设备寄存器 | 人机界面寄存器 | 格式 | 范围 | 注意 |
位 | X | X | 断续器 | 0~303237 | |
Y | Y | Y o | 0~303237 | ||
M | M | M d | 0~99999 | ||
T | T | S C | 0~99999 | ||
C | C | 断续器 | 0~99999 | ||
S | S | 断续器 | 0~99999 | ||
词 | X | X | 断续器 | 0~303237 | |
Y | Y | Y o | 0~303237 | ||
M | M | M d | 0~99999 | ||
T | T | S C | 0~99999 | ||
C | C | 断续器 | 0~199 | ||
D | D | C C | 0~7999 | ||
S | S | 断续器 | 0~99999 | ||
标清 | 标清 | 标清 d | 8000~9999 |
3)Configure the communication protocol
4)Cable Wiring
- RS422
- RS485
LX5V Serial Protocol
This example introduces the establishment of serial port communication between V-BOX and LX5V. It is introduced through three parts: PLC software configuration, V-BOX software configuration, and hardware wiring.
Software configuration of PLC
1)PLC programming software
2)New PLC project
Click New Project and select the PLC model.
3)Set Serial port parameters
Follow the steps below to configure Serial port parameters
Baud rate:115200
Data bit:8
Stop bit:1
Parity:No verification
4)Registers list
V-BOX software configuration
1)V-BOX programming software
2)V-NET add device
Open V-NET client software → add device. As shown in the figure below, click "+" in the order of steps, and the Add Device window will pop up, enter the access key, password and remark, to add the device.
3)Set communication port parameters
Click the communication configuration button on the left to find the communication protocol with LX5V. After selecting the protocol, configure the communication parameters of the COM port.
Baud rate:115200
Data bit:8
Stop bit:1
Parity:No verification
hardware connection
1)Hardware wiring diagram
The above are all the steps for establishing serial port communication between V-BOX with LX5V PLC.
LX5V-N Ethernet protocol
This example introduces the establishment of Ethernet communication between V-BOX and LX5V-N. It is introduced through three parts: PLC software configuration, V-BOX software configuration, and hardware wiring.
Software configuration of PLC
1)PLC programming software
2)New PLC project
Click New Project and select the PLC model.
3)Set Ethernet port parameters
Follow the steps below to configure Ethernet parameters
PLC IP address:192.168.39.200
default gateway:192.168.39.1
subnet mask:255.255.255.0
4)Registers list
V-BOX software configuration
1)V-BOX programming software
2)V-NET add device
Open V-NET client software → add device. As shown in the figure below, click "+" in the order of steps, and the Add Device window will pop up, enter the access key, password and remark, to add the device.
3)Set communication Protocol
Click Communication to configure the LX5V plc protocol and IP address.
hardware connection
1)Hardware wiring diagram
The above are all the steps for establishing ethernet communication between V-BOX with LX5V PLC.
Rockwell PLC
MicroLogix Protocol
MicroLogix 1000/1100/1200/1400/1500; SLC 5/03 5/04 5/05 PLC-5
1)PLC Settings
Item | Settings | Note |
Protocol | Allen-Bradlley DF1 Advanced | |
Connection | RS232 | |
Baud rate | 19200 | |
Data bit | 8 | |
Parity | None | |
Stop bit | 1 | |
PLC station No. | 1 |
2)Address List
Type | Device registers | Format | Range | Note |
Bit | I | I d.d | 0.0~255.15 | |
O | O d.d | 0.0~255.15 | ||
B | B nnhh.dd | 0.0~ffff.15 | nn: block number (hex) | |
S | S d.d | 0.0~255.15 | ||
N | N nnhh.dd | 0.0~ffff.15 | nn: block number (hex) | |
Word | S | S d | 0~255 | |
TS | TS nnhh | 0~ffff | nn: block number (hex) | |
TP | TP nnhh | 0~ffff | ||
CS | CS nnhh | 0~ffff | ||
CP | CP nnhh | 0~ffff | ||
N | N nnhh | 0~ffff | ||
C | C nnhh | 0~ffff | ||
T | T nnhh | 0~ffff | ||
R | R nnhh | 0~ffff |
3)Configure the communication protocol
4)Configure the communication protocol
Micro850_FreeTag
This example introduces the establishment of Ethernet communication between Wecon V-box and CompactLogix L1769. It is introduced through three parts: PLC software configuration, V-box software configuration, and hardware wiring.
Software configuration of PLC
1)PLC programming software
2)New PLC project
Click New Project and select the PLC model.
3)Set Ethernet parameters
Follow the steps below to configure Ethernet parameters
PLC IP address:192.168.40.101
default gateway:192.168.40.1
subnet mask:255.255.255.0
V-box software configuration
1)V-box programming software
2)Configure device network
Click the Configuration Download button, It is used to configure the device network, update the device time, obtain the device machine code, check the device network, etc.
In the example below, the IP address of V-Box is configured as 192.168.40.66, and the networking method is 4G connection
3)V-net add device
Open VNET client software → add device. As shown in the figure below, click "+" in the order of steps, and the Add Device window will pop up, enter the device machine code/product code, device password, and device alias to add the device.
4)Set communication port parameters
In the device list on the left, find the Vbox that communicates with the L1769, click it and select configuration,communication port configuration in the main interface to add a communication protocol.
The communication port is selected as Ethernet, the device type is selected as Allen-Bradley, the protocol is Allen-BradleyMicro850_FreeTag EthemetIP, and the IP is the internal IP address of the L1769 PLC. The port number is 44818.
After adding the protocol Allen-BradleyMicro850_FreeTag, clickicon add label.
5)Engineering production
According to your own needs, use the V-NET client software to edit the required data monitoring points.
hardware connection
1)Hardware wiring diagram
This example introduces Wecon V-box with Allen-Bradley L1769 PLC to establish communication through Ethernet. The connection diagram is as follows:
The above are all the steps for establishing Ethernet communication between Wecon V-box with CompactLogix L1769 PLC.
Allen-Bradley Ethernet DF1
Siemens PLC
S7-200 Smart Ethernet Protocol
S7-300 Ethernet Protocol
Supported Series: Siemens S7-300 series PLC
1)PLC Setting
Items | Settings | Note |
Protocol | Simens S7-300 Ethernet | |
Connection | Ethernet | |
Port No. | 102 | |
PLC station No. | 2 | Need to be same as the PLC setting |
2)Address List
Type | Device register | HMI register | Format | Range | Note |
Bit | I | I | I ddddd.o | 0.0~99999.7 | |
Q | Q | Q ddddd.o | 0.0~99999.7 | ||
M | M | M ddddd.o | 0.0~99999.7 | ||
DB0.DB~DB99.DB | DBxDBD | DBxDB nndddd.o | 0.0~99999999.7 | nn: block number; dddd: address; | |
Word | I | IW | IW ddddd | 0~99999 | |
Q | QW | QW ddddd | 0~99999 | ||
M | MB | MB ddddd | 0~99999 | ||
MW | MW ddddd | 0~99999 | MW0=MB(0~1) MW2=MB(2~3) Address value is a multiple of 2 | ||
MD | MD ddddd | 0~99999 | MD0=MB(0~3) MD4=MB(4~7) Address value is a multiple of 4 | ||
DB0.DB~DB99.DB | DBxDBB | DBxDBB nndddd | 0~99999999 | nn: block number; dddd: address | |
DBxDBW | DBxDBW nndddd | 0~99999999 | |||
DBxDBD | DBxDBD nndddd | 0~99999999 |
3)Configure the communication protocol
4)Cable Wiring
S7-1200 Ethernet Protocol
S7-XXX Ethernet Protocol
Supported Series: Siemens S7-400, S7-1200 and S7-1500
1)PLC Setting
Items | Settings | Note |
---|---|---|
Protocol | Siemens S7-XXX | |
Connection | Ethernet | |
Port No. | 102 | |
Device No. | Slot (Default 1 for S7-1500/ 2 for S7-1200/ 3 for S7-400) | |
HMI No. | Rack (Default as 0) |
Slot from TIA Portal is equal to Device No. of V-net
Rack from TIA Portal is equal to HMI No. of V-net
2)Address List
Type | Device register | HMI register | Format | Range | Note |
Bit | I | I | M d.o | d:0--9999 o:0-7 | |
Q | Q | Q d.o | d:0--9999 o:0-7 | ||
M | M | M d.o | d:0--9999 o:0-7 | ||
DB0.DB-DB99.DB | DBxDB | DBxDBnndddd.o | nn:0-9999, dddd:0-9999, o:0-7 | nn:DB No. dddd:address value o: digit address | |
Word | M | MB | MB d | d:0-99999 | |
M | MW | MW d | d:0-99999 | MW0=MB(0~1) MW2=MB(2~3) Address value is a multiple of 2 | |
M | MD | MD d | d:0-99999 | MD0=MB(0~3) MD4=MB(4~7) Address value is a multiple of 4 | |
I | IW | IW d | d:0-99999 | ||
Q | QW | QW d | d:0-99999 | ||
DB0.DB-DB99.DB | DBxDBB | DBxDBBnndddd | nn:0-9999 dddd:0-9999 | nn:DB No. dddd:address value | |
DB0.DB-DB99.DB | DBxDBW | DBxDBWnndddd | nn:0-9999 dddd:0-9999 | nn:DB No. dddd:address value Address value is a multiple of 2 | |
DB0.DB-DB99.DB | DBxDBD | DBxDBDnndddd | nn:0-9999 dddd:0-9999 | nn:DB No. dddd:address value Address value is a multiple of 4 |
3)Configure the communication protocol
✎Note:
- The S7-1200 supports simultaneous connection of three devices, so the driver supports simultaneous access to PLC by three V-BOX.
- V-BOX access PLC, use S7 protocol, access PLC TSAP 02.01 (s7-1200 PROFINET interface only supports three connections, the default support), detailed reference to the system manual of S7-1200.
4)Cable Wiring
Mitsubishi PLC
FX1S,1N,2N Serial Protocol
Supported Series: Mitsubishi FX1S, FX1N, FX2N series
1)V-BOX Settings
Item | Settings | Note |
Protocol | Mitsubishi FX1S/FX1N/FX2N | |
Connection | RS422/RS485/RS232 | |
Baud rate | 9600~115200 | |
Data bit | 7/8 | |
Parity | EVEN/Odd/None | |
Stop bit | 1/2 | |
PLC station No. | 1~255 |
2)Address List
Type | Device registers | HMI registers | Format | Range | Note |
Bit | X | X | Xo | 0~303237 | |
Y | Y | Y o | 0~303237 | ||
M | M | M d | 0~99999 | ||
T | T | T d | 0~99999 | ||
C | C | C d | 0~99999 | ||
S | S | S d | 0~99999 | ||
SM | SM | SM d | 8000~9999 | ||
Word | X | X | Xo | 0~303237 | |
Y | Y | Y o | 0~303237 | ||
M | M | M d | 0~99999 | ||
T | T | T d | 0~99999 | ||
C | C | C d | 0~199 | ||
D | D | D d | 0~7999 | ||
S | S | S d | 0~99999 | ||
SD | SD | SD d | 8000~9999 |
3)Configure the communication protocol
4)Cable Wiring
- RS422
FX3U,3G,3GA Serial Protocol
Supported Series: Mitsubishi FX3U, FX3G, FX3GA series
1)V-BOX Settings
Item | Settings | Note |
Protocol | Mitsubishi FX3U/3G/3GA | |
Connection | RS422/RS485/RS232 | |
Baud rate | 9600~115200 | |
Data bit | 7/8 | |
Parity | EVEN/Odd/None | |
Stop bit | 1/2 | |
PLC station No. | 1~255 |
2)Address List
Type | Device registers | HMI registers | Format | Range | Note |
Bit | X | X | Xo | 0~303237 | |
Y | Y | Y o | 0~303237 | ||
M | M | M d | 0~99999 | ||
T | T | T d | 0~99999 | ||
C | C | C d | 0~99999 | ||
S | S | S d | 0~99999 | ||
SM | SM | SM d | 8000~9999 | ||
Word | X | X | Xo | 0~303237 | |
Y | Y | Y o | 0~303237 | ||
M | M | M d | 0~99999 | ||
T | T | T d | 0~99999 | ||
C | C | C d | 0~199 | ||
D | D | D d | 0~7999 | ||
S | S | S d | 0~99999 | ||
SD | SD | SD d | 8000~9999 |
3)Configure the communication protocol
4)Cable Wiring
- RS422
FX5U Serial Protocol
Mitsubishi FX5U series PLC
1)V-BOX Settings
Item | Settings | Note |
Protocol | Mitsubishi FX5U | |
Connection | RS422/RS485 | |
Baud rate | 9600 | |
Data bit | 7 | |
Parity | Odd | |
Stop bit | 1 | |
PLC station No. | 1~255 | Need to be the same as PLC settings |
2)Address List
Type | Device registers | HMI registers | Format | Range | Note |
Bit | X | X | X o | 0~303237 | |
Y | Y | Y o | 0~303237 | ||
M | M | M d | 0~99999 | ||
B | B | B h | 0~7FFF | ||
F | F | F d | 0~32767 | ||
SB | SB | SB h | 0~7FFF | ||
TS | TS | TS d | 0~1023 | ||
TC | TC | TC d | 0~1023 | ||
STS | STS | STS d | 0~1023 | ||
STC | STC | STS d | 0~1023 | ||
CS | CS | CS d | 0~1023 | ||
CC | CC | CC d | 0~1023 | ||
SM | SM | SM d | 0~9999 | ||
L | L | L d | 0~32767 | ||
S | S | S d | 0~4095 | ||
Word | W | W | W h | 0~3FF | |
TN | TN | TN d | 0~1023 | ||
STN | STN | STN d | 0~1023 | ||
CN | CN | CN d | 0~1023 | ||
R | R | R d | 0~32767 | ||
SW | SW | SW h | 0~7FFF | ||
Z | Z | Z d | 0~23 | ||
D | D | D d | 0~7999 | ||
SD | SD | SD d | 0~11999 |
3)PLC Settings (GX Works 3)
Create a blank FX5U project
Find the 485 serial port module in the system navigation bar and double click to enter the settings.
Select protocol in the setting item, and set parameters.
Set station number, and [Message Pattern] (Pattern 1 or Pattern 4)
Click the [Apply] button to finish the setting.
Click download and select the items as below, then click [execute] to download the configuration to PLC.
As soon as download is completed, connect PLC with serial port, then configure it in the [Specify Connection Destination Connection].
Done.
4)Configure the communication protocol
5)Cable Wiring
- RS422
FX5U Ethernet Protocol
Mitsubishi FX5U series PLC
1)V-BOX Settings
Items | Settings | Note |
Protocol | Mitsubishi FX5U | |
Connection | Ethernet | |
Port No. | 5002 | Must be the same as the PLC setting |
PLC station No. | 0 |
2)Address List
Type | Device registers | HMI registers | Format | Range | Note |
Bit | X | X | X o | 0~303237 | |
Y | Y | Y o | 0~303237 | ||
M | M | M d | 0~99999 | ||
B | B | B h | 0~7FFF | ||
F | F | F d | 0~32767 | ||
SB | SB | SB h | 0~7FFF | ||
TS | TS | TS d | 0~1023 | ||
TC | TC | TC d | 0~1023 | ||
STS | STS | STS d | 0~1023 | ||
STC | STC | STS d | 0~1023 | ||
CS | CS | CS d | 0~1023 | ||
CC | CC | CC d | 0~1023 | ||
SM | SM | SM d | 0~9999 | ||
L | L | L d | 0~32767 | ||
S | S | S d | 0~4095 | ||
Word | W | W | W h | 0~3FF | |
TN | TN | TN d | 0~1023 | ||
STN | STN | STN d | 0~1023 | ||
CN | CN | CN d | 0~1023 | ||
R | R | R d | 0~32767 | ||
SW | SW | SW h | 0~7FFF | ||
Z | Z | Z d | 0~23 | ||
D | D | D d | 0~7999 | ||
SD | SD | SD d | 0~11999 |
3)PLC Settings (GX Works 3)
Find the [Ethernet port] in the navigation area.
Select [Own Node Settings] in the [Setting Item List];
Set [IP Address], [Subnet Mask], [Default Gateway];
Click [Detailed Settings] into [Ethernet Configuration (Built-in Ethernet Port)] windows;
Select [SLMP Connection Module] and add into host station as below picture shows;
Set Port number as 5002 (this is necessary settings);
Click [Close with Reflecting the Setting] to save and close window;
Click [Apply] to completed Etherenet settings;
Switch to the [On line data operation] interface as below, check the item and click [Execute] to download.
4)Configure the communication protocol
5)电缆布线
L02 Serial Protocol
Mitsubishi L02 series CPU built-in Ethernet port.
V-BOX Settings
Items | Settings | Note |
Protocol | MIT L02 CPU MELSEC | |
Connection | Ethernet | |
Port No. | 1025 | Must be the same as the PLC setting |
PLC station No. | 0 | Must be the same as the PLC setting |
Address List
Type | Device registers | HMI registers | Format | Range | Note |
Bit | X | X | X h | 0~FFFF | |
Bit | Y | Y | Y h | 0~FFFF | |
Bit | M | M | M d | 0~9999 | |
Bit | L | L | L d | 0~9999 | |
Bit | F | F | F d | 0~9999 | |
Bit | B | B | B h | 0~FFFF | |
Bit | V | V | V d | 0~2047 | |
Bit | TC | TC | TC d | 0~9999 | |
Bit | SS | SS | SS d | 0~9999 | |
Bit | SC | SC | SC d | 0~9999 | |
Bit | CS | CS | CS d | 0~9999 | |
Bit | CC | CC | CC d | 0~9999 | |
Bit | SB | SB | SB h | 0~FFFF | |
Bit | SM | SM | SM d | 0~2047 | |
Bit | STS | STS | STS d | 0~1023 | |
Bit | S | S | S d | 0~9999 | |
Bit | DX | DX | DX h | 0~FFFF | |
Bit | DY | DY | DY h | 0~FFFF | |
Bit | TS | TS | TS d | 0~9999 | |
Bit | Dbit | Dbit | Dbit d.d | 0~99999.0~15 | |
Word | W | W | W h | 0~FFFF | |
Word | TN | TN | TN d | 0~99999 | |
Word | SN | SN | SN d | 0~99999 | |
Word | CN | CN | CN d | 0~99999 | |
Word | R | R | R d | 0~99999 | |
Word | SW | SW | SW h | 0~FFFF | |
Word | Z | Z | Z d | 0~99999 | |
Word | ZR | ZR | ZR h | 0~FFFF | |
Word | D | D | D d | 0~99999 |
Communication Settings
Cable Wiring
L02 Ethernet Protocol
Mitsubishi L series CPU built-in Ethernet port.
1)V-BOX Settings
Items | Settings | Note |
Protocol | MIT L02 CPU MELSEC | |
Connection | Ethernet | |
Port No. | 1025 | Must be the same as the PLC setting |
PLC station No. | 0 | Must be the same as the PLC setting |
2)Address List
Type | Device registers | HMI registers | Format | Range | Note |
Bit | X | X | X h | 0~FFFF | |
Bit | Y | Y | Y h | 0~FFFF | |
Bit | M | M | M d | 0~9999 | |
Bit | L | L | L d | 0~9999 | |
Bit | F | F | F d | 0~9999 | |
Bit | B | B | B h | 0~FFFF | |
Bit | V | V | V d | 0~2047 | |
Bit | TC | TC | TC d | 0~9999 | |
Bit | SS | SS | SS d | 0~9999 | |
Bit | SC | SC | SC d | 0~9999 | |
Bit | CS | CS | CS d | 0~9999 | |
Bit | CC | CC | CC d | 0~9999 | |
Bit | SB | SB | SB h | 0~FFFF | |
Bit | SM | SM | SM d | 0~2047 | |
Bit | STS | STS | STS d | 0~1023 | |
Bit | S | S | S d | 0~9999 | |
Bit | DX | DX | DX h | 0~FFFF | |
Bit | DY | DY | DY h | 0~FFFF | |
Bit | TS | TS | TS d | 0~9999 | |
Bit | Dbit | Dbit | Dbit d.d | 0~99999.0~15 | |
Word | W | W | W h | 0~FFFF | |
Word | TN | TN | TN d | 0~99999 | |
Word | SN | SN | SN d | 0~99999 | |
Word | CN | CN | CN d | 0~99999 | |
Word | R | R | R d | 0~99999 | |
Word | SW | SW | SW h | 0~FFFF | |
Word | Z | Z | Z d | 0~99999 | |
Word | ZR | ZR | ZR h | 0~FFFF | |
Word | D | D | D d | 0~99999 |
3)PLC Settings (GX Works2 )
Create a project
Set PLC IP, subnet mask and gateway;
Select [Binary Code] as communication data code;
Set PLC port number, for example 1025
Save settings;
Download project into PLC device;
Restart PLC device;
4)Configure the communication protocol
5)Cable Wiring
QJ71E71 Ethernet Protocol
Mitsubishi QJ71E71 Ethernet communication module;
1)V-BOX Settings
Items | Settings | Note |
Protocol | MIT QJ71E71 MELSEC | |
Connection | Ethernet | |
Port No. | 1025 | Must be the same as the PLC setting |
PLC station No. | 0 | Must be the same as the PLC setting |
2)Address List
Type | Device registers | HMI registers | Format | Range | Note |
Bit | X | X | X h | 0~1FFF | |
Y | Y | Y h | 0~1FFF | ||
M | M | M d | 0~99999 | ||
L | L | L d | 0~8191 | ||
F | F | F d | 0~2047 | ||
B | B | B h | 0~1FFF | ||
V | V | V d | 0~2047 | ||
TS | TS | TS d | 0~2047 | ||
TC | TC | TC d | 0~2047 | ||
SS | SS | SS d | 0~2047 | ||
SC | SC | SC d | 0~2047 | ||
CS | CS | CS d | 0~1023 | ||
CC | CC | CC d | 0~1023 | ||
SB | SB | SB h | 0~7FF | ||
S | S | S d | 0~8191 | ||
DX | DX | DX h | 0~1FFF | ||
DY | DY | DY h | 0~1FFF | ||
SM | SM | SM d | 8000~9999 | ||
Word | SD | SD | SD d | 0~2047 | |
D | D | D d | 0~12287 | ||
W | W | W h | 0~1FFF | ||
TN | TN | TN d | 0~2047 | ||
SN | SN | SN d | 0~2047 | ||
CN | CN | CN d | 0~1023 | ||
R | R | R d | 0~32767 | ||
SW | SW | SW h | 0~7FF | ||
Z | Z | Z d | 0~15 | ||
ZR | ZR | ZR h | 0~FE7FF |
3)PLC Settings(GX Works2)
- Click [Ethernet/CC IE/MELSECNET];
- Please select [Ethernet] as network type;
- Set station I/O number according to situation (For example, 0000 means that the module is connected to PLC CPU in first order);
- Select [Online] as Mode;
- Click [Operation setting] to set IP;
- Select [Binary Code] as [Communication Data Code];
- Set protocol: TCP;
- Set [unpassive] in [Open system];
- Set [receive] in [Fixed buffer];
- Set [procedure Exist] in [Fixed buffer communication];
- Disable [Pairing open];
- Set [No confirm] in [Existence confirmation];
- Host station port number: 1025;
- Save settings;
- Download project into PLC and restart it
4)Configure the communication protocol
5)Cable Wiring
台达 PLC
DVP 以太网协议
DVP 串行协议
欧姆龙可编程逻辑控制器
CP1 系列协议
CJ2M 系列协议
Modbus RTU
V-BOX 作为主
选择协议“Modbus RTU Slave(All Fuction)”,
然后设置波特率,端口,停止位,数据位,奇偶校验
V-BOX 作为从站
选择协议“Modbus RTU Master”,
然后设置波特率,端口,停止位,数据位,奇偶校验
地址列表
类型 | 注册 | 函数代码和描述 |
词 | 3 | 04(读取输入寄存器:读取一个或多个输入寄存器中的当前二进制值) |
06 (write single register: write a binary value to a holding register) | ||
10 (write values to multiple addresses ) | ||
4 | 03 (read holding register: read current binary value in one or more holding registers) | |
06 (write single register: write a binary value to a holding register) | ||
10 (write values to multiple addresses ) | ||
W6 | 03 (read holding register: read current binary value in one or more holding registers) | |
06 (write single register: write a binary value to a holding register) | ||
10 (write values to multiple addresses ) | ||
W16 | 03 (read holding register: read current binary value in one or more holding registers) | |
10 (write values to multiple addresses ) | ||
Bit | 0 | 01 (Read coil state) |
05 (Force a single coil to force the on/off state of a logic coil) | ||
0F (Write multiple bits, ie write continuously) | ||
1 | 02 (Read the input state) | |
05 (Force a single coil to force the on/off state of a logic coil) | ||
0F (Write multiple bits) | ||
W5 | 01 (Read coil state to obtain the current state of a set of logic coils) | |
05 (Force a single coil to force the on/off state of a logic coil) | ||
0F (Write multiple bits) | ||
W15 | 01 (Read coil state to obtain the current state of a set of logic coils) | |
0F (Write multiple bits) |
communicate with VB inverter
User define protocol
More serial port script instruction,please refer manual:Lua script function--->3.Serial port operation
Read the temperature sensor.
the commond format is as beliow:
Send commond:01 03 02 00 00 03 04 73
Feedback commond:01 03 06 07 F7 0E 7E B7 35
Temperature data:07 F7,desimal = 2039,it means temperature is 20.39℃.
Humidity data:0E 7E,desimal = 3710, it mean humidity is 37.10%RH.
Script Demo:
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
function com.main()
--dosomething
openPlc()
end
function openPlc()
if obj then
-- If the serial port opened,then read/write data by timing
local wri = string.pack(">HHHH",0X0103,0X0200,0X0003,0X0473)
local arr = reading(wri)
-- if arr ~=nil then
-- if arr[1] ==33 and arr[2] ==v[2][2] and arr[3] ==v[2][3] then
-- local A = arr[4]*256
-- local B = A+arr[5]
-- addr_setword(v[1],B)
-- end
-- end
else
--judge if there is a serial object, then initialize and open the serial port
local configs = {
name = 'COM1', --Select serial port COM1
mode = 485, --Communication mode RS485
baud_rate = 9600, --Baud rate 9600
stop_bit = 1, --stop bit 1
data_len = 8, --data length 8
check_bit = 'NONE', --no parity
}
obj,err = serial.open(configs) --Open serial port
if not obj then
print("serial open :failed", err) -- Open serial port failed
end
end
end
function reading(wri)
obj:flush() -- Clear serial port
obj:write(wri) -- Write serial port
print(string.byte(wri,1,#wri))
obj:flush() -- Clear serial port
local readed =obj:read(9,1000) -- Read 9 bytes, timeout 1 second
if readed and readed ~= "" then
-- judge that a non-empty string is read
print(string.byte(readed,1,#readed))
a={string.byte(readed, 1, #readed)}
if nil ~= a[4] and nil ~= a[5] and nil ~= a[6] and nil ~= a[7] then
a1=a[4]*256+a[5]
a2=a[6]*256+a[7]
addr_setword("@HDW0",a1)
addr_setword("@HDW1",a2)
end
return {string.byte(readed, 1, #readed)}
elseif readed == nil then
print("serial read err:", err or "")
return nil
end
return nil
end
--------------------------------------------------------------------------------------------------------------------------------------------------------------------