08-13-2014 04:57 AM
Dear all,
I want to control the execution time of a while loop. I want the user to have the possibility to decide for how long he wants to execute the while loop. THe while loop is used to update some values, so it should continuosly run, not just run once and then wait (which I could easily do using the timing functions).
I used the elapsed time VI like suggested in this post:
and works ok, but the while loops are integrated into another for loop, and when the for goes to next iteration, the elapsed time boolean output is fixed to true and it does not execute the while (I think this is the problem).
Is it possible to set the boolean output of the elapsed time VI back to false once the time target has been reached? This would solve my problem, I think...
I attach a part of my VI, even if I don't know it could be useful to you...
Thanks for your help
Solved! Go to Solution.
08-13-2014 05:43 AM - edited 08-13-2014 05:44 AM
08-13-2014 06:01 AM
08-13-2014 06:04 AM
08-13-2014 06:19 AM
Use the iteration counter for the While loops and a Equal To Zero? node. While the output of the comparison to the Reset input of the Elapsed Time functions. The idea is that you reset on the first iteration (when i = 0).
08-13-2014 06:44 AM
Thanks crosslrutz... Now it works great, even if I still did not understand the logic of the thing! The most important is that it works 🙂
08-13-2014 08:25 AM
@fabbro12 wrote:
Thanks crosslrutz... Now it works great, even if I still did not understand the logic of the thing! The most important is that it works 🙂
Actually, understanding it is just as important because you may run into this same kind of issue in slightly different forms in the future.
When [i] = 0 (the first time through the loop), the output of Equal To Zero? will be true. The timer is reset to zero.
For any other value of [i], the output will be false and the timer will NOT be reset - it will keep counting.
This is a fairly important concept to learn because there are all kinds of situations where you would employ this logic.
08-13-2014 08:33 AM
Ok, I understood of course that we reset the Elapsed time starting from the first iteration (i=1....).
The only thing I did not get (and still I continue not to completely understand because the help is not written clearly) is WHAT this reset does... Does it turn the boolean variable of output to FALSE when the Elapsed time function is recalled?
I don't think the reset put to zero the start,time because I also wire a true constant to the auto reset terminal (means that the start time will be "Present" any time the VI is called)....
So, according to me, NI should provide a better description of what RESET does....
08-13-2014 08:45 AM
07-02-2018 08:32 PM
Hi!!
I am having the same problem now, what did you do to solve the problem? Did you use the auto reset or reset?