06-12-2009 09:17 AM
Hello. I'm having problems using the elapsed time delay to show the seconds remaining on a wait step in a simple state machine. I would like to have a front panel count down showing the time left for the step. I thought the elapsed time delay was the way to do this. The problem is the vi runs correctly the first time through. But then after that the timing does not seem to reset back to the times I had set. If I remove the elapsed time delay and just stick a wait time in the state, the vi runs as I would expect. This just doesn't give the user an idea of the time remaining. What am I missing when using the elapsed time delay, or is this just the wrong tool for the job?
A smaller issue is that I would like to move the tasks, in this case the LED's outside the loop so I don't have to repeat code. But when I tried moving them outside with only leaving the constants inside the state they did not work as I expected. If you have tasks like the operation of a set of booleans that you are used in several states, what is the cleanest way to do this without repeating code?
Thanks for the help.
Solved! Go to Solution.
06-12-2009 09:56 AM - edited 06-12-2009 09:56 AM
The problem is that the Auto Reset on the express VI resets the start time of the timer as soon as the time has completed. So you are essentially restarting the #1 timer immediately and then go on to #2. Once #2 is completed, #1 has already passed 10 seconds as well.
What you need to do is use the reset input for the express VI, but only have that be true the first time it is called. By using a shift register and the implies function on those loops, you can do that.
As for the duplication of states, don't have a state 1 and a state 2. Just have a Run state. Use a shift register to maintain a value for what your next state will be and a case structure to based on that to show what booleans should be lit and what the next state will be.

06-12-2009 10:02 AM
Hi Danny,
i recommend the use of a Producer/Consumer structure with events. With this it would be possible to directly stop your program. now it's not possible
Hope it helps.
Mike
06-12-2009 11:53 AM
Ravens Fan,
Take a look at the attached VI. I tried to do what you suggested but I don't think I did it correctly. Do I need to reset the auto reset for each elapsed time delay? What if I have 5 or 10 delay steps, do a shift register for each?
The VI I attached I wrote to try to undertand the elapsed time delay. However I want to move either the elapsed time delay or some other method to give the user the time remaining information to a larger VI with many sub vi that used a cFP unit. I used the LED in the example as a place holder for a cFP relay. Because of the number of relays I require, I would like to move the relays outside the loop so don't have to repeat the code for each state.
Thanks again for the help.
06-12-2009 12:10 PM
I'm sorry, I made a mistake when I worked with your VI and stripped it down to just the bare essentials to test. I created an indicator based on the Auto Reset input and it got that name.
Connect the boolean to the Reset input of the Express VI.
06-12-2009 12:31 PM
06-15-2009 07:39 AM
Ravens Ran,
Thanks for the help. I understand the mod you made to the VI and it works great. As a question of program design, do you think that using the elapsed time delay and the modified example you created is preferred way to create a delay and display the time remaining on the front panel? Or is there a better route to achieving the same outcome? Not being a programmer everytime I write a new VI I'm always curious if there is a better or "right" way to do it.
Thanks again for the help.
06-15-2009 09:05 AM
07-27-2009 08:59 AM
Hi,
I'm having the same problem as Danny, but I wasn't able to view the solution as my labview is an older version (8.2)!! Could please print the vi on the screen or reformat the file to my version?
Thanks!
07-27-2009 09:13 AM