2012-10-01 19:03:30 +00:00
|
|
|
|
|
|
|
unsigned int time = 0; // profile seconds
|
2012-10-02 13:03:02 +00:00
|
|
|
unsigned int temperatur = 25; // actual oven temp
|
|
|
|
unsigned int last_temperatur = 25;
|
2012-10-01 19:03:30 +00:00
|
|
|
|
|
|
|
unsigned int Ts_max = 200; // °C
|
|
|
|
unsigned int Ts_min = 150; // °C
|
|
|
|
unsigned int Tp = 260; // 245-260°C
|
|
|
|
unsigned int rampup_rate = 3; // 3°C/s
|
|
|
|
unsigned int preheat_duration = 100; // 60-180s
|
|
|
|
unsigned int tal = 217; // 217°C
|
|
|
|
unsigned int tal_duration = 100; // 60-150s
|
|
|
|
unsigned int peak_duration = 30; // 20-40s
|
|
|
|
unsigned int rampdown_max = 6; // 6°C/s max
|
|
|
|
unsigned int time_max = 480; // 8*60s max
|
|
|
|
|
2012-10-02 13:03:02 +00:00
|
|
|
#define START_STATE 0
|
|
|
|
#define PREHEAT_STATE 1
|
|
|
|
#define TAL_STATE 2
|
|
|
|
#define MAX_STATE 3
|
|
|
|
#define RAMPDOWN_STATE 4
|
|
|
|
#define END_STATE 5
|
|
|
|
#define ERROR_STATE 6
|
|
|
|
|
|
|
|
byte state = START_STATE;
|
|
|
|
|
|
|
|
unsigned int Ts_min_time = 0;
|
|
|
|
unsigned int Ts_max_time = 0;
|
|
|
|
unsigned int Tl_time = 0;
|
|
|
|
unsigned int Tp_time = 0;
|
|
|
|
unsigned int Tl_end_time = 0;
|
|
|
|
|
|
|
|
#define RAMPUP_TOO_FAST 1
|
|
|
|
#define RAMPDOWN_TOO_FAST 2
|
|
|
|
unsigned int error_condition = 0;
|
|
|
|
|
2012-10-01 19:03:30 +00:00
|
|
|
|
|
|
|
void setup() {
|
|
|
|
pinMode(13, OUTPUT);
|
|
|
|
Serial.begin(9600);
|
|
|
|
}
|
|
|
|
|
|
|
|
void get_temp() {
|
2012-10-02 13:03:02 +00:00
|
|
|
// simulating an +1K/s rampup oven
|
|
|
|
last_temperatur = ++temperatur;
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean check_rampup_rate() {
|
|
|
|
if (temperatur - last_temperatur > rampup_rate) {
|
|
|
|
error_condition = RAMPUP_TOO_FAST;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2012-10-01 19:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
time = millis() / 1000;
|
2012-10-02 13:03:02 +00:00
|
|
|
get_temp();
|
|
|
|
Serial.print(time);
|
|
|
|
Serial.print(" ");
|
|
|
|
Serial.print(temperatur);
|
|
|
|
Serial.print(" ");
|
|
|
|
Serial.println(last_temperatur);
|
|
|
|
|
2012-10-01 19:03:30 +00:00
|
|
|
|
|
|
|
// wait a second so as not to send massive amounts of data
|
|
|
|
delay(1000);
|
|
|
|
|
|
|
|
switch (state) {
|
2012-10-02 13:03:02 +00:00
|
|
|
case START_STATE:
|
|
|
|
// going from room temp to preheat, nothing to check here
|
|
|
|
if (!check_rampup_rate())
|
|
|
|
goto error;
|
|
|
|
if (temperatur > Ts_min) {
|
2012-10-01 19:03:30 +00:00
|
|
|
state++;
|
|
|
|
}
|
2012-10-02 13:03:02 +00:00
|
|
|
case PREHEAT_STATE:
|
|
|
|
if (temperatur > Ts_max)
|
|
|
|
state++;
|
2012-10-01 19:03:30 +00:00
|
|
|
break;
|
2012-10-02 13:03:02 +00:00
|
|
|
case TAL_STATE:
|
2012-10-01 19:03:30 +00:00
|
|
|
break;
|
2012-10-02 13:03:02 +00:00
|
|
|
case MAX_STATE:
|
2012-10-01 19:03:30 +00:00
|
|
|
break;
|
2012-10-02 13:03:02 +00:00
|
|
|
case RAMPDOWN_STATE:
|
2012-10-01 19:03:30 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-10-02 13:03:02 +00:00
|
|
|
error:
|
|
|
|
state = END_STATE;
|
|
|
|
Serial.println(error_condition);
|
2012-10-01 19:03:30 +00:00
|
|
|
}
|