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_SLOW 3 // oven cools down too slow
#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 temperatur = 25; // actual oven temp
@ -36,13 +37,15 @@ unsigned int Ts_max_time = 0;
unsigned int Tl_time = 0;
unsigned int Tl_time_end = 0;
unsigned int Tp_time = 0;
unsigned int Tp_time_end = 0;
unsigned int Tl_end_time = 0;
unsigned int error_condition = 0;
byte state = START_STATE;
int analogPin = 2;
void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600);
}
@ -87,50 +90,61 @@ boolean check_tal_duration() {
}
}
void loop() {
time = millis() / 1000;
get_temp();
Serial.print(time);
Serial.print(" ");
Serial.print(temperatur);
Serial.print(" ");
Serial.println(last_temperatur);
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;
boolean check_peak_duration() {
if (Tp_time_end - Tp_time > peak_duration) {
error_condition = E_PEAK_TOO_LONG;
return false;
}
delay(1000);
return;
error:
state = END_STATE;
Serial.println(error_condition);
}
void loop() {
// time = millis() / 1000;
// get_temp();
// Serial.print(time);
// Serial.print(" ");
// Serial.print(temperatur);
// Serial.print(" ");
// Serial.println(last_temperatur);
Serial.println(analogRead(analogPin));
// 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);
//
// return;
//
// error:
// state = END_STATE;
// Serial.println(error_condition);
}

View File

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