Humidistat
Arduino firmware for a humidistat (humidity controller)
Loading...
Searching...
No Matches
Humidistat.cpp
Go to the documentation of this file.
1#include "Humidistat.h"
2
3Humidistat::Humidistat(const ConfigStore *cs, HumiditySensor *hs, double Kp, double Ki, double Kd, double Kf, uint16_t
4 dt, double cvMin, double cvMax)
5 : Controller(cs, Kp, Ki, Kd, Kf, dt, cvMin, cvMax, 50, (cvMin + cvMax) / 2), hs(*hs) {}
6
7double Humidistat::getHumidity() const {
8 return hs.getHumidity();
9}
10
12 return hs.getTemperature();
13}
14
16 if (millis() - sensorLastRead < cs.dt)
17 return;
18 sensorLastRead = millis();
19
21
22 // Read humidity (if not NaN)
23 hs.readSample();
24 if (!isnan(hs.getHumidity()))
25 pv = hs.getHumidity();
26
27 // Run PID cycle if active (pid writes into this->cv)
28 pid.compute();
29}
30
31double Humidistat::getCvMin() const {
32 return pid.cvMin;
33}
34
35double Humidistat::getCvMax() const {
36 return pid.cvMax;
37}
Base class for a controller. Owns a PID instance, and holds a reference to a ConfigStore instance.
Definition Controller.h:11
bool active
Definition Controller.h:19
double pv
Process variable.
Definition Controller.h:21
const ConfigStore & cs
Definition Controller.h:14
unsigned long sensorLastRead
Definition Controller.h:16
double getHumidity() const
Read the humidity.
Definition Humidistat.cpp:7
double getCvMin() const
Humidistat(const ConfigStore *cs, HumiditySensor *hs, double Kp, double Ki, double Kd, double Kf, uint16_t dt, double cvMin, double cvMax)
Constructor.
Definition Humidistat.cpp:3
double getCvMax() const
double getTemperature() const
Read the temperature.
void runCycle()
Run a cycle of the controller. Reads a sample from the humidity controller and runs PID.
HumiditySensor & hs
Definition Humidistat.h:12
void setAuto(bool inAuto)
Set the mode of the controller.
Definition PID.cpp:52
bool compute()
Run a cycle of the PID loop.
Definition PID.cpp:17
double cvMax
Lower/upper limits for cv.
Definition PID.h:34
double cvMin
Definition PID.h:34
Config store containing variables, which can be stored in EEPROM.
Definition EEPROMConfig.h:7
uint16_t dt
Global interval for PID/logger (based on polling rate of sensor, in millis)