cRIO not running code the first time

Hi, our team ran into a problem and we’re looking for some help. We were testing our code, but when we deploy it onto the cRIO after booting it up, the CPU usage jumps up to 100% and a bunch of refnum errors pop up on the diagnostics tab. However, if we stop the code and run it again, the errors go away and the code works perfectly. We tried reimaging the cRIO, but that didn’t work, and neither did building the code and running it as startup on the cRIO (in that case it acted the same as it does the first time code is run after the cRIO boots up- super laggy, 100% CPU and loads of refnum errors).
I checked all the refnums and they’re all correct. Any idea what could be causing this behavior?

Perhaps if you are powering up the robot, some devices aren’t booted yet – I’m thinking the camera. That would cause refnum issues.

It would be useful to post the errors that are showing up. It might also be useful to know what language you are using.

Greg McKaskle

Any modifications to Robot Main?

I found some people decoupled Begin from the main loop, because they didn’t understand why there would be a wire seemingly going nowhere. :rolleyes:
That particular ill advised edit will cause the symptoms you are seeing.

Were using labview and getting the -4407 refnum error, as well as The -44061 robotdrive not running fast enough error and an error with the camera (which we don’t have plugged in right now, but that error appears both the first time and the subsequent times that the code works)

Ok, we fixed it. The problem was that it didn’t finish initializing everything in begin before we called them in our various loops (we put all of our code to run motors, pids, solenoids, etc in seperate loops to save processing power)
To fix it we put all those loops, along with periodic tasks and vision in a flat diagram that runs after begin