LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read and write variable in and out of loop

I have a rather gigantic piece of LV code that controls a series of valve manifolds, mass flow controllers and a few other things.  I have posted a little snapshot of a critical piece of this code that is giving me lots of problems.  It has to do with passing time throughout the sequence.  There is a while loop sitting outside of the sequence that controls the valves and Mass flow controllers that reads the time and creates a local variable called "current time:".  This variable is shown in the figure.  I can see when I run the code that this variable is updated in real time but I would like to pass it throughout the code so valves know when to open and close.  The terminal leaving the variable reads "not executed" when I probe it, so the code thinks that the time is stuck at the moment that I start running the code instead of being updated as the variable is.  I tried switching the variable to "write" but this produces a source-sink violation when I try and pass it on.

 

I have followed the posts on passing variables between loops but am still stumped as to the problem here.  Any help on this matter would be greatly appreciated!

 

Thanks very much.

0 Kudos
Message 1 of 6
(1,297 Views)

Looking ar the scrollbars, we can only see about 1% of the diagram in your picture. We cannot troubleshoot like that!

 

In the code where you read "current time" via a local variable, it is clear that this only happens once per execution of the visible code fragment. Is this all inside a gigantic loop? Assuming we have a big loop: in order to re-execute the visible code all inner loops need to complete. Do they ever?

 

I don't understand the diagram comment about "changing it to write". Why would even consider this? If you turn a read local into a write local it turns from data source into a data sink, and since the wire would no longer have a data source, the code will be broken.

 

 

There are many very suspicious and very dangerous code constructs, such as multiple "event structures..inside while loops..inside case structures". That's really, really bad!


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 2 of 6
(1,292 Views)

Thanks for the reply.  Yes, indeed I knew I was in for a chastising and probably should have shot for somethign a bit more manageable for a first go at LabView.  That said,  in an earlier iteration the current time: variable updated and propagated the time throughout the code but sometime in the last few days a change was made that severed that.   The issue is a I need a way to feed the time variable generated in the while loop in the upper right corner throughout.  Any suggestions would be greatly appreciated, code is now attached. 

 

 

0 Kudos
Message 3 of 6
(1,277 Views)

Run the program in Highlight Execution (+ keep values) and you can hopefully see how/where it stops.

*screams!*  *shivers*

I just looked at it and it's basically impossible to find any error due to the pure size. You need to create some sub-vi's, much of the stuff you do is similar/identical so it should be easy. You'd also gain alot be clustering controls or putting them in arrays. E.g. your leftmost loop with the events could be 1 array of controls handled be the same event.

About your particular problem i can swear that it only updates once during your whole program due to the inner loops.

 

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 6
(1,257 Views)

There is no way this can be fixed without starting with a blank slate. Trying to fix that code is like trying to rebuild Pompeii as a luxury resort.

 

The primary problem most likely started when you placed a few event loops inside the main loop.

 

Still, I don't consider this VI salvageable, there way way too many design rules broken. Even the front panel is a complete mess. Looks like you blindly copied code sections on the diagram. Why are there so many stop buttons???


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 5 of 6
(1,243 Views)

Point taken!  Thanks for taking a look.

 

0 Kudos
Message 6 of 6
(1,222 Views)