05-16-2011 06:58 PM
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.
05-16-2011 07:20 PM
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!
05-16-2011 11:45 PM
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.
05-17-2011 07:24 AM
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
05-17-2011 03:29 PM
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???
05-17-2011 06:51 PM
Point taken! Thanks for taking a look.