Incorrect Readings When Implementing 2-Wire RS-485 Modbus RTU With the Modbus API in LabVIEW

Updated Oct 6, 2025

Reported In

Software

  • LabVIEW

Driver

  • NI-VISA

Issue Details

I am working on implementing Modbus RTU communication between my PC (master) and a third-party slave through the Modbus API that is available in LabVIEW. To create the Modbus master on my PC, I am using the Create Master Instance.vi, where I have set the corresponding NI-VISA resource name, baud rate, parity and flow control to allow communication with the slave, and I am utilizing RS-485 as the physical layer with a 2-wire (half-duplex) configuration. 

Although my computer can communicate with the slave, the information I am receiving is incorrect. If I retrieve the data from a holding register with the Read Holding Registers.vi,  I receive the holding register address multiplied by 256, rather than the actual register value.  

Solution

This behavior occurs because the NI-VISA resource name used for creating the Modbus RTU Master, was not properly configured in LabVIEW for 2-wire RS-485 communication. By default, LabVIEW assumes a full-duplex (4-wire) configuration when implementing RS-485 communication.

To ensure proper operation with a 2-wire setup, it is necessary to set the correct configuration before creating the Master Instance with the Create Master Instance.vi, by passing the NI-VISA Resource Name through a Property Node and setting the Wire Mode property accordingly. Please refer to the image below for more information.

 

Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.