LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Nested while loops : inside loop not working

Solved!
Go to solution

In my VI, i want ,for each value of outer-loop, inner loop should run completely. But in my case for every alternative value of outer loop, inner loop only runs for 1 times only, while it should run n-times.One can check the 'results'.

I am new to LabView and would appreciate  any new way of doing the same code.

 

Aim of the code:

For each value fed to outer loop, inner loop should run n times forward and backward depending on 'single sweep ' status. I have included case structures inside each loop to be able to do forward and backward sweep of values in both loops.

 

Download All
0 Kudos
Message 1 of 9
(3,932 Views)

I think you are going to have to debug this one yourself, perhaps by using highlight execution and probes.

 

The next while loops along with nested case structures means everything becomes exponentially more complicated.  With that, throw in a feedback node, and complicated boolean logic between the string of NOTs, ANDs, and ORs, I bet the results of the boolean calculations are just coming out True and stopping those inner while loops when you don't want them to.

0 Kudos
Message 2 of 9
(3,913 Views)

Your False cases are supposed to go backwards through the same steps, but you still have the "Not" in that case which means that the backward stepping cases will only run once - they immediately output False from the inner cases (not Less than or equal to the minimum, for example) and then the Not makes the stop condition True.

 

Possible fix: Remove the "Not" in the False outer case in the bottom (inner loop). 

 

Do you want it to count up and then down, or just up?


GCentral
0 Kudos
Message 3 of 9
(3,877 Views)

Actually i wanted to count both up and down irrespective of sign but should have a flexilbility to do either up or down also

The program should count from start to end and then come back to start in case of "single sweep" is disabled while program should count from start to end only in case of "single sweep" is abled .

 

i will try the fix and get back to you

0 Kudos
Message 4 of 9
(3,872 Views)

there are four possibilities for the program to perform.

 

1. Outer loop runs forward and reverse and inner loop runs forward and reverse for each outer loop value(i)

1. Outer loop runs forward and reverse and inner loop runs forward only for each outer loop value(i)

1. Outer loop runs forward and inner loop runs forward and reverse for each outer loop value(i)

1. Outer loop runs forward and inner loop runs forward for each outer loop value(i)

 

 

 

0 Kudos
Message 5 of 9
(3,871 Views)

Thanks for the clarification. By the way, I would recommend considering use of the In Range and Coerce function for bounds checking.

 

Good luck solving this (or maybe someone else will chip in).  If not, I'll have a go at it if I get a chance later tonight.


GCentral
0 Kudos
Message 6 of 9
(3,854 Views)
Solution
Accepted by topic author SanjoyJena

Does this work for you?

 

It uses the Ramp Pattern VI to create arrays of values, then the Reverse Array in a Case Structure with Build Array to determine if it should go just single sweep, or up and down.


GCentral
Message 7 of 9
(3,828 Views)

this works very fine for positive values but i can now do it for negative values also. thanks

0 Kudos
Message 8 of 9
(3,821 Views)

Hi cbutcher

The program runs for negative also, sorry for the previous reply. Thank you

0 Kudos
Message 9 of 9
(3,803 Views)