LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview Loop Takes 100% cpu

Solved!
Go to solution

Hello,

 

I'm wondering the best way to send a serial command when a button is pressed.  Right now I have a while loop that checks if the button is pressed each time.  If is is, it sends the serial command and adds the response to a text box via a shift register.  If not, the original text box info is passed to the shift register.  However, this loop takes 100% cpu (ok, only one core at 100% so technically %50), and I think its because the text box is getting overwriten every cycle.  However, I'm not sure how else to do it.  Attached is a print screen, let me know if you would like the file.

 

Thanks,

Eric

 

 

0 Kudos
Message 1 of 4
(3,231 Views)

An event structure is the best way.  The next best way is to simply put in a wait in the loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 4
(3,225 Views)
Solution
Accepted by topic author Eric_Kulcyk

You have what is known as a greedy loop. It is running as fast as it can which ultimately consumes 100% of your CPU. Simply place a Wait with a 0 delay in the loop and this will allow the scheduler to do other things and will prevent the CPU from being starved.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 3 of 4
(3,224 Views)