LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

passing values between different vi's

Solved!
Go to solution

Hi guys , this may be very basic question but couldnt able to find the solution ,,,

i have Main Vi and a sub Vi ,, in which my main vi produces a random data and send it to the subvi . Here i want to open the window of subvi permenently i meant if i click display window button ,, only the value has to get update,, but in the attached example every time the screen blinks becoz of the reason everytime is called ,, i have even tried passing the random values using one more queue and read it in the subvi ,,,nthng works ,,,thanks in advance ,,

john

0 Kudos
Message 1 of 10
(2,883 Views)

You have changed the design pattern. You are doing the dequeue before the while loop starts. Here is the flow of your code.

 

  • When you 1st start running the code your upper while loop runs normally until you click Dispaly button
  • Your second loop input wire is from queue output and the timeout of the queue is -1 (by default) so it will wait indefenetly so once you click the Display button your queue gets the state and passes the value into the while loop and the input will never vary until you Abort the code.
  • You cannot stop the code since the state will never change.
  • The subvi property is kept as Open front panel when called so your sub vi opens for every iteration of the loop without a delay thats why it looks like blinking.

 

Do these steps

 

  • Place the queue inside the while loop and leave the timeout unwired and connect the error wire to the loop terminator
  • Remove the Open front panel when called (if you dont want to show the front panel
-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 10
(2,874 Views)
Solution
Accepted by john_new

Hi John,

 

One of the causes of the blinking is that the sub vi's property was set to "Close afterwards if originally closed".

Even if you set the "SubVI Node Setup..." to "Close afterwards if originally closed".

Both places must be set correctly.

 

I made a few other mods. See if this is what you wanted.

 

steve

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
Download All
0 Kudos
Message 3 of 10
(2,871 Views)

Hi steve ,, thanks for the prompt reply .. this is what i have expected to do ...

 

An other small question , i have made the same logic with Queues(loading the value in Main.vi and reading in subvi) , Notifiers(loading the value in Main.vi and reading in subvi).. whats the big difference , do i have some influence becoz of this in my program.. i mean parallel processing in main loop.

 

I have this doubt becoz later i have three to four consumer loops in my Main program ,, each has to be working parallely i.e. data acqusition , logging etc...... 

 

reagrds

John

Download All
0 Kudos
Message 4 of 10
(2,841 Views)

Hi anand, thanks for ur reply.. U r right regarding the consumer loop ,,, i have modified it using a shift register ,, so i can change between other states 

but i didnt understand when u tell keep the queue inside the while loop ,, why should i do like this ? can you explain bit further ?

 

meanwhile i have tried the steves idea ,, it was working fine and i posted another simple question reagrdng the use of queues and notifiers...

 

regards

john

0 Kudos
Message 5 of 10
(2,836 Views)

@john_new wrote:

Hi anand, thanks for ur reply.. U r right regarding the consumer loop ,,, i have modified it using a shift register ,, so i can change between other states 

but i didnt understand when u tell keep the queue inside the while loop ,, why should i do like this ? can you explain bit further ?

 

meanwhile i have tried the steves idea ,, it was working fine and i posted another simple question reagrdng the use of queues and notifiers...

 

regards

john


I mean to say the consumer loop dequeue should be inside the while loop if it is outside it gets only once.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 6 of 10
(2,797 Views)

Hi John,

 

-----------------------------------------------------

An other small question , i have made the same logic with Queues(loading the value in Main.vi and reading in subvi) , Notifiers(loading the value in Main.vi and reading in subvi).. whats the big difference , do i have some influence becoz of this in my program.. i mean parallel processing in main loop

-----------------------------------------------------

 

I can't look at your new vis (haven't installed 2012 yet), but I will give my opinion on queues versus notifiers.

Unlike queues, notifiers do not buffer data. If no one is listening - the data is lost.

Let's say, for example, that you are receiving data from a notifier in a data processing routine.

If the data processing routine does not complete before the next notification occurs, the new data is gone.

With a queue, the data would be there waiting for you.

 

In general, I would use queues to send data that might require buffering.

Notifiers are useful for sending control info (which might include data) or to synchronize operations.

 

I hope this helps,

steve

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
0 Kudos
Message 7 of 10
(2,775 Views)

Hi Steve ,

 

Thanks for your reply ,, now i am clarified about Queue and notifiers but as i have already asked ,, ist possible to pass the queues from main vi to sub vi ,, i mean passing the acquistion value from main vi to sub vi ,,,,,

0 Kudos
Message 8 of 10
(2,743 Views)

@john_new wrote:

Hi Steve ,

 

Thanks for your reply ,, now i am clarified about Queue and notifiers but as i have already asked ,, ist possible to pass the queues from main vi to sub vi ,, i mean passing the acquistion value from main vi to sub vi ,,,,,


If I understand you correctly yes. That is exactly what queues/notifiers are use for. You can wire the queue reference into the subVI or you can use named queues and have the subVI obtain the queue by name. Once you have the queue reference you can post (enqueue) or read (dequeue) data from the queue. When using queues only one task should ever dequeue data.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 9 of 10
(2,739 Views)

@Mark_Yedinak wrote:

@john_new wrote:

Hi Steve ,

 

Thanks for your reply ,, now i am clarified about Queue and notifiers but as i have already asked ,, ist possible to pass the queues from main vi to sub vi ,, i mean passing the acquistion value from main vi to sub vi ,,,,,


If I understand you correctly yes. That is exactly what queues/notifiers are use for. You can wire the queue reference into the subVI or you can use named queues and have the subVI obtain the queue by name. Once you have the queue reference you can post (enqueue) or read (dequeue) data from the queue. When using queues only one task should ever dequeue data.


Additionally I would maintain the queue reference into an LV2G or an AE and use it in the sub vi so that you can reduce the wiring and also you can use it in many sub vi's. If you have more number of queues you can maintain them in LV2G in the form of a cluster.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 10 of 10
(2,725 Views)