Humidistat
Arduino firmware for a humidistat (humidity controller)
Loading...
Searching...
No Matches
Controller Class Reference

Base class for a controller. Owns a PID instance, and holds a reference to a ConfigStore instance. More...

#include <Controller.h>

Inheritance diagram for Controller:
[legend]
Collaboration diagram for Controller:
[legend]

Public Member Functions

 Controller (const ConfigStore *cs, double Kp, double Ki, double Kd, double Kf, uint16_t dt, double cvMin, double cvMax, double defaultSP, double defaultCV)
 Constructor.
 
void getTerms (double &pTerm, double &iTerm, double &dTerm) const
 Get the three PID terms by reference.
 
void update ()
 Run the controller: Typically reads a sensor, runs a cycle of the PID loop and drives some actuator.
 
void updatePIDParameters ()
 Update the PID parameters from the configStore.
 
const ConfigStoregetConfigStore ()
 Get a pointer to the ConfigStore instance.
 

Public Attributes

bool active = false
 
double pv = 0
 Process variable.
 
double sp
 Setpoint.
 
double cv
 Control variable.
 

Protected Attributes

PID pid
 
const ConfigStorecs
 
unsigned long sensorLastRead = 0
 

Detailed Description

Base class for a controller. Owns a PID instance, and holds a reference to a ConfigStore instance.

Definition at line 11 of file Controller.h.

Constructor & Destructor Documentation

◆ Controller()

Controller::Controller ( const ConfigStore * cs,
double Kp,
double Ki,
double Kd,
double Kf,
uint16_t dt,
double cvMin,
double cvMax,
double defaultSP,
double defaultCV )

Constructor.

Parameters
csPointer to a ConfigStore instance
KpProportional gain
KiIntegral gain (in 1/s)
KdDerivative gain (in s)
KfFeed-forward gain
dtTimestep (in ms)
cvMinLower limit for control value
cvMaxUpper limit for control value
defaultSPDefault value for the setpoint
defaultCVDefault value for the control variable

Definition at line 3 of file Controller.cpp.

Member Function Documentation

◆ getConfigStore()

const ConfigStore * Controller::getConfigStore ( )

Get a pointer to the ConfigStore instance.

Returns
pointer to the ConfigStore instance.

Definition at line 13 of file Controller.cpp.

Here is the caller graph for this function:

◆ getTerms()

void Controller::getTerms ( double & pTerm,
double & iTerm,
double & dTerm ) const

Get the three PID terms by reference.

Parameters
pTerm
iTerm
dTerm

Definition at line 7 of file Controller.cpp.

◆ update()

void Controller::update ( )

Run the controller: Typically reads a sensor, runs a cycle of the PID loop and drives some actuator.

◆ updatePIDParameters()

void Controller::updatePIDParameters ( )

Update the PID parameters from the configStore.

Member Data Documentation

◆ active

bool Controller::active = false

Definition at line 19 of file Controller.h.

◆ cs

const ConfigStore& Controller::cs
protected

Definition at line 14 of file Controller.h.

◆ cv

double Controller::cv

Control variable.

Definition at line 23 of file Controller.h.

◆ pid

PID Controller::pid
protected

Definition at line 13 of file Controller.h.

◆ pv

double Controller::pv = 0

Process variable.

Definition at line 21 of file Controller.h.

◆ sensorLastRead

unsigned long Controller::sensorLastRead = 0
protected

Definition at line 16 of file Controller.h.

◆ sp

double Controller::sp

Setpoint.

Definition at line 22 of file Controller.h.


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