David Spillman / PID

Dependents:   GPSNavigationNew

Fork of PID by Aaron Berk

Embed: (wiki syntax)

« Back to documentation index

PID Class Reference

PID Class Reference

Proportional-integral-derivative controller. More...

#include <PID.h>

Public Member Functions

 PID (float Kc, float tauI, float tauD, float interval)
 Constructor.
void setInputLimits (float inMin, float inMax)
 Scale from inputs to 0-100%.
void setOutputLimits (float outMin, float outMax)
 Scale from outputs to 0-100%.
void setTunings (float Kc, float tauI, float tauD)
 Calculate PID constants.
void reset (void)
 Reinitializes controller internals.
void setMode (int mode)
 Set PID to manual or auto mode.
void setInterval (float interval)
 Set how fast the PID loop is run.
void setSetPoint (float sp)
 Set the set point.
void setProcessValue (float pv)
 Set the process value.
void setBias (float bias)
 Set the bias.
float compute (void)
 PID calculation.

Detailed Description

Proportional-integral-derivative controller.

Definition at line 64 of file PID.h.


Constructor & Destructor Documentation

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

Constructor.

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

Parameters:
Kc- Tuning parameter
tauI- Tuning parameter
tauD- Tuning parameter
intervalPID calculation performed every interval seconds.

Definition at line 11 of file PID.cpp.


Member Function Documentation

float compute ( void   )

PID calculation.

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

Definition at line 139 of file PID.cpp.

void reset ( void   )

Reinitializes controller internals.

Automatically called on a manual to auto transition.

Definition at line 87 of file PID.cpp.

void setBias ( float  bias )

Set the bias.

Parameters:
biasThe bias for the controller output.

Definition at line 132 of file PID.cpp.

void setInputLimits ( float  inMin,
float  inMax 
)

Scale from inputs to 0-100%.

Parameters:
InMinThe real world value corresponding to 0%.
InMaxThe real world value corresponding to 100%.

Definition at line 40 of file PID.cpp.

void setInterval ( float  interval )

Set how fast the PID loop is run.

Parameters:
intervalPID calculation peformed every interval seconds.

Definition at line 108 of file PID.cpp.

void setMode ( int  mode )

Set PID to manual or auto mode.

Parameters:
mode0 -> Manual Non-zero -> Auto

Definition at line 96 of file PID.cpp.

void setOutputLimits ( float  outMin,
float  outMax 
)

Scale from outputs to 0-100%.

Parameters:
outMinThe real world value corresponding to 0%.
outMaxThe real world value corresponding to 100%.

Definition at line 48 of file PID.cpp.

void setProcessValue ( float  pv )

Set the process value.

Parameters:
pvThe process value as a real world value.

Definition at line 126 of file PID.cpp.

void setSetPoint ( float  sp )

Set the set point.

Parameters:
spThe set point as a real world value.

Definition at line 120 of file PID.cpp.

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

Calculate PID constants.

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

Parameters:
Kc- Tuning parameter
tauI- Tuning parameter
tauD- Tuning parameter

Definition at line 57 of file PID.cpp.