states adjusted
This commit is contained in:
parent
0161495ffb
commit
338a8de119
|
@ -322,7 +322,7 @@ mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
make
|
make
|
||||||
make reflowctl-upload
|
make reflowctl-upload && ../serialmon.py
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -13,4 +13,4 @@ Then you have to install cmake, for the serialmon.py script python and pyserial.
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
make
|
make
|
||||||
make reflowctl-upload
|
make reflowctl-upload && ../serialmon.py
|
||||||
|
|
|
@ -1,4 +1,20 @@
|
||||||
|
|
||||||
|
#define START_STATE 0
|
||||||
|
#define PREHEAT_STATE 1
|
||||||
|
#define RAMP_UP_STATE 2
|
||||||
|
#define TAL_FIRST_STATE 3
|
||||||
|
#define PEAK_STATE 4
|
||||||
|
#define TAL_SECOND_STATE 5
|
||||||
|
#define RAMPDOWN_STATE 6
|
||||||
|
#define END_STATE 7
|
||||||
|
#define ERROR_STATE 8
|
||||||
|
|
||||||
|
// error conditions
|
||||||
|
#define E_RAMPUP 1 // oven heats up too fast
|
||||||
|
#define E_RAMPDOWN_TOO_FAST 2 // oven cools down too fast
|
||||||
|
#define E_RAMPDOWN_TOO_SLOW 3 // oven cools down too slow
|
||||||
|
#define E_TIME_MAX 4 // reflow process does take too long
|
||||||
|
|
||||||
unsigned int time = 0; // profile seconds
|
unsigned int time = 0; // profile seconds
|
||||||
unsigned int temperatur = 25; // actual oven temp
|
unsigned int temperatur = 25; // actual oven temp
|
||||||
unsigned int last_temperatur = 25;
|
unsigned int last_temperatur = 25;
|
||||||
|
@ -12,28 +28,18 @@ unsigned int tal = 217; // 217°C
|
||||||
unsigned int tal_duration = 100; // 60-150s
|
unsigned int tal_duration = 100; // 60-150s
|
||||||
unsigned int peak_duration = 30; // 20-40s
|
unsigned int peak_duration = 30; // 20-40s
|
||||||
unsigned int rampdown_max = 6; // 6°C/s max
|
unsigned int rampdown_max = 6; // 6°C/s max
|
||||||
|
unsigned int rampdown_min = 2; // 2°C/s max
|
||||||
unsigned int time_max = 480; // 8*60s max
|
unsigned int time_max = 480; // 8*60s max
|
||||||
|
|
||||||
#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_min_time = 0;
|
||||||
unsigned int Ts_max_time = 0;
|
unsigned int Ts_max_time = 0;
|
||||||
unsigned int Tl_time = 0;
|
unsigned int Tl_time = 0;
|
||||||
|
unsigned int Tl_time_end = 0;
|
||||||
unsigned int Tp_time = 0;
|
unsigned int Tp_time = 0;
|
||||||
unsigned int Tl_end_time = 0;
|
unsigned int Tl_end_time = 0;
|
||||||
|
|
||||||
#define RAMPUP_TOO_FAST 1
|
|
||||||
#define RAMPDOWN_TOO_FAST 2
|
|
||||||
unsigned int error_condition = 0;
|
unsigned int error_condition = 0;
|
||||||
|
|
||||||
|
byte state = START_STATE;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
pinMode(13, OUTPUT);
|
pinMode(13, OUTPUT);
|
||||||
|
@ -47,12 +53,40 @@ void get_temp() {
|
||||||
|
|
||||||
boolean check_rampup_rate() {
|
boolean check_rampup_rate() {
|
||||||
if (temperatur - last_temperatur > rampup_rate) {
|
if (temperatur - last_temperatur > rampup_rate) {
|
||||||
error_condition = RAMPUP_TOO_FAST;
|
error_condition = E_RAMPUP;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean check_rampdown_rate() {
|
||||||
|
unsigned int dt = temperatur - last_temperatur;
|
||||||
|
if (dt > rampdown_max) {
|
||||||
|
error_condition = E_RAMPDOWN_TOO_FAST;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dt < rampdown_min) {
|
||||||
|
error_condition = E_RAMPDOWN_TOO_SLOW;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean time_max_check() {
|
||||||
|
if (time > time_max) {
|
||||||
|
error_condition = E_TIME_MAX;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean check_tal_duration() {
|
||||||
|
if (time > time_max) {
|
||||||
|
error_condition = E_TIME_MAX;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
time = millis() / 1000;
|
time = millis() / 1000;
|
||||||
get_temp();
|
get_temp();
|
||||||
|
@ -62,32 +96,38 @@ void loop() {
|
||||||
Serial.print(" ");
|
Serial.print(" ");
|
||||||
Serial.println(last_temperatur);
|
Serial.println(last_temperatur);
|
||||||
|
|
||||||
delay(1000);
|
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case START_STATE:
|
case START_STATE:
|
||||||
// going from room temp to preheat, nothing to check here
|
// going from room temp to preheat, nothing to check here
|
||||||
if (!check_rampup_rate())
|
if (!check_rampup_rate())
|
||||||
goto error;
|
goto error;
|
||||||
if (temperatur > Ts_min) {
|
if (temperatur > Ts_min) {
|
||||||
|
Serial.println("Changed state to PREHEAT_STATE");
|
||||||
|
Ts_min_time = time;
|
||||||
state++;
|
state++;
|
||||||
}
|
}
|
||||||
case PREHEAT_STATE:
|
case PREHEAT_STATE:
|
||||||
if (temperatur > Ts_max) {
|
if (temperatur > Ts_max) {
|
||||||
Serial.println("Changed state to PREHEAT_STATE");
|
Serial.println("Changed state to PREHEAT_STATE");
|
||||||
|
Ts_max_time = time;
|
||||||
state++;
|
state++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TAL_STATE:
|
case TAL_FIRST_STATE:
|
||||||
break;
|
break;
|
||||||
case MAX_STATE:
|
case PEAK_STATE:
|
||||||
|
break;
|
||||||
|
case TAL_SECOND_STATE:
|
||||||
break;
|
break;
|
||||||
case RAMPDOWN_STATE:
|
case RAMPDOWN_STATE:
|
||||||
break;
|
break;
|
||||||
|
case END_STATE:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
|
Loading…
Reference in New Issue