How to Use RevPi as Modbus TCP Master

You can use your RevPi Flat as a Modbus TCP master in order to connect slaves.

You require:

  • RevPi Flat
  • Slave
  • Suitable Ethernet cables and Ethernet switch


  • You have installed a web browser on your PC (e.g. Chrome or Firefox).
  • Your RevPi Flat and your PC are on your network.

Let’s go!

    1. Connect the slaves to your RevPi Flatvia the RJ45 jack.
    2. Specify the IP addresses of the slaves and make a note of it. You may find information on this in the manufacturer”s operating instructions.

If you use multiple slaves, make sure that each slave has its own IP address. If two or more slaves have the same address, communication errors occur.

The Modbus TCP master can exchange data with exactly only one slave. If you use more than one slave, you have to configure the same number of Modbus TCP masters in PiCtory.

  1. Open your web browser.
  2. Enter the IP address of your RevPi Flat in the address bar of your browser.

The login window opens.

Log in with the username “admin”.

  • Enter your password. You can find it on the sticker on the side of your RevPi Flat.
  • Click on “Login”.

You can now see the current device status of your RevPi Flat.

  • Click on the “Services” tab.
  • Click on “Enabled” in the line Enable/Disable Modbus Master.
  • Click on the “Save All” button.

Tip: You can also activate the master function in the command line. Enter the following command: “sudo revpi-config enable pimodbus-master”.

  • Click on the “Apps” tab.
  • Click on the start button behind the entry “PiCtory”.

PiCtory opens.

  • Open the folder “Virtual Devices” in the “Device Catalog”.
  • Select the Modbus TCP master.
  • Hold down the left mouse button and drag the Modbus TCP master onto the grey area with heading “empty” to the right of your RevPi Flat.

The Modbus TCP Master now appears on the right side of the configuration board.


Your Modbus TCP Master is always placed on the far right. If you are using a RevPi gate, which has to be placed on the far right/left outside as well, it will still work. The RevPi Gate is a device physically present which shall be mounted on the very outside of the DIN rail. However, virtual devices such as the Modbus TCP master are not physically present. Therefore you don”t have to create a separate slot for these devices, and PiCtory automatically arranges them outside the devices that are physically present.


  • Click on the Modbus TCP master.
  • Define the basic settings for your adapters in the “Device Data” area. This entry is optional. If you use a lot of devices and wish to process the data in another program later, then this entry can be very helpful.

NOTICE! You need a virtual master for each slave you want to use.

  • Set the basic settings for your TCP connection in the “Value Editor”. You must specify the following values; they are at the bottom of the list:




The IP address of the Modbus TCP slave


The TCP port of the Modbus TCP slave. The default value is “502” according to Modbus specification. If your slave uses a different port, you can change this value here.

  • Right-click on the Modbus TCP master on the configuration board.
  • A context menu opens.
  • Select the entry “Extended Data”.

An input mask opens. You can set the Modbus commands here.



Unit ID

Please look up in the manual of your slave if you have to set this address. Most slaves ignore this address. In this case, it is recommended to set the value 255 (invalid).

Function Code

Modbus has function codes which allow to access data in a certain way. We use the following function codes:

Read single bits

Read single input bit

Read whole input/output register (16 bit)

Read whole input register (16 bit)

Write single bit

Write whole register

Write several consecutive bits

Write several consecutive registers

Register Address

The Modbus register address or bit address of the data you want to access. In the manual of the slave you will find the information how the registers of the slave are assigned. Please note the hint below this table regarding the register address!

Quantity of Registers

Number of registers (or bits) that are read/written

Action Interval

The interval at which the command is sent (in milliseconds)

Device Value

The variable name in the RevPi process image in which the first word or bit of the Modbus command is read or written.

The dropdown menu offers the appropriate target addresses of the process image depending on the selected Function Code.

Make sure that the individual commands do not overlap.


In our products we use 1 as the first register address. Some manufacturers use 0 as the first register address for their products. Check how the addressing is specified for your slave.

If your slave uses 0 as the first register address, you must add 1 to the specified value during configuration. Example: The documentation of the slave indicates the register address 30053. According to the documentation, the addresses start at 0. You shall use the address 30054 for this register when configuring a Modbus command.


  • Click on “File>Save”. This saves your file.
  • Click on “Tools>Reset Driver”. This activates the changes for the adapter.

Do you want to continue using the settings in logiCAD3 or C?

Then click on “File>Export”.

You can choose from two formats:

  • Export 01 creates a file that is suitable for using it in logiCAD3.
  • Export 02 creates an offset list that you can use as basic information for your own C program.
  • Select a format you want to continue working with.
  • Specify a file name.
  • Click on “OK”.


Help! Error!

The Modbus master has predefined Modbus registers for status messages.

If a communication error occurs, the error code is written to the Modbus register “Modbus_Master_Status”.

The error remains in this register until the value “1” is entered manually in the Modbus register “Master_Status_Reset”.

The error codes correspond to the Modbus exception codes as specified in the Modbus specification.

The following table shows the most important error messages.

Error Code





The function code used is not allowed. Check if you are using the correct function code.



The address used is not valid. The register is either read-only or does not exist. Check the address.



At least some of the data values used are invalid. You may have specified too high number of registers, for example. Check your values.



The slave responded with an incomplete packet. This can occur e. g. after the connection has been interrupted. Check your wiring.



The slave did not respond quickly enough or at all. Check your configuration and wiring.

You can find more about this topic in the Modbus specification.