LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Nested For Loops in state Machine

Hi

 

I have three nested loops in the state machine to control AC power supply voltage, Frequency, and third loop for DC Load current. Each loop runs at least 5 iterations then the state machine moves to the next state. I have made three for loops conditional terminal. I have applied local variables of the stop button to loop conditions. When I press the Stop button and the test is running these loops, it stops only after finishing loops. Is there any way to stop the test immediately?

 

Regards.

Matharoo

0 Kudos
Message 1 of 5
(1,458 Views)

(I don't consider a pyramid of FOR loops a state machine and strongly recommend to start over with a more reasonable architecture.)

 

Still, your problem is caused by dataflow in that your various "stop" local variables in each loop get read first thing and you get one additional iteration on each plane. You need to enforce dataflow so these locals get read only after all code in each loop has executed.

 

I am not sure why you need local variables. You could place the stop terminal in the innermost loop and wire to all stop conditions from there. Now it can even remain latch action.

0 Kudos
Message 2 of 5
(1,454 Views)

Hi Altenbach,

Thanks. If I use the stop button in the inner loop then there will be two stop buttons at the front panel. One from the Event structure and one from the Inner Loop. How I can hook both the stop buttons?

Regarding dataflow, You mean I have to put Excel Table vi outside the For loops? 

Regards.

Matharoo

 

 

0 Kudos
Message 3 of 5
(1,415 Views)

@Matharoo wrote:

 

Thanks. If I use the stop button in the inner loop then there will be two stop buttons at the front panel. One from the Event structure and one from the Inner Loop.


Why? That statement makes no sense at all!

 


@Matharoo wrote:

 

Regarding dataflow, You mean I have to put Excel Table vi outside the For loops? 

 


No? What does that have anything to do with the discussion?

 

You attach a broken snippet and mention an event structure that does not exist. If you want more specific help, attach the actual toplevel VI that includes the toplevel while loop and event structure so we get the full picture.

0 Kudos
Message 4 of 5
(1,402 Views)

Hi Altenbach,

 

Sorry. Due to the large size of the project file, I am unable to attach it.

That's why I added only the png of Nested loops.

 

 

Regards.

Matharoo

0 Kudos
Message 5 of 5
(1,370 Views)