LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Store calculated values in an array

Solved!
Go to solution

I am making a program that calculates a  double value each time the user clicks on an OK button. To do this I am using a while loop over the NI-SCOPE which generates a new signal each run through and a while loop around the code I am using (it requires the use of a while loop). I am wondering, how can I store a value each time it is calculated in a list or array so the user can see all the values. 

0 Kudos
Message 1 of 13
(4,484 Views)

Also, I tried wiring the double value to an array indicator of doubles, but it would not work. 

0 Kudos
Message 2 of 13
(4,483 Views)

You will want to store your array in a shift register on your loop.  When you calculate a new value, just use Build Array to add the new value.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 13
(4,475 Views)

Hi punsach,

 

did you do any of the free online courses for LabVIEW beginners?

 

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 13
(4,474 Views)

Whenever I do this, the program stores the calculated value as one element, then 0 as the next, so that two spots are filled in every run through. And I did do the tutorials, but I completely forgot about shift registers.


GerdW wrote:

 

check.png


 

0 Kudos
Message 5 of 13
(4,461 Views)

Hi Punsach,

 

when you get a value followed by another zero in your array you will do something wrong! Don't store that additional zero…

 

When you forgot shift registers you really should redo all those online courses!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 13
(4,457 Views)

@Punsach wrote:

Whenever I do this, the program stores the calculated value as one element, then 0 as the next, so that two spots are filled in every run through. And I did do the tutorials, but I completely forgot about shift registers.


Please post your code.  This doesn't sound right.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 13
(4,454 Views)

crossrulz wrote:


Please post your code.  This doesn't sound right.


 

0 Kudos
Message 8 of 13
(4,449 Views)

Your program feels really inside out.  I highly recommend getting rid of the outside loop.  Move the acquisition into the event structure with the Next Pulse event.  Stop the inner loop only with the Program Stop event.

 

But your big issue is that you should only be adding on to the array in very specific cases.  I would assue you only want to add on to the array when you go to the next pulse.  So move that logic into that event somehow.  This will be a fun one with shift registers, but it will make it run a lot better.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 13
(4,433 Views)

@crossrulz wrote:

Your program feels really inside out.  I highly recommend getting rid of the outside loop.  Move the acquisition into the event structure with the Next Pulse event.  Stop the inner loop only with the Program Stop event.

 

But your big issue is that you should only be adding on to the array in very specific cases.  I would assue you only want to add on to the array when you go to the next pulse.  So move that logic into that event somehow.  This will be a fun one with shift registers, but it will make it run a lot better.



Is that the cause of the issues with the repeated 0?

 

And the thing is I need to allow the user a chance to move the cursors in the case they are not positioned correctly, hence the inner and outer loop. 

0 Kudos
Message 10 of 13
(4,427 Views)