Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Jaguars return zero speed (http://www.chiefdelphi.com/forums/showthread.php?t=100641)

computerish 19-01-2012 15:33

Jaguars return zero speed
 
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?

Thanks!

Doc543 19-01-2012 16:56

Re: Jaguars return zero speed
 
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.
Code:

    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();

}


computerish 19-01-2012 18:19

Re: Jaguars return zero speed
 
Thanks! That got our speed working.

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?

Thanks!

Doc543 20-01-2012 00:52

Re: Jaguars return zero speed
 
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...

Doc543 21-01-2012 14:54

Re: Jaguars return zero speed
 
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


All times are GMT -5. The time now is 22:22.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi