checks and error codes

This commit is contained in:
Stefan Kögl 2012-10-03 23:52:23 +02:00
parent 5dd864d787
commit 5e8ae479ca
1 changed files with 32 additions and 13 deletions

View File

@ -13,7 +13,8 @@
#define E_DT_MIN 1 // temperatur dt too small
#define E_DT_MAX 2 // temperatur dt too big
#define E_TIME_MAX 4 // reflow process does take too long
#define E_PEAK_TOO_LONG 8 // package was roasted
#define E_TL_TOO_LONG 8 // package was roasted
#define E_TP_TOO_LONG 16 // package was roasted
// system time, timestamps and temperatures from sensors
__attribute__((__unused__)) static unsigned int time = 0; // profile seconds
@ -124,19 +125,26 @@ static void print_debug() {
Serial.println(error_condition);
}
// boolean check_max_duration() {
// if (time > time_max) {
// error_condition = E_TIME_MAX;
// return false;
// }
// }
/*
boolean check_Tl_duration() {
boolean check_max_duration() {
if (time > time_max) {
error_condition = E_TIME_MAX;
error_condition |= E_TIME_MAX;
return false;
}
}*/
}
boolean check_Tl_duration() {
if (time - Tl_time_start > Tp_duration) {
error_condition |= E_TL_TOO_LONG;
return false;
}
}
boolean check_Tp_duration() {
if (time - Tp_time_start > Tp_duration) {
error_condition |= E_TP_TOO_LONG;
return false;
}
}
static void set_start_state() {
state = START_STATE;
@ -223,6 +231,7 @@ static void handle_ramp_up_state() {
static void handle_tal_first_state() {
check_Tl_duration();
if (temperatur > Tp - 5) {
Tp_time_start = time;
set_peak_state();
@ -231,6 +240,8 @@ static void handle_tal_first_state() {
static void handle_peak_state() {
check_Tl_duration();
check_Tp_duration();
if (time - Tp_time_start > Tp_duration) {
Tp_time_end = time;
set_tal_second_state();
@ -239,6 +250,7 @@ static void handle_peak_state() {
static void handle_tal_second_state() {
check_Tl_duration();
if (temperatur < Tl) {
set_ramp_down_state();
}
@ -268,9 +280,15 @@ static void handle_error_state() {
led_on = true;
}
if (error_condition & E_DT_MIN)
Serial.print("Error: delta °K/second too low");
Serial.println("Error: delta °K/second too low");
if (error_condition & E_DT_MAX)
Serial.print("Error: delta °K/second too big");
Serial.println("Error: delta °K/second too big");
if (error_condition & E_TIME_MAX)
Serial.println("Error: reflow process does take too long");
if (error_condition & E_TL_TOO_LONG)
Serial.println("Error: temperatur above liquidus was too long");
if (error_condition & E_TP_TOO_LONG)
Serial.println("Error: peak temperature duration was too long");
}
@ -278,6 +296,7 @@ void loop() {
time = millis() / 1000;
get_temp();
check_dt();
check_max_duration();
if (error_condition) {
set_error_state();