04-21-2004 03:45 PM
04-22-2004 02:10 AM
04-22-2004 07:51 AM
04-22-2004 01:36 PM
01-29-2015 07:42 PM - edited 01-29-2015 07:45 PM
I know this is a REALLY old thread, but I am having a problem in LV 2014 that seems to apply...
I am performing a 30 minute wait, using the wait (ms) function, where I am looping on a 1000ms wait 1800 times as I am cycling through a test. The reason I am doing it like this is so the operator can break out of the loop and stop the test program at any time, without having to wait until the 30 minute wait is complete. See below for screenshot of the usage.
About 30% of the time, at random, it seems that the dwell time that is supposed to be 30 minutes is more like 15-20 minutes. The rest of the time it's right on the money, or at least close enough to 30 minutes that it doesn't matter. I can't see any code bugs that could cause this...it's pretty simple code. Does anyone see any reason why the way I'm doing it might cause this problem?
01-29-2015 08:10 PM
Is there anything telling the Global STOP variable to be True?
01-29-2015 08:11 PM
Why don't you just put the stop button's terminal in the loop itself?
"Seems like" and "is" are entirely different. Is it something you've checked or is it something that just feels shorter?
01-29-2015 09:50 PM
If the global stop variable were true, the program would end, due to that variable being wired directly to a Select function that controls the Next State of a state machine.
The time IS shorter, randomly, about 25-35% fo the time. I have not seen it go longer...FWIW...
The Stop terminal is not in the loop because this loop is a very small portion of the whole program. The Stop control terminal is actually in an event structure, so that it is immediately read when pressed, and then the stop global is set, which allows the operator to stop program execution from anywhere within the program.
01-29-2015 10:27 PM
Is there anything else going on with that event structure? With what you've shown, you can easily move it inside the for loop and use the wire you already have going out to stop the program.
It's difficult to say what else is going on with your program with such a small piece of it. Is there a reason you're unable to share your code?
With what we've seen, it's a rather awkward architecture. Seeing the whole picture might help to clear that up
01-30-2015 04:30 AM
You really can't trust the waits being exact in a Windows environment. What you should really be doing is use a While loop that iterates every 100ms or so and use the system time to see how much time has passed. When the difference reaches your 30 minutes, stop the loop.