Modbus RTU IO 8CH

From Waveshare Wiki
Jump to: navigation, search
Modbus RTU IO 8CH
Modbus RTU IO 8CH.jpg

RS485 DI/DO Midule
RS485
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Overview

Electrical Safety Precautions

  • This product should be operated and used by professional electricians or technical personnel. Please ensure electrical safety measures are in place, including protection against leakage and insulation.
  • Before installing, maintaining, or replacing relay equipment, always turn off the power and unplug the plug.
  • Do not attempt to dismantle relay equipment to avoid damaging the device or risking electric shock.
  • Please properly install and place relay equipment. Avoid use in damp, overheated, or flammable environments to prevent accidents caused by improper installation or use.

This product is an industrial-grade RS485 interface controlled 8DI / 8DO digital isolated input-output module. It supports passive input/active input, utilizes Modbus RTU protocol, and includes built-in protection circuits such as power isolation, optocoupler isolation, self-resetting fuses and TVS.

Specification

Communication Interface RS485
Baud Rate 4800, 9600, 19200, 38400, 57600
115200, 128000, 256000
Default Communication Format 9600, N, 8, 1
Modbus Protocol Standard Modbus RTU Protocol
Power Supply DC 7~36V
Digital Input 8DI, 5~36V, passive input/active input (NPN or PNP)
Built-in bidirectional optocoupler
Digital output 8DO, 5~40V, open-drain output, output load 500mA/channel(MAX)
Set the device address range 1~255 (1 by default, corresponds to the hexadecimal value of 0x01)

Basic Function

Supports reading digital input by sending Modbus RTU protocol commands via RS485 for digital output control.
Modbus RTU IO 8CH Primary.jpg

Wiring Introduction

Hardware Wiring Introduction

Modbus RTU IO 8CH Hard.jpg

Wiring Table
Channel Label Function Channel Label Function
7~36V Power Supply Positive 485 A+ RS485 Signal Wire A
GND Power Supply Negative 485 B- RS485 Signal Wire B
NC Not Connected EARTH RS485 shielding ground wire
DGND Signal Ground DGND Signal Ground
DI1 The input terminal of the first channel DO1 The output terminal of the first channel
DI2 The input terminal of the second channel DO2 The output terminal of the second channel
DI3 The input terminal of the third channel DO3 The output terminal of the third channel
DI4 The input terminal of the fourth channel DO4 The output terminal of the fourth channel
DI5 The input terminal of the fifth channel DO5 The output terminal of the fifth channel
DI6 The input terminal of the sixth channel DO6 The output terminal of the sixth channel
DI7 The input terminal of the seventh channel DO7 The output terminal of the seventh channel
DI8 The input terminal of the eighth channel DO8 The output terminal of the eighth channel
DI COM[1] the common terminal for input signals DO COM[2] the common terminal for output signals
  1. DI COM serves as the common terminal for input signals, capable of being not connected or connected to either the positive or negative pole of the power supply. It can directly draw power from the power supply or have an independent power source.
    • Not connected: Dry contact passive input.
    • Connected to the positive pole of the power supply: low-level active, NPN type wet contact active input, voltage 5V-36V DC.
    • Connected to the negative pole of the power supply: High-level active, PNP type wet contact active input, voltage 5V-36V DC.
      Modbus-RTU-IO-8CH-DI-connection.png
  2. DO COM is the common terminal for output signals, connect to the positive pole of the output power.
    • Modbus-RTU-IO-8CH-DO-connection.png

Digital Input Wiring

The digital input wiring types: passive dry contact input, active wet contact NPN input, active wet contact PNP input.

Digital Input Wiring Diagram

  • Passive dry contact input wiring diagram:

Modbus RTU IO 8CH Wiring Diagram01.jpg

  • Active wet contact NPN input wiring diagram:

Modbus RTU IO 8CH Wiring Diagram02.png

  • Active wet contact PNP input wiring diagram:

Modbus RTU IO 8CH Wiring Diagram03.png

Digital Output Wiring

  • Digital output wiring diagram:

