Modbus Communication Using LabVIEW or LabVIEW Real-Time Module

Updated May 6, 2019

Reported In

Software

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

Issue Details

  • 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?

Solution

Modbus I/O Servers

The Modbus I/O Server allows you to easily link Modbus register values to Shared Variables, which you can access in your VI. For simpler monitoring applications, Modbus I/O servers provide a simpler and easier API for accessing or serving up Modbus data. In exchange for ease of use, I/O servers give up the tight control over the protocol that can be required for some applications. Modbus I/O Servers is included in the LabVIEW DSC Module and the LabVIEW Real-Time Module.

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

The low-level Modbus API provides fine control over the Modbus protocol, with high performance, at the expense of ease of use. 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 access to 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 Library is only supported 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.

WAS THIS ARTICLE HELPFUL?

Not Helpful