Browse Source

Temperature changes

pull/1/head
Erik van der Zalm 13 years ago
parent
commit
d15f01e1b4
  1. 22
      Marlin/Configuration.h
  2. 2
      Marlin/Marlin.h
  3. 2
      Marlin/Marlin.pde
  4. 86
      Marlin/temperature.cpp
  5. 4
      Marlin/temperature.h
  6. 78
      Marlin/thermistortables.h

22
Marlin/Configuration.h

@ -27,10 +27,10 @@
#define THERMISTORHEATER_2 3
#define THERMISTORBED 3
//#define HEATER_0_USES_THERMISTOR
//#define HEATER_1_USES_THERMISTOR
//#define HEATER_2_USES_THERMISTOR
#define HEATER_1_USES_AD595
//#define HEATER_2_USES_AD595
#define HEATER_0_USES_AD595
//#define HEATER_1_USES_AD595
// Select one of these only to define how the bed temp is read.
//#define BED_USES_THERMISTOR
@ -47,8 +47,8 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
// For optos H21LOB set to true, for Mendel-Parts newer optos TCST2103 set to false
// This determines the communication speed of the printer
//#define BAUDRATE 250000
#define BAUDRATE 115200
#define BAUDRATE 250000
//#define BAUDRATE 115200
//#define BAUDRATE 230400
// Comment out (using // at the start of the line) to disable SD support:
@ -57,7 +57,7 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
#define LCD_WIDTH 16
#define LCD_HEIGHT 2
//#define ULTIPANEL
#define ULTIPANEL
#ifdef ULTIPANEL
//#define NEWPANEL //enable this if you have a click-encoder panel
#define SDSUPPORT
@ -157,15 +157,17 @@ const int dropsegments=5; //everything with this number of steps will be ignore
//#define TEMP_HYSTERESIS 5 // (C°) range of +/- temperatures considered "close" to the target one
//// The minimal temperature defines the temperature below which the heater will not be enabled
#define MINTEMP 5
#define BED_MINTEMP 5
#define HEATER_0_MINTEMP 5
//#define HEATER_1_MINTEMP 5
//#define BED_MINTEMP 5
// When temperature exceeds max temp, your heater will be switched off.
// This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure!
// You should use MINTEMP for thermistor short/failure protection.
#define MAXTEMP 275
#define BED_MAXTEMP 150
#define HEATER_0_MAXTEMP 275
//#define_HEATER_1_MAXTEMP 275
//#define BED_MAXTEMP 150
/// PID settings:
// Uncomment the following line to enable PID support.

2
Marlin/Marlin.h

@ -57,7 +57,7 @@ void ClearToSend();
void get_coordinates();
void prepare_move();
void kill(byte debug);
void kill();
//void check_axes_activity();
//void plan_init();

2
Marlin/Marlin.pde

@ -54,6 +54,8 @@ char version_string[] = "1.0.0 Alpha 1";
//-------------------
// G0 -> G1
// G1 - Coordinated Movement X Y Z E
// G2 - CW ARC
// G3 - CCW ARC
// G4 - Dwell S<seconds> or P<milliseconds>
// G28 - Home all Axis
// G90 - Use Absolute Coordinates

86
Marlin/temperature.cpp

