LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

default values in subvi

Solved!
Go to solution

HI,

  Every time when main VI calls subvi, those values/setting in subVI which are not connected with mainVI will go back to default values.

 

  How can I let subvi remember those values (which is changed in the last time call) as the setting in the next time call?

 

Wei

LV7.1 

0 Kudos
Message 1 of 11
(5,694 Views)

Here's an idea:

 

The style used is sometimes referred to as 'Functional Global'.

 

Ton

Message Edited by TonP on 12-18-2008 07:15 PM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 11
(5,686 Views)

Maybe I didn't describe my question clearly.

 

Here is the example (See attachment).

Every time, when I run main.vi, It automaticaly use y=0 (default value) as the y input in Sub.vi.

 

But, if I run Sub.vi itself only, every time the y use the last time result as this time input. I want to realize this when I use Main.vi  to call VI.

 

Do I have to read the y values in sub.vi to main VI, and then input to SubVI next time when Main.vi call it?

 

 

Download All
0 Kudos
Message 3 of 11
(5,681 Views)

I understoord your question perfectly, you didnt understood the answer Smiley Happy

 

Here's a new example, where I check both inputs (Numeric and Y) in the subVI:

 

 

Ton

Message Edited by TonP on 12-18-2008 07:47 PM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 4 of 11
(5,669 Views)
This may be a bit more than you were looking for but this is one way of doing it.  I added some stuff you your subvi to turn it into a simple action engine.  use the enum control in main to control how it works.  The first time you run it, select "init".  From then on you can either select "retain" and it well store the last y value.  "Use Y" will use whater is wirest into the Y input, and "init" at any time will reset it back to 0.
Gregory Osenbach
Download All
0 Kudos
Message 5 of 11
(5,665 Views)

Hi,

 

did u try global variable?

 

store Y in a global in Sub VI......read that when u run Sub VI from main VI........

 

Anil

Anil Punnam
CLD
LV 2012, TestStand 4.2..........
0 Kudos
Message 6 of 11
(5,664 Views)

See attachment. There are 2 pair of Main-Sub vi.

They are exatctly same code. Only difference is that they are written in different computer.

 

Please run to see the difference. Why are they different?

0 Kudos
Message 7 of 11
(5,654 Views)
Solution
Accepted by topic author weitong
Well, in the first one, you do not that the "y" control linked to a terminal on the connector pane.  The one that does not remember, you do.  So when the subVI runs in the code that has the y value linked up, it uses the default value.
Gregory Osenbach
0 Kudos
Message 8 of 11
(5,650 Views)

OK, I see. This is what I want to know.

 

Thanks to everybody answering my question.

 

Best,

 

Wei,

 

Message Edited by weitong on 12-18-2008 02:00 PM
0 Kudos
Message 9 of 11
(5,642 Views)
Althought this does not give you any way to reset y other than unloading the vi from memory...
Gregory Osenbach
0 Kudos
Message 10 of 11
(5,637 Views)