LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stop array from saving between runs

Solved!
Go to solution

Im having trouble trying to keep an array from saving information between runs. Below is a picture of my SubVI. Basically im taking an array of a cluster and turning it into an array for passing to a DLL. The part circled in red is the array which keeps building. After each run of the VI the data from the previous run is saved in the array. I dont want the data to save between runs.

 

for example: (im making up the numbers that would be in the array im just demostration how they save.)

first run the array will be [1, 2, 3, 4, 5, 6]

second run the array [1, 2, 3, 4, 5, 6, 41, 42 ,43 ,44, 45, 46] but on the second run I want the numbers to be [41, 42 ,43 ,44, 45, 46]

 

0 Kudos
Message 1 of 6
(2,382 Views)
Solution
Accepted by topic author schddc

You need to initialize the feedback node.

(e.g. right-click feedback node...move initializer one loop out...right-click initializer terminal and "create constant" (i.e. empty array of the right datatype) that now sits on the left edge of the FOR loop).

 

If you have LabVIEW 2012, you can also use a concatenating output tunnel.

 

Also note that "index array" is resizable, you only need one instance to get all elements you possibly want. 😄

Message 2 of 6
(2,376 Views)

Your inner FOR loop can be simplified.  See below.  Also by going with this shortened version, you can eliminate your extra logic on Index Array from the output of the inner FOR loop because your array will be a set size.  In fact, you won't even need the Index Array.  The array can go straight into your Build Array.

 

Top is your code.  Bottom is mine.  It would have been even simpler if the bytes weren't reversed.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 6
(2,357 Views)

my bad I should of mentioned I have LV 2010 but im saving this as 8.6 for backwards compatibility

 

@

to be clear your saying i need to:

1) create an empty array of U32 outside of the loops (so the same lvl as TxData)

2) create a tunnel to the first level of the loop containing the feedback node

3) attach the tunneled array to the initalize terminal of the feedback node

 

@crossrulz

thank you, that looks much cleaner. even your top loop looks nicer I didnt realize I could take multiple elements of an array at one time. Ill take a deeper look the bottom loop and understand how that works. I really like how it elimates elements i look forward to the increased execution speed.

0 Kudos
Message 4 of 6
(2,340 Views)

@schddc wrote:
1) create an empty array of U32 outside of the loops (so the same lvl as TxData)

2) create a tunnel to the first level of the loop containing the feedback node

3) attach the tunneled array to the initalize terminal of the feedback node


You need to right-click on your feedback node.  There should be an option to "Move Initializer Out One Loop" or something like that.  Notice then that the initializer for the feedback node is now on the FOR loop.  Wire an empty U32 array to that.  With that done, each time the FOR loop is called the array will be initialized to an empty array.  See attached for an example with my cleaned up code so you can play around a little better with what I did.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 6
(2,324 Views)
Thanks for the vi example and the help from both of you. This helped me solve another problem I was having too.
0 Kudos
Message 6 of 6
(2,288 Views)