public class SynchronousPID
extends java.lang.Object
Does all computation synchronously (i.e. the calculate() function must be called by the user from his own thread)
Constructor and Description |
---|
SynchronousPID() |
SynchronousPID(double Kp,
double Ki,
double Kd)
Allocate a PID object with the given constants for P, I, D
|
Modifier and Type | Method and Description |
---|---|
double |
calculate(double input)
Read the input, calculate the output accordingly, and write to the output.
|
double |
get()
Return the current PID result
This is always centered on zero and constrained the the max and min outs
|
double |
getD()
Get the Differential coefficient
|
double |
getError()
Returns the current difference of the input from the setpoint
|
double |
getI()
Get the Integral coefficient
|
double |
getP()
Get the Proportional coefficient
|
double |
getSetpoint()
Returns the current setpoint of the PID controller
|
java.lang.String |
getState() |
java.lang.String |
getType() |
boolean |
onTarget(double tolerance)
Return true if the error is within the tolerance
|
void |
reset()
Reset all internal terms.
|
void |
resetIntegrator() |
void |
setContinuous()
Set the PID controller to consider the input to be continuous,
Rather then using the max and min in as constraints, it considers them to
be the same point and automatically calculates the shortest route to
the setpoint.
|
void |
setContinuous(boolean continuous)
Set the PID controller to consider the input to be continuous,
Rather then using the max and min in as constraints, it considers them to
be the same point and automatically calculates the shortest route to
the setpoint.
|
void |
setInputRange(double minimumInput,
double maximumInput)
Sets the maximum and minimum values expected from the input.
|
void |
setOutputRange(double minimumOutput,
double maximumOutput)
Sets the minimum and maximum values to write.
|
void |
setPID(double p,
double i,
double d)
Set the PID controller gain parameters.
|
void |
setSetpoint(double setpoint)
Set the setpoint for the PID controller
|
public SynchronousPID()
public SynchronousPID(double Kp, double Ki, double Kd)
Kp
- the proportional coefficientKi
- the integral coefficientKd
- the derivative coefficientpublic double calculate(double input)
input
- the inputpublic void setPID(double p, double i, double d)
p
- Proportional coefficienti
- Integral coefficientd
- Differential coefficientpublic double getP()
public double getI()
public double getD()
public double get()
public void setContinuous(boolean continuous)
continuous
- Set to true turns on continuous, false turns off continuouspublic void setContinuous()
public void setInputRange(double minimumInput, double maximumInput)
minimumInput
- the minimum value expected from the inputmaximumInput
- the maximum value expected from the outputpublic void setOutputRange(double minimumOutput, double maximumOutput)
minimumOutput
- the minimum value to write to the outputmaximumOutput
- the maximum value to write to the outputpublic void setSetpoint(double setpoint)
setpoint
- the desired setpointpublic double getSetpoint()
public double getError()
public boolean onTarget(double tolerance)
public void reset()
public void resetIntegrator()
public java.lang.String getState()
public java.lang.String getType()