07-22-2014 09:40 AM
My program contains two main parts, a "Manual Cluster" and an "Auto Cluster". The idea is that both these clusters share one output, but only the activated (determined by a boolean switch) one will display its data at one time. The manual boolean overrides the auto boolean. There is a three column array in the auto cluster. The first column is the "Start Value", second the "End Value", and third the "Duration". I have a series of loops that will incrimentaly display values from the "Start Value" to the "End Value". Example: Start Value = 0, End Value = 5, Duration = 5 >>> ".0001, .0002, .0003.... 5" and it lasts 5 seconds. My problem is that when the loop is running I am unable to override the data output with the manual cluster. The program wais until the loop is fully finished to give priority back to the manual cluster. Is there anyway I can override these loops?
(The ramp meter is just there to show what is happening in the loops if it is not being displayed in the output.)
07-22-2014 10:23 AM
If you want to break a for loop inbetween the execution, enable the Conditional Terminal (Right click the for loop, you can see the option).
07-22-2014 12:36 PM
Thanks, I tried adding the conditional terminals like you suggested. The for loop will not activate if the manual Boolean is selected now, but it still will not allow me to override with the manual controls. I would like the loop to stay continue being executed in the background but only display its value when it's Boolean is selected. When the manual override is turned on and off again, the loop should pick right back up where it would have been if it had never been interrupted. I have a mini working version of the program that does the basic task without the loops. I am just having trouble scaling it up to what I need it to do.
07-22-2014 12:43 PM - edited 07-22-2014 12:46 PM
@Maximous wrote:
You have a basic misunderstanding of dataflow. If the FOR loop is supposed to read the current value of the boolean, it needs to be read inside the loop. You are currently reading the stale value from the tunnel, of whatever the boolean was when the loop was called.
Why do you wire N if you are autoindexing? (array to matrix to matrix size is pure Rube Goldberg code :D)
07-22-2014 12:54 PM - edited 07-22-2014 12:54 PM
Ok, is there a way to get a "fresh" value from a cluster through the tunnel then? Or will I have to have some separate switch in the loop to do that?
And looking at my Rube Goldberg code again, I'm not sure why I did that .
07-22-2014 12:57 PM
@Maximous wrote:
Ok, is there a way to get a "fresh" value from a cluster through the tunnel then? Or will I have to have some separate switch in the loop to do that?
Through the tunnel? What you need to do is have the cluster at the deepest nesting and read the terminal when you need the data.
07-22-2014 01:05 PM
I think you have the wrong structure of your program to handle those kind of changes.
A for loop should in my opinion only be used for a strongly defined sequences of operations. user interactions should be events.
Then maybe you need to learn about labview structures,
for fun I did a Queue based state machine of your code, here it is:
07-22-2014 01:16 PM
Wow, thanks so much. I only picked up Labview a week ago so I have really just stuck to structures I was familiar with. I will look into your queue system.
07-22-2014 01:30 PM
You still have way too much code.
It is not clear from the picture where the boolean value comes from (try to avoid overlapping wires!), so I assumed that it is the boolean (start array) going to the outer case selector. This needs to be "Switch when pressed", though).
All your inner code is way over-engineered. You can combine all inner cases. You don't need most local variables.
Here's a quick attempt at a simplification. See if it gets you some ideas. Modify as needed.
07-23-2014 02:27 AM
Better explanations of it are available, you can for example look at queues, state machines, and then the Producer/Consumer structure. For me the Producer/Consumer works much better than trying to cram everything into a single loop.
Good luck with your programming!
-Magnus