Sequences Taking 100% Of Cpu Resources


Recommended Posts

I have 4 sequences in a program.  One sequence that does the set up and starts the other sequences.

2 sequences are called when a button are pressed and the one below that runs all the time.  The program works. But when opening on a older computer, it takes about 10 minutes to load and the computer is vary slow after it loaded.

 

I have determined that it's the sequences that are taking all the resources of the computer when they are running or opening.  if i turn them off the program load vary quick less then 30 seconds.  and if i turn them on one at a time the daqfactory take up to 99% of the CPU resources,  when the sequence(s) are off Daqfactory doesn't take much of the CPU resources like only about 1 to 2 % of the CPU resources.

 

 The following is the sequence that is running all the time.  All it's doing is changing the caption of a button (my way of testing and it will be removed) and auto ranging 2 linear gauges.

Why would a sequence like this slow down a computer.  I have tried all the thread priorities and they have no effect on the CPU resources.  I when back to the computer in which i did the program on and even on it the program take 50% of the CPU resource.  The older computer is a P4 and the one i wrote the program on is an i5

 

So the question way should a sequence like the one below take all the CPU resources ??  What I'm I missing?

 

While(1)

   component.Button_A.strCaption=10

   component.Vin_P.RangeMax=(S_REF_3+.375)

   component.Vin_P.RangeMin=(S_REF_3-.375)

   component.Vin_M.RangeMax=(S_SNS_5+.375)

   component.Vin_M.RangeMin=(S_SNS_5-.375)

  

endwhile

 

 

Link to comment
Share on other sites

You have an infinite loop with no delay()'s.  When you do this, DAQFactory runs the sequence at full speed as fast as it can, using any CPU power it can find.  You need to add delay() in the loop:

 

while(1)

   // your commands

   delay(1)

endwhile

 

The number in the () is in seconds, so the above would loop once per second.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.