Modbus-RTU-IO-8CH-DO-connection.png

Dimensions

Modbus RTU IO 8CH dimen.jpg

Hardware Connection

  • Connect the USB TO 485 to the target board through a cable, connect "A-"->"A-" and "B-"->"B-" as shown below:

Modbus RTU IO 8CH Test01.jpg

Example Demonstration

The demo shows how the following two software operate.
SSCOM serial port debugging assistant is more convenient to operate, free of installation, and more convenient for complete display and analysis of instructions, but the disadvantage is that the data is not intuitive.
Modbus Poll software is directly operated on the register, and the data display is more convenient to observe, but the disadvantage is that the instruction is not displayed completely, so you need to be familiar with the Modbus register operation.
You can test using any method. It is recommended to use the SSCOM serial port debugging assistant software for the first test.

SSCOM Serial Port Debugging Assistant

  • Download SSCOM Serial port debugging assistant and open it on the computer, open the corresponding port number, and set the baud rate as 9600. Click Multi-Char to open the Send Multi-Char window, and click the function to send the corresponding command.

600px-Modbus-RTU-Relay-2-1.png
Note: The module defaults to normal mode at the factory, the relay can be directly controlled through commands. If there is a command to return normally, but the relay does not act, the module may have been changed to other control mode, you can query it by reading the relay control mode command.

  • If you need to send other commands, choose SendHEX. For checksum validation, select ModbusCRC16. After entering the first six bytes of the command, clicking SEND will automatically add the CRC check code.

Modbus-RTU-Relay-3.png

  • For detailed control commands, please see the development protocol.

Modbus Poll Software

  • It is not convenient to use the SSCOM software for observing the data, you can select Modbus Poll software to read the data. Download and install the Modbus Poll software.
  • Open the software, select Setup->Read/Write Definition, select the actual device address for Slave ID, select 01 Read Coils function code for Function, and change Quantity to 8 channels. Click OK to confirm.

Modbus-RTU-Relay-C-1.png

  • Select Connection->Connect..., choose the corresponding serial port, set the baud rate to 9600, and select 8 Data bits and None Parity. Click OK to connect.

Modbus-RTU-Analog-Input-3.png

  • After the connection is normal, you can check the current input channel status. Select the corresponding channel, then double-click the status value to pop up the send page. Choose On or Off, then click Send to control the relay opening and closing.

Modbus-RTU-Relay-C-2.png

  • Choose File->New to create a new window, select Setup->Read/Write Definition, choose the actual device address for Slave ID, select 02 for Function, set Address to 0, set Quantity to 8 channels, and change the Scan Rate to 100ms. Click OK to confirm.

Modbus-RTU-Relay-D-5.jpg

  • The new window 2 can display the current input status, change the input interface level, and the corresponding values will also change.

Modbus-RTU-Relay-D-6.jpg

Demo Test

Note: RS485 can not be directly connected to the serial port of the Raspberry Pi, otherwise the device may be burned. The 485 voltage translator is required, and Raspberry Pi is recommended to work with RS485 CAN HAT module, NUCLEO-F103RB and Arduino are recommended to use with RS485 CAN Shield module.

Raspberry Pi

Open the Raspberry Pi terminal and input the following commands to enter the configuration interface.

sudo raspi-config
Select Interfacing Options -> Serial Port, select Yes to open the hardware serial port 

And then reboot the Raspberry Pi:

sudo reboot

Insert the RS485 CAN HAT into the Raspberry Pi, and connect the Modbus RTU Relay module to the RS485 CAN HAT through A and B.
If you are using other 485 devices, you need to make sure to connect A-A, B-B.
Run the following commands:

sudo apt-get install unzip
wget https://files.waveshare.com/wiki/Modbus-RTU-IO-8CH/Modbus_RTU_IO_Code.zip
unzip Modbus_RTU_IO_Code.zip
cd Modbus_RTU_IO_Code/Python3
sudo python3 main.py

After the demo normally runs, each channel can be opened and closed in order, and the current input status is displayed.

STM32

