LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to add single element (inside while loop) to itself

Solved!
Go to solution

I have single element numeric output which is inside while loop. Its value is changing in every while loop iteration. If lets say i want to add values of first ten while loop iterations of that variable.  How can I do that.

 

See attach image for further clarification.

 

Thanks 

 

JK

 

Untitled Jan 2.jpg

 

 

 

 

0 Kudos
Message 1 of 5
(4,687 Views)
Solution
Accepted by josephkirmani

Hi Joseph,

 

THINK DATAFLOW!

 

As values are stored in wires and shift registers (and NOT in any kind of variables) you should use those basic LabVIEW elements:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(4,682 Views)

It is not working with your technique. My value is in the output variable and it changes with every while loop iteration. and I need to add output from all iterations.

Let say in 1 iteration its value is 1.5 and in 2nd iteration its value is 1.2. So after 2 iterations the sum should be 1.5+1.2 = 2.7.  This is what I want to achieve. Hope I make myself clear

0 Kudos
Message 3 of 5
(4,673 Views)

Hi Joseph,

 

how can the value in "output" change on it's own when "output" is just an indicator???

 

THINK DATAFLOW! Indicators are used just to display values. Then value has to come from some data source!

 

So my example should be ok, when you use your data source instead of the iterator output in my image…

Best regards,
GerdW


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

Example_VI_BD.png

what do you expect after 10 iterations? we are assuming here with what little information given.

Message 5 of 5
(4,641 Views)