LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus RTU with LabVIEW on Laptop

Hi all, I am very new to Modbus RTU and have a little experience with LabVIEW. My project involves communicating via Modbus RTU with a flow meter (TRICOR® Coriolis Mass Flow Meter with TCD 9000 electronics) . Is it possible to communicate with this device using labview on my laptop and can I use one of the examples provided? I have already downloaded the "LabVIEW Datalogging and Supervisory Control Module" and took a look at some of the example projects, but I don't understand enough about Modbus to know how to start reading and writing and checking that it's working. 

 

As for my physical/electrical setup: 

PC -> USB -> USB-RS485 converter -> DB9-DB9 cord -> Breakout Board

 

Breakout Board: 

Meter Pin -> Board Pin

7->5

6->4

5->9

4->8

 

Per the Flow Meter's Modbus communication manual 

ruede014umnedu_0-1727474123562.png

and DB9 pinout 

 
 

ruede014umnedu_4-1727474331067.pnghttps://www.virtual-serial-port.org/article/what-is-serial-port/rs485-pinout/.

 

I will be checking this often so I will reply to any questions needed quickly, thanks.

 

 

 

 

 

0 Kudos
Message 1 of 9
(416 Views)

I would recommend testing using QModMaster

For Modbus in LabVIEW, I recommend NI Modbus Library Toolkit for LabVIEW. You can open the master and slave examples from Quick Drop.

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 2 of 9
(398 Views)

Definitely use the NI Modbus library mentioned by ZYOng. This is a modern version of the library included in the DSC Toolkit without the need for a DSC license (which is a costly thing if you just want to do Modbus and also requires a runtime license for build applications (executable)).

 

It is not really clear what sort of pinout the DB-9 connector on that box has. It's definitely not safe to ASSUME that it would have the pinout you show in your last link, unless the documentation states so, and I don't see anything like that. There is NO standard RS-422/485 pinout for DB-9, every manufacturer tends to do its own thing! Instead I would use the screw terminal connection which is what is documented in the Quick Start Guide document you linked at.

 

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 9
(374 Views)

Thank you very much for your reply ZYOng. I don't need QModMaster right? I figured I can test it with my modbus device by sending a simple command and getting a response. I downloaded NI Modbus Library and have the master example open.

 

What all do I need to modify in this code for it work with my modbus slave device? So far I've made it create a New Serial Master instead, although I'm not sure what VISA resource name I'm supposed to feed it. Do I also need to specify the starting addresses and then I'm good?

0 Kudos
Message 4 of 9
(339 Views)

Thank you very much for your help rolfk. I got that library I just need to figure out what to change in the example now. Also, I believe that my wires were incorrect. In the flowmeter manual it says it is 2-wire RS485 so now I am going to wire pins 4 (IN+) and 5 (IN-) of the flowmeter to pins 1 (TX/RX-) and 2 (TX/RX+) on the converter as the Quick Start Guide outlines. I believe pins 6/7 (OUT+/OUT-) are for daisy chaining to other additional slaves/flowmeters?

0 Kudos
Message 5 of 9
(337 Views)

Usually RS485 adapters are ready for 4-wires communication. To get 2-wires, simply short circuit RX with TX (matching the polarity of course). Refer to the adapter manual for more information.

The VISA resource name is simply the COM you are using( (e.g. COM5 or - in older fashion - ASRL5::INSTR). And yes, you have to figure out from the documentation which are the address base and range you need to read (or write).

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 6 of 9
(324 Views)

Ok so for example if I want to read the mass flow rate per the documentation I would use fetch input registers and set starting address to 3000 and number of registers to read to 1? I don't need to go into any of these sub vis and change stuff correct? Sorry I am very new to this, I appreciate the guidance.

JRue3_2-1728329502014.png

 

JRue3_3-1728329548080.png

 

 

 

0 Kudos
Message 7 of 9
(290 Views)

I believe number of registers should be 4 according to your documentation. 

 

 

0 Kudos
Message 8 of 9
(280 Views)

@LVNinja wrote:

I believe number of registers should be 4 according to your documentation. 


I believe you wanted to say 2. Modbus registers are 2 bytes, a float is 4 bytes. Also the next value to read is at address 3002,  indicating the previous register occupies register 3000 and 3001. Now we only need to know the order in which to put the two u16 to get a u32 that then can be typecasted into a float (a LabVIEW single precision floating point  number).

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 9
(277 Views)