Temperaturregelung der Ofenheizung mit Timer auf Arduino

Ich brauchte einen Ofen zum Backen von Fimo. Nach nicht langer Suche fiel die Wahl auf den KEDR-Elektroofen für die Küche. Mit einer Leistung von 600 Watt, bei einer Maximaltemperatur von 250 Grad, ohne Regler. Zum ersten Mal wurde ein thermomechanischer Regler installiert, da die Betriebstemperatur im Bereich von 100-130 Grad erforderlich war. Das ganze Problem war jedoch, dass der Ofen eine sehr große Beschleunigung hatte (nach dem Ausschalten der Heizung stieg die Temperatur weiter um weitere 20-50 Grad an) und der Regler einen sehr großen Ein- und Ausschaltbereich hatte. Das heißt, wenn ich die Temperatur auf 130 Grad einstelle, habe ich einen Bereich von 100 - 160 Grad, was nicht zulässig ist.

Nach mehreren Monaten der Analyse der Prinzipien der Arbeit mit Arduino IDE und C ++ wurde ein Projekt geboren, das die Anforderungen vollständig erfüllt. Das Gerät kann die eingestellte Temperatur von 100 bis 150 Grad halten, sobald der Timer nach Auslösen des Alarms für 5 bis 35 Minuten eingestellt ist.

Hier ist ein Blockdiagramm des Programms.



Das Gerät enthält: vier standardmäßig im Ofen installierte serielle Heizgeräte, die durch jedes andere Heizgerät der entsprechenden Leistung ersetzt werden können, SSR-25 DA-Halbleiterrelais, Arduino Pro Mini, Inkrementalgeber mit einer über einen invertierten Schmitt-Auslöser angeschlossenen Taste, Anzeige WH1602D und zwei NTC Thermistoren MF58 bei 100 kOhm.

Hier ist der Skizzencode mit Kommentaren.

