Simple implementation of a PID controller.
More...
#include <PID.h>
|
| PID (double p_gain, double i_gain, double d_gain, double ff_gain=1.0, double i_decay=0.5, bool feedforward=true, double filterFreq=7.0) |
| Constructs a PID controller. All gains are in constant (not timebase) form.
|
|
| PID () |
| Constructs a PID controller with no gains set.
|
|
void | SetParameters (double p_gain, double i_gain, double d_gain, double ff_gain=1.0, double i_decay=0.87, bool feedforward=true, double filterFreq=7.0) |
| Sets PID parameters. All gains are in constant (not timebase) form.
|
|
virtual double | Update (double dt) |
| Updates the PID controller, call on each loop.
|
|
void | SetInput (double input) |
| Sets the feedback input.
|
|
virtual void | SetSetpoint (double setpoint) |
| Sets the setpoint.
|
|
double | GetOutput () |
| Gets the PID output.
|
|
double | GetProportionalGain () |
| Gets the p gain.
|
|
double | GetIntegralGain () |
| Gets the i gain.
|
|
double | GetDerivativeGain () |
| Gets the d gain.
|
|
double | GetFeedForwardGain () |
| Gets the feed forward gain.
|
|
double | GetIntegralDecay () |
| Gets the integral decay rate.
|
|
double | GetInput () |
| Gets the input value.
|
|
double | GetSetpoint () |
| Gets the setpoint value.
|
|
double | GetError () |
| Gets the error value.
|
|
double | GetAccumulatedError () |
| Gets the accumulated running sum.
|
|
double | GetPreviousError () |
| Gets the previous error (one iteration ago).
|
|
bool | IsFeedForward () |
| m_status flag for feed-forward PID.
|
|
void | Reset () |
| Resets PID setpoint, input, error, accumulated error, differential, and output.
|
|
void | DisablePID () |
| Disables PID (output returns setpoint).
|
|
void | EnablePID () |
| Enables PID.
|
|
void | SetIIREnabled (bool enabled) |
| Enables an IIR filter on output.
|
|
void | SetIIRDecay (double decay) |
| Sets the IFR Decay rate.
|
|
Simple implementation of a PID controller.
PID::PID |
( |
double |
p_gain, |
|
|
double |
i_gain, |
|
|
double |
d_gain, |
|
|
double |
ff_gain = 1.0 , |
|
|
double |
i_decay = 0.5 , |
|
|
bool |
feedforward = true , |
|
|
double |
filterFreq = 7.0 |
|
) |
| |
Constructs a PID controller. All gains are in constant (not timebase) form.
- Parameters
-
p_gain | proportional gain |
i_gain | integral gain |
d_gain | derivative gain |
ff_gain | feedforward gain (defaults to 1.0) |
i_decay | integral decay (defaults to 0.5) |
feedforward | whether or not feedforward is used |
filterFreq | the frequency of the low pass filter |
double PID::GetAccumulatedError |
( |
| ) |
|
Gets the accumulated running sum.
- Returns
- running sum
double PID::GetDerivativeGain |
( |
| ) |
|
Gets the d gain.
- Returns
- derivative PID gain
Gets the error value.
- Returns
- error
double PID::GetFeedForwardGain |
( |
| ) |
|
Gets the feed forward gain.
- Returns
- feed forward gain
Gets the input value.
- Returns
- input
double PID::GetIntegralDecay |
( |
| ) |
|
Gets the integral decay rate.
- Returns
- integral decay rate
double PID::GetIntegralGain |
( |
| ) |
|
Gets the i gain.
- Returns
- integral PID gain
double PID::GetOutput |
( |
| ) |
|
Gets the PID output.
- Returns
- PID output
double PID::GetPreviousError |
( |
| ) |
|
Gets the previous error (one iteration ago).
- Returns
- previous error
double PID::GetProportionalGain |
( |
| ) |
|
Gets the p gain.
- Returns
- proportional PID gain
double PID::GetSetpoint |
( |
| ) |
|
Gets the setpoint value.
- Returns
- setpoint
bool PID::IsFeedForward |
( |
| ) |
|
m_status flag for feed-forward PID.
- Returns
- whether this controller uses feedforward PID
void PID::SetInput |
( |
double |
input | ) |
|
Sets the feedback input.
- Parameters
-
void PID::SetParameters |
( |
double |
p_gain, |
|
|
double |
i_gain, |
|
|
double |
d_gain, |
|
|
double |
ff_gain = 1.0 , |
|
|
double |
i_decay = 0.87 , |
|
|
bool |
feedforward = true , |
|
|
double |
filterFreq = 7.0 |
|
) |
| |
Sets PID parameters. All gains are in constant (not timebase) form.
This method does reset accumulated error and differential error
- Parameters
-
p_gain | proportional gain |
i_gain | integral gain |
d_gain | derivative gain |
ff_gain | feedforward gain (defaults to 1.0) |
i_decay | integral decay (defaults to 0.5) |
feedforward | whether or not feedforward is used |
filterFreq | the frequency of the low pass filter |
void PID::SetSetpoint |
( |
double |
setpoint | ) |
|
|
virtual |
Sets the setpoint.
- Parameters
-
setpoint | the setpoint to set |
Reimplemented in ProfiledPID.
double PID::Update |
( |
double |
dt | ) |
|
|
virtual |
Updates the PID controller, call on each loop.
- Parameters
-
- Returns
- pid output
Reimplemented in ProfiledPID.
The documentation for this class was generated from the following files:
- Control/PID.h
- Control/PID.cpp