LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Two tasks while

I have a few VIs that need two or more separate tasks running in parallel, and I am wondering how to sync them.

The 1st example is I need an edge counting task to run in parallel with a dmm measurement task. They have very different amounts of setup time. There really is no dependence between the two tasks other than when they start and stop. They should start doing their thing at roughly at the same time, and when DMM measurements are complete I want the counting task to end and report what it found.  I want them as separate as possible with minimal added wires.

To get the edge counting task to end (other than simply timeout), I thought I would  wire a boolean true into the stop-if-true terminal of the edge counting while loop. So I am looking for some vi that I can tack onto the end of the DMM task which will just produce this true condition at that point in time. This has got to be simple but I don't see anything. The unbundle-by-name will extract a boolean status from an error cluster, but I want a true regardless of error.

To get the two task's start synced up I have seen where the error cluster of one task is branched out to the perimeter of a single sequence frame. This frame is placed into the second task chain at an appropriate sync point such as near the start. Is there better way?
0 Kudos
Message 1 of 4
(3,002 Views)
The Synchronization palette has two types of functions which will do what you want: Notifiers and Queues. Notifiers may be appropriate for what you described. Queues are a bit more involved to use, but have greater versatility if you want to pass more information than just "time to Start" and "Time to Stop."

The setup tasks should be performed outside the loops. Start the loops and have them running in an idle state until the "Start" command is received. A while loop with a case structure and a shift register implements this. See examples of state machine architecture. Similarly, any shutdown code should be outside the loops.

Lynn
0 Kudos
Message 2 of 4
(3,000 Views)
Based on the provided examples it appears I would have to rewire the entire VI to cast it in a form that could use notifiers. It is already complicated enough. I was expecting to add a couple of elements with wires at most.  The 'first call' vi looks more like what I want.

0 Kudos
Message 3 of 4
(2,993 Views)
 

Have you considered using Timed Loops perhaps? You would need LabVIEW 7.1 and above. But you can set Timed Loops to syncronize their start times. You might search the Example Finder for timed-loop or timed loop for Timed Loop examples. In particular there's one called Syncronizing the start of timed loops.vi. Another example that might interest you is called Cont Acq&Graph - Int Clk - Timed Loop.vi. This actually uses a counter to create a DAQmx timing source that actually drives the timed loop. You mentioned one of your acquisitions was a counter task. You might actually use that counter task to drive a timed loop running your DMM acquisition.

These methods are very powerful, but might not be best suited if you just want to add a few wires here or there to an existing app. You can, though, right click any While Loop and select Replace with Timed Loop to automatically change it. I would do a little research before you go with this option. It might be a great idea to start your next application with as well.

A great idea might be an occurrence. This will allow part of your block diagram to wait for an occurence until it is set from another part of the diagram. The idea is basicly like a notifier. It will require a couple wires, but not that many. Honestly, the error cluster idea is pretty standard if you don't require exact syncronization.

 
Jarrod S.
National Instruments
0 Kudos
Message 4 of 4
(2,972 Views)