LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

delay in case structure

Solved!
Go to solution

hi

 

i am using a case structure inside a while loop.

 

i want to put a delay of about one second whenever the case goes false (it should remain false untill 1 second) and then comes to normal routine. i tried to use the function wait(ms) but then it effects the while loop. is there any way to put a delay without effecting the the normal timing of the while loop operation?

i am attaching a simple example vi to clear my point.

 

thanks

0 Kudos
Message 1 of 7
(9,015 Views)

Of course it will, the case can't finish until the wait is up.  And the iteration of the while loop can't finish until the case structure is done.

 

What do you want to have happen in the while loop while the case structure is waiting for a second?

 

You have two choices.  One is to separate the two pieces of code into two while loops

 

The other is that you use an Elasped Time timer (an express VI, that doesn't slow down the loop, but only executes the true case in the event the time has elapsed and whatever other condition you want to make the true case true.  It isn't a delay, just a check whether a certain amount of time as passed.

0 Kudos
Message 2 of 7
(9,005 Views)

you are right but i want to make the false statment to stay for one second even the case is true,

or may be my approach is wrong, let me explain u in this way, suppose considering the attached example if i want to skip a complete cycle from the chart shown in case statment what i thought this can be done only when the false statment appears and stay for little longer., what i am thinking is to put some kind of delay in false statment to make it false for a while even after case statment set to true, do you have any other approach to acheive this kind of result, but offcourse i prefer to use single loop.

thanks for the reply

0 Kudos
Message 3 of 7
(8,991 Views)

You might want to consider using a boolean and a shift register for that boolean to control the case structure selection. This way you can make a smaller delay that does not affect the operation of your while loop, and keep that boolean false for some number of iterations of the while loop until a second has passed. After that, you can have a condition to set the boolean in the while loop back to true, or whatever you want.

 

You might want to consider using a timed while loop as well. 

Message 4 of 7
(8,985 Views)

can u please show me how could i do this in some picture or on the same vi i posted earlier.

thanks for the suggestion

0 Kudos
Message 5 of 7
(8,980 Views)
Solution
Accepted by qazi ahmad
Here is an example using the elapsed timer.
Message 6 of 7
(8,963 Views)
that is exectly what i want Thanks alot for the help guys
0 Kudos
Message 7 of 7
(8,930 Views)