LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Resize Array of Clusters

Solved!
Go to solution

I have an array of cluster of cluster borrowed from the "FGEN Arb Script.vi" example. By default, this is a 1D array with length 4 which allows the example to rotate through 4 output waveforms. For my application, I would like to have an adjustable number of waveforms. But I cannot find a simple way to change the length of the array control, either programmatically or before Run. 

 

I have tried:

+ Examining the size property via right click. I can change the number of dimensions, but not the length (see attachment) which seems strange. The Array Size node returns the expected value (4).

+ NumRows and NumCols property nodes. These seem to adjust the number of array elements visible on the front panel, but not the length of the underlaying array.

+ Initializing a new array of clusters with the desired length then backforming a control. This does create an array of clusters with the new length, but it is unacceptably clunky as it requires rewiring on the block diagram every time. And heaven forbid I have to explain this procedure to a labmate! 

 

Is there a simple way to change the length of this array control? If there is a loop-able programmatic solution to make this a user controllable parameter, so much the better.

 

0 Kudos
Message 1 of 15
(1,128 Views)

Hi octopod,

 


@octopod wrote:

Is there a simple way to change the length of this array control?


Simplest way: Use the context menu of the array (aka right-click the array!), then see the "Data operations" submenu to insert/delete elements to the array…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO
0 Kudos
Message 2 of 15
(1,119 Views)

Capture

 

This has nothing to do with the number of elements in the array, it's for setting the number of dimensions.

 

If you want to set elements in a control, you can use a local or a value property.

0 Kudos
Message 3 of 15
(1,087 Views)
Solution
Accepted by topic author octopod
  • The size of a 1D array, i.e. the number of elements, is part of the data (not a property!).
  • If the control currently shows four elements (you did not tell us!), you can resize the container to any other size, even add a scrollbar. The number of elements shown to the user is just a cosmetic property and has nothing to do with the number of elements.
  • I am not familiar with the expression "backforming". Can you explain what you are actually doing?
  • To change the number of elements, you simply need to change the data. (either at edit time manually or by writing a brand new array via e.g. a local variable at runtime). The new size can be an empty array, have millions of elements, or anything in-between.
  • Once you are happy, you can even make the new values the default permanently.
  • I think you are missing some very basic LabVIEW skills, so I also recommend the tutorials listed at the top of the forum.
  • If you want specific help, please attach a simplified version of your VI and we can guide you in the right direction.

Here's a quick example that constantly changes the value and size of an array control at runtime.

 

altenbach_0-1640107450214.png

 

Of course in a real application, you need to make sure not to interfere with the user actions on the same array control, so make sure that there is only one master in any given state of the run.

 

0 Kudos
Message 4 of 15
(1,079 Views)

Please do read through the training material. You seem to be missing a basic concept of LabVIEW that the wire is the data, not the control or indicator. To change the amount of data that's in the array you have to actually change the amount of data that goes into the wire.

0 Kudos
Message 5 of 15
(1,068 Views)
Sept 12th 2001 I asked by brand new coworkers "How do I initialize my variables in this LabVIEW thing?"

You don't have too! The memory manager handles all of that in a 4th generation programming language.

"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 15
(1,035 Views)

@altenbach

Thank you for this detailed answer. I am undoubtedly missing some LabVIEW skills as it did not even occur to me to create a local variable, which seems like the most straightforward solution. I'll take a look at some of the relevant tutorials.

 

 

0 Kudos
Message 7 of 15
(1,019 Views)

@GerdW
Thank you for this. I don't see this option in when I look at the array's "Data Operations" submenu (see attachment) from the front panel or block diagram. But it is visible in the "Data Operation" submenu for a single element of the array (accessible from the front panel). In my mind, length is a property of the array, not of any particular element, so I failed to fully investigate the elements' context menu. Thanks for pointing me in the right direction.

0 Kudos
Message 8 of 15
(1,014 Views)

@octopod wrote:
@GerdW wrote:

Hi octopod,

 


@octopod wrote:

Is there a simple way to change the length of this array control?


Simplest way: Use the context menu of the array (aka right-click the array!), then see the "Data operations" submenu to insert/delete elements to the array…


I don't see that option in the "data operations" submenu.

Capture


You're clicking in the terminal.

 

You get this option with the control\indicator on your front panel, or with an array constant.

 

A few things though:

1) You're changing the value. You'd have to make this value default, or it won't be saved.

2) The value is possibly changed by the code. Adding a value on the front panel will simply be changed by your code.

Message 9 of 15
(1,003 Views)

Thanks! I'll admit I'm confused that we measure the length of an array with the "Array Size" node, but can't view or edit the length from the "Size" properties tab. Is 'size' length or is it dimensions?

0 Kudos
Message 10 of 15
(998 Views)