View Single Post
  #2   Spotlight this post!  
Unread 02-22-2016, 09:22 AM
pblankenbaker pblankenbaker is offline
Registered User
FRC #0868
 
Join Date: Feb 2012
Location: Carmel, IN, USA
Posts: 102
pblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of light
Re: PID Speed control with encoders

Not sure if you are still fighting with this issue or not, but here are some things we have found useful when setting up speed/rate control PIDs:

1. Use the SmartDashboard to display the PID control editor (so you can play with your P, I, D and F values).

2. Use the SmartDashboard to display the output power (pidWrite value) that the PIDController has determined, the sensor input value for the PID, the current error and the target value.

3. For a rate controlled PID, we found that wpilib seems to be slightly different this year and that you need to play with the P, D and F values. Rate PIDs are slightly different in nature from position PIDs.

Here is an example of putting out the PID controller for your left side PID (add to the bottom of your DriveTrain() constructor):

Code:
SmartDashboard.putData("Left PID", leftPID);
And here is an example of putting out the other smart dashboard values (place at the end of your drive() method):

Code:
// Value starts big and goes to zero as your PID reaches the setpoint.
SmartDashboard.putNumber("Left PID Error", leftPID.getError());

// Input (speed) being returned by the encoder (PID input)
// Value should go to the set point you specified
SmartDashboard.putNumber("Left PID Speed", leftEncoder.pidGet());

// Output (power) being applied to motors
SmartDashboard.putNumber("Left PID Output", frontLeft.get());
This should at least give you some information on the smart dashboard to show you what your PID is trying to do. Make sure that the "Left PID Speed" values make sense and are changing.

Hope that helps.
Reply With Quote