Note: The STM32 demo is based on the NUCLEO-F103RB and RS485 CAN Shield module.

1. Download Demo, find the STM32 project file Modbus Relay.uvprojx in the path Modbus_RTU_IO_Code\STM32\MDK-ARM, and double-click to open the STM32 project file. Note that you should ensure Keil5 software is installed on your computer before using it.
600px-Modbus-RTU-Relay-stm32-1.png
2. ​​Connect the STM32 to a computer via the STM32 download and debug probe.​ Compile and download the program to the development board.
600px-Modbus-RTU-Relay-stm32-2.png
3. Install the RS485 CAN Shield module on the STM32. Connect the RS485_A on the RS485 CAN Shield module to the RS485_A on the Modbus RTU IO 8CH via a wire, and connect the RS485_B on the RS485 CAN Shield module to the RS485_B on the Modbus RTU IO 8CH via a wire. Then power on the Modbus RTU IO 8CH and the STM32 sequentially.

4. After powering on, you can observe the reply information of the device through the serial port assistant, and the digital output will be turned on in order (such as 1→2→3→4), and then turned off in order (such as 1→2→3→4) after all are turned on. The DO indicator can be used to check whether the digital output is on.

600px-Modbus-RTU-Relay-stm32-4.png

Arduino

Note: The Arduino demo is based on the UNO PLUS and RS485 CAN Shield module.
1. Download Demo, find the Arduino project file Modbus_RTU_Relay.ino in the path Modbus_RTU_IO_Code\Arduino\Modbus_RTU_Relay, and double-click to open the Arduino project file. Note that you should ensure Arduino IDE software is installed on your computer before using it.
600px-Modbus-RTU-Relay-arduino-1.png

2. Connect the Arduino to the computer via a USB cable. In the Arduino IDE software, select the Arduino board model under Tools->Board. Choose the COM port that the Arduino is connected to under Tools->Port.
3. After seeing the prompt to connect to the computer in the lower right corner, click to compile and flash the program, and wait for the flashing to complete.
600px-Modbus-RTU-Relay-arduino-2.png

4. Install the RS485 CAN Shield module on the Arduino. Connect the RS485_A on the RS485 CAN Shield module to the RS485_A on the Modbus RTU IO 8CH via a wire, and connect the RS485_B on the RS485 CAN Shield module to the RS485_B on the Modbus RTU IO 8CH via a wire. Then power on the Modbus RTU IO 8CH and the Arduino sequentially.

5. After powering on, you can observe the reply information of the device through the serial port assistant, and the digital output will be turned on in order (such as 1→2→3→4), and then turned off in order (such as 1→2→3→4) after all are turned on. The DO indicator can be used to check whether the digital output is on.

Note: The data in the figure below is in ASCII code containing spaces and line breaks, and is not the actual data sent.
600px-Modbus-RTU-Relay-arduino-4.png


PLC

Note: The PLC demo is based on SIMATIC S7-200 SMART.

1. Download Demo, find the PLC project file modbus_rtu.smart in the path Modbus_RTU_IO_Code\PLC, and double-click to open the PLC project file. Note that you should ensure STEP 7-MicroWIN SMART software is installed on your computer before using it.
600px-Modbus-RTU-Relay-plc-1.png
2. Connect the PLC to the computer via a network cable. Click to download
600px-Modbus-RTU-Relay-plc-2.png
3. Select the communication interface in the communication popup, find your device, and click Confirm
600px-Modbus-RTU-Relay-plc-3.png
4. In the download pop-up window, check the boxes for program blocks, data blocks, and system blocks, and then click Download.
600px-Modbus-RTU-Relay-plc-4.png
5. Connect the 485_A on the PLC module to RS485_A on Modbus_RTU_IO with a wire, and connect the 485_B on the PLC module to RS485_B on Modbus_RTU_IO with a wire. Then power on the Modbus_RTU_IO.

