This commit is contained in:
Stefan Kögl 2012-10-03 23:33:23 +02:00
parent 417a614d69
commit fcb2449bf4
1 changed files with 24 additions and 14 deletions

View File

@ -19,7 +19,7 @@
__attribute__((__unused__)) static unsigned int time = 0; // profile seconds
__attribute__((__unused__)) static unsigned int temperatur = 25; // actual oven temp
__attribute__((__unused__)) static unsigned int last_temperatur = 25; // last oven temp
__attribute__((__unused__)) static int actual_dt = 0; // actual difference from last to actual temperatur
__attribute__((__unused__)) static unsigned int actual_dt = 0; // actual difference from last to actual temperatur
// profile temperatures
@ -86,6 +86,7 @@ static void control_oven() {
}
}
static void set_temp(int min, int max, int dt_min, int dt_max) {
set_min = min;
set_max = max;
@ -93,12 +94,14 @@ static void set_temp(int min, int max, int dt_min, int dt_max) {
set_dt_max = dt_max;
}
static void get_temp() {
last_temperatur = temperatur;
temperatur = int(float(analogRead(2)) * 0.2929);
actual_dt = temperatur - last_temperatur;
}
static void check_dt() {
if (actual_dt > set_dt_max) {
error_condition |= E_DT_MAX;
@ -142,42 +145,50 @@ static void set_start_state() {
set_temp(Tp-5, Tp, 0, ramp_up_rate_max);
}
static void set_preheat_state() {
Serial.println("Changing state to PREHEAT_STATE");
state++;
}
static void set_ramp_up_state() {
Serial.println("Changed state to RAMP_UP_STATE");
state++;
}
static void set_tal_first_state() {
Serial.println("Changed state to TAL_FIRST_STATE");
state++;
}
static void set_peak_state() {
Serial.println("Changed state to PEAK_STATE");
state++;
}
static void set_tal_second_state() {
Serial.println("Changed state to TAL_SECOND_STATE");
set_temp(25, 25, -3, -6);
state++;
}
static void set_ramp_down_state() {
Serial.println("Changed state to RAMP_DOWN_STATE");
state++;
}
static void set_end_state() {
Serial.println("Changed state to END_STATE");
state++;
}
void set_error_state() {
if (state != ERROR_STATE) {
Serial.println("Changed state to ERROR_STATE");
@ -186,8 +197,8 @@ void set_error_state() {
}
}
static void handle_start_state() {
Serial.println("START_STATE");
if (temperatur > Ts_min) {
Ts_min_time = time;
set_preheat_state();
@ -195,35 +206,31 @@ static void handle_start_state() {
}
static void handle_preheat_state() {
Serial.println("PREHEAT_STATE");
if (temperatur > Ts_max) {
Ts_max_time = time;
set_ramp_up_state();
}
}
static void handle_ramp_up_state() {
Serial.println("RAMP_UP_STATE");
if (temperatur > Tl) {
Tl_time_start = time;
set_tal_first_state();
}
}
static void handle_tal_first_state() {
Serial.println("TAL_FIRST_STATE");
if (temperatur > Tp - 5) {
Serial.println("Changed state to PEAK_STATE");
Tp_time_start = time;
set_peak_state();
}
}
static void handle_peak_state() {
Serial.println("PEAK_STATE");
static void handle_peak_state() {
if (time - Tp_time_start > Tp_duration) {
Tp_time_end = time;
set_tal_second_state();
@ -239,12 +246,18 @@ static void handle_tal_second_state() {
static void handle_ramp_down_state() {
if (temperatur < Ts_min) {
Serial.println("Changed state to END_STATE");
set_end_state();
}
}
static void handle_end_state() {
while(true) {
continue;
}
}
static void handle_error_state() {
if (led_on) {
digitalWrite(13, LOW);
@ -298,10 +311,7 @@ void loop() {
handle_ramp_down_state();
break;
case END_STATE:
Serial.println("END_STATE");
while(true) {
continue;
}
handle_end_state();
break;
case ERROR_STATE:
handle_error_state();