06-07-2013 10:32 AM
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]
Solved! Go to Solution.
06-07-2013 10:50 AM - edited 06-07-2013 10:58 AM
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. 😄
06-07-2013 11:28 AM - edited 06-07-2013 11:30 AM
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.
06-07-2013 12:07 PM - edited 06-07-2013 12:16 PM
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.
06-07-2013 12:30 PM
@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.
06-08-2013 07:56 PM