LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Individual Elements to an Array of Unknown Length

Hi,

 

i have a formula node and if the condition is met, individual elements should be written to an array. Is a for loop and a shift register needed for this? My problem is that the array size has to be adjusted again and again when the condition of the formula node is met.

 

Best regards,

 

Tim

0 Kudos
Message 1 of 6
(622 Views)

Hallo Tim,

 


@Tim970 wrote:

i have a formula node and if the condition is met, individual elements should be written to an array.


Why do you need a formula node for such simple code?

Do you want to append elements to an array or overwrite existing elements? The term "written to an array" is ambiguous…

 


@Tim970 wrote:

Is a for loop and a shift register needed for this?


A shift register, hold on a loop border, would be fine. You can also use while loops instead of FOR loops…

 


@Tim970 wrote:

My problem is that the array size has to be adjusted again and again when the condition of the formula node is met.


Array sizes are handled by LabVIEW automatically, you don't need to worry about this.

(As long as you use G code and don't rely on C code inside a formula node…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(601 Views)

Hi GerdW,

 

i want to append elements to an array. Can you show me how the while loop with the shift register will look like?

 

Best regards.

Tim

0 Kudos
Message 3 of 6
(587 Views)

@Tim970 wrote:

Hi GerdW,

 

i want to append elements to an array. Can you show me how the while loop with the shift register will look like?

 

Best regards.

Tim


If you are not sure on the size of the array you can use Build array with shift register and append the values within the Loop. 

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 6
(560 Views)

Hi Tim,

 


@Tim970 wrote:

Can you show me how the while loop with the shift register will look like?


Like this:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(541 Views)

Hello Tim,

 

please open the "Find Examples"- Window from the Help menu. In the Search- Tab (left side) type "shift-register" (or "Schieberegister") and Doubleclick on the appearing entry in the list below. Then have a look at the example. Do the same with "Build Array"

The "Find Examples" dialog is always a good starting point.

 

P.S. Execute the VI with the Light Bulb on an watch the block diagram. This will teach you the principles of LabVIEW- primitives.

Greets, Dave
0 Kudos
Message 6 of 6
(538 Views)