6. After powering on the Modbus_RTU_IO, in the STEP 7-MicroWIN SMART software, find the "PLC" tab in the upper menu bar, switch to this tab, and click the green "RUN" button in the lower "Operation" area to perform the operation to make the PLC enter the running state
600px-Modbus-RTU-Relay-plc-5.png
7. After the PLC runs, the output channels of the Modbus_RTU_IO will be turned on in sequence (such as 1→2→3→4), and then turned off in sequence (such as 1→2→3→4) after they are all turned on. The LED indicator can be used to observe whether the channels are turned on or off.


Development Protocol V2

Function Code Introduction

Function Code Description
01 Read output status
02 Read input status
03 Read save register
05 Write single output channel
06 Set single register
0F Write multiple output channel
10 Set multiple registers

Register Address Introduction

Address (HEX) Address storage content Register value Permission Modbus Function Code
0x0000
……
0x0007
Output channels 1~8 addresses 0xFF00: on;
0x0000: off;
0x5500: toggle;
Read/Write 0x01, 0x05, 0x0F
0x00FF Control All Registers 0xFF00: all output channels on
0x0000: all output channels off
0x5500: all output channels toggle
Write 0x05
0x0200
……
0x0207
Output channels 1~8 flash on Interval time: data*100ms
Value: 0x0007, Interval time: 7*100MS = 700MS
Write 0x05
0x0400
……
0x0407
Output channels 1~8 flash off Interval time: data*100ms
Value: 0x0007, Interval time: 7*100MS = 700MS
Write 0x05
1x0000
……
1x0007
Input channels 1~8 addresses Indicates input channels 1~8 statuses Read 0x02
4x1000
……
4x1007
Output channels 1~8 control mode 0x0000~0x0003 four control modes Read/Write 0x03, 0x06, 0x10
4x2000 UART Parameter The high eight bits indicate the parity mode: 0x00~0x02
The low eight bits indicate the baud rate mode: 0x00~0x07
Write 0x03, 0x06
4x4000 Device Address Directly store Modbus address
Device address: 0x0001-0x00FF
Read/Write 0x03, 0x06
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 Output Channel

Send code: 01 05 00 00 FF 00 8C 3A

Field Description Note
01 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
05 05 Command Write single output channel command
00 00 Address The register address of the output channel to be controlled, 0x0000~0x0007
FF 00 Command 0xFF00: on;
0x0000: off;
0x5500: 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 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
05 05 Command Write single output channel command
00 00 Address The register address of the output channel to be controlled, 0x0000~0x0007
FF 00 Command 0xFF00: on;
0x0000: off;
0x5500: toggle
8C 3A CRC16 The CRC16 checksum of the first 6 bytes of data

For example: [Address 1 device]:

Output channel 0 on: 01 05 00 00 FF 00 8C 3A
Output channel 0 off: 01 05 00 00 00 00 CD CA
Output channel 1 on: 01 05 00 01 FF 00 DD FA
Output channel 1 off: 01 05 00 01 00 00 9C 0A
Output channel 2 on: 01 05 00 02 FF 00 2D FA
Output channel 2 off: 01 05 00 02 00 00 6C 0A
Output channel 3 on: 01 05 00 03 FF 00 7C 3A
Output channel 3 off: 01 05 00 03 00 00 3D CA
Output channel 0 toggle: 01 05 00 00 55 00 F2 9A
Output channel 1 toggle: 01 05 00 01 55 00 A3 5A
Output channel 2 toggle: 01 05 00 02 55 00 53 5A
Output channel 3 toggle: 01 05 00 03 55 00 02 9A

Control All Output Channels

Send code: 01 05 00 FF FF 00 BC 0A

Field Description Note
01 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
05 05 Command Write single output channel command
00 FF Address Fixed 0x00FF
FF 00 Command 0xFF00: on;
0x0000: off;
0x5500: 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 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
05 05 Command Write single output channel command
00 FF Address Fixed 0x00FF
FF 00 Command 0xFF00: on;
0x0000: off;
0x5500: toggle
BC 0A CRC16 The CRC16 checksum of the first 6 bytes of data

For example: [Address 1 device]:

