LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Feedback Node, Global Variable not keeping last value

I use a revision VI to set the revision of board I am testing with a labview test program.  We use a basic framework set of VIs which call specific VIs dynamically at runtime.  The revision VI will not keep the last set value.  It always returns the intialized value.  I have tried using a feedback node, an uninitialized shift register and a global variable to hold this value.  The only way I can get it to remember it between VIs is by programmically loading the front panel inside the VI holding this data.

 

While this is working for me I was wondering why?  Does labview clear this data when returning from a VI that was dynamically called?  When I test the revision VI by setting the value and calling it again within the same VI it works fine.

0 Kudos
Message 1 of 2
(3,253 Views)

Hi Pake,


Good Morning and I hope your well today. 

 

Thanks for the post and excellent question. 

 

When the VI is loaded into memory the memory is then created for the VI. When manually running a VI, when you open it - memory is created, and then everytime you run the VI it accesses the same memory space. Hence, why the shift register for example, the VI remembers the previous value, if you don't have anything wired to initialize it. That is because the memory location for the shift register is the same, and hence previous execution value is still remembered. 

 

Now, when you dynamically load, run and unload/stop a VI the memory is created, used and then destroyed/released. The second time you dynamically call the same VI it is going to create a NEW memory space/locations for it, hence the reset behavior you see. 

 

This explains why when you keep the VI in memory, the VI remembers the value - because it is still using the same memory space. You can keep VIs in memory without their front panels visible, so this could be a solution for you. However, generally its bad practice to not initialize shift registers. To achieve the functionality you require I would suggest using a Global Variable in your project. Function Globals are designed to store data. 

 

Please let me know your thoughts, and I hope my explanation makes sense. 

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
Message 2 of 2
(3,214 Views)