Support : Knowledge base

Knowledge Base

Welcome to OPAL-RT’s Knowledge Base

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

Loading…

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

For optimal experience, use a desktop computer.

Reference Number: AA-02120// Views: AA-02120// Created: 2023-01-06 00:39:36// Last Updated: 2023-01-09 23:31:31
HowTo
How to verify HYPERSIM's Modbus slave connection through third party software acting as Modbus master (HYPERSIM v2019.1+)

How to verify HYPERSIM's Modbus slave connection through third party software acting as Modbus master

To implement a Modbus slave communication in HYPERSIM, the I/O interface configuration tool provides an easy tool to manage the 'bridge' between the software and external hardware through the real-time simulator. If you are not familiar with I/O Interface Configuration tool in HYPERSIM, please go through the following article: https://www.opal-rt.com/support-knowledge-base/?article=AA-01778 

This article deals with the following standard registers used in Modbus:
1) Coils
2) Discrete inputs
3) Input registers
4) Holding registers

We will configure the interface to over TCP/IP using an ethernet physical link. The workflow is shown as follows:

First we will design the Modbus slave model in HYPERSIM (you can also download the HYPERSIM project attached at the end of this page). While in I/O interface configuration, add a "Modbus Slave" by right clicking on "Modbus Slave>Add"

After opening the Modbus slaves, we can configure the Mode to be either TCP or RTU, for this example, we will select TCP. Next, we need the network interface card name used to specify the communication point between the master and the slave. In this case, since the modbus master is on the local host PC connected to the slave model running on the target, therefore, it will be IP address of the target which is usually equivalent to eth0. To see which port NIC you are connected to, please refer to the link below: https://www.opal-rt.com/support-knowledge-base/?article=AA-01070. Take note of the TCP port number as well. 



Now we can specify the number and type of registers on the basis of Address, Initial Value and whether control is from Model or Master (Write Coils/Write Holding Registers). 
 

After specifying the above information, click on "Apply" and "Ok" . 

 

Once the I/O Interface Configuration has been configured for Modbus slave, the communication will be available for assignation through the sensor form of the block of interest. 



After configuring and assigning the Modbus slave for the target model, we can execute the model. Now, we will use an application called qModMaster (downloadable here: https://sourceforge.net/projects/qmodmaster/) to act as the external Modbus master. After downloading qModMaster, we can run the program and click on Options > Modbus TCP settings. and enter in your target simulator IP address and port number. 


After inputting the IP address and the port number which was same as the information set for I/O configuration in the HYPERSIM Slave model, click on options>settings and set base addr to 0. Afterwards, click on the connection icon 


Afterwards, click on the connection icon to establish connection. 


After fixing the start address, we can see the value being obtained by the master from the read coil register when we click on scan and we can change the value in HYPERSIM parameter window to observe the changes. Here are some examples.





For these addresses of registers, the control of the change of value is from the HYPERSIM model itself, however, in the IO configuration of the HYPERSIM, we can change some of the registers' control to write values from the master (which is the qmodmaster application in this case) or even both as shown below:

Now for master control, we first take note of the variable which is being controlled for that specific register (single coil in this case) so we can visualize the change in ScopeView



For the first case of coil registers, we will visualize the value as shown below. We can see the initial value of 1 as set in the I/O configuration shown above for Address 40 of Coil 11
 
Now, lets change the master value in qmodmaster as shown below and see the effect of the change from master this time in order to write the value of the coil.



Next, we do the same for holding register address 50, the initial value is set to 50 as shown below:


Similarly, we change the value to 25 for the holding register Address 50 and observe the change in ScopeView


We can also write multiple registers from the master as well. For the case of Multiple Coils, Coils with address 60,61,62,63,64 are initialized in the I/O configuration of HYPERSIM as 0.
 
Similarly for writing multiple registers, we can run the model again and observe the output in ScopeView






MODBUS_SLAVE.zip 37.7 Kb 37.7 Kb