All output channel on: 01 05 00 FF FF 00 BC 0A
All output channel off: 01 05 00 FF 00 00 FD FA
All output channel toggle: 01 05 00 FF 55 00 C2 AA

Read Output Channel Status

Send code: 01 01 00 00 00 08 3D CC

Field Description Note
01 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
01 01 Command Query output channel status command
00 00 Output Channel Start Address The register address of the output channel, 0x0000~0x0007
00 08 Number of output channels The number of output channels to be read, which must not exceed the maximum number of the output channels
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 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
01 01 Command Query output channel status command
01 Byte Number The number of all bytes of the returned status information
00 Query status Returned output channel status
Bit0: the first output channel status;
Bit1: the second output channel 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
Receive: 01 01 01 00 51 88    //All output channel off
Send: 01 01 00 00 00 08  3D CC
Receive: 01 01 01 01 90 48    //Output channel 0 is on, other output channels are off
Send: 01 01 00 00 00 08  3D CC
Receive: 01 01 01 41 91 B8 //Output channels 0 and 6 are on, other output channels are off

Write Output Channel Status

Send code: 01 0F 00 00 00 08 01 FF BE D5

Field Description Note
01 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
0F 0F Command Write the output channel status command
00 00 Output Channel Start Address The register address of the output channel to be controlled, 0x0000~0x0007
00 08 Number of output channels The number of the output channels to be controlled, which must not exceed the maximum number of the output channels
01 Byte Number The byte number of the status
FF Output channel status Bit0: the first output channel status;
Bit1: the second output channel 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 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
0F 0F Command Control all registers
00 00 Output Channel Address The register address of the output channel to be controlled, 0x0000~0x0007
00 08 Number of output channels The number of the output channels to be operated
54 0D CRC16 The CRC16 checksum of the first 6 bytes of data

For example: [Address 1 device]

All output channels on: 01 0F 00 00 00 08 01 FF BE D5
All output channels off: 01 0F 00 00 00 08 01 00 FE 95
0-1 on; 2-7 off: 01 0F 00 00 00 08 01 03 BE 94

Output Channel Flash ON/OFF Command

Send code: 01 05 02 00 00 07 8D B0

Field Description Note
01 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
05 05 Command Single control command
02 Command 02: flash on, 04: flash off
00 Output Channel Address The address of the output channel 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 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
05 05 Command Single control command
02 Command 02: flash on, 04: flash off
00 Output Channel Address The address of the output channel 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]

Output channel 0 flash on: 01 05 02 00 00 07 8D B0  //700MS = 7*100MS = 700MS
Output channel 1 flash on: 01 05 02 01 00 08 9C 74  //800MS
Output channel 0 flash off: 01 05 04 00 00 05 0C F9  //500MS
Output channel 1 flash off: 01 05 04 01 00 06 1D 38  //600MS

Read Input Channel Status

Send code: 01 02 00 00 00 08 79 CC

Field Description Note
01 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
02 02 Command Read input status
00 00 Input Start Address The address of the input register, 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
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 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
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
Receive: 01 02 01 00 A1 88    //Inputs are all untriggered
Send: 01 02 00 00 00 08 79 CC
Receive: 01 02 01 01 60 48    //Channel 1 input is triggered, and the rest of channels are not triggered
Send: 01 02 00 00 00 08 79 CC
Receive: 01 02 01 41 61 B8    //Channels 1 and 7 input is triggered, and the rest of channels are not triggered

Read Output Channel Control Mode

Send code: 01 03 10 00 00 08 40 CC

Field Description Note
01 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
03 03 Command Read holding register
10 00 Register Start Address 0x1000 - 0x1007 correspond to 1~8 output 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 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
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 control modes for output channels 1~8, 0x0000~0x0003 indicate four control modes
0x0000: Normal mode, the output channels are directly controlled by commands;
0x0001: Linkage mode, output channel statuses are the same as the corresponding input channel statuses;
0x0002: Toggle mode, the corresponding output channel status toggles once when the input channel inputs a pulse;
0x0003: Edge Trigger Mode, the corresponding output channel status changes once when the input channel level changes once
Note: All modes except Linkage mode support output channel control by command.
E4 59 CRC16 The CRC16 checksum of the first 6 bytes of data

