05-08-2006 04:12 AM
05-09-2006 02:27 AM
but when i select the "SingleFrame" button it takes some time to stop the loop.
This is expected. The Wait (ms) can't be interrupted. So in your case, depending on when the button is pressed and read by the program, the time to stop the loop can go from about 0ms to >5000ms.
I would strongly suggest to use a state machine instead of all multiple sequences. This would give you much more flexibility and would decrease the usage of local variables. But this was not your question...
An easy way, with only very small changes to your code, to achieve a faster response of the button is to replace the Wait (ms) by the attached VI. Sorry for the french documentation of the VI. See attached picture and follow above description :
1) Replace Wait (ms) in sequence 0[0..3] in case 0 with the attached VI
2) Wire Time (ms) to its Attente [ms] input. This sets the time to wait.
3) Create a constant for the Tcycle [ms] input. 100ms for example. This sets the period of the while loop inside the VI. The state of the button (passed by reference) will be read at this rate and the VI will stop "immediately" if the button is pressed. In the normal case, the loop will stop when the delay is over.
4) Create a reference for the SingleFrame boolean. Right click on the Control >> Create >> Reference
5) Wire this reference to the Réf Stop input of the VI
6) Repeat for every instance of the Wait (ms)