Introduction
Modbus TCP is a widely used Ethernet-based industrial fieldbus protocol with a master/slave architecture. A common use case for a B&R PLC is to be able to read data from some field devices over Modbus TCP, in which case the B&R PLC is used as a Modbus master. This short guide walks you through how to configure your PLC as a Modbus TCP master and start reading data from your field devices (Modbus slaves).
This guide is based on the following Help section: B&R Online Help
Step 1 - Activate and Modbus TCP Master on the PLC
The first step is to configure your PLC’s Ethernet interface as a Modbus TCP master. This is done with a few simple steps:
-
In the Automation Studio project, navigate to the Physical View and open the “Configuration” of the ETH port (IF2 of the PLC in this example) that you are using to connect to the Modbus TCP slave.
-
Set the IP address settings such that the PLC (Modbus TCP Master) will be able to communicate with the Modbus TCP Slave. In this example, the Modbus TCP Slave has the IP address 192.168.1.42 (subnet 255.255.255.0), so the Modbus TCP Master IP address will be set to a static IP address of 192.168.1.30.
- If the Modbus TCP Slave is connected to a larger network that uses a DHCP server, you can simply leave the IP address as the default “get IP address from DHCP server” and make sure you are connected to the same network as the slave.
-
Toward the bottom of the PLC Ethernet port Configuration, under "Modbus parameters, set “Activate Modbus communication” = “on” and then “Use as Modbus master” = “on”.
-
Your PLC is now ready to be used as a Modbus TCP master! Next step is to configure the Modbus slave(s).
For information on the “Diagnostics” parameters see the following Help page: B&R Online Help
Step 2 - Configure Modbus TCP Slave(s)
Modbus TCP slaves are added to the Physical View as generic Modbus TCP devices, which are called “ModbusTcp_any” in the Toolbox. These Modbus TCP Any modules allow you to configure the settings of the slave in Automation Studio to match the settings on the actual Modbus device and then easily read from them and assign them to Process Variables via the I/O mapping (Step 3).
Here are the steps to add and configure the “ModbusTcp_any” device(s):
-
In the Physical View, select the “ETH” interface that you configured as a Modbus TCP Master.
-
Open the “Toolbox” (should be open on the far right already, if not it can be opened by “View > Toolbox”) and Search for “ModbusTcp_any”. Double-click it, or drag it onto the ETH interface, to add it to the project.
-
Make sure that the Node Number (“Position”) is unique within the ETH interface. Since this is Modbus TCP and not RTU, the Node Number (or Address in Modbus terms) should not matter. It is only important that there are no duplicate Node Numbers (if needed, you can change the Node Number by selecting it, hitting the space bar, changing the number, and hit ENTER to save). This will only apply if you have multiple Modbus TCP or other Ethernet devices connected.
-
If desired, you can rename the Modbus TCP slave by selecting the Name, hitting space bar, entering your name, and saving with ENTER.
-
To Configure the Modbus TCP Slave, right-click on it and select “Configuration”. Set the network settings as follows:
-
Mode: Internet address (IP address) or Host name can be selected. Using Internet address is most common.
-
IP address: Enter the IP address of the Modbus TCP Slave. For this example, the slave is on IP address 192.168.1.42, so that is what is configured for the ModbusTcp_any device.
-
Unit identifier: From the Help: If the slave is not used as a Modbus RTU slave (serial Modbus), the value 0, 1 or 255 must be set here. This is manufacturer independent.
If communication with Modbus RTU slaves also takes place using a Modbus TCP/RTU gateway, the corresponding Unit ID for the serial Modbus slave must be configured. -
TCP port: Default is 502 (standard Modbus TCP port), however sometimes this port will change (e.g. if using a gateway), so make sure to check the documentation of the Modbus TCP slave the network configuration where it is installed to make sure you are using the right port.
-
Number of pending requests: It is recommended to leave this at the default 1.
-
-
The Timeouts settings can be left at the default values.
-
The Channel Configuration is where the different register blocks are defined to match Modbus register map of the Modbus TCP slave. The Help has a helpful example of how to configure the Modbus channels to match the register map of a 3rd-party Modbus TCP slave: B&R Online Help
-
Note 1: For the “Number of items” parameter, you can either define a set number of registers to read, or you can set it to “0” and it will automatically calculate the number of registers to read based on the number and size of the datatypes of the Channels you configured.
-
Note 2: Please observe the following warnings in the Help regarding byte swapping when using 4-byte (e.g. UDINT) or 8-byte (e.g. LREAL) Channel datatypes.


-
-
In this example, the following Channels are configured:
-
At this point, the Modbus TCP Slave is configured and ready to be connected to Process Variables.
For information on configuring the Modbus TCP slave, see the following Help page: B&R Online Help
Step 3 - Connect Modbus TCP Slave data to PVs using I/O Mapping
To connect the data from the Modbus TCP Slave, you can use the I/O Mapping of the ModbusTcp_any device that you just configured. Here are the steps to do so.
-
Open the “I/O Mapping” of the Modbus TCP Slave (ModbusTcp_any device) by right-clicking and selecting “I/O Mapping” or simply double-clicking on the ModbusTcp_any device.
-
At the bottom of the I/O Mapping file, you will see the Channels that you configured in the previous section.
-
To map a variable to each channel, double-click on the empty space in the “Process Variable” column for the desired channel, and select the “…” bubble. This will pull up a list of possible Process Variables to assign (they will have the same datatype as what was configured on the channel). Select the desired Process Variable and then select “Ok”.

-
Repeat this for all configured channels.

-
The Modbus TCP Slave channels have been successfully mapped to Process Variables and can be used in the application program.
For information on setting up the I/O mapping of the Modbus TCP slave, see the following Help page: B&R Online Help
Step 4 - Testing and Validation
The final step is to test and see if the connection and data collection are working properly. You can do this using Monitor Mode while on the I/O Mapping. See the following “Diagnostics for the master” Help page for various troubleshooting and diagnostics tools in case you run into issues: B&R Online Help
Here is a B&R Community post describing general I/O datapoints that can be useful for diagnostics: Helpful I/O Datapoints for Machine Diagnostics - #2 by hubert.brunner
Finally, remember to check the Logger (specifically the “Communication” Logger module) as well as this contains error messages that can help with troubleshooting.
Other Resources
There is more to learn about Modbus TCP in the B&R ecosystem. Here are a few additional Help and Community links that could be helpful:
- The AsMbTcp library can also be used to programmatically collect data from configured Modbus TCP Slaves. See the documentation for more information: B&R Online Help
- B&R Community post about various communication protocols, including Modbus TCP: Communication Protocol Devices
- Configuring the B&R PLC as a Modbus TCP master and slave: Using ETH port as Modbus Master and Slave
- Advanced configuration and troubleshootnig of the ModbusTcp_Any device: Can I use "Modbus TCP Any" as a TCP Server in a Gateway Configuration? - #5 by Gyun













