LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array updating after every iteration

Hello. I am using LabVIEW 2013. I need to write values to an array and show the updated values after evey iterartion. As in, after every iteration you can see the latest value added to the array along with the others. I want to use this in my code for lap timing where I can show timestamps of previous laps. I am attaching a VI you can use to demonstrate which has natural numbers that keep getting updated. 

0 Kudos
Message 1 of 13
(8,195 Views)

Hi deepen,

 

there is no array in your VI…

I need to write values to an array and show the updated values after evey iterartion.

Do you need to append values or do you want to replace existing elements?

To append you should use BuildArray, for replacing elements ReplaceArraySubset. And store the array in a shift register…

Simple example, made from your attachment:

check.png

Best regards,
GerdW


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

Oh. I'm sorry about that. Also, I tried the VI you posted, It doesnt seem to work. 

0 Kudos
Message 3 of 13
(8,169 Views)

Hi deepen,

 

your VI would work if you would do the same as me. But you didn't…

(You forgot a constant at InitArray!)

It doesnt seem to work. 

The next time you want to describe a problem you should write more than just "doesn't work"…

Best regards,
GerdW


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

Oh. Okay. No but you see the thing is, the dimension of my array is going to be unknown. 
And by this VI, all the elements of the array get the same value, I need it to be like 1 then below it 2 then 3 .. etc. New value is added and the previous values are seen too

0 Kudos
Message 5 of 13
(8,161 Views)

Hi deepen,

 

the dimension of my array is going to be unknown.

As LabVIEW requires to know the datatype at edit time the array dimension WILL (HAS TO) be known!

And by this VI, all the elements of the array get the same value

I used InitArray because YOU already had it in your VI!

I need it to be like 1 then below it 2 then 3 .. etc.

Use a loop with an autoindexing output!

New value is added and the previous values are seen too

Use BuildArray to append elements to an array. Don't forget to limit memory usage then…

Best regards,
GerdW


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

I'm sorry but I just can't get it to work. Here's what I tried. The other things I tried gave me the folowing output 

Only the first element is replaced with new numbers 

0 Kudos
Message 7 of 13
(8,153 Views)

Hi deepen,

it seems you need to learn the very basics of LabVIEW: THINK DATAFLOW!

- Your "Array" will never update as the loop never stops and so "Array" never gets any data.

- You only increment the scalar value in the shift register, but no array data.

- You only create an array consisting of just one element using the BuildArray function.

- You don't store any array data in the loop. To store data in loops you should use shift registers!

- If the loop would finish you only output the result of the last iteration due to the output tunnel mode…

Did you take the free online courses offered by NI on their website to help beginners learn LabVIEW?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 13
(8,145 Views)

I understand what you're trying to say. BuildArray will create an array of just one element. That's where my problem lies. I need to create an array of multiple elements and it has to be updated after every iteration. The whole purpose is to be able to display the lap times. Like the first lap was completed at 12 seconds, so the first element is 12, then the second lap is completed after another 10 seconds, so the second element is 22.. etc. How can I do that ? 

0 Kudos
Message 9 of 13
(8,121 Views)

No.  Look at the help for Build Array.  Yes it will add a dimension to an array turning a scalar to a 1-D, or a 1-D to a 2-D, if you only have one input.

 

But drag the border up or down, and magically now you can put a new element at the front or end of the array.  Also be sure to look at the right click menu for options such as turning on concatenation or not.

 

I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

0 Kudos
Message 10 of 13
(8,118 Views)