From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

parallel processing

Solved!
Go to solution

I use LView 8.6.1 and I'm very new to LabView.  I have two completely aysnchronous functions in a physical machine.  The first function looks at temperatures from a couple of thermistors and runs a PID controller to maintain a setpoint.  The second function runs a stepper motor to perform a mixing function that has nothing whatsoever to do with the temperature function. Both functions require calls to a 3rd-party set of vi's, and these vi's are embedded into two parallel loops within a external while loop, shown attached (generic version due to problems with confidentiality). .

 

Where the same VI's are used in both loops, I've made them re-entrant.  I've added wait states of at least 100 mS to each loop shown to allow CPU switching.  I have 2 cores and the machine reports 5% max CPU utilization.  I have wired device configuration and error handling in parallel between the two loops to avoid unintentional serial dataflow. 

 

I have spent hours and hours looking through posts on this board as well as others to try to determine how to *completely* asynchronously operate these two functions and avoiding bothering anyone, but no matter how I do it, it appears that some level of dependency is created between the loops.  This can be seen because the faster loop (temperature) terminates appropriately but then is forced to wait until the slower loop iterates to a conclusion.  I got it to a point where the dependency is tolerable (at one point one of the loops didn't even run!, the other dominated the processing entirely) but I would prefer true independence due to timing reports to the front panel being inadequate the way it currently runs.  When the loops first execute, they do so at independent rates just like I'd like.  So independent processing is possible.  It's when one loop terminates, that it has to wait for the other one to finish before restarting.  I tried timed loops with CPU core dedication and that didn't change anything.  The external while loop doesn't seem to be the culprit.

 

Question:  it appears that no matter what, some level of serial execution control is inherent in a multi-thread data process.  Queues, notifiers, rendezvous, semaphores, state machines, action engines, event cases - all appear to link one process to another.  Is there a truly independent way to process entirely separate processes in LabView so that each runs at the defined rate set by the respective wait functions, and have nothing to do with one another otherwise?

 

Thank you.

0 Kudos
Message 1 of 9
(11,826 Views)

If I understand your question correctly you just have to use 2 while loops. 2 parallel while loops will run completely in parallel.

In your current architecture for each iteration of the while loop both code parts need to execute, so they are dependent on each other.

 

Hope this helps.

 

Message 2 of 9
(11,815 Views)

If I look at your code shot, I see both system run  in a single while loop.

 

Place both functions in a seperate while loop and you should be good to go.

 

If you have actually 2 cores there is no need to use a wait state. (and 100 ms is quite long).

 

A good way to review how your code works is by using 'Executing highlighting', you can activate this by the little light bulb in the button toolbar. If you activate that and then start running your VI, you will see in slow-time how your code executes. What you will notice is that after the faster loop has run, it must wait on the slower loop before the while loop restarts. (exactly as you see it)

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 3 of 9
(11,791 Views)

That was the definitive response I was hoping for - "2 parallel while loops will run completely in parallel".

 

I'll rework the structure and see how that pans out.

 

Thanks for the input, much appreciated.

 

 

Message 4 of 9
(11,742 Views)

Thanks, Ton. I have to think about how to place them in separate while loops without duplicating initialization structures outside the original single loop, but your and Dan's inputs are very helpful.

 

Thanks again.

0 Kudos
Message 5 of 9
(11,740 Views)
Solution
Accepted by topic author Lactus

You can run initialization code before starting any of the parallel loops by using the error wire as a means to control execution flow.  See below:

 

Example_VI_BD.png

- tbob

Inventor of the WORM Global
Message 6 of 9
(11,728 Views)

Amazing....  I removed the outside while loop and the code still didn't run independently.  So I put the while loops around each code part as you instructed... sweetest thing I ever did see.  Immediately both parts started to run independently.  I stared at the front panel for half an hour to convince myself that it really did work.  Each part can start and stop independently... change rates... respond to front panel interfaces... completely independently.  So there really is a way to completely parallel execution. I have to change the way I think about execution within that original outside while loop to properly understand it.

 

Simple thing to an LView expert, but big difference to me!

 

THANK YOU!

Message 7 of 9
(11,702 Views)

You guys rock. Being able to check with experts, fast, and get trustworthy input is just out of this world.  The error wire controlled execution as you stated, and the initialization works.  The parallel while loop construct makes sense from an execution standpoint, but I couldn't find an explicit statement to that effect despite hours of looking. Well that frustrating phase of development is over....

 

Thanks for sharing your expertise, much appreciated!!

Message 8 of 9
(11,697 Views)

Thank you very much for your honest reply!

 

The fact that you were looking into the issue and debugging showed that you putting effort into it.

 

I can understand how such a basic feature for LabVIEW can be intriguing for new users.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 9 of 9
(11,624 Views)