Browse FAQs

is there an example of a MBP_MSTR function block to send Modbus messages (sub function 15)

Published date: 19 November 2020

The TCP/IP communications can be confusing to program using Unity, since they vary from PAC family to family. This is one of a series of example applications that presents each function block in a working version for the user to build on. This is a simple example of an MBP_MSTR write Modbus message (function 15) TCP/IP communication for Quantum

Product Line
Quantum, M580, Control Expert, Unity Pro

Windows 7, Windows 10

The attached application mbpmstrf15.zef will send a user configured Modbus message. Function 15 can be used to send any Modbus message. This example is parallel to the one described in Unity Help and sends a read input message. That is Modbus function code 4.  The application consists of four sections. The first is an ST section in which variables are initialized and the Modbus request is entered in the data buffer.
The second section is a LD section which uses an MBP_MSTR function block to send the Modbus message to another device, the server. The IP of the server is This should be changed to suit your own addressing scheme. There is also code in that section to time the response. The MBP_MSTR block does not contain a timeout. It is good practice to program your own application timeout. The timer can be set to an appropriate value. If the timer expires the application issues a reset of the connections to the server. This can be seen in section 3.
Section 4 is another Structured Text section which checks the response for errors and assigns the registers read to an array.
The application is annotated and should provide a start for the user of the MBP_MSTR block. It is up to the user to change the PAC type to meet his or her own requirements. There is both a .zef and .xef version in the zip file.


Was this helpful?

What can we do to improve the information ?

Can't find what you are looking for?

Reach out to our customer care team to receive information on technical support, assistance for complaints and more.