LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best method to pass DAQmx data between MAIN and SUB

This is the setup. LV2012 on WIN7 machine with PCI6229 DAQS card.

 

I have a MAIN VI that has all DAQmx read and write tasks defined for the PCI-6229 card. This MAIN VI has a user interface where the user selects one Sub VI from among 8 different sub VIs . Both the MAIN and SUB VIs have 50ms While loops

 

Once user selects a Sub VI, the UI of MAIN is hidden and the UI of the Sub VI loaded in place. The MAIN continues to run in back ground interacting with the PCI-6229 card.  I now have to  transfer DAQmx Read data from MAIN to Sub VI and DAQmx Write data from Sub to MAIN.  Which would be the best ( in terms of speed, CPU resources , memory usage etc) from following options :

 

1. Global Variables.

2. Functional Global Variables with only GET / SET mthods.

3. Queue. One queue for all data from MAIN to SUB and another queue for all data from SUB to MAIN.

4. Notifiers ?

5. Any other method ?

 

( The MAIN and SUB run on the same PC. No LAN is involved)

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 8
(3,477 Views)

Hi

      From my point of view, Using the Functional global will be effective.

0 Kudos
Message 2 of 8
(3,456 Views)

If you need to stream the data without losing any data between the Main and Sub VI, I would use a queue. If you just want to display the latest values in the SubVI (i.e. a snapshot), I'd probably use a notifier.

 

If you were to show us some code, it would help to better advise on which methods to use.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 3 of 8
(3,432 Views)

Dear Sam,

 

Thanks for the suggestion. To aid better understand my requirement I have created a small project with one MAIN and SUB. Please check out and let me know how it can be improved .... I have removed the DAQmx data input to a simple Random Number generator.

 

I have now used Timed Loops - but I would like to replace them with WHILE loops while using the DAQmx data and fire the loop when the data set is ready. For that purpose I have also enlcosed a VI called AI_HW_TIIMINGSETUP.VI. You can check that out.

 

Incidentally the MAIN does not stop at times when the STOP button is clicked. Is there any mistake in the way it is implemented ?

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 4 of 8
(3,397 Views)

This seems to me overly complicated.  The method you are using to start and stop VIs is complex and prone to errors.  A much more "intuitive" way to run a sub-VI is to simply call it -- if you want it to (temporarily) display its Front Panel, you can tell it to Show Front Panel When Called, and if you want it to "cover up" the Main (not a good idea, in my opinion), you can run it Maximized.  But why?  What functionality do you gain by having two Front Panels that show similar things at different times?

 

I tell my students that it is too easy (especially coming from text-based programming languages) to get caught up in how to do something that you lose sight of the true goal, figuring out what you want to do.  The "what" question, when asked in sufficiently broad strokes, generally dictates the overall structure of your program, and if you use LabVIEW's Secret Weapon, the sub-VI, to "hide the details", you are much more likely to have clean code that does what you want it to do, not just what you tell it to do.

 

Bob Schor

Message 5 of 8
(3,380 Views)

@Bob_Schor wrote:

This seems to me overly complicated.  The method you are using to start and stop VIs is complex and prone to errors.  A much more "intuitive" way to run a sub-VI is to simply call it -- if you want it to (temporarily) display its Front Panel, you can tell it to Show Front Panel When Called, and if you want it to "cover up" the Main (not a good idea, in my opinion), you can run it Maximized.  But why?  What functionality do you gain by having two Front Panels that show similar things at different times?

 

I tell my students that it is too easy (especially coming from text-based programming languages) to get caught up in how to do something that you lose sight of the true goal, figuring out what you want to do.  The "what" question, when asked in sufficiently broad strokes, generally dictates the overall structure of your program, and if you use LabVIEW's Secret Weapon, the sub-VI, to "hide the details", you are much more likely to have clean code that does what you want it to do, not just what you tell it to do.

 

Bob Schor


On Forum posting  it becomes difficult to share all pertinent information ( without making it a big post ) to get an answer and this is a classic case !!

 

1. When I have one MAIN ( which is used only as a App front screen and for choosing required sub VI ) and many sub VIs( at times going upto 35+ ) with their own UI, it is of course an elegant method to hide the MAIN UI and show only the Sub VI UI. And once the user is done with the Sub VI, remove it from memory and show the MAIN UI for user to choose another SUB vi. Cant see whats complicated in this..

 

2. Of course there is little to gain by showing the same Chart on two UIs !! But thats never done in actual practice - in fact when deployed on the Machine the MAIN is kind of headless - it has no user readable data except for buttons to choose the Sub VI and display the machine status.

 

When another member wanted to know what I am trying to do , I tried to put together a small project to explain the concept. I wish actual projects were this basic 😉

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 6 of 8
(3,350 Views)

Are you persisting the DAQmx Tasks to MAX or a *.lvproj?  You are saving the Tasks somewhere right?Smiley Wink


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 8
(3,312 Views)

@JÞB wrote:

Are you persisting the DAQmx Tasks to MAX or a *.lvproj?  You are saving the Tasks somewhere right?Smiley Wink


Hi Jeff,

 

Just check out the attached project and that should answer your query ... this simple application demonstrates the concept I have in mind..

 

And finally I think I will simply go with the Queue to pass data between MAIN and SUB , which incidentally was my original query.  Will be glad to get your views on this.

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 8 of 8
(3,294 Views)