Compressor initialization crashes Robo-rio?

As the title says when I run this line of code anywhere, the roborio resets

MainComp = new Compressor(0);

Anyone know why?

EDIT: Found the solution, for those of you facing the same problem, make sure the PCM is wired into the PDP and not the VRM!

In theory your one line of code is directionally correct - to use the compressor, yes you do need to one way is to instantiate it. However, something else is clearly at play.

Can you post full code, and/or the output in the rioLog (near “Robots don’t quit, but yours did!”) which shows the reason for the reset and the lines of code involved (the stack trace)?

Edit: Correcting information I had incorrect.

This is not always true. From the WPILIB docs:

If you want your compressor to turn on when your robot starts up, just instantiate your Solenoid or DoubleSolenoid object with the proper PCM mappings and it will automatically keep your compressor filling the tanks closed-loop style.

^^ this. If using the PCM, you only need to instantiate a compressor if you need to turn it off.

1 Like

There are no errors, most likely because the roborio crashes before it can post the output. I get a few overrun warnings though.

Turns out if its anything related to the PCM the roborio just crashes.

Here is my code:
Main.java (1.0 KB)

That code doesn’t actually contain anything. It’s just the Main function. You might have meant to upload your Robot.java instead.

What do you mean by “roborio crashes”? Does the DS just say “no robot code”? If you click on the gear icon in the DS and bring up the console, is anything being printed there?

For all runtime exceptions that occur within the JVM, I have always gotten text in the rioLog indicating where the problem happened at. Can you be very clear on what you mean when you say “There are no errors?”

Is the PCM properly hooked up to the CAN bus?

I found the problem, the PCM was wired to the VRM rather than directly to the PDP. Because the Roborio is wired to the VRM, when the compressor started up, it caused the system to fall into a brownout because of the power it’s trying to pull, which resulted in the Roborio restarting.

@gerthworm It was exactly as I stated, there was nothing in the output, unfortunately.

@Peter_Johnson Oh my apologies, I was in a rush and selected the wrong file.

I’m glad you found the issue. Note the RoboRIO should not be wired to the VRM either. It should be wired directly into the PDP to the terminals labeled “Vbat CONTROLLER PWR”. See http://wpilib.screenstepslive.com/s/currentCS/m/cs_hardware/l/144971-wiring-the-frc-control-system

Gotcha, makes sense. Thanks for the followup!!

1 Like