LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus on LabVIEW

Solved!
Go to solution

Hi, i'm pretty new to LabVIEW and i'm trying to create a code on LabVIEW to communicate with an heat pump. The heat pump is equipped with AER485P1 that allows to communicate with a RS485 network. The pump is connected to a NI 9871 module. The module is installed on a NI cRIO 9056 controller which is connected to my PC via an ethernet cable. I'm using LabVIEW 2021 and have installed Linux 21 System Image with all the add-ons on the cRIO controller.

My aim is to create a VI that can communicate with the heat pump but I have no idea of where I can start. 

I tried to look at the modbus libraries but couldn't figure out an easy way to do what i want. I only know some parameters that have to be set (baud rate, parity mode etc.) and the list of addresses

 

 

screenshot.PNG

I suppose i only have to create a Master Instance (the slave instance should be the pump) ?

masterinstance.PNG

I have followed this guide https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P7gZSAS&l=it-IT (I'm working in Scan Mode) but can't go further.

Can somebody help?

 

 

 

0 Kudos
Message 1 of 5
(1,236 Views)

@wingSs wrote:

Hi, i'm pretty new to LabVIEW and i'm trying to create a code on LabVIEW to communicate with an heat pump. The heat pump is equipped with AER485P1 that allows to communicate with a RS485 network. The pump is connected to a NI 9871 module. The module is installed on a NI cRIO 9056 controller which is connected to my PC via an ethernet cable. I'm using LabVIEW 2021 and have installed Linux 21 System Image with all the add-ons on the cRIO controller.

My aim is to create a VI that can communicate with the heat pump but I have no idea of where I can start. 

I tried to look at the modbus libraries but couldn't figure out an easy way to do what i want. I only know some parameters that have to be set (baud rate, parity mode etc.) and the list of addresses

 

 

 


Is there a reason you are using a CRIO system? All you need is a USB to RS-485 adaptor and the LabView Modbus Library 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 5
(1,193 Views)

I have more modules attached to the controller to read thermocouples, thermistors, flow meters, control some actuators. Since the 9871 module is already installed i need to figure out a way to use it 😞

0 Kudos
Message 3 of 5
(1,178 Views)
Solution
Accepted by topic author wingSs

I'm not sure what that mask column signifies. Modbus modes 3 and 6 are for holding registers. As for the initial connection, just drop down the Create Modbus Master and swap it to Serial -- then just put in the identified constants. Stop bits should be automatically set based off of parity, so don't worry about that. The register "1" could actually be a 1, or 40001, or a 40000 depending on manufacturer convention, so if one doesn't work try one of the others.

 

The problem you're probably going to run into is how does the returned U16 value translate to a number between -999.9 and 999.9. Ideally the manual would tell you what the representation should be and whether there's a scaling factor. I just operated under the assumption that it's a float.

 

Once you get one register working you can start reading multiple at the same time and then parsing the array that you get back. It's much faster than reading each register individually.

 

serial_modbus.png

0 Kudos
Message 4 of 5
(1,130 Views)

You're a god! Works perfectly. I just had to set "200" into Unit ID as the pump had this value set into the options and it works. 

The values between -999.9 and +999.9 are in unsigned 16 bit. A value that was set on -999.9 returned 55537 (which is -9999). I just divided this number by 10 and that's my temperature (i didn't find conversion factors on any manual though). 

I'll let you know if have more issues with the Modbus coils (the pump also has some digital variables that can be read/written).

0 Kudos
Message 5 of 5
(1,087 Views)