@ -68,11 +68,18 @@ unsigned long previous_millis_heater, previous_millis_bed_heater;
float Kc=DEFAULT_Kc;
#endif //PIDTEMP
#ifdef MINTEMP
int minttemp = temp2analog(MINTEMP);
#ifdef HEATER_0_MINTEMP
int minttemp_0 = temp2analog(HEATER_0_MINTEMP);
#endif //MINTEMP
#ifdef MAXTEMP
int maxttemp = temp2analog(MAXTEMP);
#ifdef HEATER_0_MAXTEMP
int maxttemp_0 = temp2analog(HEATER_0_MAXTEMP);
#endif //MAXTEMP
#ifdef HEATER_1_MINTEMP
int minttemp_1 = temp2analog(HEATER_1_MINTEMP);
#endif //MINTEMP
#ifdef HEATER_1_MAXTEMP
int maxttemp_1 = temp2analog(HEATER_1_MAXTEMP);
#endif //MAXTEMP
#ifdef BED_MINTEMP
@ -173,29 +180,28 @@ CRITICAL_SECTION_END;
// For a thermistor, it uses the RepRap thermistor temp table.
// This is needed because PID in hydra firmware hovers around a given analog value, not a temp value.
// This function is derived from inversing the logic from a portion of getTemperature() in FiveD RepRap firmware.
float temp2analog(int celsius) {
#ifdef HEATER_USES_THERMISTOR_1
int temp2analog(int celsius) {
#ifdef HEATER_0_USES_THERMISTOR
int raw = 0;
byte i;
for (i=1; i<NUMTEMPS_HEATER_1; i++)
for (i=1; i<NUMTEMPS_HEATER_0; i++)
{
if (temptable_1[i][1] < celsius)
if (heater_0_temptable[i][1] < celsius)
{
raw = temptable_1[i-1][0] +
(celsius - temptable_1[i-1][1]) *
(temptable_1[i][0] - temptable_1[i-1][0]) /
(temptable_1[i][1] - temptable_1[i-1][1]);
raw = heater_0_temptable[i-1][0] +
(celsius - heater_0_temptable[i-1][1]) *
(heater_0_temptable[i][0] - heater_0_temptable[i-1][0]) /
(heater_0_temptable[i][1] - heater_0_temptable[i-1][1]);
break;
}
}
// Overflow: Set to last value in the table
if (i == NUMTEMPS_1) raw = temptable_1[i-1][0];
if (i == NUMTEMPS_0) raw = heater_0_temptable[i-1][0];
return (1023 * OVERSAMPLENR) - raw;
#elif defined HEATER_1_USES_AD595
#elif defined HEATER_0_USES_AD595
return celsius * (1024.0 / (5.0 * 100.0) ) * OVERSAMPLENR;
#endif
}
@ -204,7 +210,7 @@ float temp2analog(int celsius) {
// For a thermistor, it uses the RepRap thermistor temp table.
// This is needed because PID in hydra firmware hovers around a given analog value, not a temp value.
// This function is derived from inversing the logic from a portion of getTemperature() in FiveD RepRap firmware.
float temp2analogBed(int celsius) {
int temp2analogBed(int celsius) {
#ifdef BED_USES_THERMISTOR
int raw = 0;
@ -235,28 +241,28 @@ float temp2analogBed(int celsius) {
// Derived from RepRap FiveD extruder::getTemperature()
// For hot end temperature measurement.
float analog2temp(int raw) {
#ifdef HEATER_1_USES_THERMISTOR
int celsius = 0;
#ifdef HEATER_0_USES_THERMISTOR
float celsius = 0;
byte i;
raw = (1023 * OVERSAMPLENR) - raw;
for (i=1; i<NUMTEMPS_HEATER_1; i++)
for (i=1; i<NUMTEMPS_HEATER_0; i++)
{
if (temptable_1[i][0] > raw)
if (heater_0_temptable[i][0] > raw)
{
celsius = temptable_1[i-1][1] +
(raw - temptable_1[i-1][0]) *
(temptable_1[i][1] - temptable_1[i-1][1]) /
(temptable_1[i][0] - temptable_1[i-1][0]);
celsius = heater_0_temptable[i-1][1] +
(raw - heater_0_temptable[i-1][0]) *
(float)(heater_0_temptable[i][1] - heater_0_temptable[i-1][1]) /
(float)(heater_0_temptable[i][0] - heater_0_temptable[i-1][0]);
break;
}
}
// Overflow: Set to last value in the table
if (i == NUMTEMPS_HEATER_1) celsius = temptable_1[i-1][1];
if (i == NUMTEMPS_HEATER_0) celsius = heater_0_temptable[i-1][1];
return celsius;
#elif defined HEATER_1_USES_AD595
#elif defined HEATER_0_USES_AD595
return raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR;
#endif
}
@ -403,13 +409,13 @@ ISR(TIMER0_COMPB_vect)
if(temp_count >= 16) // 6 ms * 16 = 96ms.
{
#ifdef HEATER_1_USES_AD595
#ifdef HEATER_0_USES_AD595
current_raw[0] = raw_temp_0_value;
#else
current_raw[0] = 16383 - raw_temp_0_value;
#endif
#ifdef HEATER_2_USES_AD595
#ifdef HEATER_1_USES_AD595
current_raw[2] = raw_temp_2_value;
#else
current_raw[2] = 16383 - raw_temp_2_value;
@ -426,35 +432,43 @@ ISR(TIMER0_COMPB_vect)
raw_temp_0_value = 0;
raw_temp_1_value = 0;
raw_temp_2_value = 0;
#ifdef MAXTEMP
#ifdef HEATER_0_MAXTEMP
#if (HEATER_0_PIN > -1)
if(current_raw[0] >= maxttemp) {
if(current_raw[0] >= maxttemp_0) {
target_raw[0] = 0;
analogWrite(HEATER_0_PIN, 0);
Serial.println("!! Temperature extruder 0 switched off. MAXTEMP triggered !!");
kill();
}
#endif
#if (HEATER_2_PIN > -1)
if(current_raw[2] >= maxttemp) {
#endif
#ifdef HEATER_1_MAXTEMP
#if (HEATER_1_PIN > -1)
if(current_raw[2] >= maxttemp_1) {
target_raw[2] = 0;
analogWrite(HEATER_2_PIN, 0);
Serial.println("!! Temperature extruder 1 switched off. MAXTEMP triggered !!");
kill()
}
#endif
#endif //MAXTEMP
#ifdef MINTEMP
#ifdef HEATER_0_MINTEMP
#if (HEATER_0_PIN > -1)
if(current_raw[0] <= minttemp) {
if(current_raw[0] <= minttemp_0) {
target_raw[0] = 0;
analogWrite(HEATER_0_PIN, 0);
Serial.println("!! Temperature extruder 0 switched off. MINTEMP triggered !!");
kill();
}
#endif
#endif
#ifdef HEATER_1_MINTEMP
#if (HEATER_2_PIN > -1)
if(current_raw[2] <= minttemp) {
if(current_raw[2] <= minttemp_1) {
target_raw[2] = 0;
analogWrite(HEATER_2_PIN, 0);
Serial.println("!! Temperature extruder 1 switched off. MINTEMP triggered !!");
kill();
}
#endif
#endif //MAXTEMP
@ -464,6 +478,7 @@ ISR(TIMER0_COMPB_vect)
target_raw[1] = 0;
WRITE(HEATER_1_PIN, 0);
Serial.println("!! Temperatur heated bed switched off. MINTEMP triggered !!");
kill();
}
#endif
#endif
@ -473,6 +488,7 @@ ISR(TIMER0_COMPB_vect)
target_raw[1] = 0;
WRITE(HEATER_1_PIN, 0);
Serial.println("!! Temperature heated bed switched off. MAXTEMP triggered !!");
kill();
}
#endif
#endif

4
Marlin/temperature.h

@ -27,8 +27,8 @@ void tp_init();
void manage_heater();
//int temp2analogu(int celsius, const short table[][2], int numtemps);
//float analog2tempu(int raw, const short table[][2], int numtemps);
float temp2analog(int celsius);
float temp2analogBed(int celsius);
int temp2analog(int celsius);
int temp2analogBed(int celsius);
float analog2temp(int raw);
float analog2tempBed(int raw);

78
Marlin/thermistortables.h

@ -3,7 +3,7 @@
#define OVERSAMPLENR 16
#if (THERMISTORHEATER_1 == 1) || (THERMISTORHEATER_2 == 1) || (THERMISTORBED == 1) //100k bed thermistor
#if (THERMISTORHEATER_0 == 1) || (THERMISTORHEATER_1 == 1) || (THERMISTORBED == 1) //100k bed thermistor
#define NUMTEMPS_1 61
const short temptable_1[NUMTEMPS_1][2] = {
@ -70,7 +70,7 @@ const short temptable_1[NUMTEMPS_1][2] = {
{ 1008*OVERSAMPLENR , 0 } //safety
};
#endif
#if (THERMISTORHEATER_1 == 2) || (THERMISTORHEATER_2 == 2) || (THERMISTORBED == 2) //200k bed thermistor
#if (THERMISTORHEATER_0 == 2) || (THERMISTORHEATER_1 == 2) || (THERMISTORBED == 2) //200k bed thermistor
#define NUMTEMPS_2 21
const short temptable_2[NUMTEMPS_2][2] = {
{1*OVERSAMPLENR, 848},
@ -97,7 +97,7 @@ const short temptable_2[NUMTEMPS_2][2] = {
};
#endif
#if (THERMISTORHEATER_1 == 3) || (THERMISTORHEATER_2 == 3) || (THERMISTORBED == 3) //mendel-parts
#if (THERMISTORHEATER_0 == 3) || (THERMISTORHEATER_1 == 3) || (THERMISTORBED == 3) //mendel-parts
#define NUMTEMPS_3 28
const short temptable_3[NUMTEMPS_3][2] = {
{1*OVERSAMPLENR,864},
@ -131,7 +131,7 @@ const short temptable_3[NUMTEMPS_3][2] = {
};
#endif
#if (THERMISTORHEATER_1 == 4) || (THERMISTORHEATER_2 == 4) || (THERMISTORBED == 4) //10k thermistor
#if (THERMISTORHEATER_0 == 4) || (THERMISTORHEATER_1 == 4) || (THERMISTORBED == 4) //10k thermistor
#define NUMTEMPS_4 20
short temptable_4[NUMTEMPS_4][2] = {
@ -158,7 +158,7 @@ short temptable_4[NUMTEMPS_4][2] = {
};
#endif
#if (THERMISTORHEATER_1 == 5) || (THERMISTORHEATER_2 == 5) || (THERMISTORBED == 5) //100k ParCan thermistor (104GT-2)
#if (THERMISTORHEATER_0 == 5) || (THERMISTORHEATER_1 == 5) || (THERMISTORBED == 5) //100k ParCan thermistor (104GT-2)
#define NUMTEMPS_5 61
const short temptable_5[NUMTEMPS_5][2] = {
@ -226,7 +226,7 @@ const short temptable_5[NUMTEMPS_5][2] = {
};
#endif
#if (THERMISTORHEATER_1 == 6) || (THERMISTORHEATER_2 == 6) || (THERMISTORBED == 6) // 100k Epcos thermistor
#if (THERMISTORHEATER_0 == 6) || (THERMISTORHEATER_1 == 6) || (THERMISTORBED == 6) // 100k Epcos thermistor
#define NUMTEMPS_6 36
const short temptable_6[NUMTEMPS_6][2] = {
{28*OVERSAMPLENR, 250},
@ -268,7 +268,7 @@ const short temptable_6[NUMTEMPS_6][2] = {
};
#endif
#if (THERMISTORHEATER_1 == 7) || (THERMISTORHEATER_2 == 7) || (THERMISTORBED == 7) // 100k Honeywell 135-104LAG-J01
#if (THERMISTORHEATER_0 == 7) || (THERMISTORHEATER_1 == 7) || (THERMISTORBED == 7) // 100k Honeywell 135-104LAG-J01
#define NUMTEMPS_7 54
const short temptable_7[NUMTEMPS_7][2] = {
{46*OVERSAMPLENR, 270},
@ -330,56 +330,56 @@ const short temptable_7[NUMTEMPS_7][2] = {
#if THERMISTORHEATER_0 == 1
#define NUMTEMPS_HEATER_0 NUMTEMPS_1
#define heater_0_temptable temptable_1
#elif THERMISTORHEATER_0 == 2
#define NUMTEMPS_HEATER_0 NUMTEMPS_2
#define heater_0_temptable temptable_2
#elif THERMISTORHEATER_0 == 3
#define NUMTEMPS_HEATER_0 NUMTEMPS_3
#define heater_0_temptable temptable_3
#elif THERMISTORHEATER_0 == 4
#define NUMTEMPS_HEATER_0 NUMTEMPS_4
#define heater_0_temptable temptable_4
#elif THERMISTORHEATER_0 == 5
#define NUMTEMPS_HEATER_0 NUMTEMPS_5
#define heater_0_temptable temptable_5
#elif THERMISTORHEATER_0 == 6
#define NUMTEMPS_HEATER_0 NUMTEMPS_6
#define heater_0_temptable temptable_6
#elif THERMISTORHEATER_0 == 7
#define NUMTEMPS_HEATER_0 NUMTEMPS_7
#define heater_0_temptable temptable_7
#elif defined HEATER_0_USES_THERMISTOR
#error No heater 0 thermistor table specified
#endif
#if THERMISTORHEATER_1 == 1
#define NUMTEMPS_HEATER_1 NUMTEMPS_1
#define temptable_1 temptable_1
#define heater_1_temptable temptable_1
#elif THERMISTORHEATER_1 == 2
#define NUMTEMPS_HEATER_1 NUMTEMPS_2
#define temptable_1 temptable_2
#define heater_1_temptable temptable_2
#elif THERMISTORHEATER_1 == 3
#define NUMTEMPS_HEATER_1 NUMTEMPS_3
#define temptable_1 temptable_3
#define heater_1_temptable temptable_3
#elif THERMISTORHEATER_1 == 4
#define NUMTEMPS_HEATER_1 NUMTEMPS_4
#define temptable_1 temptable_4
#define heater_1_temptable temptable_4
#elif THERMISTORHEATER_1 == 5
#define NUMTEMPS_HEATER_1 NUMTEMPS_5
#define temptable_1 temptable_5
#define heater_1_temptable temptable_5
#elif THERMISTORHEATER_1 == 6
#define NUMTEMPS_HEATER_1 NUMTEMPS_6
#define temptable_1 temptable_6
#define heater_1_temptable temptable_6
#elif THERMISTORHEATER_1 == 7
#define NUMTEMPS_HEATER_1 NUMTEMPS_7
#define temptable_1 temptable_7
#define heater_1_temptable temptable_7
#elif defined HEATER_1_USES_THERMISTOR
#error No heater 1 thermistor table specified
#endif
#if THERMISTORHEATER_2 == 1
#define NUMTEMPS_HEATER_2 NUMTEMPS_1
#define temptable_2 temptable_1
#elif THERMISTORHEATER_2 == 2
#define NUMTEMPS_HEATER_2 NUMTEMPS_2
#define temptable_2 temptable_2
#elif THERMISTORHEATER_2 == 3
#define NUMTEMPS_HEATER_2 NUMTEMPS_3
#define temptable_2 temptable_3
#elif THERMISTORHEATER_2 == 4
#define NUMTEMPS_HEATER_2 NUMTEMPS_4
#define temptable_2 temptable_4
#elif THERMISTORHEATER_2 == 5
#define NUMTEMPS_HEATER_2 NUMTEMPS_5
#define temptable_2 temptable_5
#elif THERMISTORHEATER_2 == 6
#define NUMTEMPS_HEATER_2 NUMTEMPS_6
#define temptable_2 temptable_6
#elif THERMISTORHEATER_2 == 7
#define NUMTEMPS_HEATER22 NUMTEMPS_7
#define temptable_2 temptable_7
#elif defined HEATER_2_USES_THERMISTOR
#error No heater 2 thermistor table specified
#endif
#if THERMISTORBED == 1
#define BNUMTEMPS NUMTEMPS_1

Loading…
Cancel
Save