Humidistat
Arduino firmware for a humidistat (humidity controller)
Loading...
Searching...
No Matches
CascadeHumidistat.cpp
Go to the documentation of this file.
1#include "CascadeHumidistat.h"
2
4 etl::span<const FlowSensor, 2> flowSensors, etl::array<uint8_t, 2> pins_solenoid,
5 uint8_t pwmRes)
6 : Humidistat(cs, hs, cs->HC_Kp, cs->HC_Ki, cs->HC_Kd, cs->HC_Kf, cs->dt, 0, 1),
7 fcs{FlowController(&flowSensors[0], cs, pins_solenoid[0], pwmRes),
8 FlowController(&flowSensors[1], cs, pins_solenoid[1], pwmRes)} {
9 fcs[0].active = true;
10 fcs[1].active = true;
11}
12
14 runCycle();
15
16 // Set CV of humidity controller as SP of flow controllers
18 fcs[1].sp = (1 - cv) * cs.HC_totalFlowrate;
19
20 fcs[0].update();
21 fcs[1].update();
22}
23
25 return &fcs[n];
26}
27
const FlowController * getInner(uint8_t n) const
Get a pointer to a inner FlowController instance.
CascadeHumidistat(HumiditySensor *hs, const ConfigStore *cs, etl::span< const FlowSensor, 2 > flowSensors, etl::array< uint8_t, 2 > pins_solenoid, uint8_t pwmRes)
Constructor.
FlowController fcs[2]
double sp
Setpoint.
Definition Controller.h:22
bool active
Definition Controller.h:19
const ConfigStore & cs
Definition Controller.h:14
double cv
Control variable.
Definition Controller.h:23
Controls flow. Holds a reference to a FlowSensor instance.
Base class for a humidistat. Holds a reference to a HumiditySensor instance.
Definition Humidistat.h:10
void runCycle()
Run a cycle of the controller. Reads a sample from the humidity controller and runs PID.
void setGains(double Kp, double Ki, double Kd, double Kf, uint16_t dt)
Set the gains and timestep.
Definition PID.cpp:59
const uint8_t pwmRes
Definition main.cpp:44
Config store containing variables, which can be stored in EEPROM.
Definition EEPROMConfig.h:7
double HC_totalFlowrate
Total flowrate (for cascade controller) (L/min)
double HC_Kp
Humidity controller PID parameters.
uint16_t dt
Global interval for PID/logger (based on polling rate of sensor, in millis)