MHVLib  20111011
An efficiency oriented runtime library for AVR microcontrollers
MHV_PID Class Reference

#include <MHV_PID.h>

List of all members.

Public Member Functions

 MHV_PID (float setpoint, float kP, float kI, float kD, uint16_t period, bool reverse, uint16_t min, uint16_t max)
void setDirection (bool reverse)
void enable (bool enable)
float compute (float input)
void setTuning (float kP, float kI, float kD, uint16_t period)
void setOutputLimits (float, float)

Protected Member Functions

void clampIntegral ()

Protected Attributes

float _kP
float _kI
float _kD
bool _reverse
bool _enabled
float _setpoint
float _integral
float _lastInput
float _lastOutput
float outMin
float outMax

Detailed Description

Definition at line 38 of file MHV_PID.h.


Constructor & Destructor Documentation

MHV_PID::MHV_PID ( float  setpoint,
float  kP,
float  kI,
float  kD,
uint16_t  period,
bool  reverse,
uint16_t  min,
uint16_t  max 
)

Create a new PID

Parameters:
setpointthe target value
kPthe proportional constant
kIthe integral constant
kDthe derivative constant
periodthe period that compute() is called, in ms
reversetrue if there is an inverse relationship between the output and the input (eg. running a cooler to reduce temperature)
minthe minimum value for output
maxthe maximum value four output

Definition at line 46 of file MHV_PID.cpp.


Member Function Documentation

void MHV_PID::clampIntegral ( ) [inline, protected]

Definition at line 57 of file MHV_PID.cpp.

float MHV_PID::compute ( float  input)

Calculate the next output

Parameters:
inputthe latest sample

Definition at line 69 of file MHV_PID.cpp.

void MHV_PID::enable ( bool  enable)

Enable/Disable the PID

Parameters:
enabletrue to enable the pid

Definition at line 129 of file MHV_PID.cpp.

void MHV_PID::setDirection ( bool  reverse)

Set the direction for the PID.

Setting reverse means that increasing output reduces the input (eg. increasing power to a cooler, with the input being temperature)

Definition at line 145 of file MHV_PID.cpp.

void MHV_PID::setOutputLimits ( float  min,
float  max 
)

Alter the minimum & maximum values for the output

Parameters:
minthe new minimum output value
maxthe new maximum output value

Definition at line 117 of file MHV_PID.cpp.

void MHV_PID::setTuning ( float  kP,
float  kI,
float  kD,
uint16_t  period 
)

Adjust PID parameters

Parameters:
kPthe proportional constant
kIthe integral constant
kDthe derivative constant
periodthe period that compute() is called, in ms

Definition at line 97 of file MHV_PID.cpp.


Member Data Documentation

bool MHV_PID::_enabled [protected]

Definition at line 45 of file MHV_PID.h.

float MHV_PID::_integral [protected]

Definition at line 48 of file MHV_PID.h.

float MHV_PID::_kD [protected]

Definition at line 42 of file MHV_PID.h.

float MHV_PID::_kI [protected]

Definition at line 41 of file MHV_PID.h.

float MHV_PID::_kP [protected]

Definition at line 40 of file MHV_PID.h.

float MHV_PID::_lastInput [protected]

Definition at line 49 of file MHV_PID.h.

float MHV_PID::_lastOutput [protected]

Definition at line 50 of file MHV_PID.h.

bool MHV_PID::_reverse [protected]

Definition at line 44 of file MHV_PID.h.

float MHV_PID::_setpoint [protected]

Definition at line 47 of file MHV_PID.h.

float MHV_PID::outMax [protected]

Definition at line 53 of file MHV_PID.h.

float MHV_PID::outMin [protected]

Definition at line 52 of file MHV_PID.h.


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