07-26-2018 10:17 AM
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
07-26-2018 01:08 PM
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
07-26-2018 02:12 PM
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
07-30-2018 08:08 AM
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:
07-30-2018 08:15 AM
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?
07-30-2018 08:56 AM
What do you think about that solution? Sorry, but I don't know how can I edit my post...
07-30-2018 09:00 AM
As Patryk said, you replace individual Array Elements. Here's an example. Note that the entire Array is maintained in the Shift Registers.
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
07-30-2018 09:01 AM - edited 07-30-2018 09:05 AM
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.
07-30-2018 09:14 AM
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?
07-30-2018 09:20 AM
Easiest would be to initialize the array outside the while loop and subVI. Another approach could comprise use of FGV for creating array buffer.