LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LABView not executing for loop

Hey all,

The attached VI is only executing one of the for loops. I found on one of the forums that it might be an auto indexing problem but none of my inputs are 0 (more like of the order 0.000024). 

Also I made some modification but before that the program was executing the other for loop and not this one.

0 Kudos
Message 1 of 8
(4,356 Views)

Which For loop?  I see two.

 

They both have auto-indexing tunnels.  So if the loop is executing zero times, it is likely that one of those arrays is empty.

 

Put probes on the arrays when you run it to see if that is true.

 

I don't understand your comment about the .00024 input or what that has to do with your For loops.

 

I do see that some of those waveforms that give the Y arrays are coming from case structures.  Are any of those case structures False?  If so, because you are using "Use Default if Unwired", you'd be sending out an empty waveform which means an empty array.  Zero elements means it will run the For Loop zero times when you auto-index on that array.

0 Kudos
Message 2 of 8
(4,335 Views)

@GuyDude wrote:

might be an auto indexing problem but none of my inputs are 0 (more like of the order 0.000024). 

 


It's not the value, it's the array size that matters. Note that the bottom FOR loop is vestigial and can be removed without any change in functionality (all primitives can operate on arrays directly!). Same for the upper loop, but that one needs a few small changes)

Message 3 of 8
(4,329 Views)

@RavensFan wrote:

Which For loop?  I see two.

 

They both have auto-indexing tunnels.  So if the loop is executing zero times, it is likely that one of those arrays is empty.

 

Put probes on the arrays when you run it to see if that is true.

 

I don't understand your comment about the .00024 input or what that has to do with your For loops.

 

I do see that some of those waveforms that give the Y arrays are coming from case structures.  Are any of those case structures False?  If so, because you are using "Use Default if Unwired", you'd be sending out an empty waveform which means an empty array.  Zero elements means it will run the For Loop zero times when you auto-index on that array.

 

All case structures become true at some or the other point during the run(see those flip switches....they make the structures execute). They might not stay true till the end of the run. This means the waveforms are not empty. I'm attaching a screen shot of the front panel to support this.

 

How can i get around the 'use default if unwired'. Since the display waveform is inside the case structure its not facing any problems. So how can I get the waveform out of the case structure the right way.

 

I was confusing array size with elements inside it for auto indexing hence the 0.000024.

ceeg.JPG 

0 Kudos
Message 4 of 8
(4,285 Views)

@altenbach wrote:

@GuyDude wrote:

might be an auto indexing problem but none of my inputs are 0 (more like of the order 0.000024). 

 


It's not the value, it's the array size that matters. Note that the bottom FOR loop is vestigial and can be removed without any change in functionality (all primitives can operate on arrays directly!). Same for the upper loop, but that one needs a few small changes)


Thanks. I know now. Changes becasue I'm using loop iteration as a timer/counter for building arrays? Even when i remove the FOR loops and shift the contents to the main while loop there is no data being recorded in the resulting excel sheet.

Message 5 of 8
(4,281 Views)

I suggest you try running your VI with Execution HIghlighting turned on so you can understand the dataflow better.

 


@GuyDude wrote:

@RavensFan

 

All case structures become true at some or the other point during the run(see those flip switches....they make the structures execute). They might not stay true till the end of the run. This means the waveforms are not empty. I'm attaching a screen shot of the front panel to support this.

 

How can i get around the 'use default if unwired'. Since the display waveform is inside the case structure its not facing any problems. So how can I get the waveform out of the case structure the right way.

 


Your waveform graph may not be empty, but the wire that comes out of the case structure when the False case runs IS an empty waveform.

 

If you want to be able to turn off a switch, but have you other code run based on a waveform value that was acquired in a previous iteration, you should add a shift register or a feedback node so that the waveform data wraps back around to the beginning of the loop.  The true case can output a new set of waveform data.   The false case will have the waveform wired through from the shift register.

Message 6 of 8
(4,268 Views)

So,

I fixed the For loop not executing problem Now there's a new problem. 

Everytime the case changes, from true to false or vice versa, the structures overwrites the previously written array.

How can I store the data from previous iterations of the structure.

If the answer is a feedback node, where can I put it. 

0 Kudos
Message 7 of 8
(4,254 Views)

Make 1 feedback node that is OUTSIDE the case structure.

 

With what you have now, you could probably get rid of the case structure and just use a Select node that will choose between either 0 or the value you acquired to build into the array.

Message 8 of 8
(4,251 Views)