sync
This commit is contained in:
parent
97572dbe10
commit
8b5ada1745
|
@ -3,15 +3,16 @@
|
||||||
#include <DFR_Key.h>
|
#include <DFR_Key.h>
|
||||||
|
|
||||||
// states
|
// states
|
||||||
#define START_STATE 0
|
#define CONFIG_STATE 0
|
||||||
#define PREHEAT_STATE 1
|
#define START_STATE 1
|
||||||
#define RAMP_UP_STATE 2
|
#define PREHEAT_STATE 2
|
||||||
#define TAL_FIRST_STATE 3
|
#define RAMP_UP_STATE 3
|
||||||
#define PEAK_STATE 4
|
#define TAL_FIRST_STATE 4
|
||||||
#define TAL_SECOND_STATE 5
|
#define PEAK_STATE 5
|
||||||
#define RAMP_DOWN_STATE 6
|
#define TAL_SECOND_STATE 6
|
||||||
#define END_STATE 7
|
#define RAMP_DOWN_STATE 7
|
||||||
#define ERROR_STATE 8
|
#define END_STATE 8
|
||||||
|
#define ERROR_STATE 9
|
||||||
|
|
||||||
// error conditions
|
// error conditions
|
||||||
#define E_DT_MIN 1 // temperature dt too small
|
#define E_DT_MIN 1 // temperature dt too small
|
||||||
|
@ -30,15 +31,38 @@ unsigned int temperature = 25; // actual oven temp
|
||||||
unsigned int last_temperature = 25; // last oven temp
|
unsigned int last_temperature = 25; // last oven temp
|
||||||
int actual_dt = 0; // actual difference from last to actual temperatur
|
int actual_dt = 0; // actual difference from last to actual temperatur
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
// profile temperatures
|
// profile temperatures
|
||||||
unsigned int Ts_min = 150; // °C
|
unsigned int Ts_min;
|
||||||
|
unsigned int Ts_max;
|
||||||
|
unsigned int Tl;
|
||||||
|
unsigned int Tp;
|
||||||
|
unsigned int time_max;
|
||||||
|
|
||||||
|
// profile temp per second rates
|
||||||
|
int ramp_up_rate_min;
|
||||||
|
int ramp_up_rate_max;
|
||||||
|
int ramp_down_max;
|
||||||
|
int ramp_down_min;
|
||||||
|
|
||||||
|
// profile temp durations
|
||||||
|
unsigned int Ts_duration_min;
|
||||||
|
unsigned int Ts_duration_max;
|
||||||
|
unsigned int Tl_duration_min;
|
||||||
|
unsigned int Tl_duration_max;
|
||||||
|
unsigned int Tp_duration_min;
|
||||||
|
unsigned int Tp_duration_max;
|
||||||
|
} Profile;
|
||||||
|
|
||||||
|
struct Profile profile {150, // °C
|
||||||
unsigned int Ts_max = 200; // °C
|
unsigned int Ts_max = 200; // °C
|
||||||
unsigned int Tl = 217; // 217°C
|
unsigned int Tl = 217; // 217°C
|
||||||
unsigned int Tp = 260; // 245-260°C
|
unsigned int Tp = 260; // 245-260°C
|
||||||
unsigned int time_max = 480; // 8*60s max
|
unsigned int time_max = 480; // 8*60s max
|
||||||
|
|
||||||
// profile temp per second rates
|
// profile temp per second rates
|
||||||
unsigned int ramp_up_rate_min = 0; // not used yet
|
int ramp_up_rate_min = 0; // not used yet
|
||||||
unsigned int ramp_up_rate_max = 50; // 3°C/s
|
unsigned int ramp_up_rate_max = 50; // 3°C/s
|
||||||
unsigned int ramp_down_max = 6; // 6°C/s max
|
unsigned int ramp_down_max = 6; // 6°C/s max
|
||||||
unsigned int ramp_down_min = 2; // 2°C/s max
|
unsigned int ramp_down_min = 2; // 2°C/s max
|
||||||
|
@ -50,6 +74,7 @@ unsigned int Tl_duration_min = 60; // 60-150s
|
||||||
unsigned int Tl_duration_max = 150; // 60-150s
|
unsigned int Tl_duration_max = 150; // 60-150s
|
||||||
unsigned int Tp_duration_min = 20; // 20-40s
|
unsigned int Tp_duration_min = 20; // 20-40s
|
||||||
unsigned int Tp_duration_max = 40; // 20-40s
|
unsigned int Tp_duration_max = 40; // 20-40s
|
||||||
|
} Profile;
|
||||||
|
|
||||||
// timestamps of event beginnings/ends
|
// timestamps of event beginnings/ends
|
||||||
unsigned int Ts_time_start = 0;
|
unsigned int Ts_time_start = 0;
|
||||||
|
@ -60,24 +85,24 @@ unsigned int Tp_time_start = 0;
|
||||||
unsigned int Tp_time_end = 0;
|
unsigned int Tp_time_end = 0;
|
||||||
|
|
||||||
// thermostat
|
// thermostat
|
||||||
unsigned int set_min = 0;
|
static unsigned int set_min = 0;
|
||||||
unsigned int set_max = 0;
|
static unsigned int set_max = 0;
|
||||||
int set_dt_min = 0;
|
static int set_dt_min = 0;
|
||||||
int set_dt_max = 0;
|
static int set_dt_max = 0;
|
||||||
|
|
||||||
|
|
||||||
// state machine
|
// state machine
|
||||||
unsigned int error_condition = 0;
|
static unsigned int error_condition = 0;
|
||||||
byte state = 0;
|
static byte state = 0;
|
||||||
boolean is_oven_heating = false;
|
static boolean is_oven_heating = false;
|
||||||
|
|
||||||
// ui stuff
|
// ui stuff
|
||||||
boolean led_on = false;
|
static boolean led_on = false;
|
||||||
boolean disable_checks = true;
|
static boolean disable_checks = true;
|
||||||
|
|
||||||
//Pin assignments for SainSmart LCD Keypad Shield
|
//Pin assignments for SainSmart LCD Keypad Shield
|
||||||
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
|
static LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
|
||||||
DFR_Key keypad;
|
static DFR_Key keypad;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
@ -93,23 +118,38 @@ void setup() {
|
||||||
|
|
||||||
|
|
||||||
void print_profile_state() {
|
void print_profile_state() {
|
||||||
String tmp("P: ");
|
String tmp("Profile: ");
|
||||||
tmp += state;
|
tmp += state;
|
||||||
tmp += "/";
|
tmp += "/";
|
||||||
tmp += error_condition;
|
tmp += END_STATE;
|
||||||
lcd.setCursor(0, 1);
|
lcd.setCursor(0, 1);
|
||||||
lcd.print(tmp);
|
lcd.print(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_status() {
|
void print_status() {
|
||||||
String tmp("s: ");
|
String tmp("T: ");
|
||||||
|
if (time < 10)
|
||||||
|
tmp += "00";
|
||||||
|
else if (time < 100)
|
||||||
|
tmp += "0";
|
||||||
tmp += time;
|
tmp += time;
|
||||||
tmp += " C: ";
|
tmp += " Tmp: ";
|
||||||
|
if (temperature < 10)
|
||||||
|
tmp += "00";
|
||||||
|
else if (temperature < 100)
|
||||||
|
tmp += "0";
|
||||||
tmp += temperature;
|
tmp += temperature;
|
||||||
lcd.setCursor(0, 0);
|
lcd.setCursor(0, 0);
|
||||||
lcd.print(tmp);
|
lcd.print(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_config_state() {
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* led edit mode procedures
|
/* led edit mode procedures
|
||||||
* global menu (up/down) -> select
|
* global menu (up/down) -> select
|
||||||
* start
|
* start
|
||||||
|
@ -118,7 +158,11 @@ void print_status() {
|
||||||
* value (up/down) -> select | left
|
* value (up/down) -> select | left
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void print_edit() {
|
|
||||||
|
|
||||||
|
void get_time() {
|
||||||
|
if (state>0)
|
||||||
|
time++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void control_oven() {
|
void control_oven() {
|
||||||
|
@ -400,52 +444,56 @@ void handle_error_state() {
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
time = millis() / 1000;
|
get_time();
|
||||||
get_temp();
|
get_temp();
|
||||||
check_dt();
|
check_dt();
|
||||||
|
|
||||||
// if (!error_condition) {
|
if (!error_condition) {
|
||||||
// print_debug();
|
print_debug();
|
||||||
// }
|
}
|
||||||
// else {
|
else {
|
||||||
// set_error_state();
|
set_error_state();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// switch (state) {
|
switch (state) {
|
||||||
// case START_STATE:
|
case CONFIG_STATE:
|
||||||
// handle_start_state();
|
handle_config_state();
|
||||||
// break;
|
print_config_state()
|
||||||
// case PREHEAT_STATE:
|
break;
|
||||||
// handle_preheat_state();
|
case START_STATE:
|
||||||
// break;
|
handle_start_state();
|
||||||
// case RAMP_UP_STATE:
|
break;
|
||||||
// handle_ramp_up_state();
|
case PREHEAT_STATE:
|
||||||
// break;
|
handle_preheat_state();
|
||||||
// case TAL_FIRST_STATE:
|
break;
|
||||||
// handle_tal_first_state();
|
case RAMP_UP_STATE:
|
||||||
// break;
|
handle_ramp_up_state();
|
||||||
// case PEAK_STATE:
|
break;
|
||||||
// handle_peak_state();
|
case TAL_FIRST_STATE:
|
||||||
// break;
|
handle_tal_first_state();
|
||||||
// case TAL_SECOND_STATE:
|
break;
|
||||||
// Tl_time_end = time;
|
case PEAK_STATE:
|
||||||
// handle_tal_second_state();
|
handle_peak_state();
|
||||||
// break;
|
break;
|
||||||
// case RAMP_DOWN_STATE:
|
case TAL_SECOND_STATE:
|
||||||
// handle_ramp_down_state();
|
Tl_time_end = time;
|
||||||
// break;
|
handle_tal_second_state();
|
||||||
// case END_STATE:
|
break;
|
||||||
// handle_end_state();
|
case RAMP_DOWN_STATE:
|
||||||
// break;
|
handle_ramp_down_state();
|
||||||
// case ERROR_STATE:
|
break;
|
||||||
// handle_error_state();
|
case END_STATE:
|
||||||
// break;
|
handle_end_state();
|
||||||
// default:
|
break;
|
||||||
// break;
|
case ERROR_STATE:
|
||||||
// }
|
handle_error_state();
|
||||||
//
|
break;
|
||||||
// control_oven();
|
default:
|
||||||
lcd.clear();
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
control_oven();
|
||||||
|
// lcd.clear();
|
||||||
print_debug();
|
print_debug();
|
||||||
print_status();
|
print_status();
|
||||||
print_profile_state();
|
print_profile_state();
|
||||||
|
|
Loading…
Reference in New Issue