Skip to content

Commit

Permalink
PID UI
Browse files Browse the repository at this point in the history
(cherry picked from commit 8e030f87a7c187fa4f03205d2520e4f9b651fc37)
  • Loading branch information
mathieucarbou committed Jul 5, 2024
1 parent 95ba6e8 commit 977569d
Show file tree
Hide file tree
Showing 13 changed files with 360 additions and 174 deletions.
3 changes: 2 additions & 1 deletion data/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ <h1>YaSolR Configuration</h1>
relay2_type: ["Relay 2 Type", "select", "NO,NC"],

"PID Calibration": "TITLE",
pid_view_enable: ["View PID Data", "switch"],
pid_pmode: ["Proportional Mode (1: on Error, 2: on Input, 3: Both)", "select", "1,2,3"],
pid_dmode: ["Derivative Mode (1: on Error, 2: on Input)", "select", "1,2"],
pid_icmode: ["Integral Correction Mode (0: Off, 1: Clamp, 2: Anti-windup)", "select", "0,1,2"],
pid_icmode: ["Integral Correction (0: Off, 1: Clamp, 2: Anti-windup)", "select", "0,1,2"],
pid_setpoint: ["Setpoint (Target Grid Power)", "float"],
pid_kp: ["Kp", "float"],
pid_ki: ["Ki", "float"],
Expand Down
13 changes: 11 additions & 2 deletions include/YaSolRDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@
#define YASOLR_SERIAL_BAUDRATE 115200
#define YASOLR_WEEK_DAYS "sun,mon,tue,wed,thu,fri,sat"
#define YASOLR_GRAPH_POINTS 120
#define YASOLR_PID_P_MODE_1 "1: on Error"
#define YASOLR_PID_P_MODE_2 "2: on Input"
#define YASOLR_PID_P_MODE_3 "3: Both"
#define YASOLR_PID_D_MODE_1 YASOLR_PID_P_MODE_1
#define YASOLR_PID_D_MODE_2 YASOLR_PID_P_MODE_2
#define YASOLR_PID_IC_MODE_0 "0: Off"
#define YASOLR_PID_IC_MODE_1 "1: Clamp"
#define YASOLR_PID_IC_MODE_2 "2: Anti-windup"

// UDP communication

