Corrected temp variables.

This commit is contained in:
Erik van der Zalm 2011-11-05 20:21:09 +01:00
parent 04d3b5537f
commit 2e8e8878e5
5 changed files with 2052 additions and 2050 deletions

View File

@ -803,14 +803,14 @@ inline void process_commands()
} }
break; break;
case 104: // M104 case 104: // M104
if (code_seen('S')) target_raw[TEMPSENSOR_HOTEND] = temp2analog(code_value()); if (code_seen('S')) target_raw[TEMPSENSOR_HOTEND_0] = temp2analog(code_value());
#ifdef PIDTEMP #ifdef PIDTEMP
pid_setpoint = code_value(); pid_setpoint = code_value();
#endif //PIDTEM #endif //PIDTEM
#ifdef WATCHPERIOD #ifdef WATCHPERIOD
if(target_raw[TEMPSENSOR_HOTEND] > current_raw[TEMPSENSOR_HOTEND]){ if(target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0]){
watchmillis = max(1,millis()); watchmillis = max(1,millis());
watch_raw[TEMPSENSOR_HOTEND] = current_raw[TEMPSENSOR_HOTEND]; watch_raw[TEMPSENSOR_HOTEND_0] = current_raw[TEMPSENSOR_HOTEND_0];
}else{ }else{
watchmillis = 0; watchmillis = 0;
} }
@ -821,7 +821,7 @@ inline void process_commands()
break; break;
case 105: // M105 case 105: // M105
#if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595) #if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
tt = analog2temp(current_raw[TEMPSENSOR_HOTEND]); tt = analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);
#endif #endif
#if TEMP_1_PIN > -1 #if TEMP_1_PIN > -1
bt = analog2tempBed(current_raw[TEMPSENSOR_BED]); bt = analog2tempBed(current_raw[TEMPSENSOR_BED]);
@ -852,14 +852,14 @@ inline void process_commands()
//break; //break;
case 109: {// M109 - Wait for extruder heater to reach target. case 109: {// M109 - Wait for extruder heater to reach target.
LCD_MESSAGE("Heating..."); LCD_MESSAGE("Heating...");
if (code_seen('S')) target_raw[TEMPSENSOR_HOTEND] = temp2analog(code_value()); if (code_seen('S')) target_raw[TEMPSENSOR_HOTEND_0] = temp2analog(code_value());
#ifdef PIDTEMP #ifdef PIDTEMP
pid_setpoint = code_value(); pid_setpoint = code_value();
#endif //PIDTEM #endif //PIDTEM
#ifdef WATCHPERIOD #ifdef WATCHPERIOD
if(target_raw[TEMPSENSOR_HOTEND]>current_raw[TEMPSENSOR_HOTEND]){ if(target_raw[TEMPSENSOR_HOTEND_0]>current_raw[TEMPSENSOR_HOTEND_0]){
watchmillis = max(1,millis()); watchmillis = max(1,millis());
watch_raw[TEMPSENSOR_HOTEND] = current_raw[TEMPSENSOR_HOTEND]; watch_raw[TEMPSENSOR_HOTEND_0] = current_raw[TEMPSENSOR_HOTEND_0];
} else { } else {
watchmillis = 0; watchmillis = 0;
} }
@ -867,21 +867,21 @@ inline void process_commands()
codenum = millis(); codenum = millis();
/* See if we are heating up or cooling down */ /* See if we are heating up or cooling down */
bool target_direction = (current_raw[0] < target_raw[0]); // true if heating, false if cooling bool target_direction = (current_raw[TEMPSENSOR_HOTEND_0] < target_raw[TEMPSENSOR_HOTEND_0]); // true if heating, false if cooling
#ifdef TEMP_RESIDENCY_TIME #ifdef TEMP_RESIDENCY_TIME
long residencyStart; long residencyStart;
residencyStart = -1; residencyStart = -1;
/* continue to loop until we have reached the target temp /* continue to loop until we have reached the target temp
_and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */ _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
while((target_direction ? (current_raw[0] < target_raw[0]) : (current_raw[0] > target_raw[0])) || while((target_direction ? (current_raw[TEMPSENSOR_HOTEND_0] < target_raw[TEMPSENSOR_HOTEND_0]) : (current_raw[TEMPSENSOR_HOTEND_0] > target_raw[TEMPSENSOR_HOTEND_0])) ||
(residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) { (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
#else #else
while ( target_direction ? (current_raw[0] < target_raw[0]) : (current_raw[0] > target_raw[0]) ) { while ( target_direction ? (current_raw[TEMPSENSOR_HOTEND_0] < target_raw[TEMPSENSOR_HOTEND_0]) : (current_raw[TEMPSENSOR_HOTEND_0] > target_raw[TEMPSENSOR_HOTEND_0]) ) {
#endif //TEMP_RESIDENCY_TIME #endif //TEMP_RESIDENCY_TIME
if( (millis() - codenum) > 1000 ) { //Print Temp Reading every 1 second while heating up/cooling down if( (millis() - codenum) > 1000 ) { //Print Temp Reading every 1 second while heating up/cooling down
Serial.print("T:"); Serial.print("T:");
Serial.println( analog2temp(current_raw[TEMPSENSOR_HOTEND]) ); Serial.println( analog2temp(current_raw[TEMPSENSOR_HOTEND_0]) );
codenum = millis(); codenum = millis();
} }
manage_heater(); manage_heater();
@ -889,9 +889,9 @@ inline void process_commands()
#ifdef TEMP_RESIDENCY_TIME #ifdef TEMP_RESIDENCY_TIME
/* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
or when current temp falls outside the hysteresis after target temp was reached */ or when current temp falls outside the hysteresis after target temp was reached */
if ((residencyStart == -1 && target_direction && current_raw[0] >= target_raw[0]) || if ((residencyStart == -1 && target_direction && current_raw[TEMPSENSOR_HOTEND_0] >= target_raw[TEMPSENSOR_HOTEND_0]) ||
(residencyStart == -1 && !target_direction && current_raw[0] <= target_raw[0]) || (residencyStart == -1 && !target_direction && current_raw[TEMPSENSOR_HOTEND_0] <= target_raw[TEMPSENSOR_HOTEND_0]) ||
(residencyStart > -1 && labs(analog2temp(current_raw[0]) - analog2temp(target_raw[0])) > TEMP_HYSTERESIS) ) { (residencyStart > -1 && labs(analog2temp(current_raw[TEMPSENSOR_HOTEND_0]) - analog2temp(target_raw[TEMPSENSOR_HOTEND_0])) > TEMP_HYSTERESIS) ) {
residencyStart = millis(); residencyStart = millis();
} }
#endif //TEMP_RESIDENCY_TIME #endif //TEMP_RESIDENCY_TIME
@ -907,7 +907,7 @@ inline void process_commands()
{ {
if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up. if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
{ {
float tt=analog2temp(current_raw[TEMPSENSOR_HOTEND]); float tt=analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);
Serial.print("T:"); Serial.print("T:");
Serial.println( tt ); Serial.println( tt );
Serial.print("ok T:"); Serial.print("ok T:");

View File

@ -105,7 +105,7 @@ CRITICAL_SECTION_START;
CRITICAL_SECTION_END; CRITICAL_SECTION_END;
#ifdef PIDTEMP #ifdef PIDTEMP
pid_input = analog2temp(current_raw[TEMPSENSOR_HOTEND]); pid_input = analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);
#ifndef PID_OPENLOOP #ifndef PID_OPENLOOP
pid_error = pid_setpoint - pid_input; pid_error = pid_setpoint - pid_input;
@ -440,16 +440,18 @@ ISR(TIMER0_COMPB_vect)
raw_temp_2_value = 0; raw_temp_2_value = 0;
#ifdef HEATER_0_MAXTEMP #ifdef HEATER_0_MAXTEMP
#if (HEATER_0_PIN > -1) #if (HEATER_0_PIN > -1)
if(current_raw[TEMPSENSOR_HOTEND] >= maxttemp) { if(current_raw[TEMPSENSOR_HOTEND_0] >= maxttemp_0) {
target_raw[TEMPSENSOR_HOTEND] = 0; target_raw[TEMPSENSOR_HOTEND_0] = 0;
analogWrite(HEATER_0_PIN, 0); analogWrite(HEATER_0_PIN, 0);
Serial.println("!! Temperature extruder 0 switched off. MAXTEMP triggered !!"); Serial.println("!! Temperature extruder 0 switched off. MAXTEMP triggered !!");
kill(); kill();
} }
#endif #endif
#endif #endif
if(current_raw[TEMPSENSOR_AUX] >= maxttemp) { #ifdef HEATER_1_MAXTEMP
target_raw[TEMPSENSOR_AUX] = 0; #if (HEATER_1_PIN > -1)
if(current_raw[TEMPSENSOR_HOTEND_1] >= maxttemp_1) {
target_raw[TEMPSENSOR_HOTEND_1] = 0;
if(current_raw[2] >= maxttemp_1) { if(current_raw[2] >= maxttemp_1) {
analogWrite(HEATER_2_PIN, 0); analogWrite(HEATER_2_PIN, 0);
Serial.println("!! Temperature extruder 1 switched off. MAXTEMP triggered !!"); Serial.println("!! Temperature extruder 1 switched off. MAXTEMP triggered !!");
@ -459,8 +461,8 @@ ISR(TIMER0_COMPB_vect)
#endif //MAXTEMP #endif //MAXTEMP
#ifdef HEATER_0_MINTEMP #ifdef HEATER_0_MINTEMP
#if (HEATER_0_PIN > -1) #if (HEATER_0_PIN > -1)
if(current_raw[TEMPSENSOR_HOTEND] <= minttemp) { if(current_raw[TEMPSENSOR_HOTEND_0] <= minttemp_0) {
target_raw[TEMPSENSOR_HOTEND] = 0; target_raw[TEMPSENSOR_HOTEND_0] = 0;
analogWrite(HEATER_0_PIN, 0); analogWrite(HEATER_0_PIN, 0);
Serial.println("!! Temperature extruder 0 switched off. MINTEMP triggered !!"); Serial.println("!! Temperature extruder 0 switched off. MINTEMP triggered !!");
kill(); kill();
@ -469,8 +471,8 @@ ISR(TIMER0_COMPB_vect)
#endif #endif
#ifdef HEATER_1_MINTEMP #ifdef HEATER_1_MINTEMP
#if (HEATER_2_PIN > -1) #if (HEATER_2_PIN > -1)
if(current_raw[TEMPSENSOR_AUX] <= minttemp) { if(current_raw[TEMPSENSOR_HOTEND_1] <= minttemp_1) {
target_raw[TEMPSENSOR_AUX] = 0; target_raw[TEMPSENSOR_HOTEND_1] = 0;
analogWrite(HEATER_2_PIN, 0); analogWrite(HEATER_2_PIN, 0);
Serial.println("!! Temperature extruder 1 switched off. MINTEMP triggered !!"); Serial.println("!! Temperature extruder 1 switched off. MINTEMP triggered !!");
kill(); kill();

View File

@ -34,7 +34,7 @@ int temp2analogBed(int celsius);
float analog2temp(int raw); float analog2temp(int raw);
float analog2tempBed(int raw); float analog2tempBed(int raw);
#ifdef HEATER_USES_THERMISTOR #ifdef HEATER_0_USES_THERMISTOR
#define HEATERSOURCE 1 #define HEATERSOURCE 1
#endif #endif
#ifdef BED_USES_THERMISTOR #ifdef BED_USES_THERMISTOR
@ -50,7 +50,7 @@ extern float Ki;
extern float Kd; extern float Kd;
extern float Kc; extern float Kc;
enum {TEMPSENSOR_HOTEND=0,TEMPSENSOR_BED=1, TEMPSENSOR_AUX=2}; enum {TEMPSENSOR_HOTEND_0=0,TEMPSENSOR_BED=1, TEMPSENSOR_HOTEND_1=2};
extern int target_raw[3]; extern int target_raw[3];
extern int current_raw[3]; extern int current_raw[3];
extern double pid_setpoint; extern double pid_setpoint;

View File

@ -253,17 +253,17 @@ void MainMenu::showStatus()
} }
if((abs(current_raw[TEMPSENSOR_HOTEND]-oldcurrentraw)>3)||force_lcd_update) if((abs(current_raw[TEMPSENSOR_HOTEND_0]-oldcurrentraw)>3)||force_lcd_update)
{ {
lcd.setCursor(1,0); lcd.setCursor(1,0);
lcd.print(ftostr3(analog2temp(current_raw[TEMPSENSOR_HOTEND]))); lcd.print(ftostr3(analog2temp(current_raw[TEMPSENSOR_HOTEND_0])));
oldcurrentraw=current_raw[TEMPSENSOR_HOTEND]; oldcurrentraw=current_raw[TEMPSENSOR_HOTEND_0];
} }
if((target_raw[TEMPSENSOR_HOTEND]!=oldtargetraw)||force_lcd_update) if((target_raw[TEMPSENSOR_HOTEND_0]!=oldtargetraw)||force_lcd_update)
{ {
lcd.setCursor(5,0); lcd.setCursor(5,0);
lcd.print(ftostr3(analog2temp(target_raw[TEMPSENSOR_HOTEND]))); lcd.print(ftostr3(analog2temp(target_raw[TEMPSENSOR_HOTEND_0])));
oldtargetraw=target_raw[TEMPSENSOR_HOTEND]; oldtargetraw=target_raw[TEMPSENSOR_HOTEND_0];
} }
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595 #if defined BED_USES_THERMISTOR || defined BED_USES_AD595
static int oldcurrentbedraw=-1; static int oldcurrentbedraw=-1;
@ -426,7 +426,7 @@ void MainMenu::showPrepare()
if((activeline==line) && CLICKED) if((activeline==line) && CLICKED)
{ {
BLOCK BLOCK
target_raw[TEMPSENSOR_HOTEND] = temp2analog(170); target_raw[TEMPSENSOR_HOTEND_0] = temp2analog(170);
beepshort(); beepshort();
} }
}break; }break;
@ -531,7 +531,7 @@ void MainMenu::showControl()
if(force_lcd_update) if(force_lcd_update)
{ {
lcd.setCursor(0,line);lcd.print(" \002Nozzle:"); lcd.setCursor(0,line);lcd.print(" \002Nozzle:");
lcd.setCursor(13,line);lcd.print(ftostr3(analog2temp(target_raw[TEMPSENSOR_HOTEND]))); lcd.setCursor(13,line);lcd.print(ftostr3(analog2temp(target_raw[TEMPSENSOR_HOTEND_0])));
} }
if((activeline==line) ) if((activeline==line) )
@ -541,11 +541,11 @@ void MainMenu::showControl()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=(int)analog2temp(target_raw[TEMPSENSOR_HOTEND]); encoderpos=(int)analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);
} }
else else
{ {
target_raw[TEMPSENSOR_HOTEND] = temp2analog(encoderpos); target_raw[TEMPSENSOR_HOTEND_0] = temp2analog(encoderpos);
encoderpos=activeline*lcdslow; encoderpos=activeline*lcdslow;
beepshort(); beepshort();
} }