123 lines
2.7 KiB
C++
123 lines
2.7 KiB
C++
#ifndef _H_OVEN_CTL
|
|
#define _H_OVEN_CTL
|
|
|
|
//
|
|
//
|
|
// states
|
|
#define CONFIG_STATE 0
|
|
#define START_STATE 1
|
|
#define PREHEAT_STATE 2
|
|
#define RAMP_UP_STATE 3
|
|
#define TAL_FIRST_STATE 4
|
|
#define PEAK_STATE 5
|
|
#define TAL_SECOND_STATE 6
|
|
#define RAMP_DOWN_STATE 7
|
|
#define END_STATE 8
|
|
#define ERROR_STATE 9
|
|
|
|
// error conditions
|
|
#define E_DT_MIN 1 // temperature dt too small
|
|
#define E_DT_MAX 2 // temperature dt too big
|
|
#define E_TIME_MAX 4 // reflow process does take too long
|
|
#define E_TS_TOO_SHORT 8 // Ts duration too short
|
|
#define E_TS_TOO_LONG 16 // Ts duration too long
|
|
#define E_TL_TOO_SHORT 32 // Tl duration too short
|
|
#define E_TL_TOO_LONG 64 // Tl duration too long
|
|
#define E_TP_TOO_SHORT 128 // Tp duration too short
|
|
#define E_TP_TOO_LONG 256 // Tp duration too long
|
|
#define E_CONFIG 512 // error happened in config state
|
|
|
|
#include <Arduino.h>
|
|
|
|
class LiquidCrystal;
|
|
class DFR_Key;
|
|
class Profile;
|
|
|
|
class OvenCtl {
|
|
public:
|
|
|
|
OvenCtl();
|
|
void handle_states();
|
|
void set_config_state();
|
|
|
|
private:
|
|
// system time, timestamps and temperatures from sensors
|
|
int time; // profile seconds
|
|
int temperature; // actual oven temp
|
|
int last_temperature; // last oven temp
|
|
int actual_dt; // actual difference from last to actual temperatur
|
|
|
|
// timestamps of event beginnings/ends
|
|
int Ts_time_start;
|
|
int Ts_time_end;
|
|
int Tl_time_start;
|
|
int Tl_time_end;
|
|
int Tp_time_start;
|
|
int Tp_time_end;
|
|
|
|
// thermostat
|
|
int set_min;
|
|
int set_max;
|
|
int set_dt_min;
|
|
int set_dt_max;
|
|
|
|
// ui stuff
|
|
boolean led_on;
|
|
boolean disable_checks;
|
|
|
|
// state machine
|
|
unsigned int error_condition;
|
|
unsigned int state;
|
|
boolean is_oven_heating;
|
|
|
|
LiquidCrystal * lcd;
|
|
DFR_Key * keypad;
|
|
Profile * profile;
|
|
|
|
void print_status();
|
|
void control_oven();
|
|
void set_temp(int, int, int, int);
|
|
void get_temp();
|
|
void check_dt();
|
|
void check_max_duration();
|
|
|
|
void set_start_state();
|
|
void set_preheat_state();
|
|
void set_tal_first_state();
|
|
void set_ramp_up_state();
|
|
void set_peak_state();
|
|
void set_tal_second_state();
|
|
void set_ramp_down_state();
|
|
void set_end_state();
|
|
void set_error_state();
|
|
|
|
void handle_config_state();
|
|
void handle_start_state();
|
|
void handle_ramp_up_state();
|
|
void handle_preheat_state();
|
|
void handle_tal_first_state();
|
|
void handle_peak_state();
|
|
void handle_tal_second_state();
|
|
void handle_ramp_down_state();
|
|
void handle_end_state();
|
|
void handle_error_state();
|
|
|
|
void check_Ts_duration_min();
|
|
void check_Ts_duration_max();
|
|
void check_Tl_duration_min();
|
|
void check_Tl_duration_max();
|
|
void check_Tp_duration_min();
|
|
void check_Tp_duration_max();
|
|
|
|
void send_state();
|
|
void send_config();
|
|
void reset();
|
|
|
|
void recv_config();
|
|
|
|
void dispatch_input_config(int);
|
|
};
|
|
|
|
#endif
|
|
|