For example: [Address 1 device]

Read output channels 1-8 control mode: 01 03 10 00 00 08 40 CC
Read output channel 1 control mode : 01 03 10 00 00 01 80 CA
Read output channel 2 control mode : 01 03 10 01 00 01 D1 0A
Read output channels 3-5 control mode: 01 03 10 02 00 03 A0 CB

Set Single Output Channel Control Mode

Send code: 01 06 10 00 00 01 4C CA

Field Description Note
01 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
06 06 Command Write single register
10 00 Register Start Address 0x1000 - 0x1007 correspond to output control modes for channels 1~8
00 01 Control Mode Indicates control modes for output channels 1~8, 0x0000~0x0003 indicate four control modes
0x0000: Normal mode, the output channels are directly controlled by commands;
0x0001: Linkage mode, output channel statuses are the same as the corresponding input channel statuses;
0x0002: Toggle mode, the corresponding output channel status toggles once when the input channel inputs a pulse;
0x0003: Edge Trigger Mode, the corresponding output channel status changes once when the input channel level changes once
Note: All modes except Linkage mode support output channel 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 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
06 06 Command Write single register
10 00 Register Start Address 0x1000 - 0x1007 correspond to output control modes for channels 1~8
00 01 Control Mode Output channel 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 output channel 1 as Linkage mode: 01 06 10 00 00 01 4C CA
Set output channel 2 as toggle mode: 01 06 10 01 00 02 5D 0B

Set Multiple Output Channel 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 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
10 10 Command Write multiple registers
10 00 Register Start Address 0x1000 - 0x1007 correspond to output 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 control modes for output channels 1~8, 0x0000~0x0003 indicate four control modes
0x0000: Normal mode, the output channels are directly controlled by commands;
0x0001: Linkage mode, output channel statuses are the same as the corresponding input channel statuses;
0x0002: Toggle mode, the corresponding output channel status toggles once when the input channel inputs a pulse;
0x0003: Edge Trigger Mode, the corresponding output channel status changes once when the input channel level changes once
Note: All modes except Linkage mode support output channel 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 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
10 10 Command Write multiple registers
10 00 Register Start Address 0x1000 - 0x1007 correspond to output 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 channels 1-8 output 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 channels 1-8 output 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 channels 3-5 output as Toggle mode: 01 10 10 02 00 03 06 00 02 00 02 00 02 4A 4B

Set Baudrate Command

Send code: 00 06 20 00 00 05 43 D8

Field Description Note
00 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
06 06 command Set the baud rate and device address
20 00 Command Register 0x2000: set the baud rate; 0x4000: set the device address, 0x8000: read software version
00 Parity Method 0x00: no parity, 0x01: even parity; 0x02: odd parity
05 Baud Rate Value Correspondence of baud rate values
0x00: 4800
0x01: 9600
0x02: 19200
0x03: 38400
0x04: 57600
0x05: 115200
0x06: 128000
0x07: 256000
43 D8 CRC16 The CRC16 checksum of the first 6 bytes of data

Return code: 00 06 20 00 00 05 43 D8

Field Description Note
00 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
06 06 command Set the baud rate and device address
20 00 Command Register 0x2000: set the baud rate; 0x4000: set the device address, 0x8000: read software version
00 Parity Method 0x00: no parity, 0x01: odd parity; 0x02: even parity
05 Baud Rate Correspondence of baud rate values
0x00: 4800
0x01: 9600
0x02: 19200
0x03: 38400
0x04: 57600
0x05: 115200
0x06: 128000
0x07: 256000
43 D8 CRC16 The CRC16 checksum of the first 6 bytes of data

For example: [Address 1 device]

Set the baud rate as 4800: 00 06 20 00 00 00 83 DB
Set the baud rate as 9600: 00 06 20 00 00 01 42 1B
Set the baud rate as 115200: 00 06 20 00 00 05 43 D8

