LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sub vi results retained - can I clear sub-vi output after each call?

Solved!
Go to solution

I'm new to Labview and struggling with a sub-vi that I'm trying to use.  I would be very grateful for any help you could offer!

 

I have created a sub-vi which, given a few input parameters, will generate an MxN array of values (M = rows, N = cols).  This is shown in the attached snippet "array_creating_subvi".  I wrote a simple vi to call this sub-vi (see attached snippet "main_vi") which should give the required input parameters to the sub vi, display the resulting 2D array of values the subvi generates, and also return the size of the array that has been generated.  The first time that the main vi is run an MxN array is created.  The second time it is run a 2MxN array appears - the newly generated array has been appended onto the bottom of the array created in the previous call....and so on.

 

I have tried using the 'request memory deallocation' function in both the main program and in the sub-vi, I have tried reinitilizing all values to default before running the main vi (both in the subvi and main vi) but nothing seems to work.  I'm completely at a loss and would really appreciate any advice you may have 🐵

Download All
0 Kudos
Message 1 of 7
(3,535 Views)

The shift register on the far right is uninitialized. Wire an empty array constant to the input of the shift register.

=====================
LabVIEW 2012


0 Kudos
Message 2 of 7
(3,514 Views)

 


@SteveChandler wrote:

The shift register on the far right is uninitialized.


Dear Steve,

 

Many thanks for your reply, I appreciate you taking the time to look at this 🙂  If you are refering to the shift register I think you mean (I highlighted it in "array_creating_subvi_2") I can't initialise this to zero because that then alters the way that my final array is being built...at the moment I create one array that has let's say 10 rows of different values.  My final array is created by taking row 1, copying it say 10 times, and writing it to the first 10 rows of the output array.  Then the same is done for row 2 and so on...in the end my final array looks like the original, but expanded a 'modesize' number of times.

 

I've tried creating an array of zeros, of the right final size, and then having my final computed array overwrite this one (as shown in "array_creating_subvi_2") but this hasn't helped either.  The output size of the final array has been fixed to the MxN size that I expect, but the values themselves don't change after the first run when the input parameters are changed.  So basically I think the exact same effect is still occuring with new results being tacked onto the bottom of the last call's results, but now I'm only displaying the results from the first call....

 

Perhaps the root of the problem is that I shouldn't be doing my array expansion/final array creation in this way?  Essentially what I'd like to do is a labview equivalent of the repmat function from matlab....

 

Download All
0 Kudos
Message 3 of 7
(3,503 Views)

If a shift register is not initialized it will retain the previous value. Do a search on this forum for Functional Global, Action Engine or Uninitialized Shift Register.

 

You need to wire something to the input. Otherwise you will see the results retained. If initializing it to zero is not what you need then initialize it with something else.

=====================
LabVIEW 2012


0 Kudos
Message 4 of 7
(3,496 Views)
Solution
Accepted by topic author physics_gal

You could initialize your array one for loop up, and having one more shiftregister at the outermost for loop.

 

 

0 Kudos
Message 5 of 7
(3,487 Views)

 


@SteveChandler wrote:

 

You need to wire something to the input.


 

Hurrah!  It works now 🙂 Thank you so much for your help with this. 

 

I had initially not wired anything to that shift register because then each time the outer loop executed it reset my 'final array' that was being built along the way.  So using your advice I figured out that as long as it initialised only on the first iteration of the outer loop that it would then go on to build my expanded array in the right way.  Adding a shift register to the outer loop (initialised to zero) and then linking that shift register to the previously unwired one fixed the problem.

 

I've attached the final working version here on the (highly improbable) offchance that someone else is having the same problem.

 

Thanks Steve, you've made my day 🙂

0 Kudos
Message 6 of 7
(3,483 Views)

 


@dkfire wrote:

You could initialize your array one for loop up, and having one more shiftregister at the outermost for loop.

 

 


Thanks for this dkfire!  That was indeed the solution 🙂

 

0 Kudos
Message 7 of 7
(3,482 Views)