MODBUS Library for LabVIEW

Publish Date: Oct 10, 2019 | 166 Ratings | 4.23 out of 5 | Print | 54 Customer Reviews | Submit your review


The MODBUS library is a free, downloadable set of Virtual Instruments (VIs) that provide Modbus communication from any standard Ethernet or serial port. The LabVIEW library implements the Modbus protocol in software and offers both master and slave functionality. Using the Modbus library, Programmable Automation Controllers (PACs) can communicate with gateway devices that provide connectivity to a wide variety of industrial networks, such as PROFIBUS, EthernetIP, and DeviceNet.

A newer library, intended as a replacement for this one, was added to this page. This is not an official NI Product. 

Version 1.2 ( of the MODBUS LabVIEW Library is backward compatible with previous versions of the library.  It adds a set of polymorphic VIs that make it easier to use MODBUS commands.  These new VIs are also fully documented with a help file.  Comments have also been added to the examples.  Please follow the steps in the readme file for manual installation of the library.  There is no installer available at this time.

This library is not designed for use on LabVIEW Real-Time run-time's and will not execute deterministically. Use the Modbus API available through the LabVIEW Real-Time Module or the LabVIEW Datalogging and Supervisory Control (DSC) Module instead.


Note: This is an example program and not an official NI Product.  It is also not designed to execute on LabVIEW Real-time run-times. For a more complete, fully supported MODBUS solution, NI recommends the Modbus I/O Servers and Modbus API (2014 and newer) included in the  LabVIEW Datalogging and Supervisory Control Module and LabVIEW Real-Time Module. 

Back to Top

Customer Reviews
54 Reviews | Submit your review

Modbus data collect to be used within labview script  - Nov 10, 2016

I need to connect some equipments which send MODBUS datas. I need to collect these datas provided by these equipments on a computer where there is my labview script. Which equipment or module i need to install to collect the datas and use them within my labview script.

LabVIEW Root Directory  - Aug 27, 2016

For the ones being confused about the LabVIEW Root directory, I think it is explained wrong in Help file. The Labview root is the path where you have installed your Labview version. As an example, if your are using 32-bit Labview on a 64-bit computer, it is C:\Program Files (x86)\National Instruments\LabVIEW 2015. You just need to copy the files mentioned in the Help file, to the folders under this directory. Then you will see the modbus VIs in User Libraries Palette.

MODBUS for LabVIEW 2015  - Jul 14, 2016

First, will this library work with LabVIEW 2015. If so are there better instructions on how to install this on my system. It says the NI Modbus supports versions up to LabVIEW 8.6, I'm using LabVIEW 15. The instructions keep talking about the LABVIEW_ROOT directory. Where is this directory located in LabVIEW 2015? Any help with this is appreciated.

Driver for SOLO 4848 Controller  - Nov 25, 2015

Is anybody knows a driver or RS 485 sample vi to read the registers of SOLO 4848 Temperature Controller. I could not get any examples successfully communicated with controller.

Install Instructions reference LabVIEW_ROOT but this no longer exists in labview 2015. confused at where to put files  - Aug 30, 2015

does anybody know the proper folder architecture to make so that NI Modbus will work in labview 2015?

library zip file  - Apr 9, 2015

Why does the zip file have four library files that are the same?

Better than the "Official" library in the Data-logging and Supervisory Control Module  - Nov 19, 2014

This library allows independent control of parity and stop bits etc. Whereas the DSC module locks the number of stop bits and the parity together - very frustrating. I have found only minor difficulty using this library. With sbRIO-9639 one should demand "exclusive lock" as the "access mode" input for the "visa open" block. I also had to add an option in the property node to set the "wire type" in the "Modbus Init" vi as I was using a 2 wire system. I have not used the library as a slave demon or done any TCP Modbus with it. For TCP I use the IO server and shared variable engine instead as that is quite a clean way of doing it for TCP. For serial however I've never got the IO Server to work. This library is actually very good in my opinion.

Response to Maik  - Nov 3, 2014

@Maik, the reason slave address 0 is treated as broadcast is because this is defined by the Modbus protocol. This has nothing to do with the driver itself. If either of us had to write a Modbus driver, we would have to do the same just so we comply with the Modbus protocol.

  - Oct 16, 2013

Hi, I'm trying to run the example of the Ethernet Modbus feature. I created a *.vi containing only 'MB Ethernet Example' and another one containing only 'MB Ethernet Example'. I run the slave and the Master afterwards. After some seconds, I get this message : fszr.png I use LabVIEW 8.5.1. Is this version covered by this toolbox? Thanks

Very buggy  - Oct 9, 2013

1. The Init VI handles all COM ports as true COM ports, but it does not work with VCOM. So I had to modify the serial settings init (first Visa Open, then Visa Serial Settings, not via property node) 2. There is no timing between Write and Read 3. Slave address 0 is considered as broadcast in the sub VIs, but this applies only for a serial line Modbus, which COM ports and Ethernet are not, because they're peer-to-peer. So the slave address 0 detection in the sub VIs is nonsense, because you can not make a broadcast with slave address 0 on P2P.

  - Sep 30, 2013

Hi I have the LabVIEW Run-Time 8.5 installed. I do not undersand how to install the Modbus. In the help it says I should copy the Modbus.llb to the LabVIEW_ROOT\vi.lib folder. But I have no such folder. Please help me

Compatibility with LabVIEW 8.6 and LabVIEW 2011  - Sep 20, 2013

Hello, Would you be able to tell me which of the versions available are compatible with LabVIEW 8.6? And the same for LabVIEW 2011 ?

New and improved   - Jul 15, 2013

Hi all, Use the new modbus library on NI labs instead of this one:

LabView 2011  - Jun 18, 2013

Does this lib work with version 11? Thanks for any help.

  - Apr 22, 2013

Please support this idea :

MB Update Registers bug...  - Mar 8, 2013

I'll preface my remarks with some words from Forrest Gump... "I'm not a smart man...". But it appears that I've stumbled across a problem with the MB Update Registers subVI. Specifically for the Function Code 1 and 2 (Read Coils and Read Discrete Inputs) case. The first three cases (i.e. the check quantity, check quantity and start address, and read coils/discrete inputs) all work correctly. But the 4th case (the encode booleans as U8) incorrectly encodes the data. The While Loop takes in the Bits Out array from previous case and splits it into two parts. On the first iteration, the Bits Out array is split at index 8 and the first subarray is 8 bits and gets encoded correctly as a U8, while the second subarray is passed to the next iteration of the loop. However, on the second iteration of the loop, the "new" Bits Out array being processed (the original Bits Out with the first 8 bits already removed) is split at index 16. And while for the second iteration of the loop this still returns a correct encoding of the second 8 bits of Bits Out (via truncating) array, subsequent iterations will not be correct because data gets lost. The easy fix is to ALWAYS index the split array function at 8 rather than tying it to the iteration terminal. Or you could replace the split array function with the array subset function, tying index to the iteration terminal as it is and setting the length to ALWAYS be 8, and NOT use shift registers at all. Well, that's what I've come up with anyway... but I'm not a smart man! :-)

Modify Stop bits in   - Nov 14, 2012

I was able to make the library work in ASCII mode by making changes to "MB Serial". The "Stop bits" are set to 2, in ASCII mode and "STOP bits" as 1 in RTU mode. My application needs none parity. Please see page 16 of the following ModBus spec , for clarifications on ASCII mode.

ModBus on the LVTN  - Sep 24, 2012

As an alternative to this "old" free example provided by NI, 2 toolkits are available to purchase on the LVTN. For TCP --> /nid/209754 For Serial --> /nid/210229 SAPHIR have been developing and maintaining these toolkits since LV 3.1. Feel free to try them for free during 30 days. More information and support here --> hir-toolkit

Modbus updates 2011 ???  - Aug 3, 2012

What's the status on Modbus ??? Is someone from NI available to answer???

Modbus Library Updates?  - Apr 11, 2012

When will I get NI Modbus libraries running with LabVIEW 2010? I can not install Labview 8.6 for it. Is there any alternative solution to get this

Any updated code here?  - Dec 30, 2011

has there been any investigation by NI about the numerous bugs reported by users? Have these libraries been updated? Is there one complete, verified list of fixes to this library anywhere?

  - Oct 26, 2011

Th ASCII mode seems to be broken - no chance to get it running in Labview 2011 - while the RTU mode performs well ... This is kind of poort ...

Bug in ASCII mode  - Oct 9, 2011

Bug1: In "MB Serial String to Modbus Data Unit", in the if structure, "x-9" should be changed to "x-7". Bug2: In "MB Decode Data", in the case structure (3,4) , should delete "Array subset"

Modbus Library Buggy - No real alternative  - Nov 19, 2010

NI asks us to use the "LabVIEW Datalogging and Supervisory Control Module" for professional ModBus support in LabView. Due to the run time licensing scheme where you need a DSC Runtime License that binds the software to ONE computer, this is not an alternative for our 24*7 customers. They must be able to swap a PC with a new in midst prodction if necessary. Version 1.2.1 still as the CRC 16 bug in MB as pointed out by "Jim Figucia, Code G Automation" September 15 2009. This very error haunted us with random data: We just saw Jim's comment, and fixed the bug in the VI. Isn't it about time to fix the reported bugs in this library?

  - Nov 18, 2010

NI Says <<Please note that this is an example program and not an official NI Product. For a more complete, fully supported MODBUS solution, NI recommends the LabVIEW Datalogging and Supervisory Control Module. >> That would have been fine: We own the DSC Modul. However, the LICENSING binds the deployed code to one Computer. This is NOT Acceptable in a 24*7 environment where we deploy all our systems: The customer must be able to change the PC in mid production it it breaks down. Thus, we also had to resort to the buggy Modbus Library. 1.2.1 still has the bug in MB that casts a 16 Bit CRC to an U8 ! This was pointed out by "Jim Figucia, Code G Automation. - Sep 15, 2009" and is STILL NOT FIXED.

Error in 'MB Serial'  - Oct 25, 2010

Error in 'MB Serial' Modbus spec clearly states that if no parity checking is used, 'stop bits' should be set to '2'. This vi always sets stop bits to '1'.

What about Labview 2009?  - Aug 25, 2010

Hey is this going to work with labview 2009 too? I tried using the 8.6 version but i am getting nowhere..

MODBUS  - Jul 26, 2010

This Library didn't support MB Serial Slave at Windows CE5.0 in Touch panel Module.

library modbus 6.0  - May 29, 2010

Hello i'm looking for modbus library for labview 6.0. i have the library for labview 6.1 but i can't open it with labview 6.0

MB Registers  - Dec 8, 2009

Thanx for version 121 of this free library. Is bug in "MB Registers" reported Apr 29, 2009 fixed?

a flaw in MB in NI Modbus.llb   - Sep 15, 2009

A failure mode turn up in testing at 1200 baud. It turned out to be a flaw in MB in NI Modbus.llb. The failure mode is that the MB Serial that waits for a Modbus reply to a command may falsely detemines that the message is complete before the last byte is recieved. This is becuase because MB coerces the U16 CRC to a U8, and the U8 becomes zero for a message with all but the last byte transmitted. The correction is to change the data type of the Exception Code indicator from U8 to U16.

inform us and correct this in Library!  - Apr 29, 2009

"The 'MB Registers Manager.VI' is used as the repository for the Slave registers. In the case of Write, however, the Start Address is not being taken into account (compare this with the Read cases to know what I mean). The Start Address defaults to 0, always! The fix is to wire-in the Start Address to the Index input of the Array Subset primitive. This alongwith the (already present) Length input should write to the correct set of registers, coils, etc." reported by Khalid - March 18, 2006

  - Apr 16, 2009

thx for improving the library The Modbus Slave implementation in this library is buggy since 2006. For Details see

Support for TPC targets LV8.51  - Mar 11, 2009

1. Can I use this library on a TPC-2106 target (Touch Panel Module project)? When I try, not all of the example VIs are executable - e.g. "MB Serial Wait on Query" displays Target Specific Errors. 2. Copied, as instructed, lvmodbus.chm and lvmodbus.txt from 85\help to the LabVIEW_ROOT\help directory. The help appears with the content seemingly normal, but selecting any topic results in: "This program cannot display the webpage"

ni_modbus8_2.exe file  - Sep 4, 2008

want Maodbus toolkit for labview 7.0 . plese give me a link or supply me source

  - Aug 21, 2008

Usually the LabVIEW libraries found on the NI site are very helpful, well documented, and intuitive. I'm not sure if it was just my inexperience with the protocol or not, but this has been the worst library I've downloaded. There is next to no documentation at all. Errors are not defined and the examples not as helpful as could be hoped.

I'm having probles to use the library to read/write registers from a GE PLC, Any example?   - Jun 30, 2008

automation  - Jun 5, 2008

I want Maodbus toolkit for labview 7.0 ? plese give me a link or supply me source

  - Feb 26, 2008

please tell me can i use this driver with multidrop N/W.

Modbus for LV 7.0  - Dec 28, 2007

Hello is there a serial port Modbus driver for LV 7.0?

Zipped llb, please?!  - Dec 4, 2007

Hi- please supply this as a cross-platform archive!

  - Mar 26, 2007

i'm using labview 7.1 is there a version for this? or i use the 6.1 version?

  - Feb 1, 2007

Is there the Modbus Library for labview version 6???

Modbus for CVI  - Nov 22, 2006

Is there CVI modebus function panel available?

why an MSI file?????  - Oct 18, 2006

This is just a pain to the non-windows community. Who is out there just being lazy or not-thinking.

LV 6.1 version  - Apr 27, 2006

Here's the 6.1 version of this:

Modbus Slave is buggy  - Mar 18, 2006

Modbus Slave implementation has a bug. See this for details:

Why an .msi, not .llb?!  - Feb 24, 2006

No use to us original (Mac) LabVIEW users; what am I supposed to do with a Windows installer?! Isn't LV still a cross platform language, born on the Mac?

Error in code  - Feb 21, 2006

The "MB Modbus Command to Data" has a mistake in it. The "Write Multiple Coils" Function Code will not work properly past 8 bits of data. In case "15", the index to the "Split Array" VI should just be 8. Either that or you could remove the shift register and use an index array instead. The current implementation however corrupts the output data past 8 bits.

Here's how to install this in LabVIEW 8.0 ...  - Jan 6, 2006 ding&page=2

When will it work with Labview 8.0???  - Nov 30, 2005

When will it work with Labview 8.0??? The german support team has told me that it must work, but it doesn't! After telling them that it doesn't work and asking for a call back I got no answer until now!

versjon 8.0  - Nov 10, 2005

When will these libraries be available for LV8??

Compatable with Version 8 LABVIEW?  - Nov 3, 2005

I was unable to run this Modbus Libuary using the LABVIEW 8. I am currently trying to concude that LABVIEW can talk Modbus and how hard is it to configure to do this. Thanks 513-293 4783

Several VIs display broken wires when compiled to LV8  - Nov 1, 2005

View more reviews

Bookmark & Share



NI MODBUS Library 1.2.1



Rate this document

Answered Your Question?
Yes No