LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can a sub VI run parallel to the main VI ????

 
0 Kudos
Message 1 of 7
(4,823 Views)

In terms of memory allocation a sub vi does run in parallel to a main VI - at runtime the sub vi will be loaded into memory until it is called. If you want the sub vi to also run as a seperate instance parallel to the main vi you can set it to be reentrant - that way you effectively have 2 completely seperate .vi's in memory with the same functionality.

I'm not sure if that answers your question or not - you'd have to be a bit more specific about what sort of context you mean when you say 'parallel'.

Dave C

David Clark
CLA | CTA
Genesee Technologies Ltd
Hampshire, England
0 Kudos
Message 2 of 7
(4,814 Views)

I guess you'd want a sub-vi running continously next to the main vi, as if it were just a loop in the main vi?

That's possible.   You'd want to use a queue to handle the data flow between main and sub-vi. (the normal subvi input/output is only for initializing and finishing.)  Check the example vi's I attached.   

AFAIK, the sub-vi doesn't have to be reentrant.  I think that's only necessary when you're using multiple subvi's of the same name. 

 

Message Edited by Anthony de Vries on 03-13-2006 05:01 PM

Message Edited by Anthony de Vries on 03-13-2006 05:01 PM

Download All
Message 3 of 7
(4,799 Views)

Hi,

 

       Oops! sorry for the mistake. Here is my task in detail. At the moment I am working on a Lab VIEW application to acquire data from an external device. I have a small doubt with respect to implementing a subVI in this application.

 

The actual application is based on communicating with the external hardware through CANCardX and this communication is kept alive by sending a kind of login ID every 300 ms to hardware. Now, my problem is in implementing a sub VI within a WHILE loop (The WHILE loop is the main program area which starts to run and comes to a halt when the application connects and dis-connects with the external hardware respectively). I think when I run the program with this sub VI, the transmission of the ID (which is essential to sustain communication with the hardware) stops and the external hardware communication is lost because the control of the program comes to the sub VI from the main WHILE loop.

 

So, I would like to know if it is possible to run this sub VI parallely with the main VI, which is essential to stay connected to the external hardware.

 

Also please correct me if my inference of this problem is wrong and thanks for you reply guys, I'll look into them

 

 

-Mohan.

Message 4 of 7
(4,758 Views)

Yes, putting different parts of a program in separate loops will cun concurrently (almost parallel but not quite.  The producer consumer is one such application where a synchronous communication is used to communicate between the threads.  It is always best to multithread a program which has both a user interface and a data acquisition system.  This way you avoid "freezing" either system by context switching between them (this is automatically done in a multithreaded OS)

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 5 of 7
(4,745 Views)

Hi Anthony,

Actually I work with LabVIEW version 7.1, and your example seems to be programmed in LabVIEW 8.0.  Do you have any similar program in LabVIEW 7.1???

I understand what you guys say, but just want to see the example to get it clear!!!!

-Mohan.

 

0 Kudos
Message 6 of 7
(4,721 Views)
Here are the files saved for Labview 7:
Download All
0 Kudos
Message 7 of 7
(4,703 Views)