LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI only works on first call

Solved!
Go to solution

I am using a VI that is running on the host computer that communicates with the robot's main VI which is running on the myRIO. The VI should allow me to set the desired position for the robot, and also be able to see an illustration of the robot's current pose using 3D picture control. The VI works correctly the first time I open it, but if I stop and restart it, the 3D picture control doesn't update anymore. I can tell that I am still getting the updated position from the robot, but it doesn't seem to redraw the picture. 

 

Any thoughts on why this works the first time I run the vi, but not after stopping and restarting it?

0 Kudos
Message 1 of 3
(142 Views)
Solution
Accepted by topic author RosieM

Your VI is full of race conditions due to the blatant overuse of local variables and missing execution ordering.

 

You have all these disconnected control and indicator terminals that could be placed where you currently have local variables. All you disconnected "code islands" will start executing in parallel when the VI starts and there is no guarantee that the stop button resets to default before its local variable in any one of the loops is read.

 

I think you should start with a few simple tutorial about dataflow and execution order. You seem to program this like text based code so you probably need to adapt to the spirit of graphical programming a little better. Front panel elements are NOT "variables" and should not be abused as such! You also completely blur the distinction between controls and indicators.

 

You seem to stop the RT system via a shared variable. What starts the RT system?


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 2 of 3
(110 Views)

 All you disconnected "code islands" will start executing in parallel when the VI starts and there is no guarantee that the stop button resets to default before its local variable in any one of the loops is read.

Oh, I get what you're saying. The while loop could start and stop before the stop button resets. 

 

You seem to program this like text based code so you probably need to adapt to the spirit of graphical programming a little better.

I have watched some tutorials on dataflow, but to be honest, I find it really hard to think in a graphical programming way at all. I even went through a one week labview programming bootcamp a couple years ago. Do you have any suggestions on code tutorials or examples that have a similar structure to mine?

 

The front panel elements at the bottom are databound to some shared variables that the main vi on the myrio sets. The variables in the tabs are where the user can set commands to the robot. Is there a better way to pass the data back and forth? Or is this even a worthwhile thing to be doing? I could just use the front panel of the main vi.

 

You seem to stop the RT system via a shared variable. What starts the RT system?

I start the RT system just by hitting run on the main vi that runs on the myrio.

0 Kudos
Message 3 of 3
(93 Views)