04-09-2012 07:02 PM
Hi there
I have specific test that I want the user to enter how much time it needs to run. This time gets converted to a number which then gets fed into a for loop which runs a certain amount of time (See attached jpeg).
I'm guessing my number conversion is funky because my time remaining indicator sometimes goes negative which keeps the VI from completing. When I test it with a small amount of time, for example FP_Time = 0.1, the VI ends just fine. I'm having this problem when the test is ran for 48h (The sample rate control is set to 5). How come? I noticed I don't have a number conversion wired to my "wait time" function? Could that be it? Please help me understand what is going on.
thank you!
04-09-2012 07:06 PM
Instead of a lot of awkward math to try to drive a For Loop, use a regular while loop and the Elapsed Time Express VI to determine when to end the loop.
04-10-2012 10:45 AM
yes I see your point. Thats probably what I will end up doing. But I also wanted to understand why this happens.
04-10-2012 10:59 AM
sb_oxinst wrote:I'm guessing my number conversion is funky because my time remaining indicator sometimes goes negative which keeps the VI from completing.
Well, that indicates that you check the completion with an equal comparison. Use a "less or equal zero" instead, for example.
You are running a fixed number of iterations, 5 seconds each and comparing the elapsed time at that rate. Depending on what else the computer is doing, some iterations might take 5001ms, and you will accumulate small errors over time that end up in a negative time difference at the end.
btw. why are you using a local variable? Simply wire the current time from outside the loop.
04-10-2012 11:14 AM
thanks for reply alten.
I believe you are right because the negative time is not always the same value . I must have a fairly large error accumulating in that 48h period because my counter goes negative for over 10h haha.
I realize that their are much better ways to do this.
thanks,