From 8ec316773ff1e2207c02f70684823014eeddf9df Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Tue, 5 Sep 2017 14:02:35 +0200 Subject: [PATCH] PINDA thermistor and ambient thermistor. --- Firmware/Configuration.h | 2 + Firmware/Marlin_main.cpp | 31 ++---- Firmware/pins_Einy_0_3.h | 21 ++-- Firmware/pins_Einy_0_4.h | 21 ++-- Firmware/temperature.cpp | 95 +++++++++++++++---- Firmware/temperature.h | 7 +- Firmware/ultralcd.cpp | 19 ++++ .../ultralcd_implementation_hitachi_HD44780.h | 2 + 8 files changed, 132 insertions(+), 66 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 50fb4ab9..dfd77462 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -746,4 +746,6 @@ enum CalibrationStatus #define PINDA_THERMISTOR +#define AMBIENT_THERMISTOR + #endif //__CONFIGURATION_H diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 3cb2683c..e0a79d69 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3051,7 +3051,7 @@ void process_commands() case 76: //PINDA probe temperature calibration { #ifdef PINDA_THERMISTOR - if (farm_mode && temp_cal_active) + if (true) { if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS])) { // We don't know where we are! HOME! @@ -3071,7 +3071,7 @@ void process_commands() SERIAL_ECHOPGM("start temperature: "); MYSERIAL.println(start_temp); - setTargetHotend(200, 0); +// setTargetHotend(200, 0); setTargetBed(50 + 10 * (start_temp - 30) / 5); custom_message = true; @@ -3132,7 +3132,7 @@ void process_commands() SERIAL_ECHOLNPGM("/6"); custom_message_state = i + 2; setTargetBed(50 + 10 * (temp - 30) / 5); - setTargetHotend(255, 0); +// setTargetHotend(255, 0); current_position[X_AXIS] = PINDA_PREHEAT_X; current_position[Y_AXIS] = PINDA_PREHEAT_Y; current_position[Z_AXIS] = PINDA_PREHEAT_Z; @@ -3178,7 +3178,7 @@ void process_commands() lcd_update(2); setTargetBed(0); //set bed target temperature back to 0 - setTargetHotend(0,0); //set hotend target temperature back to 0 +// setTargetHotend(0,0); //set hotend target temperature back to 0 break; } #endif //PINDA_THERMISTOR @@ -3374,10 +3374,7 @@ void process_commands() bool temp_comp_start = true; #ifdef PINDA_THERMISTOR - if (farm_mode && temp_cal_active) - { - temp_comp_start = false; - } + temp_comp_start = false; #endif //PINDA_THERMISTOR if (temp_comp_start) @@ -3514,8 +3511,7 @@ void process_commands() float offset_z = 0; #ifdef PINDA_THERMISTOR - if (farm_mode && temp_cal_active) - offset_z = temp_compensation_pinda_thermistor_offset(); + offset_z = temp_compensation_pinda_thermistor_offset(); #endif //PINDA_THERMISTOR if (verbosity_level >= 1) { @@ -3548,10 +3544,7 @@ void process_commands() bool apply_temp_comp = true; #ifdef PINDA_THERMISTOR - if (farm_mode && temp_cal_active) - { - apply_temp_comp = false; - } + apply_temp_comp = false; #endif if (apply_temp_comp) if(temp_cal_active == true && calibration_status_pinda() == true) temp_compensation_apply(); //apply PINDA temperature compensation @@ -4495,12 +4488,6 @@ Sigma_Exit: SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1); SERIAL_PROTOCOLPGM(" /"); SERIAL_PROTOCOL_F(degTargetHotend(tmp_extruder),1); -#ifdef PINDA_THERMISTOR - SERIAL_PROTOCOLPGM(" T1:"); - SERIAL_PROTOCOL_F(current_temperature_pinda, 1); - SERIAL_PROTOCOLPGM(" /"); - SERIAL_PROTOCOL_F(degTargetBed(), 1); -#endif // PINDA_THERMISTOR #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 SERIAL_PROTOCOLPGM(" B:"); SERIAL_PROTOCOL_F(degBed(),1); @@ -7291,10 +7278,6 @@ void serialecho_temperatures() { SERIAL_PROTOCOL(tt); SERIAL_PROTOCOLPGM(" E:"); SERIAL_PROTOCOL((int)active_extruder); -#ifdef PINDA_THERMISTOR - SERIAL_PROTOCOLPGM(" T1:"); - SERIAL_PROTOCOL(current_temperature_pinda); -#endif SERIAL_PROTOCOLPGM(" B:"); SERIAL_PROTOCOL_F(degBed(), 1); SERIAL_PROTOCOLLN(""); diff --git a/Firmware/pins_Einy_0_3.h b/Firmware/pins_Einy_0_3.h index d59761a1..936e8d0e 100644 --- a/Firmware/pins_Einy_0_3.h +++ b/Firmware/pins_Einy_0_3.h @@ -65,23 +65,22 @@ #define Z_MS1_PIN -1 #define Z_MS2_PIN -1 -#define HEATER_BED_PIN 4 -#define TEMP_BED_PIN 2 +#define HEATER_BED_PIN 4 //PG5 +#define TEMP_BED_PIN 2 //A2 -#define HEATER_0_PIN 3 -#define TEMP_0_PIN 0 +#define HEATER_0_PIN 3 //PE5 +#define TEMP_0_PIN 0 //A0 -#define HEATER_1_PIN 7 -#define TEMP_1_PIN 1 +#define HEATER_1_PIN -1 +#define TEMP_1_PIN 1 //A1 -#ifdef BARICUDA -#define HEATER_2_PIN 6 -#else #define HEATER_2_PIN -1 -#endif - #define TEMP_2_PIN -1 +#define TEMP_AMBIENT_PIN 6 //A6 + +#define TEMP_PINDA_PIN 3 //A3 + #define E0_TMC2130_CS 66 #define E0_TMC2130_DIAG 65 #define E0_STEP_PIN 34 diff --git a/Firmware/pins_Einy_0_4.h b/Firmware/pins_Einy_0_4.h index dcefad02..d5817a18 100644 --- a/Firmware/pins_Einy_0_4.h +++ b/Firmware/pins_Einy_0_4.h @@ -55,23 +55,22 @@ #define Z_MS1_PIN -1 #define Z_MS2_PIN -1 -#define HEATER_BED_PIN 4 -#define TEMP_BED_PIN 2 +#define HEATER_BED_PIN 4 //PG5 +#define TEMP_BED_PIN 2 //A2 -#define HEATER_0_PIN 3 -#define TEMP_0_PIN 0 +#define HEATER_0_PIN 3 //PE5 +#define TEMP_0_PIN 0 //A0 -#define HEATER_1_PIN 7 -#define TEMP_1_PIN 1 +#define HEATER_1_PIN -1 +#define TEMP_1_PIN 1 //A1 -#ifdef BARICUDA -#define HEATER_2_PIN 6 -#else #define HEATER_2_PIN -1 -#endif - #define TEMP_2_PIN -1 +#define TEMP_AMBIENT_PIN 6 //A6 + +#define TEMP_PINDA_PIN 3 //A3 + #define E0_TMC2130_CS 66 #define E0_TMC2130_DIAG 65 #define E0_STEP_PIN 34 diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index fc776055..24cf0541 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -45,10 +45,17 @@ int target_temperature[EXTRUDERS] = { 0 }; int target_temperature_bed = 0; int current_temperature_raw[EXTRUDERS] = { 0 }; float current_temperature[EXTRUDERS] = { 0.0 }; + #ifdef PINDA_THERMISTOR int current_temperature_raw_pinda = 0 ; float current_temperature_pinda = 0.0; #endif //PINDA_THERMISTOR + +#ifdef AMBIENT_THERMISTOR +int current_temperature_raw_ambient = 0 ; +float current_temperature_ambient = 0.0; +#endif //AMBIENT_THERMISTOR + int current_temperature_bed_raw = 0; float current_temperature_bed = 0.0; #ifdef TEMP_SENSOR_1_AS_REDUNDANT @@ -868,10 +875,15 @@ static void updateTemperaturesFromRawValues() { current_temperature[e] = analog2temp(current_temperature_raw[e], e); } + #ifdef PINDA_THERMISTOR current_temperature_pinda = analog2tempBed(current_temperature_raw_pinda); //thermistor for pinda is the same as for bed #endif - + +#ifdef AMBIENT_THERMISTOR + current_temperature_ambient = analog2tempBed(current_temperature_raw_ambient); //thermistor for ambient is the same as for bed +#endif + current_temperature_bed = analog2tempBed(current_temperature_bed_raw); #ifdef TEMP_SENSOR_1_AS_REDUNDANT @@ -1492,7 +1504,9 @@ ISR(TIMER0_COMPB_vect) static unsigned long raw_temp_1_value = 0; static unsigned long raw_temp_2_value = 0; static unsigned long raw_temp_bed_value = 0; - static unsigned char temp_state = 10; + static unsigned long raw_temp_pinda_value = 0; + static unsigned long raw_temp_ambient_value = 0; + static unsigned char temp_state = 14; static unsigned char pwm_count = (1 << SOFT_PWM_SCALE); static unsigned char soft_pwm_0; #ifdef SLOW_PWM_HEATERS @@ -1922,7 +1936,7 @@ ISR(TIMER0_COMPB_vect) temp_state = 9; break; case 9: //Measure FILWIDTH - #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) + #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) //raw_filwidth_value += ADC; //remove to use an IIR filter approach if(ADC>102) //check that ADC is reading a voltage > 0.5 volts, otherwise don't take in the data. { @@ -1930,14 +1944,53 @@ ISR(TIMER0_COMPB_vect) raw_filwidth_value= raw_filwidth_value + ((unsigned long)ADC<<7); //add new ADC reading } - #endif - temp_state = 0; + #endif + temp_state = 10; + break; + case 10: // Prepare TEMP_AMBIENT + #if defined(TEMP_AMBIENT_PIN) && (TEMP_AMBIENT_PIN > -1) + #if TEMP_AMBIENT_PIN > 7 + ADCSRB = 1< -1) + raw_temp_ambient_value += ADC; + #endif + temp_state = 12; + break; + case 12: // Prepare TEMP_PINDA + #if defined(TEMP_PINDA_PIN) && (TEMP_PINDA_PIN > -1) + #if TEMP_PINDA_PIN > 7 + ADCSRB = 1< -1) + raw_temp_pinda_value += ADC; + #endif + + temp_state = 0; temp_count++; break; - case 10: //Startup, delay initial temp reading a tiny bit so the hardware can settle. + case 14: //Startup, delay initial temp reading a tiny bit so the hardware can settle. temp_state = 0; break; // default: @@ -1950,21 +2003,23 @@ ISR(TIMER0_COMPB_vect) { if (!temp_meas_ready) //Only update the raw values if they have been read. Else we could be updating them during reading. { - current_temperature_raw[0] = raw_temp_0_value; + current_temperature_raw[0] = raw_temp_0_value; +#if EXTRUDERS > 1 + current_temperature_raw[1] = raw_temp_1_value; +#endif +#ifdef TEMP_SENSOR_1_AS_REDUNDANT + redundant_temperature_raw = raw_temp_1_value; +#endif +#if EXTRUDERS > 2 + current_temperature_raw[2] = raw_temp_2_value; +#endif #ifdef PINDA_THERMISTOR - current_temperature_raw_pinda = raw_temp_1_value; -#else - #if EXTRUDERS > 1 - current_temperature_raw[1] = raw_temp_1_value; - #endif - #ifdef TEMP_SENSOR_1_AS_REDUNDANT - redundant_temperature_raw = raw_temp_1_value; - #endif - #if EXTRUDERS > 2 - current_temperature_raw[2] = raw_temp_2_value; - #endif + current_temperature_raw_pinda = raw_temp_pinda_value; #endif //PINDA_THERMISTOR - current_temperature_bed_raw = raw_temp_bed_value; +#ifdef AMBIENT_THERMISTOR + current_temperature_raw_ambient = raw_temp_ambient_value; +#endif //AMBIENT_THERMISTOR + current_temperature_bed_raw = raw_temp_bed_value; } //Add similar code for Filament Sensor - can be read any time since IIR filtering is used @@ -1979,6 +2034,8 @@ ISR(TIMER0_COMPB_vect) raw_temp_1_value = 0; raw_temp_2_value = 0; raw_temp_bed_value = 0; + raw_temp_pinda_value = 0; + raw_temp_ambient_value = 0; #if HEATER_0_RAW_LO_TEMP > HEATER_0_RAW_HI_TEMP if(current_temperature_raw[0] <= maxttemp_raw[0]) { diff --git a/Firmware/temperature.h b/Firmware/temperature.h index 8896e39e..c30efbfc 100644 --- a/Firmware/temperature.h +++ b/Firmware/temperature.h @@ -51,10 +51,15 @@ extern int target_temperature_bed; extern float current_temperature_bed; #ifdef PINDA_THERMISTOR -extern int current_temperature_raw_pinda; +//extern int current_temperature_raw_pinda; extern float current_temperature_pinda; #endif +#ifdef AMBIENT_THERMISTOR +//extern int current_temperature_raw_ambient; +extern float current_temperature_ambient; +#endif + #ifdef TEMP_SENSOR_1_AS_REDUNDANT extern float redundant_temperature; #endif diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index f26a0328..1d785566 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -952,6 +952,24 @@ static void lcd_menu_extruder_info() } } +static void lcd_menu_temperatures() +{ + lcd.setCursor(1, 1); + lcd.print("Ambient: "); + lcd.setCursor(12, 1); + lcd.print(ftostr31ns(current_temperature_ambient)); + lcd.print(LCD_STR_DEGREE); + lcd.setCursor(1, 2); + lcd.print("PINDA: "); + lcd.setCursor(12, 2); + lcd.print(ftostr31ns(current_temperature_pinda)); + lcd.print(LCD_STR_DEGREE); + if (lcd_clicked()) + { + lcd_quick_feedback(); + lcd_return_to_status(); + } +} static void lcd_preheat_menu() { @@ -1026,6 +1044,7 @@ static void lcd_support_menu() MENU_ITEM(function, PSTR("XYZ cal. details"), lcd_service_mode_show_result); } MENU_ITEM(submenu, MSG_INFO_EXTRUDER, lcd_menu_extruder_info); + MENU_ITEM(submenu, PSTR("Temperatures"), lcd_menu_temperatures); #endif //MK1BP END_MENU(); } diff --git a/Firmware/ultralcd_implementation_hitachi_HD44780.h b/Firmware/ultralcd_implementation_hitachi_HD44780.h index 117af64a..4470bf00 100644 --- a/Firmware/ultralcd_implementation_hitachi_HD44780.h +++ b/Firmware/ultralcd_implementation_hitachi_HD44780.h @@ -738,6 +738,7 @@ static void lcd_implementation_status_screen() #ifdef PINDA_THERMISTOR // if (farm_mode && (custom_message_type == 4)) + if (false) { lcd.setCursor(0, 2); lcd_printPGM(PSTR("P")); @@ -747,6 +748,7 @@ static void lcd_implementation_status_screen() } #endif //PINDA_THERMISTOR + if (print_sd_status) { //Print SD status