Knowledge Base

Welcome to OPAL-RT’s Knowledge Base

OPAL-RT offers a repository of support information for optimal use of its technology.

Please note that OPAL-RT knowledge base is not fully optimized for mobile platforms.

For optimal experience, use a desktop computer.

Reference Number: AA-02091 // Views: 8 // Created: 2022-09-09 15:21:25 // Last Updated: 2022-09-30 19:39:53
HowTo
How to use Modbus with OPAL-Boards

How to use Modbus with OPAL-Boards

Setting up the Modbus Driver

Our OPAL-Boards workflow provides a flexible and easy to use workflow which allows you to map any of your IO ports or communication protocols within your model. Basic knowledge of how to set up OPAL-Boards is recommended before using Modbus, so please take a moment to read through this article: How To use Opal-RT Boards

You will follow most of the steps outlined in the above article, but when you get to the section labeled "I/O Interface", choose Modbus Master or Slave instead of OPAL-RT Board.

Once you've added the Modbus device, the Configuration tab will look like this:

After you've built your model, a list of all of the OpInput and OpOutput boards in the model will appear in the OpInputs & OpOutputs section. Click and drag the OpInputs and OpOutputs to their corresponding Modbus components (coils, registers, etc.).

There are also Modbus example models available in RT-Lab. If you create a project in RT-Lab, you can find them under IO > _Generic_ > Modbus_Master OR Modbus_Slave.

Testing the Modbus Driver

In this section, we will test the Modbus driver in two ways: configuring the target to run as a Modbus slave, and configuring the target to run as both a Modbus master and Modbus slave.

Configuring the target as a Modbus Slave

We will use an application called qModMaster (you can download it from here) to receive Modbus messages from our target that is running the Modbus slave example program, but you can use any external Modbus master program you like. Once you have downloaded qModMaster (or an alternative Modbus master program), import the Modbus slave example model using the directions above. If you open the project and look in the I/O Interfaces and expand Modbus Slave, you will see two slave drivers listed: one for TCP, and one for RTU. We will focus only on the TCP one for this example.

Put the address of your target simulator as the IP address, choose a port, and make sure the NIC name matches your target's. In this example, the TCP port was changed to 502, but the default value will also work as long as the port number is the same in the qModMaster program. You can check what the NIC names of your target are by right clicking on your target, choosing Execute > Command, and then typing in "ifconfig" and pressing Enter:

Once you've entered in your target simulator's IP address and port information, build, load, and execute your model. You should see this information during the loading process in RT-Lab:

Open the qModMaster program, click on Options > Modbus TCP settings, and enter in your target simulator's IP address and port number: