mirror of
https://github.com/vincentvdwal/crust-craft.git
synced 2026-08-18 17:26:39 +02:00
update kc and kp
This commit is contained in:
+13
-24
@@ -39,11 +39,11 @@ float pwmSwitchDelayOff = 4000; // 4s
|
|||||||
|
|
||||||
float power = 0;
|
float power = 0;
|
||||||
|
|
||||||
float kp = 0.540938;
|
float kp = 0.540721828;
|
||||||
float ki = 0.000721;
|
float ki = 0.004960751;
|
||||||
float kd = 0.0;
|
float kd = 0.0;
|
||||||
|
|
||||||
String mode = "off";
|
String mode = "manual";
|
||||||
|
|
||||||
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
|
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
|
||||||
|
|
||||||
@@ -56,27 +56,20 @@ String getSensorReadings()
|
|||||||
JsonDocument readings;
|
JsonDocument readings;
|
||||||
String jsonString;
|
String jsonString;
|
||||||
|
|
||||||
temperature = thermocouple.readCelsius();
|
readings["mode"] = mode;
|
||||||
|
|
||||||
|
temperature = thermocouple.readCelsius();
|
||||||
readings["temperature"] = temperature;
|
readings["temperature"] = temperature;
|
||||||
|
|
||||||
if (digitalRead(relay) == HIGH)
|
readings["relais"] = digitalRead(relay) == HIGH ? 1 : 0;
|
||||||
{
|
|
||||||
readings["relais"] = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
readings["relais"] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
readings["target_temp"] = targetTemp;
|
readings["target_temp"] = targetTemp;
|
||||||
|
|
||||||
readings["mode"] = mode;
|
|
||||||
readings["pid"] = power;
|
|
||||||
|
|
||||||
readings["pwm_on"] = pwmSwitchDelayOn;
|
readings["pwm_on"] = pwmSwitchDelayOn;
|
||||||
readings["pwm_off"] = pwmSwitchDelayOff;
|
readings["pwm_off"] = pwmSwitchDelayOff;
|
||||||
|
|
||||||
|
readings["pid"] = power;
|
||||||
|
|
||||||
readings["kp"] = kp;
|
readings["kp"] = kp;
|
||||||
readings["ki"] = ki;
|
readings["ki"] = ki;
|
||||||
readings["kd"] = kd;
|
readings["kd"] = kd;
|
||||||
@@ -123,19 +116,19 @@ void handleWebSocketMessage(void *arg, uint8_t *data, size_t len)
|
|||||||
{
|
{
|
||||||
data[len] = 0;
|
data[len] = 0;
|
||||||
String message = (char *)data;
|
String message = (char *)data;
|
||||||
if (strcmp((char *)data, "getReadings") == 0)
|
if (message.startsWith("getReadings"))
|
||||||
{
|
{
|
||||||
String sensorReadings = getSensorReadings();
|
String sensorReadings = getSensorReadings();
|
||||||
notifyClients(sensorReadings);
|
notifyClients(sensorReadings);
|
||||||
};
|
};
|
||||||
if (strcmp((char *)data, "switchRelais") == 0)
|
if (message.startsWith("switchRelais"))
|
||||||
{
|
{
|
||||||
Serial.printf("\nSwitch Relais");
|
Serial.printf("\nSwitch Relais");
|
||||||
if (digitalRead(relay) == HIGH)
|
if (digitalRead(relay) == HIGH)
|
||||||
{
|
{
|
||||||
digitalWrite(relay, LOW);
|
digitalWrite(relay, LOW);
|
||||||
lastSwitch = millis();
|
lastSwitch = millis();
|
||||||
mode = "off";
|
mode = "manual";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -154,11 +147,7 @@ void handleWebSocketMessage(void *arg, uint8_t *data, size_t len)
|
|||||||
}
|
}
|
||||||
if (message.startsWith("setMode"))
|
if (message.startsWith("setMode"))
|
||||||
{
|
{
|
||||||
if (message.indexOf("auto_switch") > 0)
|
if (message.indexOf("pwm") > 0)
|
||||||
{
|
|
||||||
mode = "auto_switch";
|
|
||||||
}
|
|
||||||
else if (message.indexOf("pwm") > 0)
|
|
||||||
{
|
{
|
||||||
mode = "pwm";
|
mode = "pwm";
|
||||||
}
|
}
|
||||||
@@ -168,7 +157,7 @@ void handleWebSocketMessage(void *arg, uint8_t *data, size_t len)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mode = "off";
|
mode = "manual";
|
||||||
digitalWrite(relay, LOW);
|
digitalWrite(relay, LOW);
|
||||||
lastSwitch = millis();
|
lastSwitch = millis();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user