We’re using black jaguars with the US Digital E4P quadrature encoders.
Using BDC-COMM, we were able to get closed loop speed control working nicely and the speed reported seemed to be accurate.
After attempting to transition to code, the speed PID loop (running on the jaguar) seems like it is working. We can’t tell for sure, though, because the speed through the getSpeed() method is always zero. We’ve configured the encoder codes per revolution, set it in speed mode, called enable on it, and set the position reference to kQuadEncoder. What else could account for this problem?
did you use position ref or speed ref? Position ref is for position mode and speed ref is for speed mode.
We used the encoders that where in the KOP the other year, I think they are the same ones. With this code It said that it was about 450 rpm. I used just regular kEncoder and that seemed to work fine.
we did some testing and we got ours to work with the getSpeed() here is that part of our code that we used.
double DriveP = 1; //PID is not tuned
double DriveI = 0.1;
double DriveD = 0;
int EncoderRev = 360;
public void robotInit() {
Left1 = new CANJaguar(2);
Left1.changeControlMode(CANJaguar.ControlMode.kSpeed);
Left1.setPID(DriveP, DriveI, DriveD);
Left1.configEncoderCodesPerRev(EncoderRev);
Left1.setSpeedReference(CANJaguar.SpeedReference.kEncoder);
Left1.enableControl();
}
But our PID isn’t working. We tuned it in BDC-COMM and found that P = 0.5, I = 0.005, and D = 0.0 work fairly well. Using these same constants in code, though, results in the motor jerking forward and backwards rapidly, making an awful noise.
It looks like a PID tuning issue, but we tuned it in BDC-COMM… Any ideas?
That is really weird. The code and the BDC-COMM program should be the same. I cant think of anything that would cause that besides typing the wrong PID values in your code. Very weird…
Oh! I think i know the problem. You didn’t set your encoder revolutions on the BDC-COMM or in your code. If your Speed is 0 in BDC-COMM you don’t have the encoder revolutions set right