Expand Down Expand Up @@ -87,6 +95,7 @@
#define KEY_ENABLE_OUTPUT2_DS18 "o2_ds18_enable"
#define KEY_ENABLE_OUTPUT2_PZEM "o2_pzem_enable"
#define KEY_ENABLE_OUTPUT2_RELAY "o2_relay_enable"
#define KEY_ENABLE_PID_VIEW "pid_view_enable"
#define KEY_ENABLE_RELAY1 "relay1_enable"
#define KEY_ENABLE_RELAY2 "relay2_enable"
#define KEY_ENABLE_ZCD "zcd_enable"
Expand Down Expand Up @@ -130,15 +139,15 @@
#define KEY_OUTPUT2_TIME_START "o2_time_start"
#define KEY_OUTPUT2_TIME_STOP "o2_time_stop"
#define KEY_OUTPUT2_TIME_STOP "o2_time_stop"
#define KEY_PID_P_MODE "pid_pmode"
#define KEY_PID_D_MODE "pid_dmode"
#define KEY_PID_IC_MODE "pid_icmode"
#define KEY_PID_SETPOINT "pid_setpoint"
#define KEY_PID_KD "pid_kd"
#define KEY_PID_KI "pid_ki"
#define KEY_PID_KP "pid_kp"
#define KEY_PID_OUT_MAX "pid_out_max"
#define KEY_PID_OUT_MIN "pid_out_min"
#define KEY_PID_P_MODE "pid_pmode"
#define KEY_PID_SETPOINT "pid_setpoint"
#define KEY_RELAY1_LOAD "relay1_load"
#define KEY_RELAY1_TYPE "relay1_type"
#define KEY_RELAY2_LOAD "relay2_load"
Expand Down
35 changes: 34 additions & 1 deletion include/YaSolRWebsite.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ namespace YaSolR {
void initCards();
void updateCards();
void updateCharts();
void updatePID();
void resetPID();

private:
int _historyX[YASOLR_GRAPH_POINTS] = {0};

// statistics
Statistic _appName = Statistic(&dashboard, YASOLR_LBL_001);
Statistic _appModel = Statistic(&dashboard, YASOLR_LBL_002);
Expand Down Expand Up @@ -87,7 +91,6 @@ namespace YaSolR {
Card _gridPower = Card(&dashboard, ENERGY_CARD, YASOLR_LBL_044, "W");
Card _routerDS18State = Card(&dashboard, TEMPERATURE_CARD, YASOLR_LBL_045, "°C");

int _historyX[YASOLR_GRAPH_POINTS] = {0};
int _gridPowerHistoryY[YASOLR_GRAPH_POINTS] = {0};
int _routedPowerHistoryY[YASOLR_GRAPH_POINTS] = {0};
int _routerTHDiHistoryY[YASOLR_GRAPH_POINTS] = {0};
Expand Down Expand Up @@ -245,11 +248,41 @@ namespace YaSolR {
Card _output2RelayType = Card(&dashboard, DROPDOWN_CARD, YASOLR_LBL_150);
Card _relay1Type = Card(&dashboard, DROPDOWN_CARD, YASOLR_LBL_151);
Card _relay2Type = Card(&dashboard, DROPDOWN_CARD, YASOLR_LBL_152);

Tab _pidTab = Tab(&dashboard, "\u2699 " YASOLR_LBL_159);
Card _pidView = Card(&dashboard, BUTTON_CARD, YASOLR_LBL_169);
Card _pidPMode = Card(&dashboard, DROPDOWN_CARD, YASOLR_LBL_160);
Card _pidDMode = Card(&dashboard, DROPDOWN_CARD, YASOLR_LBL_161);
Card _pidICMode = Card(&dashboard, DROPDOWN_CARD, YASOLR_LBL_162);
Card _pidSetpoint = Card(&dashboard, TEXT_INPUT_CARD, YASOLR_LBL_163);
Card _pidKp = Card(&dashboard, TEXT_INPUT_CARD, YASOLR_LBL_166);
Card _pidKi = Card(&dashboard, TEXT_INPUT_CARD, YASOLR_LBL_167);
Card _pidKd = Card(&dashboard, TEXT_INPUT_CARD, YASOLR_LBL_168);
Card _pidOutMin = Card(&dashboard, TEXT_INPUT_CARD, YASOLR_LBL_164);
Card _pidOutMax = Card(&dashboard, TEXT_INPUT_CARD, YASOLR_LBL_165);
Card _pidReset = Card(&dashboard, PUSH_BUTTON_CARD, YASOLR_LBL_177);

// input,output,error,pTerm,iTerm,dTerm,sum
int _pidInputHistoryY[YASOLR_GRAPH_POINTS] = {0};
int _pidOutputHistoryY[YASOLR_GRAPH_POINTS] = {0};
int _pidErrorHistoryY[YASOLR_GRAPH_POINTS] = {0};
int _pidPTermHistoryY[YASOLR_GRAPH_POINTS] = {0};
int _pidITermHistoryY[YASOLR_GRAPH_POINTS] = {0};
int _pidDTermHistoryY[YASOLR_GRAPH_POINTS] = {0};
int _pidSumHistoryY[YASOLR_GRAPH_POINTS] = {0};
Chart _pidInputHistory = Chart(&dashboard, LINE_CHART, YASOLR_LBL_170);
Chart _pidOutputHistory = Chart(&dashboard, LINE_CHART, YASOLR_LBL_171);
Chart _pidErrorHistory = Chart(&dashboard, LINE_CHART, YASOLR_LBL_172);
Chart _pidSumHistory = Chart(&dashboard, BAR_CHART, YASOLR_LBL_173);
Chart _pidPTermHistory = Chart(&dashboard, LINE_CHART, YASOLR_LBL_174);
Chart _pidITermHistory = Chart(&dashboard, LINE_CHART, YASOLR_LBL_175);
Chart _pidDTermHistory = Chart(&dashboard, LINE_CHART, YASOLR_LBL_176);
#endif

private:
void _boolConfig(Card& card, const char* key);
void _daysConfig(Card& card, const char* key);
void _floatConfig(Card& card, const char* key);
void _numConfig(Card& card, const char* key);
void _pinConfig(Card& card, const char* key);
void _passwordConfig(Card& card, const char* key);
Expand Down
38 changes: 19 additions & 19 deletions include/i18n/en.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,25 +162,25 @@
#define YASOLR_LBL_156 "I/O"
#define YASOLR_LBL_157 "JSY Remote UDP: Message Rate"
#define YASOLR_LBL_158 "Grid Excess Remaining"
#define YASOLR_LBL_159
#define YASOLR_LBL_160
#define YASOLR_LBL_161
#define YASOLR_LBL_162
#define YASOLR_LBL_163
#define YASOLR_LBL_164
#define YASOLR_LBL_165
#define YASOLR_LBL_166
#define YASOLR_LBL_167
#define YASOLR_LBL_168
#define YASOLR_LBL_169
#define YASOLR_LBL_170
#define YASOLR_LBL_171
#define YASOLR_LBL_172
#define YASOLR_LBL_173
#define YASOLR_LBL_174
#define YASOLR_LBL_175
#define YASOLR_LBL_176
#define YASOLR_LBL_177
#define YASOLR_LBL_159 "PID Controller"
#define YASOLR_LBL_160 "Proportional Mode"
#define YASOLR_LBL_161 "Derivative Mode"
#define YASOLR_LBL_162 "Integral Correction"
#define YASOLR_LBL_164 "Output Min (W)"
#define YASOLR_LBL_165 "Output Max (W)"
#define YASOLR_LBL_163 "Setpoint (Target Grid Power in W)"
#define YASOLR_LBL_166 "Kp"
#define YASOLR_LBL_167 "Ki"
#define YASOLR_LBL_168 "Kd"
#define YASOLR_LBL_169 "Real-time PID Data"
#define YASOLR_LBL_170 "Input (Grid Power, W)"
#define YASOLR_LBL_171 "Output (Power to route, W)"
#define YASOLR_LBL_172 "Error (W)"
#define YASOLR_LBL_173 "Sum (W)"
#define YASOLR_LBL_174 "P Term (W)"
#define YASOLR_LBL_175 "I Term (W)"
#define YASOLR_LBL_176 "D Term (W)"
#define YASOLR_LBL_177 "Chart Reset"
#define YASOLR_LBL_178
#define YASOLR_LBL_179
#define YASOLR_LBL_180
Expand Down
38 changes: 19 additions & 19 deletions include/i18n/fr.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,25 +162,25 @@
#define YASOLR_LBL_156 "E/S"
#define YASOLR_LBL_157 "JSY Remote UDP: Débit"
#define YASOLR_LBL_158 "Surplus réseau restant"
#define YASOLR_LBL_159
#define YASOLR_LBL_160
#define YASOLR_LBL_161
#define YASOLR_LBL_162
#define YASOLR_LBL_163
#define YASOLR_LBL_164
#define YASOLR_LBL_165
#define YASOLR_LBL_166
#define YASOLR_LBL_167
#define YASOLR_LBL_168
#define YASOLR_LBL_169
#define YASOLR_LBL_170
#define YASOLR_LBL_171
#define YASOLR_LBL_172
#define YASOLR_LBL_173
#define YASOLR_LBL_174
#define YASOLR_LBL_175
#define YASOLR_LBL_176
#define YASOLR_LBL_177
#define YASOLR_LBL_159 "Contrôleur PID"
#define YASOLR_LBL_160 "Mode proportionnel"
#define YASOLR_LBL_161 "Mode dérivé"
#define YASOLR_LBL_162 "Correction d'Intégrale"
#define YASOLR_LBL_164 "Sortie Min (W)"
#define YASOLR_LBL_165 "Sortie Max (W)"
#define YASOLR_LBL_163 "Consigne (puissance cible du réseau en W)"
#define YASOLR_LBL_166 "Kp"
#define YASOLR_LBL_167 "Ki"
#define YASOLR_LBL_168 "Kd"
#define YASOLR_LBL_169 "Données PID temps-réel"
#define YASOLR_LBL_170 "Entrée (Puissance réseau, W)"
#define YASOLR_LBL_171 "Sortie (Puissance à router, W)"
#define YASOLR_LBL_172 "Erreur (W)"
#define YASOLR_LBL_173 "Somme (W)"
#define YASOLR_LBL_174 "Terme P (W)"
#define YASOLR_LBL_175 "Terme I (W)"
#define YASOLR_LBL_176 "Terme D (W)"
#define YASOLR_LBL_177 "Réinitialisation graphique"
#define YASOLR_LBL_178
#define YASOLR_LBL_179
#define YASOLR_LBL_180
Expand Down
Loading

0 comments on commit 977569d

Please sign in to comment.