From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert into array keeping previous values

Solved!
Go to solution

It is always easiest of you do things in a certain order:

 

Wire the output of the build array to the right shift register to automatically define its type as 2D DBL array and the rest will fall in place. Then go to the left shift register and "right-click...create constant" to initialize it with the correct type too.

 

(By the way, my image above is a LabVIEW snippet. All you need is to drag it to the block diagram and it will turn into valid LabVIEW code.)

0 Kudos
Message 11 of 20
(2,383 Views)

That worked great it is much faster now thank you all for helping

0 Kudos
Message 12 of 20
(2,381 Views)

Hi All,

 

I tried to implement the code we were talking about with my sensors and I am getting some rather strange results. I have attached the code below if anyone could please have a look at it and see what I am doing wrong in creating the array.

 

Thanks for the help

Canalian

 

0 Kudos
Message 13 of 20
(2,376 Views)

sensor.png

0 Kudos
Message 14 of 20
(2,375 Views)

Your snippet is useless to troubleshoot. You did not include the subvi inside the loop. What does it do?

 

Maybe you want to place another shift register in the outer loop and wire the 2D array across so you keep a history across all iteratoins of the outer loop. Currently, you reinitialize the inner loop after each iteration of the outer loop, dropping all data between iterations, leaving you only the last set of 10 rows.

 

It also does not help if you tell us that you are getting "strange results". Thus is not a useful technical term. Please describe in detail in what way the results are "strange", what results you actually get, and what results you expect.

0 Kudos
Message 15 of 20
(2,366 Views)

Hi,

 

I have an appended array with time string and certain values.

I have initialized a 2D array named Output Array In.

If I run this I get the continuous value only in the first row of the 2D array.

 

My requirement is I need to get (2011/10/28 10:26:18.155) (00) (09) (22 00 00 00 00 00 00 00) in 1st row

                                              (2011/10/28 10:26:19.155) (00) (09) (22 00 00 00 00 00 00 00) in 2nd row

                                              (2011/10/28 10:26:20.155) (00) (09) (22 00 00 00 00 00 00 00) in 3rd row... and so on in the 2D array.

 

Working version is LV7.1

 

Thanks

KB29

0 Kudos
Message 16 of 20
(2,321 Views)

Hi KB29,

 

Instead of using the index array function, just wire up your loop iteration to the index of your Insert Into Array function. See screenshot. Let me know if you have any further questions!

 

array indexing.png

 

Regards,

 

Travis Ann

Customer Education Product Marketing Manager
National Instruments
0 Kudos
Message 17 of 20
(2,299 Views)

@Travis Ann N wrote:

Instead of using the index array function, just wire up your loop iteration to the index of your Insert Into Array function. See screenshot. Let me know if you have any further questions!


No, that's overly complicated.

 

If you want to start with an empty array, we don't even need the control on the left outside, and if this controls contains existing data, your code would push old data at the end of the array and retain it forever out of order, because "insert into array" is hardwired to the array index.

 

A better choice is a plain "Build array" as in the following code. The control (array in) on the left is only needed if you want to append to earlier data, else replace it with an empty array diagram constant (or even leave the shift regsiter unwired).

 

Be aware that growing arrays indefinitely, will have you run out of memory at one point.

 

0 Kudos
Message 18 of 20
(2,293 Views)

Hi.. .

        I was used your VI design in my block diagram. For my application, element wants to be add only one time. Another time another element wants to be ON. but it doesn't working like that. Its adding the values because of while loop. Is there any other way to solve this. . . .?

 

I am vey thankful for u, if u r replying. . .

0 Kudos
Message 19 of 20
(1,930 Views)
Whatever you just wrote is pure gibberish. Please attach your VI to illustrate.
0 Kudos
Message 20 of 20
(1,918 Views)