Public Types | Public Member Functions | Public Attributes

PID Class Reference

Object managing one PID control. More...

#include <PID.h>

Collaboration diagram for PID:
Collaboration graph
[legend]

List of all members.

Public Types

enum  storage_t { STORE_OFF, STORE_EEPROM_FLOAT, STORE_EEPROM_UINT16 }

Public Member Functions

 PID ()
 PID (uint16_t address, storage_t storage=STORE_EEPROM_UINT16)
 PID (float *gain_array)
long get_pid (int32_t error, uint16_t dt, float scaler=1.0)
void reset_I ()
void load_gains ()
void save_gains ()
float get_integrator ()
parameter accessors

float kP ()
float kI ()
float kD ()
float imax ()
void kP (const float v)
void kI (const float v)
void kD (const float v)
void imax (const float v)
void address (const uint16_t v)

Public Attributes

enum PID::storage_t _storage

Detailed Description

Object managing one PID control.

Definition at line 14 of file PID.h.


Member Enumeration Documentation

Enumerator:
STORE_OFF 
STORE_EEPROM_FLOAT 
STORE_EEPROM_UINT16 

Definition at line 18 of file PID.h.


Constructor & Destructor Documentation

PID::PID (  )  [inline]

Constructor

A PID constructed in this fashion does not support save/restore. Gains are managed internally, and must be read/written using the accessor functions.

Definition at line 31 of file PID.h.

PID::PID ( uint16_t  address,
storage_t  storage = STORE_EEPROM_UINT16 
) [inline]

Constructor

The PID will manage gains internally, and the load/save functions will use 16 bytes of EEPROM storage to store gain values.

Parameters:
address EEPROM base address at which PID parameters are stored.

Definition at line 45 of file PID.h.

PID::PID ( float *  gain_array  )  [inline]

Constructor

Gain values for the PID are managed externally; load/save are a NOP.

Parameters:
gain_array Address of an array of float values. The array is used as kP, kI, kD and imax respectively.

Definition at line 62 of file PID.h.


Member Function Documentation

void PID::address ( const uint16_t  v  )  [inline]

Definition at line 111 of file PID.h.

float PID::get_integrator (  )  [inline]

Definition at line 118 of file PID.h.

long PID::get_pid ( int32_t  error,
uint16_t  dt,
float  scaler = 1.0 
)

Iterate the PID, return the new control value

Positive error produces positive output.

Parameters:
error The measured error value
dt The time delta in milliseconds (note that update interval cannot be more than 65.535 seconds due to limited range of the data type).
scaler An arbitrary scale factor
Returns:
The updated control output.

Definition at line 18 of file PID.cpp.

float PID::imax (  )  [inline]

Definition at line 104 of file PID.h.

void PID::imax ( const float  v  ) 

Definition at line 61 of file PID.cpp.

void PID::kD ( const float  v  )  [inline]

Definition at line 108 of file PID.h.

float PID::kD (  )  [inline]

Definition at line 103 of file PID.h.

void PID::kI ( const float  v  )  [inline]

Definition at line 107 of file PID.h.

float PID::kI (  )  [inline]

Definition at line 102 of file PID.h.

float PID::kP (  )  [inline]

Definition at line 101 of file PID.h.

void PID::kP ( const float  v  )  [inline]

Definition at line 106 of file PID.h.

void PID::load_gains (  ) 

Load gain properties

Definition at line 67 of file PID.cpp.

void PID::reset_I (  )  [inline]

Reset the PID integrator

Definition at line 85 of file PID.h.

void PID::save_gains (  ) 

Save gain properties

Definition at line 97 of file PID.cpp.


Member Data Documentation


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