EEEN21000
GROUP 30 Line Following Buggy
Loading...
Searching...
No Matches
PID Class Reference

Proportional-integral-derivative controller. More...

#include <PID.h>

Public Member Functions

 PID (float Kc, float tauI, float tauD, float interval)
 Contructor. More...
 
void setInputLimits (float inMin, float inMax)
 Scale from inputs to 0-100%. More...
 
void setOutputLimits (float outMin, float outMax)
 Scale from outputs to 0-100%. More...
 
void setTunings (float Kc, float tauI, float tauD)
 Calculate PID constants. More...
 
void reset ()
 Reset previous values of output and error. More...
 
void setSetPoint (float sp)
 Set the set point. More...
 
float getSetPoint ()
 Get the setpoint. More...
 
void setProcessValue (float pv)
 Set the process value. More...
 
void setBias (float bias)
 Set the bias. More...
 
float compute (void)
 PID calculation. More...
 

Protected Attributes

bool _usingFeedForward
 
float _Kc
 
float _tauR
 
float _tauD
 
float _pParam
 
float _iParam
 
float _dParam
 
float _setPoint
 
float _processVariable
 
float _prevProcessVariable
 
float _prevError
 
float _controllerOutput
 
float _prevControllerOutput
 
float _inMin
 
float _inMax
 
float _inSpan
 
float _outMin
 
float _outMax
 
float _outSpan
 
float _accError
 
float _bias
 
float _a
 
float _tSample
 

Detailed Description

Proportional-integral-derivative controller.

Constructor & Destructor Documentation

◆ PID()

PID::PID ( float  Kc,
float  tauI,
float  tauD,
float  interval 
)

Contructor.

Sets default limits [0-3.3V], calculates tuning parameters, and sets manual mode with no bias.

Parameters
Kc- Proportional gain
tauI- Integral gain
tauD- Derivative gain
interval- PID calculation performed every interval seconds.

Member Function Documentation

◆ setInputLimits()

void PID::setInputLimits ( float  inMin,
float  inMax 
)

Scale from inputs to 0-100%.

Parameters
inMin- The real world value corresponding to 0%
inMax- The real world value corresponding to 100%

◆ setOutputLimits()

void PID::setOutputLimits ( float  outMin,
float  outMax 
)

Scale from outputs to 0-100%.

Parameters
outMin- The real world value corresponding to 0%
outMax- The real world value corresponding to 100%

◆ setTunings()

void PID::setTunings ( float  Kc,
float  tauI,
float  tauD 
)

Calculate PID constants.

Allows parameters to be changed on the fly without ruining calculations.

Parameters
Kc- Proportional gain
tauI- Integral gain
tauD- Derivative gain

◆ reset()

void PID::reset ( )

Reset previous values of output and error.

◆ setSetPoint()

void PID::setSetPoint ( float  sp)

Set the set point.

Parameters
spThe set point as a real world value.

◆ getSetPoint()

float PID::getSetPoint ( )

Get the setpoint.

Returns
float Setpoint

◆ setProcessValue()

void PID::setProcessValue ( float  pv)

Set the process value.

Parameters
pvThe process value as a real world value.

◆ setBias()

void PID::setBias ( float  bias)

Set the bias.

Parameters
biasThe bias for the controller output.

◆ compute()

float PID::compute ( void  )

PID calculation.

Returns
The controller output as a float between outMin and outMax.

Member Data Documentation

◆ _usingFeedForward

bool PID::_usingFeedForward
protected

◆ _Kc

float PID::_Kc
protected

◆ _tauR

float PID::_tauR
protected

◆ _tauD

float PID::_tauD
protected

◆ _pParam

float PID::_pParam
protected

◆ _iParam

float PID::_iParam
protected

◆ _dParam

float PID::_dParam
protected

◆ _setPoint

float PID::_setPoint
protected

◆ _processVariable

float PID::_processVariable
protected

◆ _prevProcessVariable

float PID::_prevProcessVariable
protected

◆ _prevError

float PID::_prevError
protected

◆ _controllerOutput

float PID::_controllerOutput
protected

◆ _prevControllerOutput

float PID::_prevControllerOutput
protected

◆ _inMin

float PID::_inMin
protected

◆ _inMax

float PID::_inMax
protected

◆ _inSpan

float PID::_inSpan
protected

◆ _outMin

float PID::_outMin
protected

◆ _outMax

float PID::_outMax
protected

◆ _outSpan

float PID::_outSpan
protected

◆ _accError

float PID::_accError
protected

◆ _bias

float PID::_bias
protected

◆ _a

float PID::_a
protected

◆ _tSample

float PID::_tSample
protected

The documentation for this class was generated from the following file: