sync to home

This commit is contained in:
Stefan Kögl 2012-10-03 02:29:05 +02:00
parent 338a8de119
commit 02e91af826
2 changed files with 66 additions and 47 deletions

View File

@ -14,6 +14,7 @@
#define E_RAMPDOWN_TOO_FAST 2 // oven cools down 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_RAMPDOWN_TOO_SLOW 3 // oven cools down too slow
#define E_TIME_MAX 4 // reflow process does take too long #define E_TIME_MAX 4 // reflow process does take too long
#define E_PEAK_TOO_LONG 5 // package was roasted
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
@ -36,13 +37,15 @@ unsigned int Ts_max_time = 0;
unsigned int Tl_time = 0; unsigned int Tl_time = 0;
unsigned int Tl_time_end = 0; unsigned int Tl_time_end = 0;
unsigned int Tp_time = 0; unsigned int Tp_time = 0;
unsigned int Tp_time_end = 0;
unsigned int Tl_end_time = 0; unsigned int Tl_end_time = 0;
unsigned int error_condition = 0; unsigned int error_condition = 0;
byte state = START_STATE; byte state = START_STATE;
int analogPin = 2;
void setup() { void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600); Serial.begin(9600);
} }
@ -87,50 +90,61 @@ boolean check_tal_duration() {
} }
} }
boolean check_peak_duration() {
if (Tp_time_end - Tp_time > peak_duration) {
error_condition = E_PEAK_TOO_LONG;
return false;
}
}
void loop() { void loop() {
time = millis() / 1000; // time = millis() / 1000;
get_temp(); // get_temp();
Serial.print(time); // Serial.print(time);
Serial.print(" "); // Serial.print(" ");
Serial.print(temperatur); // Serial.print(temperatur);
Serial.print(" "); // Serial.print(" ");
Serial.println(last_temperatur); // Serial.println(last_temperatur);
switch (state) { Serial.println(analogRead(analogPin));
case START_STATE:
// going from room temp to preheat, nothing to check here
if (!check_rampup_rate())
goto error;
if (temperatur > Ts_min) {
Serial.println("Changed state to PREHEAT_STATE");
Ts_min_time = time;
state++;
}
case PREHEAT_STATE:
if (temperatur > Ts_max) {
Serial.println("Changed state to PREHEAT_STATE");
Ts_max_time = time;
state++;
}
break;
case TAL_FIRST_STATE:
break;
case PEAK_STATE:
break;
case TAL_SECOND_STATE:
break;
case RAMPDOWN_STATE:
break;
case END_STATE:
default:
break;
}
// switch (state) {
// case START_STATE:
// // going from room temp to preheat, nothing to check here
// if (!check_rampup_rate())
// goto error;
// if (temperatur > Ts_min) {
// Serial.println("Changed state to PREHEAT_STATE");
// Ts_min_time = time;
// state++;
// }
// case PREHEAT_STATE:
// if (temperatur > Ts_max) {
// Serial.println("Changed state to PREHEAT_STATE");
// Ts_max_time = time;
// state++;
// }
// break;
// case TAL_FIRST_STATE:
// break;
// case PEAK_STATE:
// break;
// case TAL_SECOND_STATE:
// break;
// case RAMPDOWN_STATE:
// break;
// case END_STATE:
// default:
// break;
// }
//
delay(1000); delay(1000);
//
return; // return;
//
error: // error:
state = END_STATE; // state = END_STATE;
Serial.println(error_condition); // Serial.println(error_condition);
} }

View File

@ -1,6 +1,11 @@
#!/usr/bin/python #!/usr/bin/python
import serial import serial
while 1:
try:
ser = serial.Serial('/dev/ttyUSB0', 9600) ser = serial.Serial('/dev/ttyUSB0', 9600)
while 1: while 1:
print ser.readline() print ser.readline()
except Exception, e:
pass