LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus Disconnects - Shift register does not keep connection alive

Highlighted

I have a Modbus application which communicates with a Pressure Regulator.

As in many other equipment communications I have implemented, the shift register keeps the handler (and the communication) alive. (Connect, Set, Disconnect)

In this case it doesn't. It seems the TCP connection is lost when the VI is stopped.

 

To circumvent it, I added the the sequence (Connect, Set, Disconnect) in the for loop.

It works, but then it is not what I want because the instrument goes back to default setting once it gets disconnected.

 

Modbus Problems.jpg

Why the VI on top of the image doesn't work?

How can I fix it?

Is it related to Object Oriented/Classes?

I have experience with OO in Java, but I never done any OO in Labview.

Thank you

Download All
0 Kudos
Message 1 of 5
(300 Views)
Highlighted

It looks like you are running this by itself.  It looks like an action engine, but since you have no connections on the connector panel, I don't see a way for a higher level VI to call this with the different commands like it would an action engine.

 

So what is happening is when the highest level VI goes idle, in this case itself, the TCP connection is lost.

 

Connect the command controls and input and output controls to the connector panel.  Then call this from a higher level VI  (connect before a loop, set point in a loop, disconnect after the loop) and it will work just fine.

0 Kudos
Message 2 of 5
(292 Views)
Highlighted

I am not sure, but the problem may be the NI Modbus API uses preallocated clones.

 

My work around:

 

Solution for now 2.jpg

 

The top VI doesn't stop running until the VI below the Stop FGV in the VI below is triggered.pint

0 Kudos
Message 3 of 5
(285 Views)
Highlighted

That is what I just did. Good one!

 

Thank you

0 Kudos
Message 4 of 5
(284 Views)
Highlighted

Go to Tools -> Options, then select Environment. Do you have "Automatically close VISA sessions" checked? I'm just curious if LV keeps TCP connections active if the VI stops by default. (I don't have the Modbus library so it might not even use VISA)

0 Kudos
Message 5 of 5
(265 Views)