From 2decfb37cc42d7ba77ab2d3c8b098032391d6ec1 Mon Sep 17 00:00:00 2001 From: Stefan Dastig Date: Wed, 14 Oct 2020 00:09:12 +0200 Subject: [PATCH] v00.01 --- Software/reflowController/buzzer.ino | 10 ++ Software/reflowController/display.ino | 37 ++++++++ Software/reflowController/encoder.ino | 18 ++++ Software/reflowController/reflow.ino | 91 +++++++++++++++++++ .../reflowController/reflowController.ino | 69 ++++++++++++++ Software/reflowController/thermo.ino | 13 +++ 6 files changed, 238 insertions(+) create mode 100644 Software/reflowController/buzzer.ino create mode 100644 Software/reflowController/display.ino create mode 100644 Software/reflowController/encoder.ino create mode 100644 Software/reflowController/reflow.ino create mode 100644 Software/reflowController/reflowController.ino create mode 100644 Software/reflowController/thermo.ino diff --git a/Software/reflowController/buzzer.ino b/Software/reflowController/buzzer.ino new file mode 100644 index 0000000..d3fa805 --- /dev/null +++ b/Software/reflowController/buzzer.ino @@ -0,0 +1,10 @@ +const int buzzer = 5; + +void Buzzer_Init(void) { + pinMode(buzzer, OUTPUT); + tone(buzzer, 8000, 200); +} + +void Buzzer_Task(void) { + +} diff --git a/Software/reflowController/display.ino b/Software/reflowController/display.ino new file mode 100644 index 0000000..1fa64c0 --- /dev/null +++ b/Software/reflowController/display.ino @@ -0,0 +1,37 @@ +#ifdef U8X8_HAVE_HW_SPI +#include +#endif +#ifdef U8X8_HAVE_HW_I2C +#include +#endif + +//U8G2_ST7920_128X64_1_HW_SPI(rotation, cs [, reset]) [page buffer, size = 128 bytes] +//U8G2_ST7920_128X64_2_HW_SPI(rotation, cs [, reset]) [page buffer, size = 256 bytes] +//U8G2_ST7920_128X64_F_HW_SPI(rotation, cs [, reset]) [full framebuffer, size = 1024 bytes] +U8G2_ST7920_128X64_2_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); + +void Display_Init(void) { + u8g2.begin(); +} + +void Display_Task(void) { + char text[10] = {0}; + + u8g2.firstPage(); + do { + u8g2.drawLine(0,15,128,15); // horizontale oben + u8g2.drawLine(64,16,64,48); // senkrechte mitte + u8g2.drawLine(0,49,128,49); // horizontale unten + u8g2.setFont(u8g2_font_ncenB10_tf); + u8g2.drawStr(1,12,process.title); + u8g2.setFont(u8g2_font_ncenB14_tf); + sprintf(text,"%3d C",round(process.temp)); + u8g2.drawStr(0,31,text); + sprintf(text,"%3d C",round(oven_temp)); + u8g2.drawStr(0,47,text); + sprintf(text,"%02d:%02d",process.timer / 60, process.timer % 60); + u8g2.drawStr(66,31,text); + sprintf(text,"%02d:%02d",process.countdown / 60, process.countdown % 60); + u8g2.drawStr(66,47,text); + } while ( u8g2.nextPage() ); +} diff --git a/Software/reflowController/encoder.ino b/Software/reflowController/encoder.ino new file mode 100644 index 0000000..35805ec --- /dev/null +++ b/Software/reflowController/encoder.ino @@ -0,0 +1,18 @@ +Encoder rotEncoder(2, 3); + +void Encoder_Init(void) { + Serial.print("Encoder position: "); + Serial.println(EncPos); +} + +void Encoder_Task(void) { + long newEncPos; + newEncPos = rotEncoder.read(); + + if (newEncPos != EncPos) { + Serial.print("Encoder position = "); + Serial.print(newEncPos); + Serial.println(); + EncPos = newEncPos; + } +} diff --git a/Software/reflowController/reflow.ino b/Software/reflowController/reflow.ino new file mode 100644 index 0000000..c943d79 --- /dev/null +++ b/Software/reflowController/reflow.ino @@ -0,0 +1,91 @@ +void Reflow_Init(void) { + profile[0].preheat_rate = 1; + profile[0].preheat_temp = 130; + profile[0].preheat_time = 20; + profile[0].reflow_rate = 0.5; + profile[0].reflow_temp = 235; + profile[0].reflow_time = 40; + + process.profile = profile[0]; + process.phase = 0; + process.timer = 0; + process.countdown = 5; + process.temp = 0; + sprintf(process.title,"Ready"); +} + +void Reflow_Task(void) { + switch (process.phase) { + case 0: // standby + if (process.countdown > 0) { + process.countdown--; + if (process.countdown == 0) { + process.phase = 1; + sprintf(process.title,"1/4 PreHeat"); + process.temp = process.profile.preheat_temp; + process.countdown = 10; + } + } + break; + case 1: // preheat aufheizen + process.timer++; + if (process.countdown > 0) { + process.countdown--; + if (process.countdown == 0) { + process.phase = 2; + sprintf(process.title,"2/4 PreHeat"); + process.countdown = 10; + } + } + break; + case 2: // preheat temp halten + process.timer++; + if (process.countdown > 0) { + process.countdown--; + if (process.countdown == 0) { + process.phase = 3; + sprintf(process.title,"3/4 Reflow"); + process.temp = process.profile.reflow_temp; + process.countdown = 10; + } + } + break; + case 3: // reflow aufheizen + process.timer++; + if (process.countdown > 0) { + process.countdown--; + if (process.countdown == 0) { + process.phase = 4; + sprintf(process.title,"4/4 Reflow"); + process.countdown = 10; + } + } + break; + case 4: // reflow temp halten + process.timer++; + if (process.countdown > 0) { + process.countdown--; + if (process.countdown == 0) { + process.phase = 5; + sprintf(process.title,"Cooldown"); + process.temp = 0; + process.countdown = 10; + tone(buzzer, 2000, 1000); + } + } + break; + case 5: // auskühlen + if (process.countdown > 0) { + process.countdown--; + if (process.countdown == 0) { + process.phase = 0; + process.timer = 0; + sprintf(process.title,"Ready"); + process.countdown = 0; + } + } + break; + default: + process.phase = 0; + } +} diff --git a/Software/reflowController/reflowController.ino b/Software/reflowController/reflowController.ino new file mode 100644 index 0000000..0abecf5 --- /dev/null +++ b/Software/reflowController/reflowController.ino @@ -0,0 +1,69 @@ +#include +#include +#include +//#include "Adafruit_MAX31855.h" +#include "max6675.h" + +struct reflow_profile +{ + float preheat_rate; + float preheat_temp; + int preheat_time; + + float reflow_rate; + float reflow_temp; + float reflow_time; +} profile[4]; + +struct reflow_process +{ + reflow_profile profile; + int phase; // 0 = standby, 1 = heizen, 2 = preheat, 3 = heizen, 4 = reflow, 5 = cooldown + int countdown; // timer + int timer; + char title[20]; + float temp; // zieltemperatur +} process; + +float oven_temp = 0.0; +long EncPos = 0; +unsigned long timer100 = 0; +unsigned long timer500 = 0; +unsigned long timer1000 = 0; + + +void setup() { + Serial.begin(9600); + Serial.println("Reflow Controller v00.01"); + + Encoder_Init(); + Buzzer_Init(); + Display_Init(); + Thermo_Init(); + Reflow_Init(); +} + +void loop() { + + Encoder_Task(); + + if (millis() > 100 + timer100) { // alle 100ms + timer100 = millis(); + + Buzzer_Task(); + } + + if (millis() > 500 + timer500) { // alle 500ms + timer500 = millis(); + + Thermo_Task(); + } + + if (millis() > 1000 + timer1000) { // alle 1s + timer1000 = millis(); + + Reflow_Task(); + } + + Display_Task(); // so oft wie möglich +} diff --git a/Software/reflowController/thermo.ino b/Software/reflowController/thermo.ino new file mode 100644 index 0000000..d7b7aaf --- /dev/null +++ b/Software/reflowController/thermo.ino @@ -0,0 +1,13 @@ +#define MAXDO 7 +#define MAXCS 8 +#define MAXCLK 9 + +MAX6675 thermocouple(MAXCLK, MAXCS, MAXDO); + +void Thermo_Init(void) { + +} + +void Thermo_Task(void) { + oven_temp = thermocouple.readCelsius(); +}