pid tuning + temp sensor failures count & display

This commit is contained in:
Alexander Belov 2024-09-23 18:29:42 +07:00
parent 92adfc73d8
commit d4a564cea3
2 changed files with 47 additions and 14 deletions

View File

@ -1,5 +1,3 @@
## TODO
* output temp control is not ideal (on/off does not represent values between 0 and 100)
* experiment with p,i,d

View File

@ -61,14 +61,14 @@ struct Profile {
// Profiles definition
Profile profiles[] = {
{"Chickpeas", 2, {{47, 120}, {55, 60}, {65, 150}, {70, 60}, {90, 105}}, 5},
{"Lentils", 3, {{47, 120}, {53, 120}, {65, 180}, {72, 90}, {90, 15}}, 5},
{"Lentils gradual", 10, {{48, 120}, {80, 60}}, 2},
{"Soy gradual", 10, {{42, 1}, {48, 120}, {80, 60}, {90, 15}}, 4},
{"Wheat", 1, {{47, 60}, {53, 60}, {65, 20}, {72, 20}, {85, 20}}, 5},
{"55-30&85-120", 1, {{55, 30}, {85, 120}}, 2},
{"46-45", 0, {{46, 45}}, 1},
{"Test", 3, {{51, 1}}, 1},
{"Chickpeas", 1, {{46, 120}, {55, 60}, {65, 150}, {70, 60}, {90, 105}}, 5},
{"Lentils", 3, {{46, 120}, {53, 120}, {65, 180}, {72, 90}, {90, 15}}, 5},
{"Gradual", 10, {{46, 120}, {80, 60}}, 2},
{"Long gradual", 10, {{46, 120}, {80, 60}, {90, 15}}, 3},
{"Wheat", 1, {{46, 60}, {53, 60}, {65, 20}, {72, 20}, {85, 20}}, 5},
{"SV1", 1, {{55, 30}, {85, 120}}, 2},
{"SV2", 0, {{46, 45}}, 1},
{"Yoghurt maker", 0, {{40, 300}, {40, 300}, {30, 300}}, 3},
};
// Global variables for profile selection and execution
@ -87,7 +87,9 @@ bool inSelectionMode = true;
#include "GyverPID.h"
double Setpoint, Input, Output;
GyverPID regulator(50, 0, 0, 1000);
GyverPID regulator(25, 0, 0, 1000);
bool temperatureSensorError = false;
// Timing variables
long phaseStartTime;
@ -118,7 +120,10 @@ uint32_t timerChecks= 0;
bool boolLastCompletedState = false;
#define PARTS 4
float failedReadingLastValue = 0;
int failedReadingCount = 0;
#define PARTS 8
void setup() {
pinMode(ssrPin, OUTPUT);
@ -192,8 +197,13 @@ void handleTemperatureSensor() {
Input = thermocouple.readCelsius();
#endif
if (isnan(Input)) {
Input = 100;
if (isnan(Input) || Input < 20 || Input > 95) {
failedReadingLastValue = (float) Input;
failedReadingCount++;
temperatureSensorError = true;
}
else {
temperatureSensorError = false;
}
}
@ -269,6 +279,10 @@ void handleHeaterAdv() {
oled.invertText(false);
}
if (temperatureSensorError) {
next = 0;
}
digitalWrite(ssrPin, next);
currentPart++;
if (currentPart >= PARTS) {
@ -518,6 +532,27 @@ void printPhases() {
}
}
if (temperatureSensorError) {
oled.invertText(true);
oled.setCursor(0, 0);
oled.setScale(2);
oled.print("T = ");
oled.print(Input);
oled.print(" ");
oled.setScale(1);
digitalWrite(activeBuzzerPin, HIGH);
delay(5);
digitalWrite(activeBuzzerPin, LOW);
}
if (failedReadingCount) {
oled.setCursor(0, 7);
oled.print(failedReadingCount);
oled.print(" (");
oled.print(failedReadingLastValue);
oled.print(") ");
}
oled.invertText(false); // Ensure text inversion is off after the loop
// oled.setCursor(110,7);