High CPU Usage in LabVIEW even with Basic Code

Our team has been having trouble with excessive CPU utilization of the basic FIRST supplied VI’s. Even the basic code with vision turned off when deployed (not in debug mode), uses up 60% of the processor. Reading analog values and setting PWM outputs on the FPGA seems to be nearly as demanding as image processing. Given that I/O was handled easily on the old PIC, I assume there must be something wrong, either with the FRC libraries or with my teams specific version of them. I was wondering if anyone has an idea on how to fix this, and if this is a problem for other teams.

Also, when the CPU load is high, we get intermittent “no code” displays on the driver station

The symptoms you describe are those of unrestricted while-loops. In labview, the processor loves while loops. It will run them as often as it can. sometimes nothing else gets a chance to run, because the while loop is busy.
You should examine each while-loop in your code to make sure that it contains a timed element. An example is the one waiting for a camera. one waits for the drivers station message.
You can simply insert a wait-timer into a loop so that the processor will pause to catch its breath. While paused, the rest of your parallel code gets a chance to run.
Don’t pause too long, or your sequence of code steps will now take too long. for the robot, you may find that a 1 ms pause is enough to let the processor breathe.
Not all loops need to pause, since some are very quick to finish. but continuous parallel loops are the ones to check.

team-79 beta tester

May I inquire on how you know what the CPU usage is in real time?


I can find out my real time CPU usage by going into tools > real time module > system manager, and then checking the CPU monitor box.

I know I have no untimed while loops because in the profiler tool, all my run #'s are within a normal range (not like one would expect with untimed loops). I am wondering if the very high CPU utilization is normal, given that even the basic code with no vision causes a 60% load

So this is really only a Labview ability?

The System Manager is very useful, but its default setup adds a huge amount of its own overhead. After opening the system manager, click on the VIs tab (I think that is the name), the second one. Turn off the checkbox that displays VI state. Now go back to the first tab and click on the CPU and perhaps off the disk. The important one is the VI state as that will constantly visit every VI in memory to tell you if they are idle, running, etc. Like I said, that adds a huge amount of overhead.

I think at that point you should see the CPU usage being around 5.5 or so when no code is running, and around 12 to 15 without camera when your app is running. Clearly, the more panels you have open that are displaying data, the more the number will climb.

The equivalent of this tool for C/C++ is to connect the serial cable and use something similar to ps, don’t remember exactly what the command is. There may be a similar tool build into Wind River, not sure.

Greg McKaskle