LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

pausing a For Loop

I'm new to LV programming and can't quite figure out how to do this. I'd
like to generate a series of numbers with the random number generator using
a For Loop and plot the numbers on a Graph. In addition, I'd like to
stop/pause execution after each loop iteration and then start again using a
control on the front page, so that each number is plotted one at a time. Is
this possible? Thanks in advance.
Bill B.
0 Kudos
Message 1 of 3
(3,016 Views)
What you want to do is possible in a number of ways. The vi below shows a method that you can use. Your final logic will depend on your program requirement.
Message 2 of 3
(3,016 Views)
> I'm new to LV programming and can't quite figure out how to do this. I'd
> like to generate a series of numbers with the random number generator using
> a For Loop and plot the numbers on a Graph. In addition, I'd like to
> stop/pause execution after each loop iteration and then start again using a
> control on the front page, so that each number is plotted one at a time. Is
> this possible? Thanks in advance.

You can do it, but a more flexible diagram architecture may be more
appropriate.

First, if you just want something quick and dirty, the buttons on top of
the window, the || button will pause the diagram and allow you to continue.

If you want one button to pause and continue, make it have mechanical
action of a plain switch, and somewhere in your F
or loop add a while
loop that executes until the Boolean is FALSE. If you press the button,
it will change to TRUE and stay there until you press it again. The
program will still be running, but the while loop will not finish until
the button is FALSE. Since the while loop is inside the for loop, the
for loop must wait for the while loop.

If you want something more flexible, look to using a state machine.
Have a state for generating and charting a number, a state that checks
the button, and a state that does nothing. Now make your state
transition logic do the appropriate states depending on the button.

Greg McKaskle
0 Kudos
Message 3 of 3
(3,016 Views)