Modbus TCP Client configuration example

From Teltonika Networks Wiki
Revision as of 18:41, 4 April 2022 by Ricardo.Zambrano (talk | contribs) (Configuring a Modbus Master to get data from a slave device with RutOS.)

(diff) ← Older revision | Approved revision (diff) | Latest revision (diff) | Newer revision → (diff)

Summary

Modbus TCP Master section is used for configuring your router as a master device and other routers configured in this section as slave devices. A Modbus TCP master device can then request data from these Modbus TCP slaves.

First, let’s configure our second router which will be acting as a slave device.

Configure Modbus TCP slave device

In this example, we would be configuring our slave device to have a 192.168.1.2 internal IP address. This can be done by changing the IP address parameter on Network->WAN page:

Slave Device Wan Configuration
Slave Device Wan Configuration Pop menu

Now we need to enable Modbus service for this slave device as we will open a specific port for letting through TCP communications (it is also possible to 'Allow remote access' if we wish to access this router from external WAN using its public IP). This is done on Services->Modbus page:

Modbus Slave Configuration

Configuring Modbus TCP master device

Adding a new slave device

On the master device (in this example master device has 192.168.1.1 internal IP address) open Services->Modbus->Modbus TCP Master. To add a new slave, first, click the add button.

Modbus Slave configuration on Master device

Once you have clicked that button, enter the following configuration so we can add the slave device:

Modbus Slave Configuration on Master Device Pop Menu

Scroll down and click “Save and Apply”

Save and Apply

After this, this is how your main Modbus Master panel should look:

Modbus Slave Configuration on Master Device

Testing

For testing, if the functionality is working we can configure a request. A Modbus request is a way of obtaining data from Modbus slaves. The master sends a request to a slave specifying the function code to be performed. The slave then sends the requested data back to the Modbus master. You can create a maximum of 64 request configurations for each slave device. First, click the edit button:

Modbus Slaves

Scroll down to the “Request configuration” section.

Request Configuration

Write a name for the request and click the “Add” button.

Add new request

And enter a data type, a function, first register, number of registers, if you need brackets or don’t and enable the request. In this case we are trying to get System uptime information so configure the next options:

Configuring Request

Under the “Request Configuration” section there will be another section called “Request Configuration Testing” this is where you can test that the parameters that you set work properly. Just select the request that you want to test and click the test button and you should get and output.

Testing Configuration

Alarms

Alarms are a way of setting up automated actions when some Modbus values meet user-specified conditions. To configure these alarms, scroll to the end of the menu and click the “Add” button.

Alarm Configuration

After clicking the “Add” button the next menu should come up:

Alarm Configuration Menu