LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed loop and CPU usage

Platform is WIN_XP Pro and machine is a P4 at 2.5Ghz with 512 Mb ram.

LV7.1 + PCI 6229

I am using  50ms Timed loop for running a state machine inside it and also a  whole lot of other things like reading / writing DAQMx  functions;  file I/O functions and such. As the project involves a  main and sub-panlel set up local variables could not be elimnated fully and there should be something like 150 of them. But not all are accessed always - maybe about 15 of them at any given time depending on the SM staus.

Problem :

Once started the "Finished late"  indication  is off and the  actual timing  alternates between 49 to 52 ms. The CPU usage is around 25%.

But as time goes by,  the system gets unstable : After 15 minutes or so, the Finished Late indication is always ON and the CPU usage is gradually tending towards or exceeds 100%. 

Obviously the machine control timing now gets affected and things slow down badly. Closing the application ands restarting repeats the above cycle.

I am at a loss  to understand what is happening ?  WIll breaking down the single Timed Loop to multiple ones help  ? WIll that be an efficient way of parallel threading ?

I can post the code but its quite large and will do it as a last resort.

thanks

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 3
(2,988 Views)

Hello,

It sounds like an interesting problem.  It would be worth some experimentation to figure out what's going wrong - attempting to decouple major "pieces" of the code would be helpful.  For example, you could try breaking your code into multiple loops if that makes sense in your architecture, but perhaps you could even eliminate all but one of the loops to begin with, and see if you can correlate the problem to the code in just one of your loops.

Another concern is that you mention using many local variables.  Variable read operations cause new buffer allocations, so if you're passing arrays around that way, you could be hitting a problem of forcing your machine to perform many allocations and deallocations of memory.  As arrays grow, this can be a bigger and bigger problem.  You can use other techniques for passing data around your block diagram, such as dataflow if possible (just simple wires), or queues where dataflow can't dicatate program flow completely.

Hopefully looking into your code with the above considerations will lead you in the right direction.  In your case, removing code so that you can identify which elements are causing the problem should help significantly.

Best Regards,

JLS

Best,
JLS
Sixclear
Message 2 of 3
(2,946 Views)

I'll just elaborate slightly on a point that JLS made.  To me the most likely culprit sounds like an array that is increasing in size.  Many array operations' time to execute is proportional to the size of the array.  This also applies to data copies, which can be an issue if lots of local variables are in use.  Use of functions like "Build Array", "Insert Into Array", etc, particularly inside the loop where you're concatenating on to an existing array using a shift register would be a big red flag.

Similar, but easy to overlook are some string operations.  String concatenation and then processing of the resulting string is very much like a growing array.

There may be other good explanations for the behavior that I'm not thinking of, but this is where I'd start.

Good luck!

0 Kudos
Message 3 of 3
(2,924 Views)