LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple Modbus VIs

I know there are standard libraries for Modbus comm like the Modbus Master and Modbus library.  But there are some Drives that use custom Function codes like 100( 32 Bit Write ) and 101( 32 bit Read ). No doubt these are useful but become a problem when using the libraries which can only handle the standard function codes of 1 to 6.  Maybe possible to tweak them to handle special codes but have never tried so far. 

 

So to handle such cases I use the simple VIs below -  first  for generating the required command with CRC and the next to read data from slave by sending the generated command. Once the data array is in,  I can manipulate as required to get the actual value. 

 

I know the one downside of such " home brew "  VIs is that they cannot be used universally as they are specific to a project. But apart from this,  do the library VIs have some more features like repeating command if they sense error etc ? 

 

Modbus_RTU_CommandGen.png

 

 

Modbus_RTU_Read.png

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 5
(2,473 Views)

I don't think the library will repeat commands but it provides a pretty nice API interface, abstracts the underlying transfer mechanism (TCP vs Serial) and does give some basic but useful error handling (timeouts, incorrectly formatted data returned). This is all functionality you will probably end up recreating eventually so I would definitely recommend just creating a fork from the GitHub repo.

 

https://github.com/NISystemsEngineering/LabVIEW-Modbus-API

 

I wouldn't expect it to be too difficult to add a new function for additional function codes if you know Modbus pretty well. If you look at other functions you'll see that you really just need to provide some method to construct a PDU object (which you can do with a U8 function code and U8 data array) and then you need to do the exact opposite which is basically just unflattening the returned U8 array to something more useful.

Matt J | National Instruments | CLA
0 Kudos
Message 2 of 5
(2,435 Views)

I downloaded the Modbus Master from here : 

https://github.com/NISystemsEngineering/LabVIEW-Modbus-API

 

 

But unfortunately I am unable to open the CHM help file within documentation.  Any idea why this is so ?

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 3 of 5
(2,290 Views)

CHM files and other “executable” files are usually locked by the Windows shell when you download them. To unlock them, right click on the file in Explorer and select Properties. On the first page towards the end on the right side you see a checkbox “Unlock this File” or something to that wording. Check that, close the dialog and try again.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 4 of 5
(2,276 Views)

@rolfk wrote:

CHM files and other “executable” files are usually locked by the Windows shell when you download them. To unlock them, right click on the file in Explorer and select Properties. On the first page towards the end on the right side you see a checkbox “Unlock this File” or something to that wording. Check that, close the dialog and try again.


Yes . That worked . Thanks !!

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 5 of 5
(2,100 Views)