LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Apparent bug using feedback with arrays

Either I'm being really stupid, or I've stumbled across an immensely annoying bug.

Essentially all I'm trying to do is using feedback (either via the feedback node or shift registers initialised to zero) to continuously sum a series of arrays. Simple, no? Well, I've been failing miserably for the past couple of days until now, suddenly, I think I've found the answer: a stupid bug.

If I initialise the feedback node/shift register to zero, the thing simply doesn't work. If, however, I initialise each and every element of the initialisation array to an arbitrary value (say, 1), run the program and then reset them back to zero.....oh, look, it works now.

What the hell is with that? Any ideas?
0 Kudos
Message 1 of 10
(3,599 Views)
Your description is not clear. Could you attach a simple example that reproduces the bug? 🙂

Thanks!

(The sentence ".. the thing simply doesn't work" is not clear without more details, e.g. the summing does not work, the result is not as expected, it causes broken wires, it causes LabVIEW to crash, etc.). What version of LabVIEW is this? You sum a series of arrays... are they 1D, 2D, etc? You initialize it to zero... do you mean a scalar zero or an "array of zeroes" of the proper dimensions?
0 Kudos
Message 2 of 10
(3,594 Views)
Sorry, you're quite right, I was terribly clear.

I've thrown this small circuit together to show the basic problem. When you run the VI you'll notice that the output array produces an incorrect result (zero).

I can't seem to attach two files in one go so I'll attach another (identical) circuit to my next message. You'll see that it now works fun, but for no apparent reason....
0 Kudos
Message 3 of 10
(3,593 Views)
Here's an attachment where an identical circuit works!
0 Kudos
Message 4 of 10
(3,589 Views)
They both work identically for me.

Try downloading them from the forum yourself and see if your examples continue to fail for you.

Lynn
0 Kudos
Message 5 of 10
(3,581 Views)
You must make sure that the initialization array is the same size as the input array. If you add two 1D arrays, the elements are added pairwise at each index position. The resulting array will have the size of the shorter array, any other result would make no sense.

Your default "initializing array" is an empty array, i.e. has zero length, thus all results will have zero length! Note that the elements have grey instead of white background and the zeroes just indicate the generic default value. (I know, the difference is a bit hard to see on some LCD monitors :()

You have quite a few possibilities to work around it (see attached VI, LabVIEW 7.1):

If the array size is always the same, you should initialize with an array of proper size, all filled with zeroes. You can also manually fill a zero at the 4th position of your current design, then "right-click...data operation...make current values default" to keep it that way after saving. The "initialize array" node will serve your purpose.

If the array sizes vary and you want to always pad to the size of the larger array to be added, use something like the attached code.


Good luck and happy wiring! 🙂
Message 6 of 10
(3,574 Views)
Thank you so much, Altenbach; it works beautifully! 🙂
Message 7 of 10
(3,546 Views)
As a follow-up question, I'd like the system to keep running once the data has been processed, and wait for the user to, say, click on 'OK' button before processing another dataset. I can set this 'OK button' operation using an Event structure, but the VI always terminates after the data is processed. How can I achieve this?

Many thanks!
0 Kudos
Message 8 of 10
(3,540 Views)
Place a while loop around the event structure, create a stop button and add an event for clicking that button (a Value Change should do). From the stop case wire T into the loop's stop condition and that's it. The loop will iterate each time you click the OK button and will stop when you click the stop button. Just make sure you put the stop button terminal inside the loop, otherwise it won't get read and it won't jump back to F.

___________________
Try to take over the world!
Message 9 of 10
(3,535 Views)
Splendid! It works a treat. What would I do without you guys, eh?
0 Kudos
Message 10 of 10
(3,526 Views)