08-09-2019 01:49 PM
Hello. In my code I have 6 Boolean arrays. I did a Build array to join these arrays into 1 because I am sending them into a subVI (I did not want to send 6 arrays into the subVI). When I did the Build Array, I right-clicked on the output of it and clicked on All Controls & Indicators. LabVIEW made a 2d "Appended Array" indicator. Why did LabVIEW make my 1-d arrays into a 2d array? Build Array was in Append mode.
Four of the Boolean arrays are indicators, while the other two Boolean arrays are controls.
Solved! Go to Solution.
08-09-2019 02:08 PM
Usually, if you are trying to conglomerate data to pass into a subVI you should cluster it rather than building an array.
If you really want to pass an array I would think it would be easier to unfold a 2D array than a 1D into its original components.
In any case you can't combine indicators and controls the way you are describing. Can you tell us what you're trying to achieve with all this? Maybe there's a better way to do what you need...
08-09-2019 11:29 PM
We are graphical programmers, so instead of writing long ambiguous paragraphs, show us your code. Thanks!
So you have six Boolean arrays. Are the 1D? Are all the same length?
Which are controls? Which are indicators?
08-10-2019 02:27 AM - edited 08-10-2019 02:30 AM
When I take a 1D boolean array and connect it to either input of a Build Array node (pulled down once, to give two inputs, although the same is true for more inputs), and then right click on the node and choose Create > All Controls and Indicators, the control created is a 1D array and the indicator is a 2D array of booleans. This is because the default mode is to not "Concatenate Arrays".
When you write "Append mode", do you mean you already set it to tick the "Concatenate Arrays" option? In that case, the behaviour is to add 1D arrays to both the input and output, which doesn't seem to be what you described.
Regarding this comment
@Dhouston wrote:
Four of the Boolean arrays are indicators, while the other two Boolean arrays are controls.
Indicators can be filled with data - hence the wires going into them can be passed as sources to a Build Array node. On the other hand, Controls are already a source - they should be connected directly to a Build Array node. Does that make sense? A pair of images are shown below:
Concatenate to 1D Array
Don't concatenate - 2D Array output
A point to be aware of (hinted at above) is that the size of your arrays is important if you form 2D array(s). In LabVIEW, 2D arrays are always rectangular, so if some of your inputs are shorter than others, they'll be padded to form the same length output:
This doesn't happen with a cluster:
08-12-2019 07:44 AM
Attached is a portion of our code. The circled part is where we were having the issue. What you see now is another approach we took, as we used two build arrays instead of one. Originally we had the controls and the indicators all going into one build array.
08-12-2019 07:59 AM - edited 08-12-2019 08:00 AM
Hi Dhouston,
Four of the Boolean arrays are indicators, while the other two Boolean arrays are controls.
4 of them are local variables in read access mode!
(Why do you use so many local variables in this loop? Why not use shift registers? Why not use one shift register holding a cluster, which bundles all relevant information?)
Both BuildArray nodes are in concat mode and create an output of boolean 1D arrays…
08-12-2019 08:11 AM
Local variables are used here because there is another while loop which is accessing the actual terminals. This other loop runs much faster than the snippet, as it is a safety check that will immediately shut down the test fixture if it goes into an error state. The snippet still needs to access those same terminals, so that is why all the locals are appearing in it.
We believe the method shown in the snippet is working for us (we haven't fully finished out the code yet), so that is why the Build Arrays are set up in concat mode now. The original setup with one Build Array had that Build Array in its default mode, but we don't understand why it made all the 1-d arrays into a 2-d array instead of just one long 1-day array.
08-12-2019 08:16 AM
Hi dhouston,
We believe the method shown in the snippet is working for us (we haven't fully finished out the code yet), so that is why the Build Arrays are set up in concat mode now.
The original setup with one Build Array had that Build Array in its default mode, but we don't understand why it made all the 1-d arrays into a 2-d array instead of just one long 1-day array.
So now you use BuildArray in concat mode and the original code used BuildArray in append mode.
And you don't understand the different output of those two code versions???
08-12-2019 08:28 AM
Correct. We had thought that Build Array would just join the arrays together into one, basically putting them in sequence. It seems we have the wrong concept of what append and concatenate actually do.
08-12-2019 09:49 AM
@Dhouston wrote:
Correct. We had thought that Build Array would just join the arrays together into one, basically putting them in sequence. It seems we have the wrong concept of what append and concatenate actually do.
Yes, apparently you do. In append mode the 1-D arrays are treated as elements of the array that you are building. So if you build an array in append mode from two 1-D arrays you will get a 2-D array. If you build an array from two individual elements you will get a 1-D array.