06-08-2006 11:16 PM
06-09-2006 01:40 AM
06-09-2006 01:46 AM - edited 06-09-2006 01:46 AM
Message Edited by Dynamik on 06-09-2006 01:52 AM
06-09-2006 03:27 AM
You are completely tearing up all dataflow and the various parts of the code step on each others shoe laces. 😉
Use a single while loop and implement e.g. a queued state machine architecture. (5 States: State 1-3, pause, and stop).
Also remember that if you have several LEDs where at any time exactly zero or one is TRUE, you can use a radio indicator. Attached is a very simple implementation to give you some ideas.
As mentioned above, a queued state machine would be more flexible. Have a look at e.g. the shipping example labeled "queued message handler". There is even a design template.
06-09-2006 10:30 AM
06-09-2006 10:59 AM - edited 06-09-2006 10:59 AM
@tadk wrote:
I did start with a simpler vi. I added the local variables, ... to understand the flow of execution and to try to fix a simple issue - the exit button did not cause an exit.
There is little "flow" in local variables 😄
@tadk wrote:
If there are race conditions, can you help me understand where? Are the button presses lasting too long? Are the local variables not updated quickly enough?
Very simple: There is NO data dependency between the local variable read of stop5 in the big loop and the execution of the sequence structure in the big loop. This means that stop5 puts data into the termination condition before stop5 ever changes.
Quick Fix: Place the Stop5 local variabel read in the last frame to ensure it is read after the inner while loop completes. See image. 🙂

... Actually, you should just wire from the inner stop5 local variable to the stop condition of the outer loop. A wire always ensures proper dataflow and eliminates race conditions entirely. Why do you think you need to read the same value with two identical local variables?
... Even simpler. Place the stop4 button terminal at the location of the inner stop5 local and delete the extra while loop at the bottom entirely. Then wire from the stop4 terminal to the termination condition of the outer loop. Look ma, no locals (except for the LED indicators)!
Have you tried execution highlighting yet? It will help you solve such problems easily!
Message Edited by altenbach on 06-09-2006 09:00 AM
06-09-2006 12:04 PM
... Even simpler. Place the stop4 button terminal at the location of the inner stop5 local and delete the extra while loop at the bottom entirely. Then wire from the stop4 terminal to the >termination condition of the outer loop. Look ma, no locals (except for the LED indicators)!Not exactly since the inner loop will not exit, but I get the point.
06-09-2006 12:11 PM
@tadk wrote:
Not exactly since the inner loop will not exit, but I get the point.
Of course it will exit. 😄 Try!
06-09-2006 12:16 PM