Set Device Address Command

Send code: 00 06 40 00 00 01 5C 1B

Field Description Note
00 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
06 06 command Set the baud rate and device address
40 00 Command Register 0x2000: set the baud rate; 0x4000: set the device address, 0x8000: read software version
00 01 Device Address Set the device address, 0x0001-0x00FF
5C 1B CRC16 The CRC16 checksum of the first 6 bytes of data

Return code: 00 06 40 00 00 01 5C 1B

Field Description Note
00 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
06 06 command Set the baud rate and device address
40 00 Command Register 0x2000: set the baud rate; 0x4000: set the device address, 0x8000: read software version
00 01 Device Address Set the device address, 0x0001-0x00FF
5C 1B CRC16 The CRC16 checksum of the first 6 bytes of data

For example: [Address 1 device]

Set the device address as 0x01: 00 06 40 00 00 01 5C 1B
Set the device address as 0x02: 00 06 40 00 00 02 1C 1A
Set the device address as 0x03: 00 06 40 00 00 03 DD DA

Read Device Address Command

Send code: 00 03 40 00 00 01 90 1B

Field Description Note
00 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
03 03 Command Read the device address
40 00 Command Register 0x2000: set the baud rate; 0x4000: set the device address, 0x8000: read software version
00 01 Byte Number Fixed 0x0001
90 1B CRC16 The CRC16 checksum of the first 6 bytes of data

Return code: 01 03 02 00 01 79 84

Field Description Note
00 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
03 03 Command Read the software version and device address
02 Byte Number The number of bytes returned
00 01 Device Address Set the device address, 0x0001-0x00FF
79 84 CRC16 The CRC16 checksum of the first 6 bytes of data

For example: [Address 2 device]

Send: 00 03 40 00 00 01 90 1B
Receive: 00 03 02 00 02 04 45     //Address: 0x02

Read Software Version Command

Send code: 00 03 80 00 00 01 AC 1B

Field Description Note
00 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
03 03 Command Read the software version and device address
80 00 Command Register 0x2000: set the baud rate; 0x4000: set the device address, 0x8000: read software version
00 01 Byte Number Fixed 0x0001
AC 1B CRC16 The CRC16 checksum of the first 6 bytes of data

Return code: 00 03 02 00 C8 84 12

Field Description Note
00 Device Address 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address
03 03 Command Read the software version and device address
02 Byte Number The number of bytes returned
00 C8 Software Version Converting to decimal and then shifting the decimal point two places to the left will represent the software version
0x00C8 = 200 = V2.00
84 12 CRC16 The CRC16 checksum of the first 6 bytes of data

For example:

Send: 00 03 80 00 00 01 AC 1B
Receive: 03 03 02 00 C8 F1 00       //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:

Return code: 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

Resources

Demo

Software

Related Resources

Project Resources

This section features third - party project resources. We merely provide links and bear no responsibility for content updates or maintenance. Thank you for your understanding.

Miroslav Hrbka-Modbus IO Monitor & Control

FAQ

 Answer:

The device does not require an additional driver download. You can control the device relay's on/off or query the relay status by sending Modbus commands through the device's 485 interface.

{{{5}}}


 Answer:

There is no DIP switch, it can only be set through commands

{{{5}}}


 Answer:

Please refer to Modbus Series BootLoader Description to enter the boot mode, then you can select option 3 to read communication parameters or select option 2 to reset communication parameters

{{{5}}}


 Answer:

Check if the 485 bus is reversed. If not, connect a 120 Ω terminal resistor across the A and B cables

{{{5}}}



 Answer:

Under 5V power supply, the reference power consumption when in standby mode: 0.39W. Please refer to actual conditions for specific power consumption

{{{5}}}



 Answer:
Note: This tutorial is only applicable to hardware versions labeled with "V03 QC. (Versions shipped after June 2024.)"

{{{5}}}


 Answer:
The command must be sent in hex format with a CRC checksum.

1. 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.
2. If the above steps do not resolve the issue, please submit a ticket to contact the Waveshare technical support team.

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