LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Aquire data to array on trigger

My advice is "don't get too fancy".  The difference in time between "allocating on the fly" and "pre-allocating" was (to my way of thinking) pretty small.  If you add a Mod function to the "pre-allocating" code, you make it slower, and wrapping it in a sub-VI (I really like wrapping things in sub-VIs for purposes of hiding the details), you slow it down (another trivial amount) more.  One has to ask if "simpler is better", i.e. a For Loop + Indexing Tunnel.

 

Bob Schor

0 Kudos
Message 11 of 19
(1,156 Views)

I agree with you Bob. Great that you pointed out that for loop is more time efficient! For purposes of this application it looks like time criticality is not so important (especially comparing to memory management) and even my example would do the job, but keeping good practices since the beginning is really important.

 

@Wojtek

Have you managed to fix your memory problem?

 

Patryk Jankowski
NI CER Application Engineer | Certified LabVIEW Architect
0 Kudos
Message 12 of 19
(1,137 Views)

Memory is still continously growing and I see one more thing. Now my DMA buffer have some lag, and gave me always old data from aprox. 2s before

0 Kudos
Message 13 of 19
(1,119 Views)

Can you post updated version of your application code? Also how do you measure the memory? Option that i would recommend is using NI Distributed System Manager. You can find a guide how to measure memory with this tool in this article: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P9kJSAS.

Patryk Jankowski
NI CER Application Engineer | Certified LabVIEW Architect
0 Kudos
Message 14 of 19
(1,115 Views)

I'm using NI Distributed System Manager.

I've got one more question to you. In my application I'm using lvclass with ctl in which I'm storing data like process controls and 3 data plots. I'm continously putting data to it every loop cycle(example is in attached vi) and showing some of them on main front panel. Can I have memory problem from that? I assume that my lag in data from DMA buffer comes from high CPU usage, am I right?

0 Kudos
Message 15 of 19
(1,110 Views)

To answer your question - it depends. Are you creating new class object every iteration? In that case memory may leak. If not, then it shouldn't occur. Why don't just use Cluster instead of Classes, does your whole application requires you to use Objective Programming? If you have high CPU usage, then definitely it will affect your acquisition and determinism of your application. For information about DMA FIFO behavior you should check them for Overflow and Underflow errors. Please refer to this article for more information: http://zone.ni.com/reference/en-XX/help/371599N-01/lvfpgaconcepts/fpga_dma_fifo_buffer_size/.

Patryk Jankowski
NI CER Application Engineer | Certified LabVIEW Architect
0 Kudos
Message 16 of 19
(1,099 Views)

 

aq.png

I'm only using it to have data avalible for the other part of my program. Do you think that changing it to cluster will make my application work better?

 

Another question is about Queues. Are they dealocating memory? Can they have infuence on my memory problems?

0 Kudos
Message 17 of 19
(1,092 Views)

If you are using Classes properly then everything should be ok. Usage of clusters is just easier. To get more control over memory allocation of your queues you should use RT FIFOs, you can find them in Real-Time palette. The differences between standard queues and RT one you can find in this article http://www.ni.com/product-documentation/54516/en/. But as for the influence on memory problems, although you can check it, it is probably not the main cause. What is the level of cpu usage and memory leak that you encounter? I'm almost sure that somewhere in your code there has to be some iterating memory allocation, that we still cannot find. 

 

I can see that in your Analog_In.vi you are unbundling and then bundling yours data class elements. You can try to do this operation in In Place Element Structure that may increase memory efficiency. http://zone.ni.com/reference/en-XX/help/371361P-01/glang/in_place_element_structure/

Patryk Jankowski
NI CER Application Engineer | Certified LabVIEW Architect
0 Kudos
Message 18 of 19
(1,087 Views)

You were right. In my code I had one element that was continously iterating and when I removed it, everything works fine. Thanks for your help 🙂

0 Kudos
Message 19 of 19
(1,065 Views)