From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

initializer terminal for 1D-array of waveform

Hello,
I have a question - how to initializate the 1D-array of waveform (for feedback)?
It is not possible to use  numeric value.
 
Thank you in advance.
Anna
 
 
0 Kudos
Message 1 of 6
(3,062 Views)
You don't need to. Use the while loop's auto-indexing to get your array. Right-click on the tunnel and select "Enable Indexing". You can also expand the Index Array to peel off each channel.
0 Kudos
Message 2 of 6
(3,055 Views)

smercurio_fc is of course right.

Do you know how big the arrays get? Growing arrays in loops is very expensive because of contant memory reallocations.

Still, if you really wanted to initialize a shift register/feedback node with the proper datatype in this case, just right-click on it and select "create constant". Voila! (see image)

Message Edited by altenbach on 05-09-2007 05:19 PM

0 Kudos
Message 3 of 6
(3,045 Views)

to smercurio:

Unfortunately, I can't use your variant (I have already tried it), because I have to read data on high frequency (up to 500kHz) very precisely in time. Furthermore, I need to have 8 input channels, not 2 (2 is only to develop simple example, working properly) (but my DAboard has only 1 DAC...).

But, using enable indexing, we have time delay during loop is sending data outside. And I can't count it. At high frequency with switching DAC (8 input channels) - it is very undesirable. I need to accumulate the whole array of data without delays as much as possible. Ideally, it should be simple dynamic array (as, for example, C++ has), but I don't know to do it with LabVIEW without any loops.

0 Kudos
Message 4 of 6
(3,026 Views)

to altenbach:

Thank you a lot. It is exactly what I need.

About size of array - I expect about 100 per each of 8 channels. I think, it is not big. I have strong requirements about time, not memory. But, if the re-accocation of memory is long in time? It is not quicker to create zero array (150 samples, for example) initially, and after it only replace zero with measured data?

Message Edited by mikhaylova_anna on 05-10-2007 05:55 AM

0 Kudos
Message 5 of 6
(3,025 Views)
You misunderstand how the loop works. Your statement "But, using enable indexing, we have time delay during loop is sending data outside." is false. No data is sent outside the loop until the loop is done. The array is accumulated inside the loop. Once the loop is done, the data gets passed out. As far as the Index Array, it doesn't matter whether you have 2 or 8 or 80 channels. The Index Array is resizable, though this should actually be done outside the loop after you've collected the data.

As Chistian pointed out, depending on how much data you have, you may run into memory thrashing as LabVIEW reallocates memory. In your example you're still going to have this issue since you're using Insert Into Array. This is going to trigger a memory reallocation. Whether this is an issue or not depends on a number of factors, such as your computer's speed, how much memory you have, the kind of acquisition you're doing, how fast you're doing it, etc. Some DAQ boards have on-board memory so you collect all the data on the board and then read it in all at once into LabVIEW.

The optimal solution in your case is to pre-allocate an array (using Initialize Array) based on how many channels and iterations you plan to do. You said that the VI you posted was a simple example. What is your actual application? Do you know how many acquisitions you need to do? If so, use a for-loop. In that case LabVIEW will already know how many iterations you need to do. You can still pre-allocate the array before the loop and then just use Replace Array Element when you're sweeping each channel. You may want to consider using a 2D array so you can collect all the channels with all the data, as long as there's not too much of it and you're not going to tax your computer's memory.
0 Kudos
Message 6 of 6
(3,013 Views)