modm API documentation
|
A proportional-integral-derivative controller (PID controller) More...
#include <modm/math/filter/pid.hpp>
Classes | |
struct | Parameter |
Parameter for a PID calculation More... | |
Public Typedefs | |
typedef T | ValueType |
Public Member Functions | |
Pid (const float &kp=0, const float &ki=0, const float &kd=0, const T &maxErrorSum=0, const T &maxOutput=0) | |
Pid (Parameter ¶meter) | |
void | setParameter (const Parameter ¶meter) |
void | reset () |
Reset all values. | |
void | update (const T &input, bool externalLimitation=false) |
Calculate a new output value. More... | |
const T & | getValue () const |
Returns the calculated actuating variable. | |
const T & | getLastError () const |
Get last error. More... | |
const T & | getErrorSum () const |
Get integrated error. More... | |
A proportional-integral-derivative controller (PID controller)
The PID controller is one of the basic controlling algorithm.
The maxErrorSum
is to be used, to limit the internal integrator and so provide an anti wind up.
With the template parameter ScaleFactor
this class provides an fix point capability with integer types.
Example for a motor speed control with a 10-bit PWM output.
modm::Pid< T, ScaleFactor >::Pid | ( | const float & | kp = 0 , |
const float & | ki = 0 , |
||
const float & | kd = 0 , |
||
const T & | maxErrorSum = 0 , |
||
const T & | maxOutput = 0 |
||
) |
kp | proportional gain |
ki | integral gain |
kd | differential gain |
maxErrorSum | integral will be limited to this value |
maxOutput | output will be limited to this value |
modm::Pid< T, ScaleFactor >::Pid | ( | Parameter & | parameter | ) |
parameter | list of parameters to the controller |
|
inline |
Get integrated error.
This function is provided for debugging purposes only.
|
inline |
Get last error.
This function is provided for debugging purposes only.
The differential term is calculated via:
void modm::Pid< T, ScaleFactor >::setParameter | ( | const Parameter & | parameter | ) |
Reset the parameters of the controller.
parameter | list of parameters to the controller |
void modm::Pid< T, ScaleFactor >::update | ( | const T & | input, |
bool | externalLimitation = false |
||
) |
Calculate a new output value.
input | Error |
externalLimitation | If true an external limitation is applied, this disables integral summation. |