Kubo Posted March 21, 2009 Report Share Posted March 21, 2009 Hello everyone, I have a statemachine being used to run a sequence of steps that, when completed, will be about 40 minutes long. I am trying to figure out how to impliment a timer function that will act like a stop watch for this whole process. Right now I have it so that at the first step it will capture the current time then at the end it will take that captured time and delete from the new current time which in theory will display the elasped time it took to compete the whole process. Could someone point me in the right direction that could get it so that this can display the time its taking in real time and not just display the time it took once its done. Thanks in advance Quote Link to comment
Mark Yedinak Posted March 21, 2009 Report Share Posted March 21, 2009 I would create a parallel loop which contains your timer which is effectively a stop watch. This timer loop can be controlled by a queue so that you can pass in events such as start, stop or pause. When running this state machine will generally have one event queued which would be "update the display". When your master state machine is running you can pass the timer loop messages to start or stop your timer as well as pause or reset it. You can even package this up as a simple set of subVIs or a LVOOP object and give it a reference to your display indicator. If you do this you can reuse this in multiple applications. Quote Link to comment
Kubo Posted March 21, 2009 Author Report Share Posted March 21, 2009 QUOTE (Mark Yedinak @ Mar 20 2009, 04:38 PM) I would create a parallel loop which contains your timer which is effectively a stop watch. This timer loop can be controlled by a queue so that you can pass in events such as start, stop or pause. When running this state machine will generally have one event queued which would be "update the display". When your master state machine is running you can pass the timer loop messages to start or stop your timer as well as pause or reset it. You can even package this up as a simple set of subVIs or a LVOOP object and give it a reference to your display indicator. If you do this you can reuse this in multiple applications. Do you happen to have an example of a timer? Maybe a start, stop and reset function? Quote Link to comment
ned Posted March 21, 2009 Report Share Posted March 21, 2009 Do you dislike shift registers? Instead of writing the start time to a local variable in your initialization case, instead write it to a shift register. Then every execution of the while loop (outside your case structure), subtract the shift register value from the current time and display that on your screen - voila, the elapsed time. Is that what you want? Maybe I misunderstood. You will need to do something with that elapsed time in your final case - maybe write it to total time indicator - because the elapsed time indicator will continue to increase after the sequence completes. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.