11-17-2006 07:31 PM
11-17-2006 08:01 PM
1... You have a timeout of 1 mSec. Is it really necessary to detect the STOP button within 1 mSec? I doubt it - change that to 100 or something, and your CPU will run a bit cooler.
2... Each time you timeout, you set the STOP LOOP flag to the value of the STOP button. That will work, although you could do that via an event more easily.
3... When Button 1 is changed, if it's ON, you set the display to 1 (and do nothing if it's off).
4... When Button 2 is changed, if it's ON, you continually test (probably a million times per second) the DISPLAY, and don't stop until it's > 0. During this time you are doing nothing else.
The problem here is item 4. If the numeric is not set > 0 when you start that inner loop, it will NEVER get set, because you are not allowing anything else to happen. Your code says to wait here until it's >0, but there is no chance for anything to affect it.
Re-think your design. It's almost always a bad idea to have a WAIT UNTIL SOMETHING HAPPENS piece that's INSIDE an EVENT case.
Event cases should examine the current state, modify the state if appropriate, and get the heck out.
Maybe you could use the TIMEOUT event to check the states. If Button 2 has been pressed AND button 1 has been pressed, then light the light.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
11-18-2006 05:04 AM