LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Aquire data to array on trigger

Hi!

 

I'v got a question to you. I'm reading data from Analog Input modules on FPGA, place them in DMA buffer, and then on RTOS I'm reading that data in 20 element arrays every iteration.

In my application I want to join that data to one big array on boolean trigger, and when I finish it, then I want to make some calculations on that big array (screen attached).

 

My method causes large memmory usage after triggering that aquisition few times. Can you advise me how can I do it properly?

 

 

Regards

 

0 Kudos
Message 1 of 19
(3,538 Views)

Start by attaching VIs, not pictures of parts of VIs.  We can't see "off the edge", we can't see inputs and outputs, we can't try moving wires around, ...

 

Bob Schor

0 Kudos
Message 2 of 19
(3,517 Views)

Here you got FPGA Vi, and part of my program, where I want to get data on trigger, to make some calculations on it without occuping too much memory

Download All
0 Kudos
Message 3 of 19
(3,511 Views)

Hi Wojtek!

 

The things that you might try:

1) As for the image that you attached, do not build array every iteration - try to allocate an array before the loop and then only replace it's elements. At this moment your system allocates memory for new array every iteration.

2) Take care when using "Request deallocation" function. It is used only for very specific and rare cases Definitely you shouldn't use it in the loop.

3) Remember that every Local variable makes another data copy (memory allocation).

 

For other ideas you may look into this forum topic:

https://forums.ni.com/t5/LabVIEW-Development-Best/LabVIEW-Performance-and-Memory-Management/ta-p/351...

 

Patryk Jankowski
NI CER Application Engineer | Certified LabVIEW Architect
0 Kudos
Message 4 of 19
(3,467 Views)

Thanks for your help. Can you show me an example of array allocation? I assume, that I should create for example array of zeros of n elements. Then I'm starting test and have n-100 elements. What can I do with that zeros?

0 Kudos
Message 5 of 19
(3,464 Views)

What do you think about that solution? Sorry, but I don't know how can I edit my post...

0 Kudos
Message 6 of 19
(3,456 Views)

As Patryk said, you replace individual Array Elements.  Here's an example.  Note that the entire Array is maintained in the Shift Registers.

Allocate Array.png

How fast is this?  If N = 2000, so I'm generating a fairly large 2D array, it takes 122 milliseconds.  If I do it the "old-fashioned" way, and just have two For Loops with a single Random Number in the inner one, brought out by two Indexing Terminals, it takes 155 milliseconds.  I didn't time it with appending elements to the Array, but I'm sure it is much slower.

 

Bob Schor

0 Kudos
Message 7 of 19
(3,454 Views)

EDIT: I saw that Bob already provided nice example after I posted mine. What I can add is that with While Loop you can use Quotient&Reminder to get proper index number in case of overwriting array elements.

Array Init.png

 

 

 

Patryk Jankowski
NI CER Application Engineer | Certified LabVIEW Architect
0 Kudos
Message 8 of 19
(3,453 Views)

Your examples are very usefull for me 🙂

Could you also tell me if it will work, when I will create subVI from it, and put it inside while loop. How can I make that array initialization after that?

0 Kudos
Message 9 of 19
(3,440 Views)

Easiest would be to initialize the array outside the while loop and subVI. Another approach could comprise use of FGV for creating array buffer.

Patryk Jankowski
NI CER Application Engineer | Certified LabVIEW Architect
0 Kudos
Message 10 of 19
(3,436 Views)