MODBUS Library for LabVIEW
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.
Version 1.2 (ni_modbus_1_2.zip) 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.
If you are new to MODBUS, here is an introduction to the protocol.
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.
Application Software: LabVIEW Base Development System 7.1
Reader Comments | Submit a comment »
Please support this idea :
- Apr 22, 2013
MB Update Registers bug...
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! :-)
- Stephen Robinson, Huntington Ingalls Industries. firstname.lastname@example.org - Mar 8, 2013
Modify Stop bits in
I was able to make the library work in ASCII mode by making changes to "MB Serial Init.vi". 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 http://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf , for clarifications on ASCII mode.
- Siva Telasula, Sutron Corporation. email@example.com - Nov 14, 2012
ModBus on the LVTN
As an alternative to this "old" free example provided by NI, 2 toolkits are available to purchase on the LVTN. For TCP --> http://sine.ni.com/nips/cds/view/p/lang/en /nid/209754 For Serial --> http://sine.ni.com/nips/cds/view/p/lang/en /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 --> https://decibel.ni.com/content/groups/sap hir-toolkit
- Olivier Jourdan, SAPHIR. firstname.lastname@example.org - Sep 24, 2012
Modbus updates 2011 ???
What's the status on Modbus ??? Is someone from NI available to answer???
- email@example.com - Aug 3, 2012
Modbus Library Updates?
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
- firstname.lastname@example.org - Apr 11, 2012
Any updated code here?
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?
- Dec 30, 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 ...
- email@example.com - Oct 26, 2011
Bug in ASCII mode
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"
- firstname.lastname@example.org - Oct 9, 2011
Modbus Library Buggy - No real alternative
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 CRC-16.vi 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?
- Geir Skjærvik, Objective Technology. email@example.com - Nov 19, 2010
NI Says <
- Geir Skjærvik, Objective Technology. firstname.lastname@example.org - Nov 18, 2010
Error in 'MB Serial Init.vi'
Error in 'MB Serial Init.vi' 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'.
- Wayne Crawfis, Franklin Electric. email@example.com - Oct 25, 2010
What about Labview 2009?
Hey is this going to work with labview 2009 too? I tried using the 8.6 version but i am getting nowhere..
- Ankit Agrawal, Nirma University. firstname.lastname@example.org - Aug 25, 2010
This Library didn't support MB Serial Slave Demon.vi at Windows CE5.0 in Touch panel Module.
- Won - HyungChul, pusan university. email@example.com - Jul 26, 2010
library modbus 6.0
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
- May 29, 2010
MB Registers Manager.vi
Thanx for version 121 of this free library. Is bug in "MB Registers Manager.vi" reported Apr 29, 2009 fixed?
- Dec 8, 2009
a flaw in MB CRC-16.vi in NI Modbus.llb
A failure mode turn up in testing at 1200 baud. It turned out to be a flaw in MB CRC-16.vi in NI Modbus.llb. The failure mode is that the MB Serial Recieve.vi 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 CRC-16.vi 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.
- Jim Figucia, Code G Automation. firstname.lastname@example.org - Sep 15, 2009
inform us and correct this in Library!
"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 29, 2009
thx for improving the library The Modbus Slave implementation in this library is buggy since 2006. For Details see http://forums.ni.com/ni/board/message?board.id=170&message.id=174431&query.id=142893#M174431
- Apr 16, 2009
Support for TPC targets LV8.51
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"
- Boyko Bejaniyski, Johnson Security Ltd. email@example.com - Mar 11, 2009
want Maodbus toolkit for labview 7.0 . plese give me a link or supply me source
- modbus library for LabVIEW version 7.0, canopus. anon4110029 - Sep 4, 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.
- Aug 21, 2008
I'm having probles to use the library to read/write registers from a GE PLC, Any example?
- Omar Quintanilla. firstname.lastname@example.org - Jun 30, 2008
I want Maodbus toolkit for labview 7.0 ? plese give me a link or supply me source
- Modbus toolkit for labview 7.0, Kevin Tech. email@example.com - Jun 5, 2008
please tell me can i use this driver with multidrop N/W.
- firstname.lastname@example.org - Feb 26, 2008
Modbus for LV 7.0
Hello is there a serial port Modbus driver for LV 7.0?
- bryan ehrhart, Infinera. email@example.com - Dec 28, 2007
Zipped llb, please?!
Hi- please supply this as a cross-platform archive!
- Tom Lawton, EnFlo, University of Surrey. firstname.lastname@example.org - Dec 4, 2007
i'm using labview 7.1 is there a version for this? or i use the 6.1 version?
- Leow Cheah Wei, Universiti Teknologi Malaysia. email@example.com - Mar 26, 2007
Is there the Modbus Library for labview version 6???
- modbus for labview 6, Polytech. firstname.lastname@example.org - Feb 1, 2007
Modbus for CVI
Is there CVI modebus function panel available?
- Moshe Aizler, MKS TENTA PRODUCTS. email@example.com - Nov 22, 2006
why an MSI file?????
This is just a pain to the non-windows community. Who is out there just being lazy or not-thinking.
- Scott Hannahs, NHMFL - FSU. firstname.lastname@example.org - Oct 18, 2006
LV 6.1 version
Here's the 6.1 version of this: http://zone.ni.com/devzone/cda/epd/p/id/4564
- Khalid Ansari, Advanced Measurements Inc - AMI (Canada). - Apr 27, 2006
Modbus Slave is buggy
Modbus Slave implementation has a bug. See this for details: http://forums.ni.com/ni/board/message? board.id=170&message.id=174314
- Mar 18, 2006
Why an .msi, not .llb?!
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?
- Tom Lawton, EnFlo, UniS. email@example.com - Feb 24, 2006
Error in code
The "MB Modbus Command to Data Unit.vi" 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.
- Jim Gruenbacher, Airgas. firstname.lastname@example.org - Feb 21, 2006
Here's how to install this in LabVIEW 8.0 ...
http://forums.ni.com/ni/board/message? board.id=170&message.id=156677&view=by_threa ding&page=2
- Jan 6, 2006
When will it work with Labview 8.0???
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!
- Nov 30, 2005
When will these libraries be available for LV8??
- Nov 10, 2005
Compatable with Version 8 LABVIEW?
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
- Mike Wendt, Rolls Royce. email@example.com - Nov 3, 2005
Several VIs display broken wires when compiled to LV8
- Nov 1, 2005