06-25-2020 05:09 PM
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.
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
06-25-2020 05:38 PM
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.
06-25-2020 06:07 PM
I am not sure, but the problem may be the NI Modbus API uses preallocated clones.
My work around:
The top VI doesn't stop running until the VI below the Stop FGV in the VI below is triggered.pint
06-25-2020 06:09 PM
That is what I just did. Good one!
Thank you
06-25-2020 06:38 PM - edited 06-25-2020 06:39 PM
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)