LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to enable (start timer) and disable (stop) an elapsed time bloc??

I have a program that gives the user 2 seconds (i use an elapsed time bloc of 2 s) to push a button (hardware, from a keypad). If within this time there is no action it executes the rest of the program in a certain sequence, if a button has been pressed, it executes the same sequence. as it is running in a while loop, after the rest of sequence is finished, i will observe the 2 seconds again until 50 push buttons are done. if the user doesnt push the button, there is no problem (in other words 2 sec elapse). however, if a button is pushed, the sequence moves on to a different bloc, but the elapsed time bloc does not stop and keeps running. when the program runs again the elapsed time bloc, it finds 2 sec have been elapsed and skips a whole bloc of waiting for 2 sec. when i try to reset the elapsed time bloc when a button is pressed, it starts the counting time when the button is pressed, and when the program runs again the elapsed time bloc, it finds that most of the time (some 1.5 secs) are already gone and does only observe 0.5sec. I hope this is clear, please is there a way of enabling or disabling the elapsed time bloc so it wont run while other blocs are running, and starts counting time only when the bloc (or sequence it is in is run). Thanks in advance
0 Kudos
Message 1 of 3
(3,705 Views)
The description of your program isn't very clear, but if you are running into a situation where you need additional functionality from the elapsed time VI, then the best thing to do is to write your own.

An elapsed time VI is easy to write using a functional global and the Get Date/Time in Seconds VI. By default, the functional global usually has an option to initialize (reset) the time (store the current time in an uninitialized shift register) and and another option to check the time (subtract the time in the shift register from the current time and return either the difference or a boolean indicating whether the difference is greater than some desired time). This type of timing module design is discussed further in chapter 6 of the LabVIEW Intermediate I course (implemented in excercise 6-3).

Once you have a basic timing module you can easily expand it to include other functionality. It sounds like what you want might be pause/resume options, which could be added by using another uninitialized shift register. If that's not exactly what you are looking for, then try writing the timing module and you'll probably understand the solution to your problem in the process.

Regards,
Ryan K.
0 Kudos
Message 2 of 3
(3,689 Views)
I'm also confused by the description. Another option might be to use the event structure and the timeout event there. Any code in the timeout event will execute when the timeout value is reached. When the code in the timeout event finishes, the timeout starts from 0. It might also be the best way to handle al those push buttons as well. Post some more details and a sample of your own program.
0 Kudos
Message 3 of 3
(3,685 Views)