Compare commits

..

No commits in common. "67c1f0503acf0bd1aeadbf9b1b981ba2cd01d4df" and "0b8e4d3a5c86c4692087c7644e474f1da8e50e48" have entirely different histories.

View file

@ -16,16 +16,17 @@ DallasTemperature sensors(&oneWire); // declare sensors
double pidset, watertemp, output;
// PID adjustment
double Kp=500, Ki=10, Kd=0;
double Kp=2, Ki=5, Kd=1;
PID myPID(&watertemp, &output, &pidset, Kp, Ki, Kd, DIRECT);
int WindowSize = 5000;
unsigned long windowStartTime;
// Temp adjustment
float tempset;
int tempset;
int poti;
// time
int onesecond = 1000;
unsigned long previousMillis;
@ -66,26 +67,7 @@ void setup() {
lcd.print("Weckkubator 0.0.1");
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() {
@ -95,13 +77,11 @@ void loop() {
// update LCD
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= 250) {
if (currentMillis - previousMillis >= onesecond) {
settemp();
readtemp();
lcdoutput();
previousMillis = currentMillis;
}
}
//------------------------------------------
@ -109,7 +89,10 @@ 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;
@ -134,20 +117,23 @@ void readtemp() {
// LCD output
void lcdoutput() {
// Output temperatureset
lcd.setCursor(8, 1);
lcd.print(pidset);
lcd.setCursor(0, 1);
lcd.print("set: ");
lcd.print(tempset);
lcd.write((byte)0);
lcd.print("C");
// Output watertemp
lcd.setCursor(8, 2);
lcd.setCursor(0, 2);
lcd.print("temp: ");
lcd.print(watertemp);
lcd.write((byte)0);
lcd.print("C");
lcd.print(" ");
// output PID
lcd.setCursor (8, 3);
lcd.setCursor (0, 3);
lcd.print("output: ");
lcd.print(output);
lcd.print(" ");
@ -158,15 +144,6 @@ void lcdoutput() {
// Read Poti
void settemp() {
poti = analogRead(A3);
tempset = (20+(poti*0.04));
if (tempset <= 50) {
pidset = tempset;
}
if (tempset >= 51) {
pidset = (tempset+30);
}
tempset = (18+(poti*0.07)); // range between 18°C and 18+1024*0,07 (~89°C)
pidset = tempset;
}