Cannot turn on compressor programatically via Spike Relay

Hey guys,

We’re having a lot of trouble getting the air compressor to turn on and regulate itself via a Spike Relay. Here’s our setup:

  1. We have the DSC plugged into the cRIO and all three power lights are brightly lit
  2. The Spike Relay is plugged into the DSC on relay port 1 and the light is amber
  3. The pressure switch is also plugged into the DSC on DIO port 1
  4. The light on the Spike Relay does NOT turn green when it should be enabled, and the light next to the relay port on the DSC does NOT turn green when it should

Here is a link to our code, if you’d like to take a look. The compressor code is in the UpdatePressure class in the launcher package.

Any help would be appreciated. We’ve been working on this for two days with no luck. All we know is that the problem is between the DSC and the Spike Relay, but we can’t figure out why.

We were having a very similar issue earlier.

Our problem is that our ribbon cable was not in correctly. If you are using a ribbon cable, make sure to screw down both ends, (in the cRio module and Digital Side Car). This fixed our issue for us.

I would not put the compressor in a command. It’s designed to run in the background automatically. I would declare the compressor in your launcher subsystem, and call start in the constructor of that subsystem. You don’t need any other code.

You want this command to always run on the compressor so that it will always have full pressure and so that it will automatically shut off at the right time. To do this you need to set your UpdatePressure command as the default command for the compressor.

Here is an example from my team’s code:

Compressor Subsystem


public class Compressor1 extends Subsystem {

    Compressor compressor = RobotMap.compressor1compressor;

    public void initDefaultCommand() {
        setDefaultCommand(new CompressorCommand());
    }
}

CompressorCommand


public class  CompressorCommand extends Command {
    Compressor compressor;
    
    public CompressorCommand() {
        requires(Robot.compressor1);
        compressor = RobotMap.compressor1compressor;
    }

    protected void execute() {
        
        if(!compressor.getPressureSwitchValue()){
            //Compressor NOT Full
            if(!compressor.enabled()){
                compressor.start();
            }
        }else{
            //Compressor Full
            compressor.stop();
        }
    }

    protected boolean isFinished() {
        return false;
    }

}