Modbus POE ETH Relay (B)
| ||
Overview
- This product is an industrial 8-ch relay module controlled via Ethernet port, with 8-ch digital input, adopts Modbus RTU/Modbus TCP protocols, supports PoE power supply, also comes with an ABS rail-mount case. The Modbus POE ETH Relay (B) is very easy to use. Due to its fast communication, stability, reliability, and safety, it is an ideal choice for industrial control equipments or applications with high communication requirements.
Electrical Safety Precautions
- This product must be operated and used by professional electricians or technical personnel. During use, please ensure electrical safety and take measures to prevent leakage and insulation.
- Before installing, maintaining, or replacing relay equipment, be sure to turn off the power and unplug the plug.
- Do not attempt to disassemble relay equipment to avoid damaging the equipment or causing the risk of electric shock.
- Please install and place the relay equipment product properly. Do not use it in damp, overheated, or flammable environments to avoid safety incidents caused by improper installation or use.
Parameters
Power Supply | PoE Ethernet Port, DC 5.5*2.1 Power Port Or Power Supply Screw Terminal (7~36V) |
---|---|
Communication Interface | PoE Ethernet Port, Support IEEE 802.3af Standard |
Relay Channels | 8 Channels |
Touch Contact | 1NO, 1NC |
Touch Contact Load | ≤10A 250V AC Or ≤10A 30V DC |
Digital Input | 8DI, 5~36V, Passive Input/Active Input (NPN or PNP) Built-in Bidirectional Optocoupler |
Modbus Protocol | Modbus RTU Protocol Or Modbus TCP Protocol |
Indicator Description
Indicator | Description |
---|---|
RUN | The network port operation indicator, when the network port is working normally, will output a square wave with a period of 2 seconds |
STA | MCU indicator, blinks when MCU is working normally |
TXD | Transmitting indicator, light on when transmitting data |
RXD | Receiving indicator, light on when receiving data |
Network port green indicator | Green indicator is on when TCP connection is established, used to determine if the module has established a communication link with the host computer software |
Network port yellow indicator | Data transmission light, when there is data transmission on the network port, the yellow light transition state will change, which can be used to determine whether there is data transmission |
Primary Functions
Supports reading digital input by sending Modbus RTU protocol commands, and can control relay output based on input.
Wiring Description
Connect the Modbus POE ETH Relay (B) to the LAN via a network cable and power it via the 7~36V power port or power it via POE.
- DI1-DI8 is the 8-channel signal input terminal, and DGND is the ground signal. COM is the common terminal for the input signal, it can be NC(Not Connected), connected to the positive or negative of the power supply, directly powered from the power supply or connected to an independent power supply.
- NC: dry contact passive input.
- Connect to the power supply positive: low active, NPN wet contact active input, voltage: 5V-30V DC.
- Connect to the power supply negative: high active, PNP wet contact active input.
Digital Input Wiring
Passive Dry Contact Wiring
- Passive dry contact input
Active Wet Contact Wiring
- Active wet contact NPN input
- Active wet contact PNP input
Operating Modes
The relay supports multiple control modes, and each channel supports independent setting of control modes:
Software Installation
Vircom can be used for configuring device IP and other parameters, as well as creating virtual serial ports. If the virtual serial port functionality is not needed, you can simply download the installation-free version of the configuration software.
- VirCom: Configuration Software
- Virtual serial port: Serial port driver
- Sscom5.13.1_for_Modbus_POE_ETH_Relay: Sscom software
- Modbus Poll: Modbus Poll software
Driver installation requires decompression, double-click the software to install, if the virtual serial port in Vircom is not displayed, then reboot and check again.
Example
TCP Communication Test
Software Preparation
Host Computer Setting
After connecting to the Modbus POE ETH Relay, connect it to the network. Run the Vircom software, (The computer on which Vircom is installed must be on the same LAN as the module).
The operation is shown below:
- ① Click
Device
- ② Click
Auto Search
- ③ Software search recognizes Modbus POE ETH Relay devices connected to the LAN.
- ④ Select the device, and then click
Edit Device
or directly double click the searched device. - ⑤ Set up the device parameters.
- Click the "Local IP" button to identify the computer's IP address, change the "IP Address" to a static address, and note that the static IP address entered is not used by other devices and needs to be on the same LAN as the computer.
- The operating mode is TCP server. The serial port setting defaults to 115200 and cannot be modified.
- The "Convert Protocol" in the
Advanced settings
, the default setting is "None", that is, you select modbus rtu protocol. If you use Modbus_TCP protocol, you can select "modbus tcp protocol".
- Click the "Local IP" button to identify the computer's IP address, change the "IP Address" to a static address, and note that the static IP address entered is not used by other devices and needs to be on the same LAN as the computer.
- ⑥ After setting, click
Modify Setting
. - ⑦ Click
Restart Dev
. After restarting the module, the new setting takes effect.
- The last step is to click "Modify Settings" to save the settings and take effect.
TCP Communication Test
- Open the serial debugging assistant window, select TCPClient for the port number, modify the remote IP and port number according to the above Vircom settings, click the "Connect" button to connect to the TCP server, the green light of the network port will light up after successful connection.
- Click Multi-Char to open the Send Multi-Char window, and click the function to send the corresponding command.
- Please refer to the development agreement for detailed Development Protocol.
Modbus Poll Software
- If the serial port software is inconvenient for observing data, you can choose the Modbus Poll software to read data. Download and install the Modbus Poll software.
- Open the software, select setup->Read/Write Definition, choose the actual device address for Slave ID, select Function Code 01 Read Coils, and change Quantity to 8 channels. Click OK to confirm.
- Select Connection->Connect..., choose Modbus RTU/ASCII Over TCP/IP for Connection, select RTU for Mode, and enter the correct IP address and port number. Click OK to connect.
- After a normal connection is established, you can view the current relay status. Select the corresponding channel, and double-click the status value to bring up the send page. Choose ON or OFF, and then send to control the corresponding relay to open or close.
- Select File->New to create a new window, then choose Setup -> Read/Write Definition. Set the Slave ID to the actual device address, choose function code 02, set the Address to 0, and set the Quantity to 8 channels. Change the Scan Rate to 100ms. Click OK to confirm.
- The newly created Window 2 can display the current input status. When the input interface level is changed, the corresponding value will also change.
Virtual Serial Port Testing
The SSCOM2 in the diagram communicates directly with the TCP and serial port server. In order to allow users to communicate with the serial port server using their existing serial port software, a virtual serial port needs to be added between the user program and the serial port server. As shown in the diagram, Vircom and the user program run on the same computer. Vircom virtualizes a COM port that corresponds to the serial port server. When the user program opens the COM communication, it can send data to the user's serial port device through the Vircom serial port server. The following steps demonstrate this operation:
- Click on "Serial Port Management" on the Vircom main interface.
- Click on "Add" and select to add COM2. Note that COM2 is a COM port that does not exist on the computer originally.
- After that, go to the device management and double-click on the device that needs to be bound to COM2. As shown in the diagram, select COM2 from the "Virtual Serial Port" list in the top left corner. Then click on "Modify Settings" and then click on "Restart Device".
- Return to the main Vircom interface. You can see that COM2 is already connected to the device with IP 192.168.1.200. At this point, you can use COM2 to communicate instead of SSCOM2.
- Open it on your computer, open the corresponding port number, set the baud rate to 115200, click Multi-String to open the Multi-String Send window, and click the corresponding function to send the corresponding command.
MODBUS TCP Test
By default, data is transparently transmitted using the Modbus RTU protocol. If you need to implement Modbus TCP to RTU conversion, you need to select the conversion protocol as "Modbus TCP Protocol" in the device settings dialog, as shown in the diagram below. In this case, the device port automatically changes to 502. Users can connect their Modbus TCP tool to the IP of the serial port server on port 502, and the Modbus TCP commands they send will be converted to RTU commands and outputted through the serial port.
For example, if the server's Ethernet port receives a Modbus TCP command of 00 00 00 00 00 06 01 05 00 00 FF 00 (to turn on the first relay), the host controller will receive the Modbus RTU command of 01 05 00 00 FF 00 8C 3A.
- Click on "More advanced options..." Select the Modbus gateway type as a non-storage Modbus gateway.
Multi-host non-storage type
.- Open the Sscom software, click on the Import ini button in the Send Multi-Char column, and select the Modbus tcp.ini file to import.
If the error "A component named HEX0 already exists" is displayed,then close the software and reopen it, and re-import the file.
- After successful import, the following is displayed, click on the corresponding function to send the corresponding command.
Note: Modbus TCP does not require CRC check, select None for the check.
- Please refer to the Modbus TCP protocol section later for more details on Modbus TCP conversion.
WEB Configuration
Using Vircom, you can search and configure device parameters in different network segments. For Web configuration, you must first ensure that the computer and the serial server are in the same IP segment, and you need to know the IP address of the serial server in advance. But web configuration can be done on any computer without Vircom.
1. Enter the IP address of the serial server in the browser, such as http://192.168.1.200
2. Enter password in "Password": There is no login password set by default in the factory, you can enter a password at will, and click the Login button to log in. After setting the password to log in, the settings at "Modify webpage login password" will take effect:
3. The serial server parameters can be modified on the web page that appears. For the relevant parameters, please refer to Table 4 for the meaning of the parameters.
4. After modifying the parameters, click the "Submit" button.
5. If the configuration web page files are overwritten during the configuration and downloading of MQTT and Jetson Modbus firmware, causing the configuration web page to be inaccessible, please follow these steps to re-download the web page files:
- Configuration Interface Web Files to Modbus POE ETH Relay:
Demo Example
Raspberry Pi
Connect the Raspberry Pi and the Modbus POE ETH Relay (B) module to the same LAN.
Open the Raspberry Pi terminal and run the program by entering the following command.
After the demo runs normally, each channel opens and closes in turn, and finally the current input status is displayed.
sudo apt-get install unzip wget https://files.waveshare.com/upload/d/d5/Modbus_POE_ETH_Relay_B_Code.zip unzip Modbus_POE_ETH_Relay_B_Code.zip cd Modbus_POE_ETH_Relay_B_Code #modbus rtu protocol vi modbus_rtu.py #Change the IP address and port number according to the actual situation sudo python3 modbus_rtu.py #modbus tcp protocol vi modbus_tcp.py #Change the IP address and port number according to the actual situation sudo python3 modbus_tcp.py
Modbus RTU Development Protocol V2
Function Code Introduction
Function Code | Description | |
---|---|---|
01 | Read coil status | Read relay status |
02 | Read discrete input status | Read input status |
03 | Read holding register | Read the address and version |
05 | Write single coil | Write single relay |
06 | Write single register | Set the baud rate and address |
0F | Write multiple coils | Write relay status |
10 | Set multiple registers | Set multiple registers |
Register Address Introduction
Address (HEX) | Address storage content | Register value | Permission | Modbus Function Code |
---|---|---|---|---|
0x0000 …… 0x0007 |
Channel 1~8 relay address | 0xFF00: relay on 0x0000: relay off 0x5500: relay toggle |
Read/Write | 0x01, 0x05, 0x0F |
0x00FF | Control all relays | 0xFF00: all relays on 0x0000: all relays off 0x5500: all relays toggle |
Write | 0x05 |
0x0100 …… 0x0107 |
Channel 1~8 relay toggle address | 0xFF00: relay toggle 0x0000: relay unchanged |
Write | 0x05, 0x0F |
0x01FF | Control all relays toggle | 0xFF00: all relays toggle 0x0000: all relays unchanged |
Write | 0x05 |
0x0200 …… 0x0207 |
Channel 1~8 relay flash on | Interval time: data*100ms Value: 0x0007, Interval time: 7*100MS = 700MS |
Write | 0x05 |
0x0400 …… 0x0407 |
Channel 1~8 relay flash off | Interval time: data*100ms Value: 0x0007, Interval time: 7*100MS = 700MS |
Write | 0x05 |
1x0000 …… 1x0007 |
Channel 1~8 input address | Indicates channel 1~8 input channel status | Read | 0x02 |
4x1000 …… 4x1007 |
Channel 1~8 relay control mode | 0x0000~0x0003 four control modes | Read/Write | 0x03, 0x06, 0x10 |
4x4000 | Device Address | Directly store Modbus address Device address: 0x0001 |
Read | 0x03 |
4x8000 | Software Version | Converting to decimal and then shifting the decimal point two places to the left will represent the software version 0x0064 = 100 = V1.00 |
Read | 0x03 |
Modbus RTU Command Introduction
Control Single Relay
Send code: 01 05 00 00 FF 00 8C 3A
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
05 | 05 Command | Relay control |
00 00 | Address | The register addresses of the relays to be controlled, 0x0000-0x0007 |
FF 00 | Command | 0xFF00: relay on; 0x0000: relay off; 0x5500: relay toggle |
8C 3A | CRC16 | The CRC16 checksum of the first 6 bytes of data |
Return code: 01 05 00 00 FF 00 8C 3A
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
05 | 05 Command | Relay control |
00 00 | Address | The register address of the relay to be controlled, 0x0000-0x0007 |
FF 00 | Command | 0xFF00: relay on; 0x0000: relay off; 0x5500: relay toggle |
8C 3A | CRC16 | The CRC16 checksum of the first 6 bytes of data |
For example: [Address 1 device]:
Relay 0 on: 01 05 00 00 FF 00 8C 3A Relay 0 off: 01 05 00 00 00 00 CD CA Relay 1 on: 01 05 00 01 FF 00 DD FA Relay 1 off: 01 05 00 01 00 00 9C 0A Relay 2 on: 01 05 00 02 FF 00 2D FA Relay 2 off: 01 05 00 02 00 00 6C 0A Relay 3 on: 01 05 00 03 FF 00 7C 3A Relay 3 off: 01 05 00 03 00 00 3D CA Relay 0 toggle: 01 05 00 00 55 00 F2 9A Relay 1 toggle: 01 05 00 01 55 00 A3 5A Relay 2 toggle: 01 05 00 02 55 00 53 5A Relay 3 toggle: 01 05 00 03 55 00 02 9A
Control All Relays
Send code: 01 05 00 FF FF 00 BC 0A
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
05 | 05 Command | Relay control |
00 FF | Address | Fixed 0x00FF |
FF 00 | Command | 0xFF00: relay on; 0x0000: relay off; 0x5500: relay toggle |
BC 0A | CRC16 | The CRC16 checksum of the first 6 bytes of data |
Return code: 01 05 00 FF FF 00 BC 0A
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
05 | 05 Command | Relay control |
00 FF | Address | Fixed 0x00FF |
FF 00 | Command | 0xFF00: relay on; 0x0000: relay off; 0x5500: relay toggle |
BC 0A | CRC16 | The CRC16 checksum of the first 6 bytes of data |
For example: [Address 1 device]:
All relays on: 01 05 00 FF FF 00 BC 0A All relays off: 01 05 00 FF 00 00 FD FA All relays toggle: 01 05 00 FF 55 00 C2 AA
Read Relay Status
Send code: 01 01 00 00 00 08 3D CC
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
01 | 01 Command | Query relay status |
00 00 | Start Address | Relay start address, 0x0000-0x0007 |
00 08 | Relay Number | Cannot exceed the maximum number of relays |
3D CC | CRC16 | The CRC16 checksum of the first 6 bytes of data |
Receive code: 01 01 01 00 51 88
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
01 | 01 Command | Query relay status |
01 | Byte Number | The number of all bytes of the returned status information |
00 | Query status | Received relay status Bit0: the first relay status; Bit1: the second relay status; And so on, with the idle high bit being zero |
51 88 | CRC16 | The CRC16 checksum of the first 6 bytes of data |
For example: [Address 1 device]:
Send: 01 01 00 00 00 08 3D CC //Query all relays Receive: 01 01 01 00 51 88 //all relays off Send: 01 01 00 02 00 01 5C CA //Query relays 2 Receive: 01 01 01 01 90 48 //Relay 1 on Send: 01 01 00 01 00 03 2D CB //Query relays 1, 2, 3 status Receive: 01 01 01 05 91 8B //Relays 1 and 3 are on, relay 2 is off
Write Relay Status
Send code: 01 0F 00 00 00 08 01 FF BE D5
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
0F | 0F Command | Write relay status |
00 00 | Relay Start Address | The register address of the relay to be controlled, 0x0000 - 0x0007 |
00 08 | Relay Number | The number of relays to be operated, which must not exceed the maximum number of relays |
01 | Byte Number | The byte number of the status |
FF | Relay Status | Bit0: the first relay status; Bit1: the second relay status; And so on, with the idle high bit being zero |
BE D5 | CRC16 | The CRC16 checksum of the first 6 bytes of data |
Receive code: 01 0F 00 00 00 08 54 0D
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
0F | 0F Command | Control all registers |
00 00 | Address | Relay start address |
00 08 | Relay Number | The number of relays to be written |
54 0D | CRC16 | The CRC16 checksum of the first 6 bytes of data |
For example: [Address 1 device]:
All relays on: 01 0F 00 00 00 08 01 FF BE D5 All relays off: 01 0F 00 00 00 08 01 00 FE 95 0-1 on; 3-7 off: 01 0F 00 00 00 08 01 03 BE 94 Relays 1, 2, and 3 on: 01 0F 00 01 00 03 01 07 F3 55
Relay Flash ON/OFF Command
Send code: 01 05 02 00 00 07 8D B0
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
05 | 05 Command | Single control command |
02 | Command | 02: flash on, 04: flash off |
00 | Relay Address | The address of the relay to be controlled, 0x00~0x07 |
00 07 | Interval Time | The interval time: data*100ms Value: 0x0007, Interval time: 7*100MS = 700MS The maximum setting for the flash-on flash-off time is 0x7FFF |
8D B0 | CRC16 | The CRC16 checksum of the first 6 bytes of data |
Receive code: 01 05 02 00 00 07 8D B0
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
05 | 05 Command | Single control command |
02 | Command | 02: flash on, 04: flash off |
00 | Relay Address | The address of the relay to be controlled, 0x00~0x07 |
00 07 | Interval Time | The interval time: data*100ms Value: 0x0007, Interval time: 7*100MS = 700MS The maximum setting for the flash-on flash-off time is 0x7FFF |
8D B0 | CRC16 | The CRC16 checksum of the first 6 bytes of data |
For example: [Address 1 device]:
Relay 0 flash on: 01 05 02 00 00 07 8D B0 //700MS = 7*100MS = 700MS Relay 1 flash on: 01 05 02 01 00 08 9C 74 //800MS Relay 0 flash off: 01 05 04 00 00 05 0C F9 //500MS Relay 1 flash off: 01 05 04 01 00 06 1D 38 //600MS
Read Input Status
Send code: 01 02 00 00 00 08 79 CC
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
02 | 02 Command | Read input status |
00 00 | Input Start Address | Input start address, 0x0000-0x0007 |
00 08 | Register Number | The number of the input channels to be read, which must not exceed the maximum number of the input channels |
79 CC | CRC16 | The CRC16 checksum of the first 6 bytes of data |
Receive code: 01 02 01 00 A1 88
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
02 | 02 Command | Read input status |
01 | Byte Number | The number of all bytes of the returned status information |
00 | Query status | Received input channel status Bit0: the first channel status; Bit1: the second channel status; And so on, with the idle high bit being zero |
A1 88 | CRC16 | The CRC16 checksum of the first 6 bytes of data |
For example: [Address 1 device]:
Send: 01 02 00 00 00 08 79 CC //Query all input channels Receive: 01 01 01 00 51 88 //Inputs are all untriggered Send: 01 02 00 00 00 08 79 CC //Query all input channels Receive: 01 02 01 41 61 B8 //Channels 1 and 7 input is triggered, and the rest of channels are not triggered Send: 01 02 00 01 00 03 69 CB //Query input channels 2, 3, and 4 Receive: 01 02 01 03 E1 89 //Channels 2 and 3 input is triggered, and channel 4 is not triggered
Read Relay Control Mode
Send code: 01 03 10 00 00 08 40 CC
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
03 | 03 Command | Read Holding Register |
10 00 | Register Start Address | 0x1000 - 0x1007 corresponds to 1~8 input channels |
00 08 | Register Number | Read register number, up to 8 channels |
40 CC | CRC16 | The CRC16 checksum of the first 6 bytes of data |
Receive code: 01 03 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 E4 59
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
03 | 03 Command | Read Holding Register |
10 | Byte Number | The number of all bytes of the returned status information |
00 00 …… 00 00 |
Control Mode | Indicates relay 1 - 8 control mode, 0x0000~0x0003 indicate four control modes 0x0000: Normal mode , the relay is directly controlled by commands;0x0001: Linkage mode , relay status is the same as the corresponding input channel status;0x0002: Toggle mode , the corresponding relay toggles once when the input channel inputs a pulse;0x0003: Jump Mode , the corresponding relay status toggles once when the input channel level jumps onceNote: All modes except Linkage mode support relay control by command.
|
E4 59 | CRC16 | The CRC16 checksum of the first 6 bytes of data |
For example: [Address 1 device]:
Read relay 1-8 control mode: 01 03 10 00 00 08 40 CC Read relay 1 control mode: 01 03 10 00 00 01 80 CA Read relay 2 control mode: 01 03 10 01 00 01 D1 0A Read relay 3-5 control mode: 01 03 10 02 00 03 A0 CB
Set Single Relay Control Mode
Send code: 01 06 10 00 00 01 4C CA
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
06 | 06 Command | Write single register |
10 00 | Register Start Address | 0x1000 - 0x1007 correspond to relay control modes for channels 1~8 |
00 01 | Control Mode | Indicates relay 1 - 8 control mode, 0x0000~0x0003 indicate four control modes 0x0000: Normal mode , the relay is directly controlled by commands;0x0001: Linkage mode , relay status is the same as the corresponding input channel status;0x0002: Toggle mode , the corresponding relay toggles once when the input channel inputs a pulse;0x0003: Jump Mode , the corresponding relay status toggles once when the input channel level jumps onceNote: All modes except Linkage mode support relay control by command.
|
4C CA | CRC16 | The CRC16 checksum of the first 6 bytes of data |
Return code: 01 06 10 00 00 01 4C CA
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
06 | 06 Command | Write single register |
10 00 | Register Start Address | 0x1000 - 0x1007 correspond to relay control modes for channels 1~8 |
00 01 | Control Mode | Relay control modes, 0x0000~0x0003 indicate four control modes |
4C CA | CRC16 | The CRC16 checksum of the first 6 bytes of data |
For example: [Address 1 device]:
Set relay 1 as Linkage mode: 01 06 10 00 00 01 4C CA Set relay 2 as toggle mode: 01 06 10 01 00 02 5D 0B
Set Multiple Relay Control Mode
Send code: 01 10 10 00 00 08 10 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 7C B1
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
10 | 10 Command | Write multiple registers |
10 00 | Register Start Address | 0x1000 - 0x1007 correspond to relay control modes for channels 1~8 |
00 08 | Register Number | Set register number, up to 8 channels |
10 | Byte Number | Set the number of bytes to be output |
00 01 …… 00 01 |
Control Mode | Indicates relay 1 - 8 control mode, 0x0000~0x0003 indicate four control modes 0x0000: Normal mode , the relay is directly controlled by commands;0x0001: Linkage mode , relay status is the same as the corresponding input channel status;0x0002: Toggle mode , the corresponding relay status toggles once when the input channel inputs a pulse;0x0003: Jump Mode , the corresponding relay state toggles once when the input state of the input channel changes onceNote: All modes except Linkage mode support relay control by command.
|
7C B1 | CRC16 | The CRC16 checksum of the first 6 bytes of data |
Return code: 01 10 10 00 00 08 C5 0F
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
10 | 10 Command | Write multiple registers |
10 00 | Register Start Address | 0x1000 - 0x1007 correspond to relay control modes for channels 1~8 |
00 08 | Register Number | Set register number, up to 8 channels |
C5 0F | CRC16 | The CRC16 checksum of the first 6 bytes of data |
For example: [Address 1 device]:
Set channel 1-8 relay as Normal mode: 01 10 10 00 00 08 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0B 5C Set channel 1-8 relay as Linkage mode: 01 10 10 00 00 08 10 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 7C B1 Set channel 3-5 relay as Toggle mode: 01 10 10 02 00 03 06 00 02 00 02 00 02 4A 4B
Read Software Version Command
Send code: 01 03 80 00 00 01 AD CA
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
03 | 03 Command | Read Holding Register |
80 00 | Command register | 0x8000: read software version |
00 01 | Byte Number | Fixed 0x0001 |
AD CA | CRC16 | The CRC16 checksum of the first 6 bytes of data |
Receive code: 01 03 02 00 64 B9 AF
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
03 | 03 Command | Read Holding Register |
02 | Byte Number | The number of bytes returned |
00 64 | Software Version | Converting to decimal and then shifting the decimal point two places to the left will represent the software version 0x0064 = 100 = V1.00 |
B9 AF | CRC16 | The CRC16 checksum of the first 6 bytes of data |
For example:
Send: 01 03 80 00 00 01 AD CA Receive: 01 03 02 00 C8 B9 D2 //0x00C8 = 200 =V2.00
Exception Function Code
When the received command is incorrect or the device is abnormal, an exception response will be returned in the following format:
Receive: 01 85 03 02 91
Field | Description | Note |
---|---|---|
01 | Device Address | 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address |
85 | Exception Function Code | Exception function code = Request function code + 0x80 |
03 | Byte Number | Exception Code |
02 91 | CRC16 | The CRC16 checksum of the first 6 bytes of data |
An exception code is a single-byte value that indicates the type of error. Several commonly used exception codes defined by the Modbus protocol:
Exception Code | Name | Description |
---|---|---|
0x01 | Illegal Function | The requested function code is not supported |
0x02 | Illegal Data Address | The requested data address is incorrect |
0x03 | Illegal Data Value | The requested data value or operation cannot be executed |
0x04 | Server Failure | Server equipment failure |
0x05 | Response | The request has been received and is being processed |
0x06 | Device Busy | The device is currently busy and cannot perform the requested operation |
Modbus TCP Command Introduction
Here is a brief introduction to Modbus TCP and Modbus RTU protocol conversion using the above commands to open the first relay as an example.
- Modbus RTU command: 01 05 00 00 FF 00 8C 3A
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
05 | 05 Command | Relay control |
00 00 | Address | The register address of the relay to be controlled, 0x00, that is, the first relay |
FF 00 | Command | 0xFF00: Relay on |
8C 3A | CRC16 | The CRC16 checksum of the first 6 bytes of data |
- Modbus TCP command: 00 00 00 00 00 06 01 05 00 00 FF 00
Field | Description | Note |
---|---|---|
00 00 | Message Label | Both be 0x00 |
00 00 | modbus Label | Must both be 0, which means this is Modbus communication |
00 06 | Byte Length | Indicates the number of all bytes that follow, followed by 6 bytes |
01 | Device Address | Fixed 0x01 |
05 | 05 Command | Relay control |
00 00 | Address | The register address of the relay to be controlled, 0x00, that is, the first relay |
FF 00 | Command | 0xFF00: Relay on |
By comparing the commands above, we can observe that to convert a Modbus RTU command to Modbus TCP protocol, the CRC check is removed, and the command is prefixed with five 0x00 bytes followed by a byte representing the length.
For example, if the server's Ethernet port receives a Modbus TCP command of 00 00 00 00 00 06 01 05 00 00 FF 00 (to turn on the first relay), the host controller will receive the Modbus RTU command of 01 05 00 00 FF 00 8C 3A.
Modbus TCP Development Protocol
Here is a brief introduction to modbus tcp and modbus rtu protocol conversion using the above command to open the first relay as an example.
- Modbus RTU command: 01 05 00 00 FF 00 8C 3A
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
05 | 05 Command | Control relays |
00 00 | Address | Register address of the relay to be controlled, 0x00, the first relay |
FF 00 | Command | 0xFF00: Relay on |
8C 3A | CRC16 | CRC16 checksum of the first 6 bytes of data |
- Modbus TCP command: 00 00 00 00 00 06 01 05 00 00 FF 00
Field | Description | Note |
---|---|---|
00 00 | Message label | All 0x00 |
00 00 | modbus mark | All must be 0, indicate the modbus communication |
00 06 | Byte length | Indicates all the bytes that follow, followed by 6 more bytes |
01 | Device address | Fixed 0x01 |
05 | 05 Command | Control relays |
00 00 | Address | Register address of the relay to be controlled, 0x00, the first relay |
FF 00 | Command | 0xFF00: relay on |
Comparing the above commands reveals that the modbus rtu command removes the CRC checksum and adds five 0x00s and a byte length in front of it, which can be converted to the modbus tcp protocol.
Advanced Applications - MQTT Connected Cloud Platform
Software Preparation
Hardware Preparation
How to Connect
- Create an account access the platform using an email verification code, and then enter "Devices | Attributes" to create the device to operate after login.
- Viewing the device list, a new device appears:
- In the device menu, click to display the attributes section. Then, click on the "Address" button on the right to view the MQTT connection parameters. These parameters are preconfigured as part of the one-click setup, and the relevant attributes have already been created.
- The creation of the Waveshare Cloud device is now complete.
Configure Modbus POE ETH Relay with Vircom Software
- Plug in the device, connect it to the Ethernet cable, ensuring that the computer and the device are on the same local network, and then open Vircom to follow the instructions as shown in the diagram.
- Fill in the corresponding boxes with the parameters provided by Waveshare Cloud. Please note that errors may occur at this stage, and there may be related configuration files in the target directory. In this case, it is advisable to create a new empty directory and point to this empty directory.
- Confirm and then download the config.
- Afterward, click the "Refresh" button to search for the device. The device will automatically restart after updating the settings. At this point, you should see that the TCP Connection status is now 'Established.'
- Return to Waveshare Cloud to check the device status, which should now be in the "online" state.
- Access to the device is now complete.
Device Control
Dashboard Control
- Enter the Dashboard interface and select the corresponding device to develop.
- Controls the corresponding access switch buttons to perform operations:
Debug Online Test
Resource
Demo
Softwares
- Vircom
- Virtual serial port: Serial port driver
- Sscom5.13.1 for Modbus POE ETH Relay: SSCOM software
- Modbus Poll software
- SecureCRT software
Related applications
FAQ
1、If the command is sent and the module returns a code but the relay does not respond, please ensure the relay is set to Normal Mode
or Toggle mode
.
2、If the module does not respond to the command, verify that the baud rate and device ID are correct. You may also try Restoring the factory settings.
3、If the above steps do not resolve the issue, please submit a ticket to contact the Waveshare technical support team.
{{{5}}}
-15℃~70℃.
{{{5}}}
Support
Technical Support
If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)