PID Control Loop - MDHSRobotics/TeamWiki GitHub Wiki
PID Explained
- P Gain: Kp constant to use when control mode is a closed-loop mode.
- I Gain: KI constant to use when control mode is a closed-loop mode.
- D Gain: KD constant to use when control mode is a closed-loop mode.
- Feed Forward Gain: KF constant to use when control mode is a closed-loop mode.
- I Zone: Integral Zone. When nonzero, Integral Accumulator is automatically cleared when the absolute value of Closed-Loop Error exceeds it.
- (Closed-Loop) Ramp Rate: Ramp rate to apply when control mode is a closed-loop mode.
- Allowable Closed-Loop Error: When Closed-Loop Error’s magnitude is less than this signal, Integral Accum and motor output are auto-zeroed during closed-loop.
- Peak Closed-Loop Output: Caps the maximal or peak motor-output during closed-loop.
- Nominal Closed-Loop Output: Promotes the minimal or weakest motor-output during closed-loop.

#References https://www.youtube.com/watch?v=UR0hOmjaHp0

Sample Code (Courtesy of an image to text converter)
double currentAmps = _talons[masterId].getOutputCurrent();
double outputV = _talons[masterId].getOutputVoltage();
double busV = _talons[masterId].getBusVoltage();
double quadEncoderPos = _talons[masterId].getEncPosition();
double quadEncoderVelocity = _talons[master1d].getEchelocity();
int analogPos = _talons[masterId].getAnalogInPosition();
int analogVelocity = _talons[masterId].getAnalogInVelocity();
double selectedSensorPos = _talons[masterId].getPosition();
double selectedSensorSpeed = _talons[master1d].getSpeed();
int closeLoopErr = _talons[masterId].getClosedLoopError();
if(bEverySecond){
System.out.print1n("currentAmps" + currentAmps);
System.out.print1n("outputv:" + outputv);
System.out.println("output%:" + 100*(outputV / busV) );
System.out.print1n("busv:" + busV);
System.out.print1n("");
System.out.print1n("quadEncoderPos:
System.out.println("quadEncoderVelocity:
System.out.print1n("");
System.out.print1n("analogPos:
System.out.print1n("analogVelocity:
System.out.println("");
System.out.print1n("selectedSensorPosz + selectedSensorPos);
System.out.print1n("selectedSensorSpeed:" + selectedSensorSpeed);
System.out.print1n("");
System.out.print1n("closeLoopErr:
+ quadEncoderPos);
“ + quadEncoderVelocity);
//robert is a noob
+ analogPos);
“ + analogVelocity);
+ closeLoopErr);