05-10-2018 11:14 AM
I am trying to run parallel loops. The VI should run both the "before record loop" and the event structure loop in parallel when starting the program. Both these loops exit and the "record loop" begins when the "record data" Boolean is selected on the front panel. About half the time I start the program, the "before record loop" does not begin. The other half, the both loops run as expected. Please let me know why this is occurring. I'm willing to send the files if needed. Is there an easy way to post a project and all it's subvis? Or do I have to load each subvi independently?
Solved! Go to Solution.
05-10-2018 11:19 AM
Please post your code. I was not able to open the picture plus it is recommended as part pf the posting guidelines to post your code so we can better help you.
05-10-2018 11:26 AM
I have quite a few subvis and controls in the VI. Do I need to post each of those individually? Or is there way to "pack" up a project so that all of its dependents come with it?
05-10-2018 11:42 AM - edited 05-10-2018 11:45 AM
The reason the "Before Record Loop" appears to not run half the time is because of the 'Record Data' global that is used for the loop exit condition. Before your top-level VI starts, if the 'Record Data' global is set to TRUE, then the "Before Record Loop" will read that TRUE value and exit the loop.
A quick fix would be to initialize the 'Record Data' global variable to FALSE before any of the loops run.
EDIT:
Since you're already using notifiers, you could use Get Notifier Status function to stop the "Before Record Loop". Check out the Notifiers section of this KB. This would ensure that the loops would execute in the proper order.
05-10-2018 11:45 AM
Just send the vi with the loops in it first. Maybe we can see what is going on there. If we need more we can get the rest later.
05-10-2018 11:50 AM - edited 05-10-2018 11:51 AM
You can upload everything by creating a zip file. In windows, select all files, right click >> send to >> compressed folder.
In your case, I think the top loop is starting and running only once. (A while loops always runs at least once). However, since the stop condition comes from a GLOBAL VARIABLE it is probably still set to True from the previous run, meaning it will stop after the first iteration.
05-10-2018 11:51 AM
Thanks Daniel K! That makes total sense. And I can easily add a notifier in that loop also.
05-10-2018 11:56 AM
Your code seems overly complicated and poorly designed. What's the state of the global when the program starts? Why can't the code of the top loop be combined with the middle loop (e.g. using the timeout event). Stopping a loop containing an event structure while other loops continue to spin is obviously a very bad idea. Maybe a simple state machine would be a better solution.