02-09-2016 07:19 AM
Hello,
What could be the approach allowing to stop while loop caused by an event in another while loop.
In my setup (snapshot below), the BOTTOM loop serves to:
When the number of transitions goes over certain value (e.g. 100), the TOP loop (served to generates analog output) must stop and DAC must keep the last run-time value at the output.
Local variable seem can't be used for this purpose (limited to controls only), while trying to wire a global variable to the ouput comparator, error appeared.
Thanks in advance
Pavel.
02-09-2016 07:24 AM
02-09-2016 07:25 AM
Pavel_47 wrote: while trying to wire a global variable to the ouput comparator, error appeared.
Did you actually create a global variable yet? A global variable is a special type of VI. Go to File->New. In there you will see the option to create a global variable.
02-09-2016 07:33 AM
Why can't you use a local variable? Using local variable is not best-practice but in these case it is the simplest way.
You can also use a notifier. In the second loop, you write notification (TRUE) and in the first loop you continuosly read the notification. Then the notification is TRUe, loop terminates. Notifiers can be used in loops of different VIs.
Here is an example of the use of notifier for loop termination:
02-09-2016 07:35 AM
I think creating propriety node / value of on Boolean bottom could do this but it need one more cycle of loop to acur
do you need any sample code fo that ?
02-09-2016 08:33 AM
02-09-2016 08:35 AM
Hello AC_85,
Concerning "Local Variables" you are right, I can use it ... but it requires creating a supplementary indicator that is useless, ... but Ok, it's minor problem.
I've just tried it (please, see the top snapshot).
It works ... but something happened with device.
It's no more under control - e.g. on control panel I specified Amplitude = 4V, whereas on oscilloscope I see former value of 1V, also the frequency of sawtooth isn't the same.
As result there is descrepancy in values: loops must stop when edge counter = 12, whereas it stops when counter = 21 (bottom snapshot).
It's probably normal, because when "stop event" occurs, there are still samples in the input buffer.
To diminish this effect and also to see is the last value is really kept at output when "transmitting loop" stops, I decrease the sawtooth frequency ... but surprisingly the old value persist. Strange.
I've rebooted (Power OFF/ON) the USB-6343, but problem persists.
Concerning notification, I didn't properly understand how to use them ... I will serach in examples.
Regards
Pavel
02-09-2016 08:36 AM
@Hatef wrote:I think creating propriety node / value of on Boolean bottom could do this but it need one more cycle of loop to acur
do you need any sample code fo that ?
You just hit pet peeve #1 for me: using a value property node to avoid using a local. You fix nothing (still have race conditions) and you slowed down your system by >1000x. Yes, a property node is that much slower than the local.
02-09-2016 08:49 AM
Incredible ...
I've run this VI at least 20 times and it still can't take into account updated values for Frequency and Amplitude.
Is there some way to "reinitialize" VI ?
02-09-2016 09:20 AM
Strange phenomena continue ...
I've tried to change default values for frequency and amplitude on control panel.
For both I proceed with:
When I reopen it the frequency and amplitude still keep old values !!!
What happens ?
Thanks in advance
Pavel.