public class MiniPID extends Object
http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-direction/improving-the-beginners-pid-introduction| Constructor and Description |
|---|
MiniPID(double p,
double i,
double d)
Create a MiniPID class object.
|
MiniPID(double p,
double i,
double d,
double f)
Create a MiniPID class object.
|
| Modifier and Type | Method and Description |
|---|---|
double |
getOutput()
Calculate the output value for the current PID cycle.
|
double |
getOutput(double actual)
Calculate the output value for the current PID cycle.
|
double |
getOutput(double actual,
double setpoint)
Calculate the output value for the current PID cycle.
|
void |
reset()
Resets the controller.
|
void |
setD(double d)
Changes the D parameter
This has two primary effects:
|
void |
setDirection(boolean reversed)
Set the operating direction of the PID controller
|
void |
setF(double f)
Configure the FeedForward parameter.
|
void |
setI(double i)
Changes the I parameter
This is used for overcoming disturbances, and ensuring that the controller always gets to the control mode. |
void |
setMaxIOutput(double maximum)
Set the maximum output value contributed by the I component of the system
This can be used to prevent large windup issues and make tuning simpler
|
void |
setOutputFilter(double strength)
Set a filter on the output to reduce sharp oscillations.
|
void |
setOutputLimits(double output)
Specify a maximum output range.
|
void |
setOutputLimits(double minimum,
double maximum)
Specify a maximum output.
|
void |
setOutputRampRate(double rate)
Set the maximum rate the output can increase per cycle.
|
void |
setP(double p)
Configure the Proportional gain parameter.
|
void |
setPID(double p,
double i,
double d)
Configure the PID object.
|
void |
setPID(double p,
double i,
double d,
double f)
Configure the PID object.
|
void |
setSetpoint(double setpoint)
Configure setpoint for the PID calculations
This represents the target for the PID system's, such as a position, velocity, or angle. |
void |
setSetpointRange(double range)
Set a limit on how far the setpoint can be from the current position
Can simplify tuning by helping tuning over a small range applies to a much larger range. |
public MiniPID(double p,
double i,
double d)
p - Proportional gain. Large if large difference between setpoint and target.i - Integral gain. Becomes large if setpoint cannot reach target quickly.d - Derivative gain. Responds quickly to large changes in error. Small values prevents P and I terms from causing overshoot.public MiniPID(double p,
double i,
double d,
double f)
p - Proportional gain. Large if large difference between setpoint and target.i - Integral gain. Becomes large if setpoint cannot reach target quickly.d - Derivative gain. Responds quickly to large changes in error. Small values prevents P and I terms from causing overshoot.f - Feed-forward gain. Open loop "best guess" for the output should be. Only useful if setpoint represents a rate.public void setP(double p)
p - Proportional gain. Affects output according to output+=P*(setpoint-current_value)public void setI(double i)
i - New gain value for the Integral term#setMaxIOutput(double) setMaxIOutput} for how to restrictpublic void setD(double d)
d - New gain value for the Derivative termpublic void setF(double f)
f - Feed forward gain.public void setPID(double p,
double i,
double d)
p - Proportional gain. Large if large difference between setpoint and target.i - Integral gain. Becomes large if setpoint cannot reach target quickly.d - Derivative gain. Responds quickly to large changes in error. Small values prevents P and I terms from causing overshoot.public void setPID(double p,
double i,
double d,
double f)
p - Proportional gain. Large if large difference between setpoint and target.i - Integral gain. Becomes large if setpoint cannot reach target quickly.d - Derivative gain. Responds quickly to large changes in error. Small values prevents P and I terms from causing overshoot.f - Feed-forward gain. Open loop "best guess" for the output should be. Only useful if setpoint represents a rate.public void setMaxIOutput(double maximum)
maximum. - Units are the same as the expected output valuepublic void setOutputLimits(double output)
output - public void setOutputLimits(double minimum,
double maximum)
minimum - possible output valuemaximum - possible output valuepublic void setDirection(boolean reversed)
reversed - Set true to reverse PID outputpublic void setSetpoint(double setpoint)
setpoint -
public double getOutput(double actual,
double setpoint)
actual - The monitored value, typically as a sensor input.setpoint - The target value for the systempublic double getOutput()
public double getOutput(double actual)
actual - The monitored value, typically as a sensor input.setpoint - The target value for the systemMiniPID#setSetpoint()public void reset()
public void setOutputRampRate(double rate)
rate, - with units being the same as the outputpublic void setSetpointRange(double range)
range, - with units being the same as the expected sensor range.public void setOutputFilter(double strength)
output*(1-strength)*sum(0..n){output*strength^n} algorithm.output - valid between [0..1), meaning [current output only.. historical output only)Copyright © 2019. All rights reserved.