LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel Loop not starting

Solved!
Go to solution

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? 

0 Kudos
Message 1 of 8
(4,020 Views)

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.

Tim
GHSP
0 Kudos
Message 2 of 8
(4,016 Views)

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? 

0 Kudos
Message 3 of 8
(4,013 Views)
Solution
Accepted by ChristineM

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.

dK
0 Kudos
Message 4 of 8
(4,002 Views)

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.

Tim
GHSP
0 Kudos
Message 5 of 8
(3,996 Views)

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. 

0 Kudos
Message 6 of 8
(3,988 Views)

Thanks Daniel K!  That makes total sense.  And I can easily add a notifier in that loop also. 

0 Kudos
Message 7 of 8
(3,985 Views)

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.

0 Kudos
Message 8 of 8
(3,979 Views)