LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

build array when values are changing in runtime

Solved!
Go to solution

Hello all, 

 

i have a continuous stream of frequencies that keep changing during runtime. I need to make an array out of these values. i am using build array function. this stores the first value only and the next item replaces the stored one rather than storing itself after that. I was going through the labview examples and i think using shift register can somehow solve this problem. However after a good one hour of futile play around with shift registers, while loop and build array blocks i decided to post on this problem. I would like if someone can clear my concepts as well as propose a solution. The conceptual hitch is that why the first value keeps getting replaced. If i am using the build array block then the coming values should fill in the next vacant slot logically. Rather than doing that it replaces the first one only. 

Regards
Asad Tirmizi
Design Engineer
Institute of Avionics and Aeronautics

" Its never too late to be, what u want to be"
Using LabVIEW 8.2
0 Kudos
Message 1 of 7
(3,084 Views)

Asad,

 

could you please post the code you have built? Known from experience we can give more valuable hints to you if we know what your current level of LV knowledge is.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 7
(3,079 Views)
well ive been trying to play around this concept. i take a while loop i try to log its iterations into an array using build array function. i have been trying to clear the above mentioned concept using the simplest possible iterative routine. If u want me to paste that i can do that.
Regards
Asad Tirmizi
Design Engineer
Institute of Avionics and Aeronautics

" Its never too late to be, what u want to be"
Using LabVIEW 8.2
0 Kudos
Message 3 of 7
(3,067 Views)
Use Insert into Array function in while loop. Be aware that this is not memory efficient technique. If you already know the array size, you can initialize the array for the number of elements and then use insert into array function.
-FraggerFox!
Certified LabVIEW Architect, Certified TestStand Developer
"What you think today is what you live tomorrow"
Message 4 of 7
(3,058 Views)

Asad,

 

you should avoid to build arrays in while loops since there is the danger of indefinetly growing amount of memory.

There situations where the build array function is very handy, but in this case, i have to warn you.

 

Regarding your question: You have to keep the array in a shift register and connect the array to the top connector of the build array function. Expand the build array to accept a second input and connect the iterator to it. The output of the build array function has to be wired to the right component of the shift register.

You can see a general usage of the shift register in the Standard State Machine design pattern which can be found in the template browser (File >> New).

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 5 of 7
(3,057 Views)

Norbert B wrote:

 

 You have to keep the array in a shift register and connect the array to the top connector of the build array function. Expand the build array to accept a second input and connect the iterator to it. The output of the build array function has to be wired to the right component of the shift register.


 

Norbert,

Wont this cause the same problem as you mentioned? This is not a memory efficient technique to build an array if you dont know the array size. Everytime the array element encounters a filled in memory address, it would have to search for a new destinattion where it would again have to write all the addresses one by one, slowing up the application and consuming more memory.

 

Can you suggest a better way?

-FraggerFox!
Certified LabVIEW Architect, Certified TestStand Developer
"What you think today is what you live tomorrow"
Message 6 of 7
(3,054 Views)
Solution
Accepted by topic author Asad_Tirmizi

You are correct that i simply elaborated the case i warned about the sentence before.

Other methods require a certain amount of planning regarding data structure and - handling. This is at least suggested....

 

A better approach would be something like a circular buffer where you initialize an array of the desired size (e.g. 10000 elements) and then start to replace the elements. You can use the iterator of the loop which you have to "scale down" using quotient&reminder function (which is the mathematical "modulo" operation).

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 7 of 7
(3,051 Views)