LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Time Delay

Hi, all,
I am a beginner with labview and currently use it for DAQ. I developed
a very simple VI to show the movement of a handler. I put four
different pictures, which showed the four states of the handler in a
picture ring. Then I used a for loop as inner loop to control the
picture ring for movement. A while loop was placed for repeating and
controlling the STOP. When i run this VI, the handler can move as i
want, but there were 2-3 seconds time delay when i tried to stop this
VI. Could anybody help me?
Thank you in advance!!

Regards,
celery
0 Kudos
Message 1 of 2
(2,606 Views)
....A while loop was placed for repeating and
> controlling the STOP. When i run this VI, the handler can move as i
> want, but there were 2-3 seconds time delay when i tried to stop this
> VI. Could anybody help me?


What is usually happening in cases like this is that a while loop is
running one more iteration after it sees the abort button pressed. If
one or two iteration of the loop can account for the time delay, maybe
this explanation will help

When a while loop diagram begins, it typically sees quite a few things
in parallel. At the top of the loop are your computations, at the
bottom is your Stop button read. Let's say the while loop is just
beginning iteration 10. The diagram begins execution, and lets say it
inspects the button terminal, passing it to the continuation terminal
with a FALSE, meaning to run another iteration. At this point you have
already committed to running iteration 11. Then the top of the loop,
the computation starts. If it takes about a second to run, during that
second you press the Stop button. The screen shows the button pressed.
At the end of the diagram, the loop starts the diagam again and starts
iteration 11. First it reads the Stop button, and this pops the button
out on the front panel. It sends the value to the continuation
terminal, and the loop will not execute again, 11 will be the last one.
So then the top part of the diagram executes, taking about one second.

From your point of view in this example, you asked that the loop stop
after nine finished. LV didn't see the change until 11 began.

The solution is to sequence the button read with the diagram. Either
read the button at the end of the loop, or read it at the very
beginning, but make the code inside be conditional. Many people do this
by using a state machine and making the check state and execute state
alternate. For something this simple, you can also use a sequence, and
if you know what this means, use a single frame sequence with a data
dependency.

Greg McKaskle
0 Kudos
Message 2 of 2
(2,606 Views)