05-27-2009 12:08 PM
Hello all, I'm trying to build a simple state machine that changes steps based on a timer. As time elapses, go to the next step. The simple example I created here, uses two steps with a step to check for an e-stop and an idle step to burn off the time. I'm using the Express Elapsed Time vi. The steps are 60 seconds each, after sixty seconds, the express vi resets, and the next step is started.
The problem I'm haveing is that the timer falls behind after a few minutes compared to the system clock. After 5 minutes, I'm already behind almost two seconds.
To test the app, hit reset when the system clock minute is at a whole number and watch the two clocks, after a cup of coffee it will slowly fall behind.
I'm pretty sure I'm doing this wrong and would really appreciate any suggestions as to a better method, such as using the tick counter. Thank you.
05-27-2009 01:08 PM
First delete the wait function with the 125ms at the upper right.
Second, delete the elapsed time function. You already use a timed loop so you can measure time.
Adding a second timed function in a timed function is... confusing.
Use a shift register and increase it by one in each iteration. When you reach 600 you will have 1 minute. (as your loop has period 100ms) Then reset it to zero.
05-28-2009 08:33 AM
05-29-2009 08:10 AM
05-29-2009 10:33 AM
Try this.
The other case is the "Default" and it's emty.
05-29-2009 12:25 PM
05-29-2009 12:57 PM
Pnt, I spent today playing around. I'm convinced that I just can't get an accurate time from the loop timer. I switched to the system clock and seem to be making progress. Depending on my +- range selection in the Idle state, I can control how accurate my loop time is. Still not confident, I will have to work more on this.
05-29-2009 01:14 PM
05-29-2009 01:22 PM
06-02-2009 11:52 AM
Hello johnnyt,
This VI should work much better on a cRIO than on a Windows machine. There is a significantly less amount of jitter on an RT system than on a Windows system. Have you tired to eliminate the local variables in your code. I would expect the total iteration count to correspond to the total elapsed time and be very accurate.