Friday, January 1, 2021

Running Tasks in Parallel instead of series using NI LabVIEW

 We have been developing large-scale projects in LabVIEW in our Mumbai factory since 2005 like this for ISRO (Indian Space Research Agency).

I made this article for those who are new to LabVIEW in order to quickly understand how you can run tasks in parallel using NI LabVIEW. LabVIEW makes that super easy which programmers who are experienced with other languages find daunting even using latest Integrated Development Environments.

Even many intermediate-level LabVIEW programmers will find this informative. If you do not know LabVIEW but are working on projects which involve NI LabVIEW, this information will be extremely valuable. Many projects these days utilise PLC with LabVIEW, so if you are programming using 'Ladder' for any PLC such as Siemens, Allen-Bradley etc. and someone else in your team is building the SCADA using LabVIEW - make sure he/she understands how to run tasks in parallel instead of serially using NI LabVIEW.

This is especially important as most CPUs these days are multi-core!

It's expected that you already know 'While-loops', 'Timed-While-loop' and 'Shift-registers' in LabVIEW.

LabVIEW provides an architecture to take full advantage of multi-core processors. If you do not explicitly program longer tasks using such architecture, Windows will offer very less power & advantage of multi-core.


There are many aspects of parallel programming. Even the simplest task parallelism looks like this - 



In short, suppose we are getting an array over and over (say an analog value sent in batches to us continuously), next we need to apply some Math like Fourier or Filtering etc. on the array – and finally we need to save that array on disk. So instead of doing this in series, as  in  - 


We can parallelize the 3 tasks instead as in – 






This will help in every task that uses data-sets in series.

Now the real power of LabVIEW is in the ‘Timed-While Loops’ which literally let you assign each core of the CPU to each loop. And LabVIEW takes care of the complex work of achieving it. You just need to put the core-number on each diagram.




So, now you can exploit the full advantage of multi-core CPUs using LabVIEW. If you have any questions, please feel free to comment them in this post, I'll be glad to address those!

No comments:

Post a Comment