my version

Dependents:   aps_so_c2

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.

Includes.

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.
Author:
Aaron Berk

LICENSE

Copyright (c) 2010 ARM Limited

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

DESCRIPTION

A PID controller is a widely used feedback controller commonly found in industry.

This library is a port of Brett Beauregard's Arduino PID library:

http://www.arduino.cc/playground/Code/PIDLibrary

The wikipedia article on PID controllers is a good place to start on understanding how they work:

http://en.wikipedia.org/wiki/PID_controller

For a clear and elegant explanation of how to implement and tune a controller, the controlguru website by Douglas J. Cooper (who also happened to be Brett's controls professor) is an excellent reference:

http://www.controlguru.com/

Definition at line 52 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 223 of file PID.cpp.

void reset ( void   )

Reinitializes controller internals.

Automatically called on a manual to auto transition.

Definition at line 162 of file PID.cpp.

void setBias ( float  bias )

Set the bias.

Parameters:
biasThe bias for the controller output.

Definition at line 216 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 80 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 192 of file PID.cpp.

void setMode ( int  mode )

Set PID to manual or auto mode.

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

Definition at line 180 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 104 of file PID.cpp.

void setProcessValue ( float  pv )

Set the process value.

Parameters:
pvThe process value as a real world value.

Definition at line 210 of file PID.cpp.

void setSetPoint ( float  sp )

Set the set point.

Parameters:
spThe set point as a real world value.

Definition at line 204 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 127 of file PID.cpp.