LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does my application slow down?

Hi,
 
I'm designing a LabVIEW PDA application which has to receive, display and save data. One data is received every 30ms through Bluetooth (the other side is a microcontroller). My problem is that after about 5 secondes the LabVIEW application slows down and my system is not real-time any more. Is it because of the shift registers? I don't have a lot of knowledges in LabVIEW and I hope somebody will be able to guide me toward a solution.
 
Thanks in advance

Message Edited by roberto.venetz on 02-22-2007 02:23 PM

0 Kudos
Message 1 of 27
(9,199 Views)
Hi Roberto,

Your code is probably running more slowly over time as a result of the memory allocations being made in it. You have uninitialized arrays being populating with data in a loop. This causes the application to ask the OS to allocate memory at runtime every iteration of the loop. This memory allocation takes a significant amount of time, and as free memory becomes more scarce, it takes the OS longer to find a block of memory of sufficient size.

Here is an alternate way to structure the application. Move the array constants outside of the loops. Also, initialize the array constants to the largest size you anticipate that they might reach. This way, no runtime memory allocations are needed.

Reference this document on ways you can optimize your application further. Although the document was written for LabVIEW Embedded, the tips hold true for LabVIEW PDA as well.
--
Michael P
National Instruments
0 Kudos
Message 2 of 27
(9,182 Views)
Your image is not good enought to really see what's going on, but nothing seems very efficient from what I recognize. 😉
 
You don't need the flat 4 frame sequence structure at all. Simply delete the read globals in the fourth frame and use a wire from the value a few frames over. Now execution order is fully determined by dataflow. Delete the sequence.
 
What's all that song and dance to get a DBL from a string? (looks like "string to byte array...split string...combine...delete from array(?!)...to DBL") I think all you need is a "typecast" and a "to DBL". (I've see that before but it is very hard to comprehend why people use "delete from array" and then only use the "deleted portion" output to get a subset. What's wrong with "index array" or "array subset"????)
 
You are growing four arrays without bounds, this is very expensive. Do you have any idea how long the arrays will get in the worst case scenario?
 
you are reading the dt global four times with each iteration. I doubt it will ever change during the loop, so read it once outside the loop and wire it to all users.
 
Why are you constantly building new waveforms? You might as well just graph the arry direclty and set x0 and dx once with a property node before the loop.
 
What determines the loop rate?
 
Why are you bundling the four arrays into a cluster at the end? Keep the datatype simple! For example you could use a single 2D array.
 
What is going on in the other frames of the big sequence?
 
Why on'y ou attach your program, it would be easer to inspect. 🙂
Message 3 of 27
(9,179 Views)
Also your raw data seems to be integer type. Why do you even convert to DBL at all?
0 Kudos
Message 4 of 27
(9,171 Views)

First, thank you for the informations.

I'm not surprise when you tell me that my program is not optimized and maybe a bit difficult to understand. I'm doing my first steps with this software and I built my application using a lot of example I found.

- I don't have any idea how long the arrays will get in the worst case scenario;

- The construction for the waveform is something I found and it seemed to be what I need;

- The rate loop is determined by the Bluetooth reception. The application has to wait for two bytes each step before going on, and the microcontroller manages the sending rate.

Look at my attached program

0 Kudos
Message 5 of 27
(9,136 Views)
Hi roberto,

I changed some items according to Altenbachs suggestions. But there is much more to change 😞
You have to separate data aquisition and display into their own loops to keep a proper aquisition rate.

Please look into examples coming with LabView or search the forum for "producer/consumer pattern".
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 27
(9,117 Views)

I'll take a look to your modifications, thanks.

The step you seem to not understand is used to concatenate the two received bytes to build a word. Isn't it correct?

0 Kudos
Message 7 of 27
(9,087 Views)


@roberto.venetz wrote:
The step you seem to not understand is used to concatenate the two received bytes to build a word. Isn't it correct?

We understand your code very well, but this is NOT the way to do it! You have a two-byte string. Simply typecast it to a U16. Voila! (see lower part of image).

You should keep all your data as U16, it will take 4x less memory than your DBLs (leave ot the "to DBL").. The only place you might need U32 is for the FLOW, which is the product of two U16.

What is with all the globals. Is this program part of a bigger system? Most of the globals are not used anywhere. Are they used elsewhere?

Message Edited by altenbach on 02-23-2007 01:47 PM

0 Kudos
Message 8 of 27
(9,075 Views)


@altenbach wrote:
(I've see that before but it is very hard to comprehend why people use "delete from array" and then only use the "deleted portion" output to get a subset. What's wrong with "index array" or "array subset"????)



I use that trick/feature to get the latest element!

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 9 of 27
(9,033 Views)


@TonP wrote:
I use that trick/feature to get the latest element!

Yes, as long as you have a reason it's probably OK! 😄
0 Kudos
Message 10 of 27
(9,028 Views)