LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Application Design In LabWindows/CVI

Hello Smiley Happy,

 

I have been using LabVIEW for almost 5 years as part of academic and professional projects.

Recently i have kickstarted test and measurement system development using LabWindows CVI.

Given that i have only some basic knowledge in C- programming, i'm finding it a little difficult to understand concepts like multithreading and all. I'm familiar with c programs using a top down approach and some function calls, but nothing like mutithreading or any other advanced concepts. Hence i need some guidance in designing a large application in LabWindows CVI.

 

Assume that my application consists of 5 modules, all of them should be running in parallel. 

I'm planning to write seperate c source files for each of them and call/control them from a main code. Is this approach correct? If not what is the best approach or design pattern that should be followed.

 

Below are some queries

  1. How to run the 5 modules in parallel?  multi threading?
  2. If i'm creating header files(.h) for each of the 5 modules and include the headers in main code(.c) using #include , does that mean that all the 5modules will run in parallel, once the main code starts running.?

Regards

Deepu Jacob

 

-----------------------------------------------------------------------------------------------------------------------------
Waiting For the inner calling 🙂


0 Kudos
Message 1 of 6
(3,544 Views)

Hi djac91

anwering to your "simple" question would require a full course of concurrent programming, so if you want really do this, be prepared to study carefully the problems that arise when you have to manage the concurrent access to common resources, and so on. 

Yes, you have to use multithreading to have several functions to run in parallel. 

And no, it's not a matter of simple declaring function in different files, you have to tell the operating system that your functions are to be run in parallel, just to start...
There are more than a way to obtain this result, and recent versions of CVI support OpenMP, and this could be a good starting point to learn.

Here a couple of links, just googled for you:
http://zone.ni.com/reference/en-XX/help/370051Y-01/cvi/libref/openmptutorialhelloworld/

https://decibel.ni.com/content/docs/DOC-29830

You will found tons of documents on this topic, and do many many many experiments before to try to use concurrency in "production code", because concurrent programs are the perfect candidates to intermittent failures and differences of behavior between debug and release version, different PCs and so on

Good luck 🙂

Carlo A.
Megaris




0 Kudos
Message 2 of 6
(3,489 Views)

Hi Carlo,

 

Thanks for the suggestions. I'm picking up multithreading concepts. I hope it will take me some time before anything complex can be implemented. Anyway i have no plans to give up.Smiley Wink

 

Regards

Deepu Jacob

-----------------------------------------------------------------------------------------------------------------------------
Waiting For the inner calling 🙂


0 Kudos
Message 3 of 6
(3,487 Views)

Dear Deepu,

 

first of all: If you are new to multithreading in C, please get familiar with the following links to get some basic knowledge about the advantages and challenges about it:

 

Multithreading in LabWindows™/CVI - National Instruments
http://www.ni.com/white-paper/3663/en/

 

Building Multithreading Applications with LabWindows/CVI - Tutorial - Developer Zone - National Instruments
http://200.126.14.82/web/NationalInstruments/Instrupedia/instrupedia/appnotes/C420218625686900732DF3...

 

When implementing your code, the following link describes the documentation to the CVI functions for multithreading:

 

Using LabWindowsCVI Multithreading Functions - LabWindows/CVI 2012 Help - National Instruments
http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/programmerref/usingcvimultfuncs/

 

In general, it could be useful for you, to visit a CVI Core 2 training in your local branch. CVI Core 2 teaches using multithreading in CVI and other advanced topics. The full training description can be found under the following link:

 

LabWindows/CVI Core 2 - National Instruments
http://sine.ni.com/tacs/app/overview/p/ap/of/lang/de/pg/1/sn/n24:14928/id/1592/

 

Concerning the application architechture, it is hard to recommand a pattern or architechture without knowing any details of the requirements.

 

I would recommand starting with the basics first to get an idea of what is possible. Maybe you will grow an architechture in your mind then anyway. Otherwise it could be useful to contact a software architect and discuss the requirements document with him.

Best regards,
Melanie Eisfeld
Senior Applications Engineer, National Instruments Germany
Certified LabVIEW Developer
Certified TestStand Architect
0 Kudos
Message 4 of 6
(3,482 Views)

Multithreading is a passionating but challenging technique that can help you dramatically to design concurrent tasks in your application, but requires a careful design.

 

The starting point for addressing multithreading can be this page:

General Information on Multithreading for C Programmers

Carefully reading that document, the attached Multithreading Overview and other pages linked there you will have a full view of problems you may find, design concepts you may use to address them and practical implementations of those concepts.

 

Unfortunately, as Carlo already told you, this is not an area where to go with a trial-and-error method: some basic design concepts are needed to start with, and the documentation we pointed you to will be of help in this matter.

 

Edit: I see Melanie was faster and provided a very detailed list of resources! Smiley Happy



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 6
(3,480 Views)

I'd add one thing: are you SURE you need multithreading ? Excuse me for mentioning it, but if you are not an expert you may have the wrong approach. Maybe a simple UIR timer switching between your 5 tasks is enough. Maybe simple run-in-sequence with interspesed ProcessSystemEvents()... Maybe an async timer (which is multithreaded but mostly transparent)...

 

Those approaches are much simpler and much less prone to mysterious errors and hangups the others have mentioned. And if they don't fit the bill you can also progressively adapt them to a mulithreading approach.

Message 6 of 6
(3,458 Views)