LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing DI states from main.vi to sub panel VIs

Hi Raghunathan, Gerardo,

Re: Globals, I'm a big fan of the structure [relatively] recently labeled "Action Engine" (which may be the same thing as a "Functional Global"?) - but try to avoid passing data via globals as they tend to make logic harder to understand & debug.  To be honest, I'm not 100% sure I understand Raghunathan's application, and maybe there's a good argument for using a Global here!

Cheers!  

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 11 of 22
(981 Views)
Hi Raghunathan and TBD,

There is a very complete description about AE (action engines) and Functional Globals in this link. I do still call them functional globals, even if they will have extensive functionality.
Coming back to this thread question:


For a machine control application, I have a sub panel container called the Main.vi. And depending on the user menu selection , I have a variety of  sub VIs to load ( AutoMode, ManualMode , Calibration mode etc )

I need to read and update the state of some 14 Digital Inputs in each of the above VIs at 50ms intervals in a Timed Loop. Since the 14 DIs are common to all the sub VIs, which is the best way to go  ? :



I am not sure if I understand completely but seems to me that Functional Globals will do the job but will block the execution (until they are finish with the action) and therefore Queues will do this without stopping the execution and little extra wire.
Gerardo O.
RF SW Engineering R&D
National Instruments
Message 12 of 22
(973 Views)
Hello Gerardo and TBD,

I am sorry I cannot post the VIs as they are quite large with plenty of DAQMx tasks and thus will be "broken" by the time you open them !

Anyway I am now clear on the Queue and find that it is a great way to pass data between VIs without wires.  I think I will call the process WiDT for  "Wireless Data Transfer "  - something  like WiFi   ;-))

Thanks for your support.

Regards

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 13 of 22
(962 Views)
Hi TBD,

I have a requirement to pass a String array as well as a numeric value from a main VI to a sub-panel VI.

The enclosed zip has them both as I have developed. It is enough if the String array is just read once ( maybe I will use a LV2 global finally for this )

But I want to know how to create the required Queue  Refnums between the main and sub panel for both queues. Now the update happens just once in the sub panel and stops.

I tried based on the sample given by you but got into a mess Smiley Surprised

Thanks for your time.

Regards

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 14 of 22
(933 Views)
Hi Raghunathan,

Sorry for the latency since probably you saw where the problem is.
When you dequeue an element, the VI will wait forever (by default) until there is an element on the queue. Your string array was only placing one element and the pressure queue was en queuing but, the string one was waiting for a new element. This is why it worked only one time.
There are some changes you can make here:
A) Wire a timeout for the dequeue element VI.
B) Make two independent loops in the subVI.
C) Make single Queue.

I use C most of the times by creating a typedef of an Enum and Variant. This way I can pass any datatype in the variant and use the enum to know what datatype was about.
Hope this helps,
Gerardo O.
RF SW Engineering R&D
National Instruments
0 Kudos
Message 15 of 22
(919 Views)
Hi Yardov,

Thanks. But I am still on LV8.0 - so could you still save the example suitably and post back. Sorry for the trouble.

Yes your point is clear on the VI waiting on the queue ( it makes lots of sense now Smiley Wink)

In fact I did switch on the "Highlight Execution" button and was observing - but I still could not figure out  the problem as the VI just was keeping quiet !

In the meanwhile I have managed the situation with a LV2 global and its a such nice concept - if one can accept the marginal speed loss compared to queues.

Regards

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 16 of 22
(903 Views)
Hi Yardov,

Ok Now I have got my sample VI after I removed the "Run Once" condition for the string.

ANd what I did was to configure the numeric queue as single element and made the Main.vi run at 500ms loop and the sub panel VI which was dequeing the numeric at 1000ms. But I found that no data was lost as I expected - the enqueing was happeing at 500ms and dequeuing was at 1000ms with the queue size at single element.

I don't think I understand how thats possible, unless there is a background buffer....

Thanks

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 17 of 22
(901 Views)
Hi Raghunathan,
      Here's another approach.  It's only using one queue to pass "dynamic-data" - the constant-string-array is passed via connector-pane.


@Raghunathan wrote:

ANd what I did was to configure the numeric queue as single element and made the Main.vi run at 500ms loop and the sub panel VI which was dequeing the numeric at 1000ms. But I found that no data was lost as I expected - the enqueing was happeing at 500ms and dequeuing was at 1000ms with the queue size at single element.

I don't think I understand how thats possible, unless there is a background buffer....

With your "data-consumer" running deliberately slower than the data-producer, it's sounds like you want to drop data? Smiley Surprised  If so, the queue may be the wrong tool, it's purpose is to buffer data.  If you don't want to retain intermediate values, a Notifier is the right tool for the job.  A single-element queue would work, but may be misleading to someone trying to understand SubVI later. Smiley Wink
 
Cheers!
"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
Download All
0 Kudos
Message 18 of 22
(884 Views)
Correction!

@tbd wrote:
A single-element queue would work
 
A single element queue could work - but the Enqueue time-out (in Queue Main) would need to be set to something other than "wait forever".  As is, the Queue-main timed-loop will "hang" until the queue is emptied by SubVI - so Main only runs as fast as SubVI. Smiley Surprised
Cheers.

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 19 of 22
(876 Views)
Hi TBD,

1. I tried to run the example VIs posted. by you after selecting the right path for the subVI. But I got an error at the first Invoke node which said "Strings not found ". I then removed that invoke altogether and ran it again. This time the Queue ref worked alright but when the ten iterations were over the sub VI raised an error before closing.

2. In the meanwhile I repeated my original VI by changing the Queue element value to 20 and set the main VI timed loop to 250ms and the subVI timed loop to 1000ms. But this time i set a DeQueue time out of 100ms. Now I lost quite a bit of data Smiley Wink

3. With all of above remaining same I once again changed the queue element to "1" again.  No loss of data. And the main took about 20 sec to finish.


Frankly I am NOT trying to loose data. I am just trying to understand what happens to the "unconsumed " data due to a mismatch in the producer-consumer rates,  when you set the queue element size to 1.

Thanks

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 20 of 22
(868 Views)