04-21-2010 01:33 PM
I have a series of simple calculations (multiply, divide, add, subtract) occuring in a while loop based on data input on the front panel by the user. The results are then connected to local variables which change the settings of a signal generator in a seperate while loop.
The while loop containing the calculations only repeats one iteration unless I turn on the 'Highlight Execution' button on in which case it repeats until the loop is stopped as I would expect. With the 'Highlight Execution' button off and using a probe to check instead the loop does not repeat.
The other while loop with the signal generator does repeat, but only uses the values that were entered before the VI started running.
I need the VI to recalculate every time a value on the front panel is changed and change the output from the signal generator accordingly.
What am I missing?
Solved! Go to Solution.
04-21-2010 01:48 PM
It is easier to troubleshoot if you post the VI giving you trouble.
Several possibilities.
1. You are using local variables in ways you shouldn't and are getting race conditions.
2. You don't understand the way data flows and have some interdependency between your loops. Also, where you are reading your controls only happens outside of your while loops and only get read once the program starts.
3. If you want to to something where you act when a user changes a front panel control, you should probably be using an event structure.
04-21-2010 01:53 PM
04-21-2010 02:16 PM
04-21-2010 03:04 PM
04-21-2010 03:10 PM
04-21-2010 03:18 PM
04-21-2010 03:44 PM
Because the local variables are attached to the LEDs that are in the on position after ending the VI it runs correctly the first time and only runs one iteration before stopping the while loops containing the calculations if you run the VI more than once. As long as the LEDs are in the off position when the VI is started then everything works fine.
Thanks for the hints everybody.
04-21-2010 04:32 PM
Why do you have three separate loops running in parallel with local variables used to pass values to the bottom loop? Just put everything in one loop and eliminate the local variables. See attached vi. works great.