After adding a pneumatics command and subsystem file, there seem to be CTRE CAN Receive Timeouts that are causing the program to crash. I attached an image of it and the base code.
We have no idea why that’s happening?
After adding a pneumatics command and subsystem file, there seem to be CTRE CAN Receive Timeouts that are causing the program to crash. I attached an image of it and the base code.
We have no idea why that’s happening?
Subsystem:
public class Solenoid extends Subsystem {
DoubleSolenoid hatch;
DoubleSolenoid habFront;
DoubleSolenoid habBack;
Joystick joystick;
public Solenoid() {
hatch = new DoubleSolenoid(0, 1);
habFront = new DoubleSolenoid(2, 3);
habBack = new DoubleSolenoid(4, 5);
joystick = OI.rightJoystick;
}
public void runSolenoid() {
if (joystick.getRawButton(12) == true && joystick.getRawButton(11) != true) {
hatch.set(DoubleSolenoid.Value.kForward);
} else {
hatch.set(DoubleSolenoid.Value.kOff);
}
if (joystick.getRawButton(11) == true && joystick.getRawButton(12) != true) {
hatch.set(DoubleSolenoid.Value.kReverse);
} else {
hatch.set(DoubleSolenoid.Value.kOff);
}
if(joystick.getRawButton(10) == true && joystick.getRawButton(9) != true) {
habFront.set(DoubleSolenoid.Value.kForward);
} else {
habFront.set(DoubleSolenoid.Value.kOff);
}
if(joystick.getRawButton(9) == true && joystick.getRawButton(10) != true) {
habFront.set(DoubleSolenoid.Value.kReverse);
} else {
habFront.set(DoubleSolenoid.Value.kOff);
}
if(joystick.getRawButton(8) == true && joystick.getRawButton(7) != true) {
habBack.set(DoubleSolenoid.Value.kForward);
} else {
habFront.set(DoubleSolenoid.Value.kOff);
}
if(joystick.getRawButton(7) == true && joystick.getRawButton(8) != true) {
habBack.set(DoubleSolenoid.Value.kReverse);
} else {
habFront.set(DoubleSolenoid.Value.kOff);
}
}
public void initDefaultCommand() {
setDefaultCommand(new SolenoidCommand());
}
}
Command:
public class SolenoidCommand extends Command {
public SolenoidCommand() {
requires(Robot.solenoid);
}
@Override
protected void initialize() {
}
@Override
protected void execute() {
Robot.solenoid.runSolenoid();
}
@Override
protected boolean isFinished() {
return false;
}
@Override
protected void end() {
}
@Override
protected void interrupted() {
}
}
Did you change anything as far as hardware? This is the error we get when someone reverses a CAN wire by accident.
Seems like the CAN bus could be terminated prematurely at the PDP before the PCM. Not sure if that would throw this error but worth a look.
First things first, open Phoenix Tuner and confirm the PCM is present under the CAN Devices tab. Then, check its ID is 0.
You are also instantiating a second PCM’s worth of DoubleSolenoid objects.
You have them properly on 0,1 and 2,3 for the first two. According to the DoubleSolenoid javadocs I think you need to use the second constructor option, where you specify the PCM as well as the two pins that are connecting the red/black wires of the Solenoid.
It will be something like:
hatch = new DoubleSolenoid(0, 0, 1);
habFront = new DoubleSolenoid(0, 2, 3);
habBack = new DoubleSolenoid(1, 0, 1);
You must have fancier PCMs than we have…ours only have 4. I thought that what our electronics team puts on the robot was what everybody uses.
Maybe I should stick to software.
As far as I am aware, there is only one PCM for FRC teams to use.
Perhaps your electronics team have tricked you
http://www.ctr-electronics.com/pcm.html
The CTRE PCM can handle 4 double solenoids or 8 single solenoids.
In regards to the code, I think you can use this:
solenoid = new DoubleSolenoid(PCM_ID, 0, 1);
Where PCM_ID is the PCM’s CAN ID.
This is correct however only 3 double solenoid are used in this instance, the constructor that uses the default ID of 0 would be fine unless the ID had changed.
So is it not working because not all of the solenoids are connected? I thought that even if a solenoid isn’t connected to the PCM, it just doesn’t run and the rest of the code works fine
No sorry, not all the ports need to be used on the PCM.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.