LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop a elapse time

Here it is:
- tbob

Inventor of the WORM Global
Message 11 of 19
(1,640 Views)
Thanks,

This is a very good work but I continue having the same problem: the cpu usage is 100% because it is a while loop and it is iterating each 100ms. I need a pasive wait (not active wait)... some like semaphores, the same behavior. Inside the while loop I need someting that waits for a x ms but while it is waiting there I don't want the while loop continues executing, I want to pause it until my time (x ms) is elapsed or the user press a button. When the time is elapsed or the user press the button, then I want the while loop continues its current iteration and then finishes this iteration and begins another iteration (next iteration of the while loop, i+1), and so on.

ToNi.
0 Kudos
Message 12 of 19
(1,635 Views)
Hi again,

Your idea is just what I want but the problem is the % CPU usage. How can I reduce the usage of CPU with you example? Is there any way? I need to consume the minimum CPU possible.

Thanks,

ToNi.
0 Kudos
Message 13 of 19
(1,627 Views)
I have never seen a loop with a 100 ms delay in it which causes 100% CPU usage, unless it does something graphic which LV doesn't like.
The problem here is that the inner loop does not have a wait in it. Put one in and the usage will go down.

___________________
Try to take over the world!
Message 14 of 19
(1,612 Views)
Sorry, my oversight. I always put waits in every loop unless I have to run full speed. I just forgot this one. CPU usage will drop when adding the wait in the inner loop. Thanx for pointing this out, tst.
- tbob

Inventor of the WORM Global
0 Kudos
Message 15 of 19
(1,603 Views)
Yes tst, you are right. I refer to the inner loop, not to the outer. The inner loop doesn't have a wait in it so the CPU utilization is 100% but the problem is.... if in the inner while loop I have an elapsed time vi... is it correct to put a wait for x ms? then counting the time I want to wait in the inner loop gets more difficult to control. How can I control exactly the time I need to wait if I put a wait in the inner loop in which I have a elpased time vi? then the loop launches every x ms, for example if I want to wait 10 seconds with a elapsed time in the inner loop and I put a wait in it of 100ms... the time I wait (10 seconds) is exactly 10 seconds or more? I say to you it because I don't know in what manner the wait of the 100ms I add in the inner loop affects to the elapsed time vi because then, I gets a delay of 100ms for each loop... and finally I don't wait 10 seconds... I wait 10 seconds plus the delay 100ms for each loop.... (10 seconds + 100ms * number of iterations in the inner loop). I don't know If I explained correctly.

Thanks very much to everybody for helping me,

ToNi.
0 Kudos
Message 16 of 19
(1,596 Views)
I think you're missing something basic about the way this works.
A Time Elpased VI only checks if X seconds have passed since it was reset. It doesn't do the waiting, only the checking.
You can never get exact accuracy, but if you set a 100 ms delay the loop will run 10 times a second to check if 10 seconds have passed since the VI was reset. Once it will determine that 10 seconds have passed, it will output a T instead of a F. The most you will get is 10.1 seconds +\- a few ms.

___________________
Try to take over the world!
Message 17 of 19
(1,591 Views)
Yes tst, you are right. Thanks very much. I have modified the vi of tbob. I add a wait ms in the inner loop and now the CPU utilization is under 10%, 7% aproximately and the time I want to wait never is exactly, for example, if I put 10 seconds I gets 10.007 but it doesn't matter, it is insignificant. Now I understand How it works.

Also I add a stop button. Now you can stop it when you want or leave it reaches the seconds you want.

I attach here in LV7 format.

Thanks very much,

ToNi 😉
0 Kudos
Message 18 of 19
(1,581 Views)
Resurrecting an old thread here...
 
How would one go about wiring a 'reset to zero' switch on this VI?  This is exactly what I need to implement (actually I need about 6 of these running at once) into a VI I've been working on since day one....  I need to have user control over start/stop an elapsed timer (whilst retaining the value as this VI does), and user control to reset to zero if need be.
 
I'm attaching my VI so you can see what I'm working with.  The DAQ input has been replaced by randomized data and all the input fields have to be set to at least 1 in order to get  true cases on all the timers.  The bank of six 'elapsed time' express VI's in t/f case structures is what I'd like to replace with a VI similar to what's been developed over the course of the thread.   The ONLY thing I see missing from the VI in this thread is the reset function...
 
Any input?
 
 
___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 19 of 19
(1,496 Views)