Some timetunings

This commit is contained in:
Fliegerjohn 2024-05-05 22:51:30 +02:00
parent fc39b3c863
commit 67c1f0503a
Signed by: fliegerjohn
GPG key ID: E2221D5FE4656B6A

View file

@ -26,7 +26,6 @@ float tempset;
int poti; int poti;
// time // time
int onesecond = 1000;
unsigned long previousMillis; unsigned long previousMillis;
@ -68,6 +67,25 @@ void setup() {
delay(3000); delay(3000);
lcd.clear(); 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() { void loop() {
@ -77,11 +95,13 @@ void loop() {
// update LCD // update LCD
unsigned long currentMillis = millis(); unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= onesecond) { if (currentMillis - previousMillis >= 250) {
settemp(); settemp();
readtemp(); readtemp();
lcdoutput(); lcdoutput();
previousMillis = currentMillis;
} }
} }
//------------------------------------------ //------------------------------------------
@ -89,10 +109,7 @@ void loop() {
void pid() { void pid() {
myPID.Compute(); myPID.Compute();
/************************************************
* turn the output pin on/off based on pid output
************************************************/
if (millis() - windowStartTime > WindowSize) if (millis() - windowStartTime > WindowSize)
{ //time to shift the Relay Window { //time to shift the Relay Window
windowStartTime += WindowSize; windowStartTime += WindowSize;
@ -117,23 +134,20 @@ void readtemp() {
// LCD output // LCD output
void lcdoutput() { void lcdoutput() {
// Output temperatureset // Output temperatureset
lcd.setCursor(0, 1); lcd.setCursor(8, 1);
lcd.print("set: ");
lcd.print(pidset); lcd.print(pidset);
lcd.write((byte)0); lcd.write((byte)0);
lcd.print("C"); lcd.print("C");
// Output watertemp // Output watertemp
lcd.setCursor(0, 2); lcd.setCursor(8, 2);
lcd.print("temp: ");
lcd.print(watertemp); lcd.print(watertemp);
lcd.write((byte)0); lcd.write((byte)0);
lcd.print("C"); lcd.print("C");
lcd.print(" "); lcd.print(" ");
// output PID // output PID
lcd.setCursor (0, 3); lcd.setCursor (8, 3);
lcd.print("output: ");
lcd.print(output); lcd.print(output);
lcd.print(" "); lcd.print(" ");