LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Time Delay not working properly

I want a delay of 5 seconds when a condition is TRUE and 0 seconds when the Value is FALASE.Its working with the TRUE Condition but taking too much time when i change value to FALSE.
 
 
Pls check the code.
0 Kudos
Message 1 of 10
(4,419 Views)
Could you please post the code (perhaps you have previewed your post this will erase attachments)

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 10
(4,405 Views)
Pls find attached file in Labview and Microsoft word format. Thanks Atif Sarfraz
Download All
0 Kudos
Message 3 of 10
(4,379 Views)
How exactly are you using your program? Do you use the "continuous run" button?
 
Once the subVI is in a 5 second wait state nothing will happen until the subVI is called again. It is not obvious how you are using the program you have attached. Can you be more specific?
 
0 Kudos
Message 4 of 10
(4,375 Views)
Thanks, I am running (sub VI) continuously,  I want to start a pump  5 seconds after water level  reaches at HIGH Level (when input is True), but want to STOP it immediately if it Reaches LOW Level (when input is False),  This VI is working fine with the High Level (True Condition), but taking about 2 seconds to stop the pump when i change the boolean input from True to False.  If i RUN this VI (not continuously) then it stops (VI) immediately.
0 Kudos
Message 5 of 10
(4,367 Views)
Hi M_Atif
  1. it is bad practice to use run continiously!
  2. What happens if you use run continiously and hit the false button is that the true case is finished first (eg. it times out) and then the false case is executed
This is normal behaviour.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 6 of 10
(4,361 Views)

"run continuously" is for debugging subVIs, no to run a serious program. What basically happens is that whenever the program finishes it gets relaunched immediately. In your case it will immediately enter the delay case and nothing will happen until the current delay has finished.

There are many easy solutions to your problem, atttached are two possibilities.

  1. (ON-delay.vi) Using events, probably less suitable since you are not reading front panel controls, but hardware.
  2. (ON-DelayII.vi) Using a plain while loop. Basically, reset a timer whenever the switch goes to true and output the boolean AND of "time>5000ms" and the "input switch".

 

Download All
Message 7 of 10
(4,343 Views)
Hi
Hope this can help you
0 Kudos
Message 8 of 10
(4,332 Views)
Thanks a lot, it solved my problem and now i can understand the difference between RUN and RUN CONTINUOUSLY,  Now i want to create it as Sub VI with one Input and One Output. But you used Shift Registers to get the previous state, which are not letting me to convert this as SUB VI. Can I use another function other than SHIFT REGISTERs to store old value.
0 Kudos
Message 9 of 10
(4,302 Views)
You can use shift registers in subVIs. Why do you think that this is not allowed?
 
One simple example is attached. You have to be a bit careful with unititialized shift registers in subVIs if you use that subVI in multiple locations. For this reason I have set it to reentrant execution. The code might still need a few tweaks, but should point you in the right direction.
 
BTW: If contributors go through the effort of answering your question and even making examples, and these anwers get a relatively low rating (two ot three stars in this case) it is very well possible that some users will not answer in this thread because they are afraid it might hurt their rating average. Think about it. 😉

Message Edited by altenbach on 11-27-2006 09:53 AM

Message 10 of 10
(4,265 Views)