LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Override For Loop Output

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.)

Download All
0 Kudos
Message 1 of 10
(3,285 Views)

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).

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 10
(3,265 Views)

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.

Download All
0 Kudos
Message 3 of 10
(3,247 Views)

@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)

 

Message 4 of 10
(3,239 Views)

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 Smiley LOL

0 Kudos
Message 5 of 10
(3,232 Views)

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 10
(3,225 Views)

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: 

Message 7 of 10
(3,217 Views)

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.

0 Kudos
Message 8 of 10
(3,213 Views)

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.

 

 

0 Kudos
Message 9 of 10
(3,204 Views)

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

 

0 Kudos
Message 10 of 10
(3,172 Views)