From 67c1f0503acf0bd1aeadbf9b1b981ba2cd01d4df Mon Sep 17 00:00:00 2001 From: fliegerjohn Date: Sun, 5 May 2024 22:51:30 +0200 Subject: [PATCH] Some timetunings --- firmware/weckkubator/weckkubator.ino | 38 +++++++++++++++++++--------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/firmware/weckkubator/weckkubator.ino b/firmware/weckkubator/weckkubator.ino index 58d0a5e..209f534 100644 --- a/firmware/weckkubator/weckkubator.ino +++ b/firmware/weckkubator/weckkubator.ino @@ -26,7 +26,6 @@ float tempset; int poti; // time -int onesecond = 1000; unsigned long previousMillis; @@ -68,6 +67,25 @@ void setup() { delay(3000); lcd.clear(); + // Setup LCD + // Output temperatureset + lcd.setCursor(0, 1); + lcd.print("set: "); + lcd.print(pidset); + lcd.write((byte)0); + + // Output watertemp + lcd.setCursor(0, 2); + lcd.print("temp: "); + lcd.print(watertemp); + lcd.write((byte)0); + lcd.print("C"); + + // output PID + lcd.setCursor (0, 3); + lcd.print("output: "); + lcd.print(output); + } void loop() { @@ -77,11 +95,13 @@ void loop() { // update LCD unsigned long currentMillis = millis(); - if (currentMillis - previousMillis >= onesecond) { + if (currentMillis - previousMillis >= 250) { settemp(); readtemp(); lcdoutput(); + previousMillis = currentMillis; } + } //------------------------------------------ @@ -89,10 +109,7 @@ void loop() { void pid() { myPID.Compute(); - - /************************************************ - * turn the output pin on/off based on pid output - ************************************************/ + if (millis() - windowStartTime > WindowSize) { //time to shift the Relay Window windowStartTime += WindowSize; @@ -117,23 +134,20 @@ void readtemp() { // LCD output void lcdoutput() { // Output temperatureset - lcd.setCursor(0, 1); - lcd.print("set: "); + lcd.setCursor(8, 1); lcd.print(pidset); lcd.write((byte)0); lcd.print("C"); // Output watertemp - lcd.setCursor(0, 2); - lcd.print("temp: "); + lcd.setCursor(8, 2); lcd.print(watertemp); lcd.write((byte)0); lcd.print("C"); lcd.print(" "); // output PID - lcd.setCursor (0, 3); - lcd.print("output: "); + lcd.setCursor (8, 3); lcd.print(output); lcd.print(" ");