public abstract class CasserolePID
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected double |
curError |
protected double |
integratorDisableThresh |
protected boolean |
invertActual |
protected boolean |
invertOutput |
protected double |
Kd |
protected double |
Kdf |
protected double |
Kf |
protected double |
Ki |
protected double |
Kp |
protected double |
Kp2 |
protected double |
outputMax |
protected double |
outputMin |
double |
setpoint |
java.lang.String |
threadName |
protected boolean |
useErrForDerivTerm |
protected long |
watchdogCounter |
Modifier | Constructor and Description |
---|---|
protected |
CasserolePID(double Kp_in,
double Ki_in,
double Kd_in)
Simple Constructor
|
protected |
CasserolePID(double Kp_in,
double Ki_in,
double Kd_in,
double Kf_in,
double Kdf_in,
double Kp2_in)
More-Complex Constructor
|
Modifier and Type | Method and Description |
---|---|
double |
getCurError() |
double |
getKd() |
double |
getKdf() |
double |
getKf() |
double |
getKi() |
double |
getKp() |
double |
getKp2() |
double |
getSetpoint() |
protected void |
periodicUpdate() |
void |
resetIntegrators()
Reset all internal integrators back to zero.
|
protected abstract double |
returnPIDInput()
Override this method! This function must be implemented to return the present "actual" value
of the system under control.
|
void |
setActualAsDerivTermSrc()
Call this method to set up the algorithm to utilize only the actual (sensor feedback) value
for the derivative term calculation.
|
void |
setErrorAsDerivTermSrc()
Call this method to set up the algorithm to utilize the error between setpoint and actual for
the derivative term calculation.
|
void |
setintegratorDisableThresh(double integratorDisableThresh_in)
Set the Integral term disable threshold.
|
void |
setKd(double kd) |
void |
setKdf(double kdf) |
void |
setKf(double kf) |
void |
setKi(double ki) |
void |
setKp(double kp) |
void |
setKp2(double kp2) |
void |
setOutputInverted(boolean inv)
Sets the control effort to be inverted from the normal calculation
|
void |
setOutputRange(double min,
double max)
Set limits on what the control effort (output) can be commanded to.
|
void |
setSensorInverted(boolean inv)
Sets the sensor input (actual) to be inverted in the normal calculation
|
void |
setSetpoint(double setpoint_in)
Assign a new setpoint for the algorithm to control to.
|
void |
start()
Start the PID thread running.
|
void |
stop()
Stop whatever thread may or may not be running.
|
protected abstract void |
usePIDOutput(double pidOutput)
Override this method! This function will return the value calculated from the PID.
|
protected double Kp
protected double Ki
protected double Kd
protected double Kf
protected double Kdf
protected double Kp2
protected double curError
protected boolean useErrForDerivTerm
protected boolean invertOutput
protected boolean invertActual
public volatile double setpoint
protected double outputMin
protected double outputMax
protected double integratorDisableThresh
protected volatile long watchdogCounter
public java.lang.String threadName
protected CasserolePID(double Kp_in, double Ki_in, double Kd_in)
Kp_in
- Proportional Term GainKi_in
- Integral Term GainKd_in
- Derivative Term Gainprotected CasserolePID(double Kp_in, double Ki_in, double Kd_in, double Kf_in, double Kdf_in, double Kp2_in)
Kp_in
- Proportional Term GainKi_in
- Integral Term GainKd_in
- Derivative Term GainKf_in
- Setpoint Feed-Forward Term GainKdf_in
- Setpoint Derivative Feed-Forward Term GainKp2_in
- Proportional Squared Term Gainpublic void start()
public void stop()
public void resetIntegrators()
public void setSetpoint(double setpoint_in)
public void setOutputInverted(boolean inv)
inv
- public void setSensorInverted(boolean inv)
inv
- public double getCurError()
protected abstract double returnPIDInput()
protected abstract void usePIDOutput(double pidOutput)
pidOutput
- The control effort output calculated by the PID algorithmprotected void periodicUpdate()
public void setErrorAsDerivTermSrc()
public void setActualAsDerivTermSrc()
public double getKp()
public void setKp(double kp)
kp
- the kp to setpublic double getKi()
public void setKi(double ki)
ki
- the ki to setpublic double getKd()
public void setKd(double kd)
kd
- the kd to setpublic double getKf()
public void setKf(double kf)
kf
- the kf to setpublic double getKdf()
public void setKdf(double kdf)
kdf
- the kdf to setpublic double getKp2()
public void setKp2(double kp2)
kp2
- the kp2 to setpublic void setOutputRange(double min, double max)
min
- Smallest allowed control effortmax
- Largest allowed control effortpublic double getSetpoint()
public void setintegratorDisableThresh(double integratorDisableThresh_in)
integratorDisableThresh_in
- The new threshold to use.