LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

timed while loop

Sorry - I know this has been rehased much here , however my problem sems to differ from others and cannot figure out a solution. I am trying update some measurements for a specified amount of time in seconds in a while loop. I have tried using elapsed time , current time etc. however these seem to stop the measuremetns from updating. What I basically have is I am monitoring 4 analog inputs from a daq card. I am monitoring each input sequentially in a while loop. The user specifies how long the overall process runs. Whatever timer scheme I seem to come up with halts the updating while the timer runs, the loop ends when the timer elapses and my data is not correct and the program advances to the next process. This loop could iterate several times so I need the timer to basically reset every time I enter the loop also. I attached a small sample though I could show the whole vi - but it is large. Thanks for any input!
 
 
0 Kudos
Message 1 of 4
(3,303 Views)
Measuring time should not interfere with the updating at all. Maybe you have a dataflow problem. For a full analysis, we would need to see the full VI.
 
In general, the easiest way to stop a while loop after a certain time would be to use the "elapsed time" express VI, e.g. as follows.
 
 
 
 
 


Message Edited by altenbach on 01-31-2008 02:13 PM
0 Kudos
Message 2 of 4
(3,285 Views)
I have attached the the whole sequence. I know there are some inefficienies that I will correct once I figure my td problem. Thanks for looking.
0 Kudos
Message 3 of 4
(3,276 Views)
Don't put the "elapsed time" inside its own while loop. Just delete the small while loops and you should be OK.
 
If the bigger loop needs to repeat until the time has elapsed, you cannot prevent it from spinning by trapping execution in the small loop.
 
(Try to run your code with execution highlighting and you will see that the small inner loop will spin until the time has elapsed, at which point both loops stop.)
 
Of course instead of such a sequence worm, you should refactor your code as a compact state machine. You have an incredible amount of duplicate code for no apparent reason.
0 Kudos
Message 4 of 4
(3,269 Views)