LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

boolean output after a certain time is passed

Dear Labview Experts,

I have a problem with respect to having two "Wait until next ms multiple" vi. Please look at the vi. There I have a text message just below the AND operator indicating the place where I want to something.

This is where I want another condition of time, say when the time is more than 5 secs then the output should be a boolean True and the output of the AND operator true. I already tried some options. The first one was "Wait until next ms multiple" where I had 5 sec (5000ms) as condition. But then it interferes with my For-Loop where I am counting every 5 ms of time 100 times (so 1 full loop is half a sec). For 5 secs I have 10 full rounds of for loop. But with 5 sec also in there, my for loop counts for half a second and waits for 4.5 secs and then counts again and so on. Which is not what I want. I want the two timers to count independent of each other. I also tried another for loop directly in that place, where I count 5000 msec (5sec) and I give a output to my AND operator. The problem here is the output from the for loop is a 1 D array of Boolean type (I dont remember exactly what it is now but something with 1D array) and the input to my AND operator should be a Boolean input. So they didnt match good. Some other options tried where also not successful.

Is there any other option or better way to do it?

Thanks once again for reading.

Best Regards,

Jan
0 Kudos
Message 1 of 5
(4,933 Views)
It sounds like the issue here is that from the standpoint of that (at this point unknown) operation you want to perform, you don't want to create a time delay, you want to measure one. The thing to do is create a shift register on your while loop and initialize it with the current time using Get Date/Time in Seconds. Now inside the loop call Get Date/Time in Seconds again and subtract the value in the shift register from this function's output. The result is the time in seconds between rigth now and when the loop started. So do a comparison to see if the difference is greater than 5. Next, because you probably want this process to continue with the output of this logic going true every 5 seconds, add code to pass the time value from the shift register to the right-hand node of the shift register if the comparison is false but passes the new time value if the comparison is true.

A couple general comments: When creating LV code neatness counts. The idea is that you don't just write code you also have to be able to test it and debug it, and these jobs get very difficult if you can't tell where wires are going because they run over the top of one another and under things or the wires don't visibly connect to tunnels (as in every one of your little case structures). Likewise you need to be thinking in terms of creating reusable bits of code, so be on the lookout for places where you are doing the same thing over and over again - like every one of your little case structures.

Finally, I haven't followed the logic through completely, but it looks like all you are really doing in the mass of case structures is determining what the delay value should be based on the value in a shift register. I seems like that whole mass could be replaced with better (i.e. much simpler, more readable, more maintainable) code. For example, the value in the shift register can only have one of 13 values:  0 through 12. Therefore create a numeric array with 13 values in it, where element 0 is the delay value for 0, element 1 is the delay value for 1 - and so on. Now wire this array to the array input of an array indexer, and the value in the shift register to the index input of the array indexer. The output of the indexer is your delay.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 5
(4,924 Views)
You posted the following clarification on another thread:


Dear Mr. Mikeporter,

Thank you very much for your reply. Actually the two questions are different. In the first question, I made a mistake in describing my problem. For example, the condition you added in my vi, is operating continuously independent of the above boolean condition where I am comparing a value with 0.03. Say, the clock is running and at the time the drehregler shows value less than 0,03 I have a boolean output of TRUE from the adjacent less than condition icon. When the time the condition is satisfied, may be your clock is already showing 3 seconds (or 2 or 4 or 4,5 seconds). That means I have a counter output after 2 seconds. I am sorry for not explaining it properly at the first place. Since, I realize that I don't want this. I added one more post, where I am saying something different and something what I want. Say, my drehregler goes below 0,03 and the boolean output is TRUE, here I want to start my clock and wait for 5 seconds and after 5 seconds, when I still have TRUE output (i.e., the drehregler is less than 0,03) then I want to activate the counter.

Thank you very much for your reply and assistance.

Best Regards

Jan



So what you are wanting is this 5 second delay, but you don't want it to start until after the top comparison goes true. At the end of the timeout if the top comparison is still true then you want the output that increments the counter. Correct?

One additional point, what do you want to happen if the output of the top comparison goes true but let's say that after 2 or 3 seconds it goes false and then a second later true again and remains true for the remainder of the timeout. Give that the comparison wasn't true for the entire 5 second period, do you still want to trigger the increment when the timeout finishes? Or do you want the timeout to be restarted when the comparison goes false?

Mike...

Message Edited by mikeporter on 06-14-2007 08:38 PM


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 5
(4,908 Views)
So what you are wanting is this 5 second delay, but you don't want it to start until after the top comparison goes true. At the end of the timeout if the top comparison is still true then you want the output that increments the counter. Correct?

Yes. If all the 5 secs the output remains TRUE then the output should increment or decrement the counter depending on which condition was satisfied (MORE THAN or LESS THAN)

One additional point, what do you want to happen if the output of the top comparison goes true but let's say that after 2 or 3 seconds it goes false and then a second later true again and remains true for the remainder of the timeout. Give that the comparison wasn't true for the entire 5 second period, do you still want to trigger the increment when the timeout finishes? Or do you want the timeout to be restarted when the comparison goes false?

Actually, say the output goes TRUE and I start my timer and the timer is in 2 secs and the output goes FALSE, the timer can stop (or can keep running but when the boolean output goes TRUE again then the timer should start from zero, so for this reason better the timer stops when boolean is FALSE and starts when the boolean is TRUE). And say after one sec the boolean goes TRUE again, the timer should start counting, now after 5 sec (and when it is between 0 and 5 secs) the boolean was always TRUE, it should increment or decrement. After making the 5 sec rotation and after making an increment or decrement, if the Boolean is still TRUE then the counter should start counting again from 0 to 5 secs and if it is for 5 secs TRUE then once again increment or decrement. The idea behind to write this is, the importance of Boolean output in starting the timer and the importance of 5 secs in doing increment or decrement even when it is continuous. (Say the Boolean was TRUE for 23 secs, then my timer counter 4 full cycles of 5 secs so, it made 4 increments or decrements and after which the counter was on for just 3 secs and went off.  Now after 4 secs, the boolean goes TRUE again for 16 secs, then the timer starts to count again , makes 3 full 5 sec rounds, make 3 increments or decrements and after 1 sec stops since the boolean is not TRUE any more)

Thank you for your assistance

Jan
0 Kudos
Message 4 of 5
(4,894 Views)
Here, try this. So I could test it I stripped out all the DAQ code. I also cleaned up the code that was generating the value that was driving the inner loop - as it turns out all you really need to do was one subtraction. The indicator labeled "Result" corresponds to the output of the big adder in the original code.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 5
(4,863 Views)