#include <OneWire.h>
#include <DallasTemperature.h>
#include <AutoPID.h>
// Data wire is plugged into digital pin x on the Arduino
#define ONE_WIRE_BUS 8
// Setup a oneWire instance to communicate with any OneWire device
OneWire oneWire(ONE_WIRE_BUS);
// Pass oneWire reference to DallasTemperature library
DallasTemperature sensors(&oneWire);
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
double isttemp = 20;
double solltemp = 65;
double hysterese = 5;
double outputVal;
#define KP .12
#define KI .0003
#define KD 0
AutoPID myPID(&isttemp, &solltemp, &outputVal, 0, 10000, KP, KI, KD);
void setup(void)
{
// Initalisiern des Outputs: Active on Low
pinMode(10, OUTPUT);
digitalWrite(10, HIGH);
sensors.begin(); // Start up the library
Serial.begin(9600);
Serial.println("Version 1.1");
Serial.print("Anzahl 1-wire Geraete: ");
lcd.begin(16, 2);
digitalWrite(13, HIGH);
//if temperature is more than 4 degrees below or above setpoint, OUTPUT will be set to min or max respectively
myPID.setBangBang(4);
//set PID update interval to 4000ms
myPID.setTimeStep(4000);
}
void loop(void)
{
// Send the command to get temperatures
sensors.requestTemperatures();
isttemp = sensors.getTempCByIndex(0);
solltemp = (float)map (analogRead(A2), 0, 1023, 500, 1200)/10;
hysterese = (float)map (analogRead(A3), 0, 1023, 1, 100)/10;
Serial.print("Temperature: ");
Serial.print(isttemp);
Serial.print((char)176);//shows degrees character
Serial.print("C ");
Serial.print("BangBang: ");
Serial.print(hysterese);
Serial.print((char)176);//shows degrees character
Serial.println("C");
lcd.setCursor(0, 0); lcd.print("Soll");
lcd.setCursor(5, 0); lcd.print(solltemp);
lcd.setCursor(12, 0); lcd.print(hysterese);
lcd.setCursor(0, 1); lcd.print("Ist");
lcd.setCursor(5, 1); lcd.print(isttemp);
myPID.run();
Serial.println(outputVal);
delay(500);
}