We just got our compressor working today that's attached with a pressure switch and a relay. Our compressor turns on when we start the robot on teleoperated mode but it doesn't turn off when we reach a PSI of above 125 (factory default).
Our spike is connected up to slot 7 in the relay on the digital sidecar, and our pressure switch is connected to slot 3 on our digital I/O. Everything works fine except that the signal to the pressure switch isn't being received so it's not opening and closing the circuit. We aren't quite sure what the problem is, but here's my code dealing with the compressor, and the relay.
tldr;We are able to manually start and stop the compressor with a button on our joystick, but not have it work automatically via the pressure switch.
Code:
public class RobotTemplate extends SimpleRobot {
//Check robot for right numbers
Joystick controller = new Joystick(2);
Compressor mainCompressor = new Compressor(7,3); // Relay, Digital IO
Relay spike = new Relay(7);
public void roboinit(){
mainCompressor.start();
System.out.println("Robot Initiated:");
}
public void operatorControl()
{
System.out.println("Telop Activated:");
mainCompressor.start();
while (true){
//==================== Spike ====================//
spike.set(Relay.Value.kOn);
spike.set(Relay.Value.kForward);
/* if(controller.getRawButton(5)){
//spike.set(Relay.Value.kForward);
}
else if(controller.getRawButton(6)){
spike.set(Relay.Value.kReverse);
}
else{
spike.set(Relay.Value.kOff);
}
*/
}
}