03-14-2007 01:35 PM
03-14-2007 01:40 PM
03-15-2007 04:43 PM
03-16-2007 11:09 AM
Since you're in "learning" mode, I'd also suggest you start looking into things like "Notifiers." They can be used like local variables (with admittedly more complexity) OR they can be used to help enforce synchronization. The usefulness is that they can be set to react immediately when the value gets updated but without wasting CPU by repeatedly polling and looking for a change. Also, the main loop can destroy the notifier on termination, causing all other parallel loops containing a "Wait on Notification" to produce an error that can terminate them in turn.
Check 'em out, they're really pretty neat for accomplishing this kind of thing.
-Kevin P.
03-16-2007 11:24 AM
03-16-2007 11:28 AM
Thank you for the succes story!
I love to read them.
Ben
03-16-2007 11:32 AM
@Nickerbocker wrote:
Is there a more graceful way of doing what I am trying to do here?
The small loop at the bottom is NOT necessary. If you want to leave it, it needs a small wait primitive, otherwise it sucks up significant CPU resources spinning as fast as it can. It also will spin multiple times before releasing the thread. A wait primitive give all other parts a turn after each iteration.
There is no reason to poll for the stop button more often that the slowest loop (even if the small loop stops, the VI will continue to run until all loops have finished!), so place the stop button directly in one of the other loops and eliminate the small loop.
Also make sure that the other loops contain some reasonable timing.
03-16-2007 11:50 AM
03-16-2007 12:01 PM
03-16-2007 12:12 PM
@Nickerbocker wrote:
The application has one while loop that continuously sets an analog output as fast as it can.
This is pointless and makes everything unpredictable. The rate will change with every computer upgrade and it will continually change depending on how many other things are running on the computer. Pick a defined fast rate and stick with it.
There are a few more issues I noticed:
After you clear the graph history with a property node, wire the error output of the property node to the edge of the upper while loop. This data dependency ensures that the loop starts after the history clears. RIght now you have no data dependency and you cannot tell at which time the history clears. In the worst case, it might happen after new data has already be written to the graph (unlikely, but still.....).
If one loop stops due to error, the remaining loops will continue to run and there is no way to restart the failed loop without stopping the entire VI. It would make more sense to stop all loops if an error occurs in any one of them.
If your AI needs to run fast, place it in a separate loop writing to a FIFO (e.g. a suitable LV2 style functional global). Don't place analysis and file IO (!!!) in a loop that needs to be fast. All this can be done at leisure with the buffered data.