Our team has decided to plug an encoder into one of our Jaguars to regulate the speed of our shooter for more accurate results.
However, we are not getting any output from the encoder.
There is potentially a hardware or software issue.
Our Code:
Initialization
try {
rightMotor1 = new CANJaguar(11, CANJaguar.ControlMode.kPercentVbus);
rightMotor2 = new CANJaguar(12, CANJaguar.ControlMode.kPercentVbus); //Change these to id Nums of jaguar!!!!!
leftMotor1 = new CANJaguar(13, CANJaguar.ControlMode.kPercentVbus);
leftMotor2 = new CANJaguar(15, CANJaguar.ControlMode.kPercentVbus);
rightMotor2.enableControl();
} catch (CANTimeoutException ex) {
ex.printStackTrace();
}
Hardware wise everything seems to be wired normally except the Index signal which is supposed to go into the Jaguar is left floating because our encoder does not output an Index signal.
It’s most likely a software issue.
You have to tell the Jaguar the reference for the encoder.
I haven’t tried it, but you should be able to set it without going into speed control.
(I have only tried it in position control mode, but after the reference is set, it works until the Jag is power cycled. That includes changing modes.)
What you should try is code that is something like this:
try {
rightMotor1 = new CANJaguar(11, CANJaguar.ControlMode.kSpeed); // on the one that has the encoder plugged into it.
rightMotor1.configEncoderCodesPerRev(360); // change to however many counts per rev on your shooter
rightMotor1.enableControl(); // Not sure if this line is needed
rightMotor1.changeControlMode(CANJaguar.ControlMode.kPercentVbus); //Change back to voltage mode now that the encoder is configured
rightMotor1.enableControl(); // From this point on, you should see a speed on your debugging statements
rightMotor2 = new CANJaguar(12, CANJaguar.ControlMode.kPercentVbus);
leftMotor1 = new CANJaguar(13, CANJaguar.ControlMode.kPercentVbus);
leftMotor2 = new CANJaguar(15, CANJaguar.ControlMode.kPercentVbus);
} catch (CANTimeoutException ex) {
ex.printStackTrace();
}