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-01393// Views: AA-01393// Created: 2018-02-13 18:19:18// Last Updated: 2018-03-21 15:44:42
HowTo
How to test RT-LAB Slave Modbus: updating the Output registers with a Python-based master

How to test RT-LAB Slave Modbus: Reading and writing registers with a Python-based master

This RT-LAB model and python script  demonstrate sub second refreshing rate of the Modbus Slave output registers in RT-LAB (besides all the other read write functions for SlaveModbus). The RT-LAB model "modbus_slave.mdl.mdl" runs the SlaveModbus implementation while the python script "Modbus_TCP_Master_script.py" emulates a MasterModbus.


The test updates incrementally 3 output registers from [1 to 1000], [6 to 1006] and [ 11 to 1011] respectively:


 Execute the script: output registers in the SC console should be updated continuously during 100 seconds: roughly 1 update per 0.1 seconds, the maximum update rate will vary depending on the particularities of your network and the own specification of the Modbus protocol. This update rate can be configured in the python script:



All necessary files are contained in the attached file. 

You need to have the next software configuration to run the script:

 Test requirement:

-    pymodbus 1.2.0 (https://github.com/bashwork/pymodbus)

-    Microsoft Visual C++ 9.0 (http://aka.ms/vcpython27)

-    Python 2.7


You also need to set the Modbus slave IP to whichever IP your target uses in line 20 of the script:



Compile the attached model within RT-LAB and execute. Open a CMD window in the location of the “Modbus_TCP_Master_script.py”, execute the script from the opened CMD window.



Modbus_RTLABSlave_PYTHONmaster.rar 23.2 Kb 23.2 Kb