LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Memory Allocation

Hi
Is it possible to do memory allocation in Labview 7.1. If yes how can we do it?
I want to store the information acquired from my data card into an array and then use a pointer to do a FFT of this data. This is believe will result in faster calculations as the data in the array will not be read several times in the memory.
 I am new to labview and i tried searching the help files, ni website and google but could not find anything on memory allocation and pointers for labview, and on top of this i need to submit this program by friday.

Please help

Manuj
0 Kudos
Message 1 of 10
(3,693 Views)

LabVIEW has automatic memory management. It does not have pointers. This allows for much greater simplicity when writing code, but can be a problem if things aren't done right. There are quite a few methods for improving memory management, so I suggest you post your code and we could probably give you a few pointers (no pun intended). As a wild guess - if you see that LV is taking all the CPU resources, this is probably because you have a loop with no wait function. Such a loop runs all the time.

Note that if this is only an exercise and your program works, you should probably focus on the program working and not on optimization. A good way to read about some of the tricks mentioned earlier is to go to Help>>Search the LabVIEW Bookshelf and reading the white paper about memory management and performance.

To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).


___________________
Try to take over the world!
0 Kudos
Message 2 of 10
(3,682 Views)
Thanks for the reply
Basically iwant to acquire data from my acquisition card and during that process dont want to lose any data. hence i have created two arrays where the data is captured alternately, hence when data is being read into the 1st array the 2nd arrays data is processed and vice versa. In this process i end up shifting the data 3 times before processing it...i.e. buffer,array and feedback node which i dont want...i want to reduce this to 2 steps and i am not able to figure out this. initialy we had thought that if lv supported pointers we would be able to overcome this problem but unfortunately lv doesnt like pointers so we dont know what to do?

any suggestions


Regards
Manuj
0 Kudos
Message 3 of 10
(3,660 Views)

If you don't want to lose data you should use a queue (Advanced>>Synchronization palette). Feed the data into the queue in your acquisition loop and take it out of the queue in your processing loop. As long as you're not reading data faster than you're processing it, you should be fine. If you are getting data faster than you can process, your queue will start getting bigger and bigger and you will eventually run out of memory (unless the acquisition stops or slows down).
If you give the Dequeue Element VI an infinite timeout the processing loop will hold whenever the queue is empty.


___________________
Try to take over the world!
0 Kudos
Message 4 of 10
(3,647 Views)
thx for the reply tst
My processign has to be in real time hence eventually my queue will start becoming bigger and i will start losing data, which i cannot afford. That is why we are working on the concept of parallel processing, but the problem is as mentioned above, ..instead of shifting data to 3 places we want to do just 2 shifts, and as lv does not help us with pointers we are confused as to how we should approach the problem.

manuj
0 Kudos
Message 5 of 10
(3,646 Views)

I think there is some misunderstanding between us, so I will repeat my suggestion: Use a queue.

The queue VIs can be found in the Advanced>>Synchronization palette and they will allow you to keep all your data and do the processing in another loop, parallel to the acquisition. The queue will only grow if you are not processing fast enough and even if it does grow all the time, it will take a long time until it causes a memory problem and by then your acquisition will probably be over and it will stop growing.

Search the example finder (Help>>Example FInder) for examples of how to work with queues.


___________________
Try to take over the world!
0 Kudos
Message 6 of 10
(3,640 Views)
Hi i am attaching a part of the vi here.
in this vi i am having a problem the data gets overwritten before i can read it.....
I am trying to get a data of a daqpad 6070e
I hope this helps else let me know and i will try to elaborate

manuj
0 Kudos
Message 7 of 10
(3,629 Views)
I would suggest using Real TIme FIFO's.  They function like LabVIEW Queues, but pre-allocate memory to store a user defined amount of elements.  The preallocation is important with respect to RT memory managment.  The biggest benefit to you would be the fact that each FIFO allows you to simultaneously read and write elements into a single FIFO.  Very convenient...and there aren't the synchronization issues involved with swapping reads and writes for arrays, like you are doing currently. 
Hell, there are no rules here...we're trying to accomplish something!!! - Thomas Edison
0 Kudos
Message 8 of 10
(3,626 Views)

I would guess you don't have access to LVRT anyway.

First of all, I don't see any relation between this VI to the system you described. Where are the arrays you talked about? I see you're worried about the buffer (I think), but if you are, just make it bigger. I don't have DAQ, so I hope I got it right.

I still don't understand what your problem is with using queues. If the AI Read VI outputs something, you should be able to create a queue of that type and use it. You will NOT lose data and you will probably not over burden the computer. Open the example finder and go to the Search tab. type Q and you will see the queues topic. Select it and you will find several examples for how to use queues. If this isn't good for you I want to know why. Also, if you post your code, you should post the code you talked about.


___________________
Try to take over the world!
0 Kudos
Message 9 of 10
(3,609 Views)
I'd just like to add that if data is being lost while running the posted example, then there's a much more basic problem. I would suggest you try DAQmx or adjust the buffer size, number of samples to acquire, or the acquire time until the scan backlog is zero. With no data processing being done in this loop, you should be able to do continuous acquisition.
0 Kudos
Message 10 of 10
(3,603 Views)