80-100% CPU usage

My dad is having issues when running code on the cRIO. The cRIO is running at was is being reported as 80-100% CPU usage causing it to act sluggish and lag a lot. I do not have access to his code but I can get it this weekend when I go home. When he runs the default code I believe he said it was 50-60%. Any one see anything like this before? If so what was the cause of it?

check for unneeded loops. This is the #1 for me to look for. I generally advocate for loopless code (outside robot main and periodic tasks).

Do you have vision code?

We had a similar problem during several matches, where the cRio either rebooted or stopped responding for a while because the cpu usage maxed out. We will be doing more tests, but in our case it seems to be due to lots of sensors (Axis and NXT cameras, a repeating if->then loop with an ultrasonic).

CPU usage of 100% will not in itself cause a reboot or a crash. It can cause lag, but doesn’t necessarily have to.

If the code has errors being printed to the Messages tab of the DS, then that adds quite a bit to the CPU load. Correct the errors first, as they may also explain other driving symptoms.

If the CPU usage still seems high, post code along with a description of how it behaves and we can help and can show tools that will help determine how fast various parts of the code are running.

Greg McKaskle

We repeatedly get CPU usage errors from the code if we are calling Refnums in Periodic Tasks or Teleop that are not valid. Make sure every Refnum (the pink string that names a motor/solenoid/etc) you are calling is being properly set-up in Begin and is actually wired on the robot.

In addition, calling the same Refnum twice in periodic tasks has caused 100% CPU usage as well. Just my 2 cents

The refnum issues you mention would cause errors, and piping unhandled errors to the console is somewhat expensive. If you fix the errors, the CPU usage will drop dramatically.

Greg McKaskle