Modbus Communication Using LabVIEW or LabVIEW Real-Time Module

Updated Dec 18, 2023

Environment

Software

  • LabVIEW Datalogging and Supervisory Control Module
  • OPC Servers
  • LabVIEW
  • LabVIEW Real-Time Module

  • I need to communicate with my device using the Modbus protocol. Is this possible with LabVIEW?
  • Do I have the free version of the Modbus toolkit/API, or do I have the licensed version of Modbus VIs that comes with the LabVIEW Datalogging and Supervisory Control (DSC) Module?

Modbus I/O Servers

The Modbus I/O Server allows you to easily link Modbus register values to Shared Variables that you can use in your LabVIEW VIs.  Modbus I/O Servers provide a simple way to access and write Modbus data in LabVIEW. Modbus I/O Servers is included in the LabVIEW DSC Module and the LabVIEW Real-Time Module.

In exchange for ease of use, Modbus I/O Servers do not have the fine control that the supported LabIVEW Modbus API has over the Modbus protocol that can be required for some applications.


 

Supported Modbus API (boxed in blue in the screenshot above)

The supported Modbus API provides fine control over the Modbus protocol, with high performance. Everything must be done manually when using this low-level API. The supported Modbus API is included in the LabVIEW DSC Module and the LabVIEW Real-Time Module.
 

NI OPC Servers and DataSockets

If you are using LabVIEW on Windows, you can also use DataSockets to communicate with an OPC Server that can communicate with Modbus. If you do not have an OPC Server, NI OPC Servers provides an interface to many protocols, including Modbus. To learn more about using DataSockets to connect to OPC Servers, take a look at the tutorial on connecting LabVIEW to an OPC server using front panel DataSockets.
 

Unsupported Modbus Library (boxed in green in the screenshot above)

  • LabVIEW 2012 and later
    The LabVIEW Modbus API is the latest release of the free LabVIEW Modbus Library. It is intended as a replacement and expansion of the free Modbus library functionality that supports versions of LabVIEW before 2012.
  • LabVIEW 7.1 and later
    The Modbus Library for LabVIEW is a wrapper for VISA commands. Programming with it requires some knowledge of Modbus function calls to program. This library may not contain as many features you need as the LabVIEW Modbus API or the supported API included with LabVIEW DSC Module.
 Note: The unsupported Modbus Libraries are not supported by NI.  You may get a response if you post your questions on the NI Community Forums.
 

Additional Information

Modbus is a serial communication protocol. This means it is also possible to program LabVIEW to talk to a Modbus device via serial communications. The same principles apply to Modbus TCP/IP, which is built on the TCP/IP protocol.