Actions

MD20002 Modbus RTU 16 Relays (EN)

From Modig.pl Wiki

Revision as of 19:15, 31 May 2026 by Grzegorzbecker (talk | contribs) (Created page with "==== Description ==== <b>16-relay card controlled via RS485 and Modbus RTU</b><br> The Modig Modbus 16R module is equipped with 16 SPDT electromagnetic relays, which are controlled using Modbus standard commands transmitted via the RS485 interface. The control interface features galvanic isolation and surge protection, ensuring stable operation even in installations exposed to severe interference. The communication and operational parameters of the module can be f...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

16-relay card controlled via RS485 and Modbus RTU

The Modig Modbus 16R module is equipped with 16 SPDT electromagnetic relays, which are controlled using Modbus standard commands transmitted via the RS485 interface. The control interface features galvanic isolation and surge protection, ensuring stable operation even in installations exposed to severe interference. The communication and operational parameters of the module can be flexibly configured and adapted to the requirements of various applications.





Key Features and Parameters

  • 16 relay outputs - NC/NO contacts, 10 A, 250 V AC / 30 V DC
  • RS485 interface with galvanic isolation and surge protection
  • Configurable communication parameters:
    • baud rate: 1200…1000000;
    • parity: none/even/odd;
    • stop bits: 1/1.5/2
  • Power supply: 5 V (4.9…5.3 V) with a minimum current capacity of 1.5 A
  • Power delivery via USB-C connector, 2.1/5.5 mm DC barrel jack, or Phoenix MC 3.81 mm connector
  • Control and configuration of settings via Modbus commands
  • Measurement of power supply voltage and module temperature
  • Dimensions: 200x110x60 mm
  • Mounting on DIN-35 rail




Relay Connectors

The relay contacts are routed to screw terminals with a 5.08 mm pitch. Each of the 16 outputs offers normally closed (NC) and normally open (NO) contacts. When a given output is turned on, the NO contact is connected to the common contact (COM), while the NC contact is disconnected from COM. The active state for a specific output is indicated by a lit LED located near the terminals of that connector. The layout of individual pin assignments is shown in the figure.


An example circuit controlled using the Modig Modbus 16 Relays is shown in the figure.



RS485 Interface

The RS485 interface is brought out as a 4-pin Phoenix Contact MC 3.81 mm connector. Depending on the installation, only lines A+ and B- or all lines T, A+, B-, and G can be used. Their functions are described in the table.



Designation Function
120 Ω / T Activation of the internal 120 Ω termination

resistor. The resistor is active when terminal T is connected to terminal A+, e.g., using a jumper installed directly inside the plug.

A+ Line A of the RS485 bus (positive potential)
B- Line B of the RS485 bus (negative potential)
GND / G Signal ground GND of the RS485 bus.


The RS485 interface is galvanically isolated from the remaining components and equipped with surge protection elements, ensuring stable operation even in installations exposed to severe interference.



The RS485 communication parameters are configured using Modbus commands; the default settings are: 19200, 8, none, 1.



The Modig Modbus 16R module can be connected to an RS485 bus that links up to 64 devices (including the module). Each device should be connected in a way that prevents bus branching – any stubs should be kept as short as possible. At both ends of the bus, it is recommended to connect 120 Ω termination resistors. Modig Modbus 16R has such a resistor integrated, but to activate it, the A+ and T terminals must be connected together inside the plug.



The figure shows a simplified diagram of the RS485 bus, terminated with a 120 Ω resistor on one end, and with the integrated termination resistor in the module on the other end. Furthermore, correct and incorrect methods of connecting devices to the bus are shown.



Power Supply

The Modig Modbus 16R module is equipped with 3 different power connectors, connected in parallel. Only one of them must be chosen to connect a power supply with a voltage of 4.9…5.3 V, a minimum capacity of 1.5 A, and correct polarity.



Connector Function
USB-C (J3) Standard USB-C socket, serves only a power delivery function
2.1/5.5 (J2) 2.1/5.5 mm DC barrel jack compatible with

"brick-type" power adapters. Note the polarity – center positive.

MC 3.81 mm (J1) Terminal block connector for wire attachment. Note the polarity – positive terminal on the side facing the relays.


LED Indicators

There are two status LEDs on the Modig Modbus 16R board that inform about the device's operation.



Indicator Function
STA A continuously lit LED with brief, cyclic blanking indicates correct operation of the device
BUS A blinking LED indicates data reception from the RS485 bus and Modbus commands





Factory Reset

There is a SET tactile micro-button on the Modig Modbus 16R module board. Pressing and holding it for approximately 5 seconds will restore all settings (configuration register values) to their defaults. This function is useful in situations where incorrect parameter settings prevent sending Modbus commands to the module. Restoring defaults sets the RS485 communication parameters to: 19200, 8, none, 1 and the module address to "1".



Configuration Registers (Holding Registers)

All parameters of the device are defined by the values of configuration registers, known as Holding Registers. These registers can be read and written using Modbus commands to modify the device's operation. The list of registers and their functions are described in the table.



Register Number (hex) Name Description Default Value /

Value Range

x4000 Address Specifies the module address for Modbus command control 1 (x0001)

1…255

x4002 Coils Contains a value specifying the number of outputs

(Coils) available in the module.
Read-only value

16 (x0010)
x4004 Inputs Contains a value specifying the number of inputs (Discrete inputs) available in the module.

Read-only value

0 (x0000)
x4006 Baud Specifies the RS485 communication speed (baud rate).
Value without the last 2 zeros, e.g.:

1200 = 12 = x000C; 2400 = 24 = x0018

4800 = 48 = x0030; 9600 = 96 = x0060

19200 = 192 = x00C0; 57600 = 576 = x0240

115200 = 1152 = x0480;

256000 = 2560 = x0A00

192 (x00C0)

12…10000

x4008 Parity Specifies the parity for RS485 communication.
0 - none; 1 - even; 2 - odd
0 (x0000)

0…2

x400A Stop Specifies the number of stop bits for RS485 communication.

1 - 1 stop bit; 2 - 2 stop bits

1 (x0001)

1…2

x400C Broadcast Defines whether the device executes

commands with the broadcast address value of 0 (x00). 0 - no, 1 - yes

1 (x0001)

0…1

x400E CRC Defines whether the device verifies the checksum in Modbus commands. 0 - no, 1 - yes 0 (x0000)

0…1

x4010 Response Enables sending responses to Modbus commands.

0 - does not send any responses,

1 - sends responses to Modbus commands

1 (x0001)

0…1

x4012 IO Offset Specifies the starting index for inputs and outputs (coils)

0 - inputs/outputs start from 0 (0…15)

1 - inputs/outputs start from 1 (1…16)

1 (x0001)

0…1

x4014

and

x8000

Version Contains the firmware version.

A value of 10 indicates version 1.0, etc.

Read-only value

10 (x00A0)
x2000 ExBaud Allows setting communication parameters using one of the predefined values.

The low byte corresponds to the baud rate:

0 - 4800, 1 - 9600, 2 - 19200, 3 - 38400

4 - 57600, 5 - 115200, 6 - 12800, 7 - 256000

8 - other value

The high byte specifies the parity:

0 - none, 1 - even, 2 - odd

x0002

x0000…x0208




Measurement Input Registers (Input Registers)

The device is equipped with measurement circuits for power supply voltage and temperature, which allow monitoring of the module's operating conditions to prevent failures. The measurement results are available in the measurement input registers, known as Input Registers. These registers can be read using Modbus commands.



Register Number (hex) Name Description Value Range
x3000 Voltage Measurement of the power supply voltage. A value of 495 = 4.95 V, etc. 330…550
x3002 Temp Measurement of the module temperature. A temperature value of 24 (x0018) indicates 24 degrees C.

Temperature range: -20…-1 is stored as xFF14…xFF01

Temperature range: 0…70 is stored as x0000…x0046

-20…-1 *C =

xFF14…xFF01

0…70 *C =

x0000…0046




Modbus Standard Control Commands

Each command in the Modbus standard takes the form of a data frame, the structure of which is shown in the figure:

Consecutive frames must be separated by an interval of at least 3.5 character times (the time required to transmit a full ASCII character), whereas the interval between transmitting one character and starting the transmission of the next within the same frame must not exceed 1.5 character times. These rules apply for communication speeds (baud rates) up to 19200.



If the communication speed is set above 19200, the minimum interval between frames has a fixed value equal to 1.75 ms. Meanwhile, the interval between consecutive characters of the same frame must not exceed 0.75 ms.



Each device connected to the Modbus bus must be assigned a unique address. The address field is present in every transmitted frame, has a size of 1 byte, and can have a value in the range of 1…255. An address value of 0 is the so-called broadcast address and allows directing a command to all devices connected to the bus. In some systems, it is recommended not to set addresses above the value of 247.



Outputs and inputs are standardly numbered from 1. In this case, the first output is output number 1 (x01), and the last one is number 16 (0x10). The command descriptions and command examples refer specifically to this variant. However, the device can be configured in such a way that the outputs and inputs are numbered from 0. In that case, the first output is output number 0 (x00), and the last one is number 15 (0x0F). If the output number referenced by the control/read command exceeds the number of outputs contained in the device (15 or 16, depending on configuration), the command will not be executed and will remain unanswered.



The Modbus standard includes several standard commands. Each of them, along with example commands and device responses, is described in the subsequent section of this manual.



List of Supported Modbus Commands

Command Name Command Code Function
Write Single Coil x05 Allows controlling the state of an output or outputs
Write Multiple Coils x0F Allows controlling the state of multiple outputs simultaneously, both turning specific outputs ON and OFF.
Read Coils x01 Allows reading the state of an output or outputs
Read Discrete Inputs x02 Allows reading the state of inputs. Since the

Modig Modbus 16R device does not have inputs for reading states, it reads the state of the outputs in response to this command, similarly to the “Read Coils” - x01 command.

Read Input Registers x04 Allows reading values from the measurement input registers
Read Holding Registers x03 Allows reading values from the configuration registers
Write Single Holding Register x06 Allows setting a value in a configuration register
Write Multiple Holding Registers x10 Allows setting values in several configuration registers



“Write Single Coil” Command - x05


The x05 command allows controlling the state of an output or outputs.


Data frame with x05 command 01 05 00 00 FF 00 8C 3A
Byte Number Value (hex) Meaning
1 x01 Target device address
2 x05 “Write Single Coil” command - control of a single output
3…4 x0000 Number of the output to be controlled:

0 - none of the outputs, 1 - output 1 (first), 16 - output 16 (last)

x00FF - controls all outputs - from 1 to 16

5…6 xFF00 Value specifying the task to be executed:

x0000 - turn off (OFF), xFF00 - turn on (ON),

x5500 - toggle state to the opposite (TOGGLE) ON->OFF / OFF->ON

7…8 x8C3A CRC16 checksum
Response The device that reads and executes

the command will send an identical frame in response:
01 05 00 00 FF 00 8C 3A


Similar commands:

  • A5 05 00 08 55 00 6A 7C - x05 command to the device with address 165

(xA5), output no. 8 (x0008) will toggle its state (x5500)

Response: A5 05 00 08 55 00 6A 7C


  • 14 05 00 10 00 00 CE CA - x05 command to the device with address 20

(x14), output no. 16 (x0010) will be turned OFF (x0000)

Response: 14 05 00 10 00 00 CE CA


  • 29 05 00 FF FF 00 BA 22 - x05 command to the device with address 41

(x29), all outputs (x00FF) will be turned ON (xFF00)

Response: 29 05 00 FF FF 00 BA 22




“Write Multiple Coils” Command - x0F


The x0F command allows controlling the state of multiple outputs simultaneously, both turning specific outputs ON and OFF.



Data frame with x0F command 01 0F 00 01 00 03 02 00 05 27 76
Byte Number Value (hex) Meaning
1 x01 Target device address
2 x0F “Write Multiple Coils” command - control of multiple outputs
3…4 x0001 Number of the output from which control will begin:

0 - none of the outputs will be controlled,

1 - from output 1 (first), 16 - from output 16 (last)

5…6 x0003 Number of outputs to be controlled:

0 - none of the outputs will be controlled

1 - one output, 16 - to control 16 outputs

7 x02 Number of data bytes containing the control sequence - must be 2
8…9 x0005 Control sequence, LSB -> output no. 1.

Bits with a value of 0 cause outputs to turn off,

bits with a value of 1 cause outputs to turn on.

x0005 = 00000000 00000101 - outputs 1 and 3 turned ON

10...11 x27 76 CRC16 checksum
Response The device that reads and executes the command will send the following frame in response:


01 0F 00 01 00 03 44 0A

1 x01 Address of the responding device
2 x0F “Write Multiple Coils” command - output control
3...4 x0001 Number of the output from which control was initiated
5...6 x0003 Number of outputs that were actually controlled
7...8 x440A CRC16 checksum


If the number of outputs to be set exceeds the number of outputs contained in the device (after considering the starting output number from which control begins), the command will be executed correctly for the existing outputs. The response will return the number of outputs actually controlled.



Similar commands:

  • A5 0F 00 08 00 04 02 00 07 6D 9D - x0F command to the device with

address 165 (xA5), controls 3 (x0003) outputs starting from output no. 8 (x0008),

the control sequence is: x0007 (00000000 00000111), meaning it will turn ON outputs
8, 9, 10 and turn OFF output 11.
Response: A5 0F 00 08 00 04 CC EE
  • 14 0F 00 0F 00 05 02 00 00 14 43 - x0F command to the device with

address 20 (x14), controls 5 (x0005) outputs starting from output no. 15 (x000F),

the control sequence is: x0000 (00000000 00000000), meaning it will turn OFF outputs
15 and 16.
Response: 14 0F 00 0F 00 02 E6 CC (2 outputs controlled instead of 5)
  • 29 0F 00 01 00 10 02 FF FF 1C 40 - x0F command to the device with

address 41 (x29), controls 16 (x0010) outputs starting from output no. 1 (x0001),

the control sequence is xFFFF (11111111 11111111), meaning it will turn ON all
outputs from 1 to 16.
Response: 29 0F 00 01 00 10 03 EF




“Read Coils” Command - x01


The x01 command allows reading the state of an output or outputs.



Data frame with x01 command 01 01 00 02 00 04 9C 09
Byte Number Value (hex) Meaning
1 x01 Target device address
2 x01 “Read Coils” command - reading output states
3…4 x0002 Number of the output from which reading of output states will begin:

2 - read starting from output no. 2

5…6 x0004 Value specifying how many outputs will be read:

4 - reading 4 outputs, namely: 2, 3, 4, and 5

7…8 x9C09 CRC16 checksum
Response The device that reads and executes

the command will send the following frame in response:
01 01 02 00 0C B9 F9

1 x01 Address of the responding device
2 x01 “Read Coils” command - reading output states
3 x02 Number of data bytes containing the response - 2
4…5 x000C Output states: 2 - OFF (0), 3 - OFF (0), 4 - ON (1), 5 - ON (1)

Binary: 00000000 00001100

6…7 xB9F9 CRC16 checksum


Similar commands:

  • A5 01 00 08 00 06 6A 7C - x01 command to the device with address 165

(xA5), reading the state of 6 (x0006) outputs, starting from output 8 (x0008).

Response: A5 01 02 00 02 49 E4 - only output no. 9 is active (x0002)


  • 14 01 00 10 00 01 CE CA - x01 command to the device with address 20

(x14), reading the state of one (x0001) output, starting from output 16 (x0010).

Response: 14 01 02 00 00 B4 3F - output turned off (x0000)


  • 29 01 00 20 01 00 BA 06 - x01 command to the device with address 41

(x29), reading the state of 16 (x0010) outputs, starting from output 32 (x0020).

Response: no response - cannot read states starting from output 32


If the number of outputs to be read exceeds the number of outputs contained in the device (after considering the starting output number from which the status reading begins), non-existent outputs in the response will always have an OFF (0) state.





“Read Discrete Inputs” Command - x02


The x02 command allows reading the state of inputs. Since the Modig Modbus 16R device does not have inputs for reading states, it reads the state of the outputs in response to this command, similarly to the “Read Coils” - x01 command.



Data frame with x02 command 01 02 00 02 00 04 D8 09
Byte Number Value (hex) Meaning
1 x01 Target device address
2 x02 “Read Discrete Inputs” command - reading input states
3…4 x0002 Number of the input from which reading of input states will begin:

2 - read starting from input no. 2

5…6 x0004 Value specifying how many inputs will be read:

4 - reading 4 inputs, namely: 2, 3, 4, and 5

7…8 xD809 CRC16 checksum
Response The device that reads and executes

the command will send the following frame in response:
01 02 02 00 0C B9 BD

1 x01 Address of the responding device
2 x02 “Read Discrete Inputs” command - reading input states
3 x02 Number of data bytes containing the response - 2
4…5 x000C Input states: 2 - inactive (0), 3 - inactive (0), 4 - active (1), 5 - active (1);

Binary: 00000000 00001100

6…7 xB9BD CRC16 checksum


Similar commands:

  • A5 02 00 08 00 06 60 EE - x02 command to the device with address 165

(xA5), reading the state of 6 (x0006) inputs, starting from input 8 (x0008).

Response: A5 02 02 00 02 49 A0 - only input no. 9 is active (x0002)


  • 14 02 00 10 00 01 BA CA - x02 command to the device with address 20

(x14), reading the state of one (x0001) input, starting from input 16 (x0010).

Response: 14 02 02 00 00 B4 7B - input inactive (x0000)


  • 29 02 00 20 01 00 7E 78 - x02 command to the device with address 41

(x29), reading the state of 16 (x0010) inputs, starting from input 32 (x0020).

Response: no response - cannot read states starting from input 32


If the number of inputs to be read exceeds the number of inputs contained in the device (after considering the starting input number from which the status reading begins), non-existent inputs in the response will always have an inactive (0) state.




“Read Input Registers” Command - x04


The x04 command allows reading values from the measurement input registers. The Modig Modbus 16R device supports measurement of the power supply voltage and the module temperature.



Data frame with x04 command 01 04 30 00 00 02 7E CB
Byte Number Value (hex) Meaning
1 x01 Target device address
2 x04 “Read Input Registers” command - reading measurement input registers
3…4 x3000 Number of the register from which reading will begin.

x3000 - reading the power supply voltage measurement

x3002 - reading the module temperature measurement

5…6 x0002 Value specifying how many registers will be read:

1 - one, e.g., voltage only; 2 - both measurement registers

7…8 x7ECB CRC16 checksum
Response The device that reads and executes

the command will send the following frame in response:
01 04 04 02 06 00 18 1A 37

1 x01 Address of the responding device
2 x04 “Read Input Registers” command - reading measurement input registers
3 x04 Number of data bytes containing the response - 4
4…5 x0206 Voltage value - x0206 = 518, which means 5.18 V
6…7 x0018 Temperature value - x0018 = 24, which means 24 degrees C

Temperature range: -20…-1 is stored as xFF14…xFF01

Temperature range: 0…70 is stored as x0000…x0046

8…9 x1A37 CRC16 checksum


Similar commands:

  • A5 04 30 00 00 01 27 EE - x04 command to the device with address 165

(xA5), reading one register (x0001) numbered x3000, i.e., the power supply voltage measurement register.

Response: A5 04 02 01 F0 49 A0 - voltage is 4.96 V (x01F0 = 496)


  • 14 04 30 08 00 02 FD CC - x04 command to the device with address 20

(x14), reading two (x0002) measurement registers starting from number x3008.

Response: no response - there is no measurement register with the number x3008.


  • 29 04 30 02 00 02 7E 78 - x04 command to the device with address 41

(x29), reading two (x0002) measurement registers starting from number x3002.

Response: A5 04 02 00 18 C8 E3 - the device has no measurement registers

higher than x3002, therefore only one register was read (number x3002) - module temperature = 24 (x0018), and the response contains only two data bytes (x02)




“Read Holding Registers” Command - x03


The x03 command allows reading values from the configuration registers.



Data frame with x03 command 01 03 40 00 00 01 91 CA
Byte Number Value (hex) Meaning
1 x01 Target device address
2 x03 “Read Holding Registers” command - reading configuration registers
3…4 x4000 Number of the register from which reading will begin.

Available registers are in the ranges x4000…x4014 as well as x2000 and x8000

5…6 x0001 Value specifying how many registers will be read:

1 - one, etc., up to a maximum of 8

7…8 x91CA CRC16 checksum
Response The device that reads and executes

the command will send the following frame in response:
01 03 02 00 01 79 84

1 x01 Address of the responding device
2 x03 “Read Holding Registers” command - reading configuration registers
3 x02 Number of data bytes containing the response - 2
4…5 x0001 Register number x4000 contains the address for Modbus commands, which in this case is 1 (x0001)
6…7 x7984 CRC16 checksum


Similar commands:

  • A5 03 40 06 00 04 28 EE - x03 command to the device with address 165

(xA5), reading four configuration registers (x0004) starting from number (x4006).

Response: 01 03 08 00 C0 00 00 00 01 00 01 C5 DB - values of 4 configuration registers, meaning 8 data bytes


  • 14 03 80 00 00 01 AF 0F - x03 command to the device with address 20

(x14), reading one (x0001) configuration register numbered x8000, i.e., the firmware version.

Response: 14 03 02 00 A0 B5 FF - response of 2 bytes (x00A0) = 10, indicating firmware version 1.0




“Write Single Holding Register” Command - x06


The x06 command allows setting a value in a configuration register.



Data frame with x06 command 01 06 40 00 00 01 5D CA
Byte Number Value (hex) Meaning
1 x01 Target device address
2 x06 “Write Single Holding Register” command - writing a configuration register
3…4 x4000 Number of the register to which the new value will be written.

Available registers are in the ranges x4000, x4006…x4012, and x2000

5…6 x0001 Value to be written to the register
7…8 x5DCA CRC16 checksum
Response The device that reads and executes

the command will send an identical frame in response:
01 06 40 00 00 01 5D CA


Similar commands:

  • A5 06 40 00 00 04 84 ED - x06 command to the device with address 165

(xA5), writing a value of 4 (x0004) to the configuration register numbered x4000, i.e., assigning a new address of 4.

Response: A5 06 40 00 00 04 84 ED


  • 14 06 40 0C 00 00 5E CC - x06 command to the device with address 20

(x14), writing a value of 0 (x0000) to the configuration register numbered x400C, i.e., disabling broadcast command handling.

Response: 14 06 40 0C 00 00 5E CC




“Write Multiple Holding Registers” Command - x10


The x10 command allows setting values in several configuration registers.



Data frame with x10 command 01 10 40 0C 00 03 06 00 01 00 00 00 01 8F 7E
Byte Number Value (hex) Meaning
1 x01 Target device address
2 x10 “Write Multiple Holding Registers” command - writing several configuration registers
3…4 x400C Number of the register from which writing will begin.

Available registers are in the ranges x4000, x4006…x4012, and x2000

5…6 x0003 Value specifying how many registers will be written:

1 - one, etc., up to a maximum of 8

7 x06 Number of data bytes containing the values to be written
8…13 x0001
x0000
x0001
Three values to be written into the configuration registers
14…17 x8F7E CRC16 checksum
Response The device that reads and executes

the command will send the following frame in response:
01 10 40 0C 00

03 55 CB
1 x01 Address of the responding device
2 x10 “Write Multiple Holding Registers” command - writing several configuration registers
3...4 x400C Number of the register from which the value writing was initiated
5...6 x0003 style="text-align