Auflistung
#include <LiquidCrystal.h> #include "timer-api.h" const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 6; //    LiquidCrystal lcd(rs, en, d4, d5, d6, d7); int encCLK = 2 ; //    int encDT = 7; //    int button = 8 ; //    //        !!! volatile bool button_not_press = true; //     volatile int pinClkValue = 0; //      volatile int pinDtValue = 0; //      uint8_t temp_cel[8] = {B00111,B00101,B00111,B00000,B00000,B00000,B00000}; //   int temp_upside_pin = 14; //     MF58 100k,     int temp_downside_pin = 15; //   .      (-),   //    100k  (+5v). volatile float temp_upside; //       volatile float temp_downside; //       #define B 3950 // B-    int heater_pin = 10; //     SSR-25DA. volatile bool preheating_state = false; //  ,      volatile bool heater_state = true; //   volatile int hyst = 40; //        volatile int changeTemp; //     60 . volatile long timeHyst = 0; //     volatile long normalModeTime; //     volatile int curTemp = 0; //    ,    volatile int setTemp = 0; //     int *pCurTemp = &curTemp; // ,     ...? int *pSetTemp = &setTemp; // ,     ...? volatile bool alarm; //  volatile int count = 0; //    state*5 volatile int state = 0; //    volatile int setTimeMinute = 0; //        volatile int second = 0; //        int *pMinute = &setTimeMinute; // ,     ...? volatile long currentTime = millis(); //     //======================================================= void setup() { //     timer-api.h,       timer_init_ISR_1Hz(TIMER_DEFAULT); //    /(pin) pinMode(encCLK, INPUT); //  CLK  pinMode(encDT, INPUT); //  DT  pinMode(button, INPUT); //  button  pinMode(temp_upside_pin, INPUT); //       1 pinMode(temp_downside_pin,INPUT); //       2 pinMode(heater_pin, OUTPUT); //    attachInterrupt(0, clkEnc, CHANGE);//     lcd.createChar(1, temp_cel); //    //    !!! lcd.begin(16, 2); lcd.setCursor(2, 0); lcd.print("Polimer Clay"); lcd.setCursor(0, 1); lcd.print("BURNER ver. 1.01"); delay(2000); //     lcd.clear(); lcd.print("Set"); lcd.setCursor(11, 0); lcd.print("Timer"); lcd.setCursor(0, 1); lcd.print("Cur"); lcd.setCursor(9, 1); lcd.print(" NotSet"); setupTemp(); //      } //===================================================== void clkEnc(){ //    ,    pinClkValue = digitalRead(encCLK); pinDtValue = digitalRead(encDT); cli(); if (!pinClkValue && pinDtValue) state = 1; if (!pinClkValue && !pinDtValue) state = -1; if (pinClkValue && state != 0) { if (state == 1 && !pinDtValue || state == -1 && pinDtValue) { count += state*5; state = 0; }} sei(); } //===================================================== void setupTemp(){ //    count = 0; //   button_not_press = true; //   ,     while,      while(button_not_press){ //    ... if (count <= 100) count = 100; //      100 if (count >= 151) count = 150; //      150 setTemp = count; //    //    lcd.setCursor(4, 0); if(*pSetTemp<10) lcd.print(" "); else if(*pSetTemp<100) lcd.print(" "); lcd.print(*pSetTemp); lcd.print("\1"); lcd.print("C"); lcd.print(" "); if(*pSetTemp !=0)button_not_press = digitalRead(button); //   preheating_state = true;}} //      //===================================================== void setupTimer(){ //   lcd.setCursor(11, 0); //     lcd.print("Timer"); //   count = 0; //   button_not_press = true; lcd.setCursor(9, 1); //  lcd.print(" "); // NotSet while(button_not_press){ //    ... if (count <= -1) count = 0; //       -  0 if (count >= 36) count = 35; //       -  35 setTimeMinute = count; //    lcd.setCursor(11, 1); //     if(*pMinute<10)lcd.print("0"); lcd.print(*pMinute); //    lcd.print(":00"); //     00:00 tempMonitor(); //   if(*pMinute !=0)button_not_press = digitalRead(button);} //   if (*pMinute != 0){second = 0; timerStart();} //   ,     timeEnd(); } //   , !!! //====================================================== void tempMonitor(){ //   !!! //          . if(millis() > normalModeTime + 10){ heater_state = !heater_state; normalModeTime = millis();} //          if(millis() > currentTime + 500){ lcd.setCursor(4, 1); if(*pCurTemp<10) lcd.print(" "); else if(*pCurTemp<100) lcd.print(" "); lcd.print(*pCurTemp); lcd.print("\1"); lcd.print("C"); lcd.print(" "); int US = analogRead(temp_upside_pin); //   1  int DS = analogRead(temp_downside_pin); //   2  int MID = (US+DS)/2; //    float tr = (5 / 1023.0) * MID ; //    float VR = 5 - tr; //    float RT = tr/(VR / 99000); //    float ln = log(RT / 100000); float TX = (1 / ((ln / B) + (1 / (25+273.15)))); //    —  TX = round(TX - 273.15); //        *pCurTemp = int(TX); //    currentTime = millis(); } //      ( - hyst) if(preheating_state){ if(*pCurTemp < (*pSetTemp - hyst)) digitalWrite(heater_pin, HIGH); //     ( - hyst), //         (pSetTemp). else if(*pCurTemp > (*pSetTemp - hyst)) digitalWrite(heater_pin, LOW); if (*pCurTemp >= *pSetTemp){ preheating_state = false; Serial.print(preheating_state); } //             //   ,       //      ,     // .    , //     . if (millis() > timeHyst + 30000){ changeTemp = *pCurTemp; //   30 ,     timeHyst = millis(); } if(changeTemp >= *pCurTemp){ if(!digitalRead(heater_pin)){ digitalWrite(heater_pin, HIGH);}}} //   (pSetTemp)  //           //    5    if(!preheating_state){ if(*pCurTemp < *pSetTemp - 5) { digitalWrite(heater_pin, heater_state);} else digitalWrite(heater_pin, LOW); }} //==================================================== void timer_handle_interrupts(int timer){second--;} //==================================================== //          //  second,     //     . void timerStart(){ while(*pMinute+second != 0){ if (second == 0){(*pMinute)--; second = 59;} lcd.setCursor(11, 1); if(*pMinute<10)lcd.print(" "); lcd.print(*pMinute); lcd.print(":"); if(second<10)lcd.print("0"); lcd.print(second); lcd.print(" "); if(alarm){ noTone(9); if(!digitalRead(button)){ alarm = false; noTone(9); return;}} tempMonitor(); if(alarm) tone(9,100); }} //=================================================== //  !!! void timeEnd(){ alarm = true; lcd.setCursor(11, 0); lcd.print("Alarm"); *pMinute = 1; //second = 30; //   <- ,    timerStart(); //,       0 if(alarm){ //    ,    *pSetTemp = 0; //       ,   digitalWrite(heater_pin, LOW); //  ,      lcd.setCursor(4, 0); if(*pSetTemp<10) lcd.print(" "); else if(*pSetTemp<100) lcd.print(" "); lcd.print(*pSetTemp); lcd.print("\1"); lcd.print("C"); lcd.print(" "); alarm = false; }} //==================================================== //       void loop() { tempMonitor(); // <-    if(*pSetTemp == 0 && !digitalRead(button)) setupTemp(); // <-     0 if(*pCurTemp == *pSetTemp) setupTimer(); } // <-    


Da dies eines der ersten Projekte ist, bitte ich um mehr Kritik!

Source: https://habr.com/ru/post/de460044/


All Articles