From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

while loop: execution time and continuos updated - elapsed time VI back to false?

Solved!
Go to solution

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:

 

http://forums.ni.com/t5/LabVIEW/How-to-create-a-time-control-for-while-loop/m-p/2530212/highlight/fa...

 

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

0 Kudos
Message 1 of 11
(7,028 Views)

Hi fabbro,

 

read the help for ElapsedTime and use all of it's options…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(7,015 Views)
Dear gerdW,

I did read the help of the function vi but i did not find it well explained. Is the reset button that i have to use? I also tried to wire a boolean constant set to true into the reset and into the autoreset, but the vi is still not working as expected...
0 Kudos
Message 3 of 11
(7,003 Views)

Hi Fabbro,

 

to quote the help:

Dialog Box Options

ParameterDescription
   
Automatically reset after time target Resets the elapsed time marker.

 

I think this is what you are asking for…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 11
(6,997 Views)
Solution
Accepted by topic author fabbro12

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).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 11
(6,986 Views)

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 🙂

0 Kudos
Message 6 of 11
(6,968 Views)

@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.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 11
(6,949 Views)

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.... 

0 Kudos
Message 8 of 11
(6,941 Views)

Hi fabbro,

 

beside the (maybe) needed better description:

ElapsedTime is an ExpressVI. You can open ExpressVIs (with a right-click) and look what they do inside!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 11
(6,931 Views)

Hi!! 

 

I am having the same problem now, what did you do to solve the problem? Did you use the auto reset or reset? 

0 Kudos
Message 10 of 11
(5,023 Views)