LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving a reference in a shift register issue

Solved!
Go to solution

Hello,

     I am writing some small drivers to control a Real 30 Thermal Chamber. I ran into the following issue, and I was wondering what I might be missing. So I have the enclosed For Loop with a case statement inside. The idea being that I can initialize the TCP address and Remote port as shown, and then later I can send any additional commands (via additional cases) to the chamber via "Real 30 Chamber Control". (Via the reference in the shift register) This is when things got a bit strange.

I can run this vi one time to "Init", and that works fine. Then I run the program again, for any of the other states, and I get an Error 1. It appears that the next time I run the program, it has lost it's reference in the shift register somehow.

Just to prove this to myself, I took the whole vi, created a test program where I used three instances of the same .vi, and set the first one to "init", then one of the other cases, and then "close" case. (All instances were connected via the error line). This worked without errors through many attempts.

 

I had thought that the contents of a shift register are supposed to survive a .vi shutdown, as long as Labview itself is still running? If that is not the problem, does it have something to do with losing the reference to the TCP init function after a program stop? I hope I have described this problem ok. This .vi will be used as a call in a Teststand sequence, so it will work fine as it is, I was just curious why I was getting this unexpected result when I ran the .vi multiple times by itself. Thanks....

 

 

 

 

 

 

0 Kudos
Message 1 of 4
(3,014 Views)
Solution
Accepted by topic author Z4CRUZN

LabVIEW has built-in methods for auto-closing references when it thinks you're done with them.  The program ending is one of the times it does this.

 

Your best method here to avoid opening multiple references is to check the reference each time you run the VI using the "Not a number/path/refnum" node from the comparison palette.  If True, create the reference again, and pass the good reference through if False.

0 Kudos
Message 2 of 4
(3,010 Views)

Instead of the FOR loop, you could use a feedback node instead. While the reference is still in the shift register, I am sure it is stale the next time your run the VI. (It is typically better to attach the VI instead of a picture). Also play with the "first call?" to create a new reference of needed.

0 Kudos
Message 3 of 4
(3,006 Views)

Ok.... I thought it had to be something small and subtle like that. So once I detect the reference is missing, how would I create another and send it back into the shift register without actually running through the “INIT” case again?

0 Kudos
Message 4 of 4
(3,004 Views)