(Hshop - VN) Module 1 Relay Modbus RTU RS485
(Hshop - VN) Module 1 Relay Modbus RTU RS485
1. Overview:
The single-channel Modbus relay module is equipped with a mature and stable 8-bit MCU and
RS485 level communication chip. Using standard MODBUS RTU format RS485 communication
protocol, it can realize 1 optocoupler input signal detection, 1 relay output, can be used for digital
detection or power control occasions.
2. Features:
1) Onboard mature and stable 8bit MCU and MAX485 level conversion chip;
2) Communication protocol: support standard Modbus RTU protocol;
3) Communication interface: support RS485 / TTL UART interface;
4) Communication baud rate: 4800/9600/19200, default 9600bps, support to save after power off;
5) Optocoupler input signal range: DC3.3-30V (this input cannot be used for relay control);
6) Output signal: relay switch signal, support manual, flash off, flash off mode, the delay base of
flash off / flash is 0.1S, the maximum set flash off / flash time is 0xFFFF * 0.1S = 65535 * 0.1 S =
6553.5S;
7) Device address: range 1-255, default 255, support to save after power off;
8) Baud rate, optocoupler input status, relay status, and device address can be read using software
/ command;
9) Onboard 1 channel 5V, 10A / 250V AC 10A / 30V DC relay, which can be continuously
attracted 100,000 times, with diode leakage protection, short response time
10) On-board relay switch indicator;
11) Power supply voltage: DC7-24V, with input anti-reverse protection;
1) Board size
2) Interface introduction
Modbus devices perform related operations by receiving Modbus RTU commands from an
external control terminal (such as a host computer / MCU). A frame of commands is generally
composed of device address, function code, register address, register data, check code, frame
length and Function code. Generally, the first byte of each frame of data is the device address, and
the settable range is 1-255, the default is 255 (that is, 0xFF), and the last 2 bytes are the CRC
check code.
Assuming the device address is 255, the commonly used Modbus RTU instructions are as follows:
1). Turn on relay No. 1 (manual mode)
Send: FF 05 00 00 FF 00 99 E4
Return as is: FF 05 00 00 FF 00 99 E4
Remarks:
(1) The 3rd to 4th bytes of the sent frame represent the relay address, and the addresses of relay
1-relay 8 are 0x0000, 0x0001,0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007
(2) The 5th to 6th bytes of the transmitted frame represent data, 0xFF00 represents opening the
relay, and 0x0000 represents closing the relay
2) Turn off relay No. 1 (manual mode)
Send: FF 05 00 00 00 00 D8 14
Return as is: FF 05 00 00 00 00 D8 14
3) Turn on all relays
Send: FF 0F 00 00 00 08 01 FF 30 1D
Returns: FF 0F 00 00 00 08 41 D3
4) Close all relays
Send: FF 0F 00 00 00 08 01 00 70 5D
Returns: FF 0F 00 00 00 08 41 D3
5) Set the device address to 1
Send: 00 10 00 00 00 01 02 00 01 6A 00
Return as is: 00 10 00 00 00 01 02 00 01 6A 00
Remarks: The 9th byte 0x01 of the sent frame is the written device address
6) Set the device address to 255
Send: 00 10 00 00 00 01 02 00 FF EB 80
Return as is: 00 10 00 00 00 01 02 00 FF EB 80
Remarks: The 9th byte 0xFF of the sent frame is the written device address
7) Read device address
Send: 00 03 00 00 00 01 85 DB
Returns: 00 03 02 00 FF C5 C4
Remarks: The 5th byte of the returned frame, 0xFF, is the read device address
8) Read relay status
Send: FF 01 00 00 00 08 28 12
Returns: FF 01 01 01 A1 A0
Remarks: Bit 0--Bit 7 of the 4th byte of the returned frame, 0x01, represent relay 1--relay 8, 0 is
off, 1 is on
9) Read optocoupler input status
Send: FF 02 00 00 00 08 6C 12
Returns: FF 02 01 01 51 A0
Remarks: IN1--IN8 of the 4th byte of the returned frame, 0x01, represents the input signal of
optocoupler 1--optocoupler 8, 0 represents low level, 1 represents high level
10) Set the baud rate to 4800
Send: FF 10 03 E9 00 01 02 00 02 4A 0C
Returns: FF 10 03 E9 00 01 C5 A7
Remarks: The 9th byte of the sent frame is the baud rate setting value, 0x02, 0x03, x04
respectively represent 4800, 9600, 19200
11) Set the baud rate to 9600
Send: FF 10 03 E9 00 01 02 00 03 8B CC
Returns: FF 10 03 E9 00 01 C5 A7
12) Set the baud rate to 19200
Send: FF 10 03 E9 00 01 02 00 04 CA 0E
Returns: FF 10 03 E9 00 01 C5 A7
13) Read baud rate
Send: FF 03 03 E8 00 01 11 A4
Returns: FF 03 02 00 04 90 53
Remarks: The 5th byte of the returned frame represents the baud rate read, 0x02, 0x03, x04
represent 4800, 9600, 19200 respectively
14) Turn on relay No. 1 (flash off mode 2S)
Send: FF 10 00 03 00 02 04 00 04 00 14 C5 9F
Returns: FF 10 00 03 00 02 A4 16
Remarks:
(1) The 3rd to 4th bytes of the transmitted frame represent the relay address, and the addresses of
Relay 1--Relay 8 are 0x0003, 0x0008, 0x000D, 0x0012, 0x0017, 0x001C, 0x0021,0x0026
(2) The 10th to 11th bytes of the transmitted frame represent the delay setting value, the delay base
is 0.1S, so the delay time is 0x0014 * 0.1 = 20 * 0.1S = 2S, and the relay is automatically closed
after opening 2S
15) Turn off relay No. 1 (flash mode 3S)
Send: FF 10 00 03 00 02 04 00 02 00 1E A5 99
Returns: FF 10 00 03 00 02 A4 16
Remarks:
(1) The 3rd to 4th bytes of the transmitted frame represent the relay address, and the addresses of
Relay 1--Relay 8 are 0x0003, 0x0008, 0x000D, 0x0012, 0x0017, 0x001C, 0x0021,0x0026
(2) The 10--11th bytes of the transmitted frame represent the delay setting value, the delay base is
0.1S, so the delay time is 0x001E * 0.1 = 30 * 0.1S = 3S, the relay is automatically turned on after
3S is closed
5. Simple instructions
The Modbus relay module can receive Modbus RTU commands from the host computer / MCU
via the RS485 / TTL UART interface to perform related operations. The following uses the host
computer software to open relay 1 (manual mode) through the RS485 interface as an example.
Assuming that the device address is 255 and the baud rate is 9600, the steps are as follows:
1) VCC and GND are respectively connected to the positive and negative poles of the power
supply;
2) A +, B-, respectively A + and B- from USB to RS485 module output;
3) Open the host computer software "ModbusRTU Configuration Tool", select the correct port
number, select the baud rate of 9600, set the address to 255, and click "Open Serial Port";
4) Click "JD1 open" to turn on relay 1, and the indicator light of relay 1 lights up. As shown
below:
When the Modbus RTU instruction is sent through the existing host computer software (such as:
ModbusRTU configuration tool), the CRC check code is automatically generated. If you want to
use serial debugging software (such as SSCOM) to test the Modbus relay module, you need to
manually generate the CRC The check code is placed at the end of the transmitted frame, for
example, to open the first relay (manual mode):
1). The transmission frame composition of opening / closing relay (manual mode) is:
Device address (1Byte) + function code (1Byte) + register address (2Byte) + register data (2Byte)
+ CRC check code (2Byte)
2). Assuming the device address is 0xFF, the first 6 bytes of the transmitted frame are:
FF 05 00 00 FF 00
3). Use the CRC check tool to find the check code for these 6 bytes: http://www.ip33.com/crc.html
4). After exchanging the high and low byte positions of the calculation result E499, the CRC
check code 99E4 is obtained, and the complete transmission frame: FF 05 00 00 FF 00 99 E4
5). Send the sending frame to the Modbus relay module through the serial debugging software
SSCOM V5.13.1 to open the first relay (manual mode)