From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.


Showing results for 
Search instead for 
Did you mean: 

LabVIEW vi communication with MODBUS


  I am trying to establish a communication with my LabVIEW program and MODBUS to read the speed and torque off of a servo motor application. What is the easiest way to do this using LabVIEW? I am pretty much new to communication process/coding. Would really appreciate a few examples.




0 Kudos
Message 1 of 32

There is a modbus library available for download.


NI Modbus Library for LabVIEW

0 Kudos
Message 2 of 32

For Modbus examples, try checking in the LabVIEW Example Finder.  In LabVIEW, click Help » Find Examples... When the Example Finder window pops up, search for "Modbus".  I'd recommend taking a look at the examples called Modbus Simulator.lvproj and Modbus Fundamentals.lvproj.




0 Kudos
Message 3 of 32

If you use the modbus library check the comments, there's a bug (that can show up intermittently) in the MB It's easy to fix you need to change the representation of CRC-16 from a U8 to a U16 in MB within NI-Modbus.llb. I wish NI would upload a fixed version but considering the modbus library is "not an official NI Product" and the bug is approaching 2 years old, that doesn't seem too likely.

Message 4 of 32

That's the first I heard about a bug.  Can you post a link to a thread that brings this issue up and discusses it?

0 Kudos
Message 5 of 32

The only place I know the bug being reported is in the reader comments for the download.

0 Kudos
Message 6 of 32

Hi Rory R,

  I could not find the examples.. when I type in Modbus in the 'Find examples' window in LabVIEW, nothing shows up.. can you please attach those two examples with this thread.. I would really appreciate it. Thank you.



0 Kudos
Message 7 of 32

Hi ksurdi,


The examples that Rory pointed you to are included in the Datalogging and Supervisory Control (DSC) Module. It is very likely that you are not able to find these examples, and likely will not be able to run them, because  LabVIEW DSC is not installed on your machine.


More information and the evaluation download of DSC can be found on the NI LabVIEW Datalogging and Supervisory Control Module page.

NI Community Team
National Instruments
0 Kudos
Message 8 of 32

Hi Ksurdi,


To work on ModBUS DSC module is not required, only you need one ModBUS library.

This is simple as a serial communication. First you have to Initialize the MB. In this you have to define the device ID, baud rate, parity, stop bit, data bit and time out settings. Second for read the register values you have to define the register range and your device identification setting. As a output you will get the register values. So you can use the register values and an output or that value holding by that register.


I have attached a sample VI for your reference. Just go through this and if some more clarification is required please let me know.

To access modBUS, one modBUS library(LabVIEW 8.6) also attached with this post copy and past this in LabVIEW user library and restart LabVIEW.


Thanks and Regards

Himanshu Goyal 

Thanks and Regards
Himanshu Goyal | LabVIEW Engineer- Power System Automation
Values that steer us ahead: Passion | Innovation | Ambition | Diligence | Teamwork
It Only gets BETTER!!!
Download All
Message 9 of 32

Hi Himanshu,

I'm trying to gain knowledge of how to implement a simple MODBUS read/write VI in LabView through your post... 

In your post you say: "This is simple as a serial communication. First you have to Initialize the MB. In this you have to define the device ID, baud rate, parity, stop bit..."


Where are can you set the stop bits?  I have a device that uses two stop bits.  I'm able to talk to it using software called "Modbus Poll" but I can't get anywhere with LabView.  I noticed that in LabView the "Init MB" VI doesn't have a stop bit setting.  Is there another way to handle two stop bits?


Thanks in advance,


0 Kudos
Message 10 of 32