LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Wlile loop that takes all the CPU time

Hello,
I'm working on a control system that has a main VI with two parallel while loops. My problem is that one of these seem to eat up all the CPU time. Even though I've given it a 500 ms wait, the other loop is simply left out of the loop. (Pun intended).
The two while loops are attached (in parallel, as mentionned) by artificial data dependency after a sequence.
I have noticed that when i minimize the VI window and remaximize it, the other loop gets an iteration.

Anyone have any idea what might be causing this?

Thanks
0 Kudos
Message 1 of 10
(3,516 Views)
It should work. Post some code so we can look for an error.

Les
0 Kudos
Message 2 of 10
(3,516 Views)
Just a guess here, but it could be that your code is taking more than 500ms to execute. The 'Wait' would then have no effect.

The 'Wait' functions start waiting as soon as they have thier value, not after all the code in the loop has finished executing. So unless there is data dependency between the wait and the other code, the 'Waits' wait while the rest of the code is executing.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 3 of 10
(3,516 Views)
This is true only if you use the "Wait until next ms Multiple", the Wait function on the other hand will always give the CPU it's rest...
0 Kudos
Message 4 of 10
(3,516 Views)
Mads wrote:

> This is true only if you use the "Wait until next ms Multiple", the
> Wait function on the other hand will always give the CPU it's rest...

Not really. As long as there is not data dependancy between the rest of
the code and the Wait function the Wait will wait in parallel with the
rest inside the diagram, assuming that other code is not some
synchronous operation (non-reentrant Call Library Node, UI execution
system VI).

Rolf K
0 Kudos
Message 5 of 10
(3,516 Views)
OK, so which way is it. I've read various things over the past couple hours and it seems nobody really knows or can agree what happens here.

The KB artical here seems to agree with MADS on the way the Wait function works. Maybe an App Eng can chime in on this to set us all straight.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 6 of 10
(3,516 Views)
It's kind of in the middle;-)

As Rolf says if there is other code that takes all the CPU then sure, the wait included in another code does not help...But for the code that the wait is involved in it will allways ensure a halt, contrary to the wait until next ms which would immediately let everything run if the target ms has been reached already.

If you could post a picture of the code or the code itself I'm sure we can find a solution/explanation.
0 Kudos
Message 7 of 10
(3,516 Views)
Hi,

Can you do a test by putting a larger wait in there. If it resolves the
problem, at least you know you're on the right track.

Btw. You said "Even though I've given it a 500 ms wait, the other loop is
simply left out of the loop. (Pun intended).". I'm not sure what you mean by
this, but just to be sure; There are two loops, and both have a wait in it?

Regards,

Wiebe.


"Ed Dickens" wrote in message
news:506500000005000000E0720100-1079395200000@exchange.ni.com...
> OK, so which way is it. I've read various things over the past couple
> hours and it seems nobody really knows or can agree what happens here.
>
> The KB artical
>
href="http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/12b2
ea9a
d5b265ad86256257004...

> seems to agree with MADS on the way the Wait function works. Maybe an
> App Eng can chime in on this to set us all straight.
>
> Ed
0 Kudos
Message 8 of 10
(3,516 Views)
Thanks for your answers everyone, I'll try out what you suggest, and if that don't help me, I'll see if i can post some code(it's a small part of a big system).

Kyrre
0 Kudos
Message 9 of 10
(3,516 Views)
Do have a DAQ VI inside either loop?
0 Kudos
Message 10 of 10
(3,516 Views)