Browse Source

Temperature changes

Erik van der Zalm 12 years ago
parent
commit
d15f01e1b4
6 changed files with 107 additions and 87 deletions
  1. 12
    10
      Marlin/Configuration.h
  2. 1
    1
      Marlin/Marlin.h
  3. 2
    0
      Marlin/Marlin.pde
  4. 51
    35
      Marlin/temperature.cpp
  5. 2
    2
      Marlin/temperature.h
  6. 39
    39
      Marlin/thermistortables.h

+ 12
- 10
Marlin/Configuration.h View File

@@ -27,10 +27,10 @@
27 27
 #define THERMISTORHEATER_2 3
28 28
 #define THERMISTORBED 3
29 29
 
30
+//#define HEATER_0_USES_THERMISTOR
30 31
 //#define HEATER_1_USES_THERMISTOR
31
-//#define HEATER_2_USES_THERMISTOR
32
-#define HEATER_1_USES_AD595
33
-//#define HEATER_2_USES_AD595
32
+#define HEATER_0_USES_AD595
33
+//#define HEATER_1_USES_AD595
34 34
 
35 35
 // Select one of these only to define how the bed temp is read.
36 36
 //#define BED_USES_THERMISTOR
@@ -47,8 +47,8 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
47 47
 // For optos H21LOB set to true, for Mendel-Parts newer optos TCST2103 set to false
48 48
 
49 49
 // This determines the communication speed of the printer
50
-//#define BAUDRATE 250000
51
-#define BAUDRATE 115200
50
+#define BAUDRATE 250000
51
+//#define BAUDRATE 115200
52 52
 //#define BAUDRATE 230400
53 53
 
54 54
 // 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
57 57
 #define LCD_WIDTH 16
58 58
 #define LCD_HEIGHT 2
59 59
 
60
-//#define ULTIPANEL
60
+#define ULTIPANEL
61 61
 #ifdef ULTIPANEL
62 62
  //#define NEWPANEL  //enable this if you have a click-encoder panel
63 63
  #define SDSUPPORT
@@ -157,15 +157,17 @@ const int dropsegments=5; //everything with this number of steps  will be ignore
157 157
 //#define TEMP_HYSTERESIS 5       // (C°) range of +/- temperatures considered "close" to the target one
158 158
 
159 159
 //// The minimal temperature defines the temperature below which the heater will not be enabled
160
-#define MINTEMP 5
161
-#define BED_MINTEMP 5
160
+#define HEATER_0_MINTEMP 5
161
+//#define HEATER_1_MINTEMP 5
162
+//#define BED_MINTEMP 5
162 163
 
163 164
 
164 165
 // When temperature exceeds max temp, your heater will be switched off.
165 166
 // This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure!
166 167
 // You should use MINTEMP for thermistor short/failure protection.
167
-#define MAXTEMP 275
168
-#define BED_MAXTEMP 150
168
+#define HEATER_0_MAXTEMP 275
169
+//#define_HEATER_1_MAXTEMP 275
170
+//#define BED_MAXTEMP 150
169 171
 
170 172
 /// PID settings:
171 173
 // Uncomment the following line to enable PID support.

+ 1
- 1
Marlin/Marlin.h View File

@@ -57,7 +57,7 @@ void ClearToSend();
57 57
 
58 58
 void get_coordinates();
59 59
 void prepare_move();
60
-void kill(byte debug);
60
+void kill();
61 61
 
62 62
 //void check_axes_activity();
63 63
 //void plan_init();

+ 2
- 0
Marlin/Marlin.pde View File

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

+ 51
- 35
Marlin/temperature.cpp View File

@@ -68,11 +68,18 @@ unsigned long previous_millis_heater, previous_millis_bed_heater;
68 68
   float Kc=DEFAULT_Kc;
69 69
 #endif //PIDTEMP
70 70
 
71
-#ifdef MINTEMP
72
-int minttemp = temp2analog(MINTEMP);
71
+#ifdef HEATER_0_MINTEMP
72
+int minttemp_0 = temp2analog(HEATER_0_MINTEMP);
73 73
 #endif //MINTEMP
74
-#ifdef MAXTEMP
75
-int maxttemp = temp2analog(MAXTEMP);
74
+#ifdef HEATER_0_MAXTEMP
75
+int maxttemp_0 = temp2analog(HEATER_0_MAXTEMP);
76
+#endif //MAXTEMP
77
+
78
+#ifdef HEATER_1_MINTEMP
79
+int minttemp_1 = temp2analog(HEATER_1_MINTEMP);
80
+#endif //MINTEMP
81
+#ifdef HEATER_1_MAXTEMP
82
+int maxttemp_1 = temp2analog(HEATER_1_MAXTEMP);
76 83
 #endif //MAXTEMP
77 84
 
78 85
 #ifdef BED_MINTEMP
@@ -173,29 +180,28 @@ CRITICAL_SECTION_END;
173 180
 // For a thermistor, it uses the RepRap thermistor temp table.
174 181
 // This is needed because PID in hydra firmware hovers around a given analog value, not a temp value.
175 182
 // This function is derived from inversing the logic from a portion of getTemperature() in FiveD RepRap firmware.
176
-float temp2analog(int celsius) {
177
-  #ifdef HEATER_USES_THERMISTOR_1
183
+int temp2analog(int celsius) {
184
+  #ifdef HEATER_0_USES_THERMISTOR
178 185
     int raw = 0;
179 186
     byte i;
180 187
     
181
-    for (i=1; i<NUMTEMPS_HEATER_1; i++)
188
+    for (i=1; i<NUMTEMPS_HEATER_0; i++)
182 189
     {
183
-      if (temptable_1[i][1] < celsius)
190
+      if (heater_0_temptable[i][1] < celsius)
184 191
       {
185
-        raw = temptable_1[i-1][0] + 
186
-          (celsius - temptable_1[i-1][1]) * 
187
-          (temptable_1[i][0] - temptable_1[i-1][0]) /
188
-          (temptable_1[i][1] - temptable_1[i-1][1]);
189
-      
192
+        raw = heater_0_temptable[i-1][0] + 
193
+          (celsius - heater_0_temptable[i-1][1]) * 
194
+          (heater_0_temptable[i][0] - heater_0_temptable[i-1][0]) /
195
+          (heater_0_temptable[i][1] - heater_0_temptable[i-1][1]);  
190 196
         break;
191 197
       }
192 198
     }
193 199
 
194 200
     // Overflow: Set to last value in the table
195
-    if (i == NUMTEMPS_1) raw = temptable_1[i-1][0];
201
+    if (i == NUMTEMPS_0) raw = heater_0_temptable[i-1][0];
196 202
 
197 203
     return (1023 * OVERSAMPLENR) - raw;
198
-  #elif defined HEATER_1_USES_AD595
204
+  #elif defined HEATER_0_USES_AD595
199 205
     return celsius * (1024.0 / (5.0 * 100.0) ) * OVERSAMPLENR;
200 206
   #endif
201 207
 }
@@ -204,7 +210,7 @@ float temp2analog(int celsius) {
204 210
 // For a thermistor, it uses the RepRap thermistor temp table.
205 211
 // This is needed because PID in hydra firmware hovers around a given analog value, not a temp value.
206 212
 // This function is derived from inversing the logic from a portion of getTemperature() in FiveD RepRap firmware.
207
-float temp2analogBed(int celsius) {
213
+int temp2analogBed(int celsius) {
208 214
   #ifdef BED_USES_THERMISTOR
209 215
 
210 216
     int raw = 0;
@@ -235,28 +241,28 @@ float temp2analogBed(int celsius) {
235 241
 // Derived from RepRap FiveD extruder::getTemperature()
236 242
 // For hot end temperature measurement.
237 243
 float analog2temp(int raw) {
238
-  #ifdef HEATER_1_USES_THERMISTOR
239
-    int celsius = 0;
244
+  #ifdef HEATER_0_USES_THERMISTOR
245
+    float celsius = 0;
240 246
     byte i;  
241 247
     raw = (1023 * OVERSAMPLENR) - raw;
242
-    for (i=1; i<NUMTEMPS_HEATER_1; i++)
248
+    for (i=1; i<NUMTEMPS_HEATER_0; i++)
243 249
     {
244
-      if (temptable_1[i][0] > raw)
250
+      if (heater_0_temptable[i][0] > raw)
245 251
       {
246
-        celsius  = temptable_1[i-1][1] + 
247
-          (raw - temptable_1[i-1][0]) * 
248
-          (temptable_1[i][1] - temptable_1[i-1][1]) /
249
-          (temptable_1[i][0] - temptable_1[i-1][0]);
252
+        celsius  = heater_0_temptable[i-1][1] + 
253
+          (raw - heater_0_temptable[i-1][0]) * 
254
+          (float)(heater_0_temptable[i][1] - heater_0_temptable[i-1][1]) /
255
+          (float)(heater_0_temptable[i][0] - heater_0_temptable[i-1][0]);
250 256
 
251 257
         break;
252 258
       }
253 259
     }
254 260
 
255 261
     // Overflow: Set to last value in the table
256
-    if (i == NUMTEMPS_HEATER_1) celsius = temptable_1[i-1][1];
262
+    if (i == NUMTEMPS_HEATER_0) celsius = heater_0_temptable[i-1][1];
257 263
 
258 264
     return celsius;
259
-  #elif defined HEATER_1_USES_AD595
265
+  #elif defined HEATER_0_USES_AD595
260 266
     return raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR;
261 267
   #endif
262 268
 }
@@ -403,13 +409,13 @@ ISR(TIMER0_COMPB_vect)
403 409
     
404 410
   if(temp_count >= 16) // 6 ms * 16 = 96ms.
405 411
   {
406
-    #ifdef HEATER_1_USES_AD595
412
+    #ifdef HEATER_0_USES_AD595
407 413
       current_raw[0] = raw_temp_0_value;
408 414
     #else
409 415
       current_raw[0] = 16383 - raw_temp_0_value;
410 416
     #endif
411 417
     
412
-    #ifdef HEATER_2_USES_AD595
418
+    #ifdef HEATER_1_USES_AD595
413 419
       current_raw[2] = raw_temp_2_value;
414 420
     #else
415 421
       current_raw[2] = 16383 - raw_temp_2_value;
@@ -426,35 +432,43 @@ ISR(TIMER0_COMPB_vect)
426 432
     raw_temp_0_value = 0;
427 433
     raw_temp_1_value = 0;
428 434
     raw_temp_2_value = 0;
429
-#ifdef MAXTEMP
435
+#ifdef HEATER_0_MAXTEMP
430 436
   #if (HEATER_0_PIN > -1)
431
-    if(current_raw[0] >= maxttemp) {
437
+    if(current_raw[0] >= maxttemp_0) {
432 438
       target_raw[0] = 0;
433 439
       analogWrite(HEATER_0_PIN, 0);
434 440
       Serial.println("!! Temperature extruder 0 switched off. MAXTEMP triggered !!");
441
+      kill();
435 442
     }
436 443
   #endif
437
-  #if (HEATER_2_PIN > -1)
438
-    if(current_raw[2] >= maxttemp) {
444
+#endif
445
+#ifdef HEATER_1_MAXTEMP
446
+  #if (HEATER_1_PIN > -1)
447
+    if(current_raw[2] >= maxttemp_1) {
439 448
       target_raw[2] = 0;
440 449
       analogWrite(HEATER_2_PIN, 0);
441 450
       Serial.println("!! Temperature extruder 1 switched off. MAXTEMP triggered !!");
451
+      kill()
442 452
     }
443 453
   #endif
444 454
 #endif //MAXTEMP
445
-#ifdef MINTEMP
455
+#ifdef HEATER_0_MINTEMP
446 456
   #if (HEATER_0_PIN > -1)
447
-    if(current_raw[0] <= minttemp) {
457
+    if(current_raw[0] <= minttemp_0) {
448 458
       target_raw[0] = 0;
449 459
       analogWrite(HEATER_0_PIN, 0);
450 460
       Serial.println("!! Temperature extruder 0 switched off. MINTEMP triggered !!");
461
+      kill();
451 462
     }
452 463
   #endif
464
+#endif
465
+#ifdef HEATER_1_MINTEMP
453 466
   #if (HEATER_2_PIN > -1)
454
-    if(current_raw[2] <= minttemp) {
467
+    if(current_raw[2] <= minttemp_1) {
455 468
       target_raw[2] = 0;
456 469
       analogWrite(HEATER_2_PIN, 0);
457 470
       Serial.println("!! Temperature extruder 1 switched off. MINTEMP triggered !!");
471
+      kill();
458 472
     }
459 473
   #endif
460 474
 #endif //MAXTEMP
@@ -464,6 +478,7 @@ ISR(TIMER0_COMPB_vect)
464 478
       target_raw[1] = 0;
465 479
       WRITE(HEATER_1_PIN, 0);
466 480
       Serial.println("!! Temperatur heated bed switched off. MINTEMP triggered !!");
481
+      kill();
467 482
     }
468 483
   #endif
469 484
 #endif
@@ -473,6 +488,7 @@ ISR(TIMER0_COMPB_vect)
473 488
       target_raw[1] = 0;
474 489
       WRITE(HEATER_1_PIN, 0);
475 490
       Serial.println("!! Temperature heated bed switched off. MAXTEMP triggered !!");
491
+      kill();
476 492
     }
477 493
   #endif
478 494
 #endif

+ 2
- 2
Marlin/temperature.h View File

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

+ 39
- 39
Marlin/thermistortables.h View File

@@ -3,7 +3,7 @@
3 3
 
4 4
 #define OVERSAMPLENR 16
5 5
 
6
-#if (THERMISTORHEATER_1 == 1) || (THERMISTORHEATER_2 == 1) || (THERMISTORBED == 1) //100k bed thermistor
6
+#if (THERMISTORHEATER_0 == 1) || (THERMISTORHEATER_1 == 1) || (THERMISTORBED == 1) //100k bed thermistor
7 7
 
8 8
 #define NUMTEMPS_1 61
9 9
 const short temptable_1[NUMTEMPS_1][2] = {
@@ -70,7 +70,7 @@ const short temptable_1[NUMTEMPS_1][2] = {
70 70
 {	1008*OVERSAMPLENR	,	0	} //safety
71 71
 };
72 72
 #endif
73
-#if (THERMISTORHEATER_1 == 2) || (THERMISTORHEATER_2 == 2) || (THERMISTORBED == 2) //200k bed thermistor
73
+#if (THERMISTORHEATER_0 == 2) || (THERMISTORHEATER_1 == 2) || (THERMISTORBED == 2) //200k bed thermistor
74 74
 #define NUMTEMPS_2 21
75 75
 const short temptable_2[NUMTEMPS_2][2] = {
76 76
    {1*OVERSAMPLENR, 848},
@@ -97,7 +97,7 @@ const short temptable_2[NUMTEMPS_2][2] = {
97 97
 };
98 98
 
99 99
 #endif
100
-#if (THERMISTORHEATER_1 == 3) || (THERMISTORHEATER_2 == 3) || (THERMISTORBED == 3) //mendel-parts
100
+#if (THERMISTORHEATER_0 == 3) || (THERMISTORHEATER_1 == 3) || (THERMISTORBED == 3) //mendel-parts
101 101
 #define NUMTEMPS_3 28
102 102
 const short temptable_3[NUMTEMPS_3][2] = {
103 103
 		{1*OVERSAMPLENR,864},
@@ -131,7 +131,7 @@ const short temptable_3[NUMTEMPS_3][2] = {
131 131
 	};
132 132
 
133 133
 #endif
134
-#if (THERMISTORHEATER_1 == 4) || (THERMISTORHEATER_2 == 4) || (THERMISTORBED == 4) //10k thermistor
134
+#if (THERMISTORHEATER_0 == 4) || (THERMISTORHEATER_1 == 4) || (THERMISTORBED == 4) //10k thermistor
135 135
 
136 136
 #define NUMTEMPS_4 20
137 137
 short temptable_4[NUMTEMPS_4][2] = {
@@ -158,7 +158,7 @@ short temptable_4[NUMTEMPS_4][2] = {
158 158
 };
159 159
 #endif
160 160
 
161
-#if (THERMISTORHEATER_1 == 5) || (THERMISTORHEATER_2 == 5) || (THERMISTORBED == 5) //100k ParCan thermistor (104GT-2)
161
+#if (THERMISTORHEATER_0 == 5) || (THERMISTORHEATER_1 == 5) || (THERMISTORBED == 5) //100k ParCan thermistor (104GT-2)
162 162
 
163 163
 #define NUMTEMPS_5 61
164 164
 const short temptable_5[NUMTEMPS_5][2] = {
@@ -226,7 +226,7 @@ const short temptable_5[NUMTEMPS_5][2] = {
226 226
 };
227 227
 #endif
228 228
 
229
-#if (THERMISTORHEATER_1 == 6) || (THERMISTORHEATER_2 == 6) || (THERMISTORBED == 6) // 100k Epcos thermistor
229
+#if (THERMISTORHEATER_0 == 6) || (THERMISTORHEATER_1 == 6) || (THERMISTORBED == 6) // 100k Epcos thermistor
230 230
 #define NUMTEMPS_6 36
231 231
 const short temptable_6[NUMTEMPS_6][2] = {
232 232
    {28*OVERSAMPLENR, 250},
@@ -268,7 +268,7 @@ const short temptable_6[NUMTEMPS_6][2] = {
268 268
 };
269 269
 #endif
270 270
 
271
-#if (THERMISTORHEATER_1 == 7) || (THERMISTORHEATER_2 == 7) || (THERMISTORBED == 7) // 100k Honeywell 135-104LAG-J01
271
+#if (THERMISTORHEATER_0 == 7) || (THERMISTORHEATER_1 == 7) || (THERMISTORBED == 7) // 100k Honeywell 135-104LAG-J01
272 272
 #define NUMTEMPS_7 54
273 273
 const short temptable_7[NUMTEMPS_7][2] = {
274 274
    {46*OVERSAMPLENR, 270},
@@ -330,56 +330,56 @@ const short temptable_7[NUMTEMPS_7][2] = {
330 330
 
331 331
 
332 332
 
333
+#if THERMISTORHEATER_0 == 1
334
+#define NUMTEMPS_HEATER_0 NUMTEMPS_1
335
+#define heater_0_temptable temptable_1
336
+#elif THERMISTORHEATER_0 == 2
337
+#define NUMTEMPS_HEATER_0 NUMTEMPS_2
338
+#define heater_0_temptable temptable_2
339
+#elif THERMISTORHEATER_0 == 3
340
+#define NUMTEMPS_HEATER_0 NUMTEMPS_3
341
+#define heater_0_temptable temptable_3
342
+#elif THERMISTORHEATER_0 == 4
343
+#define NUMTEMPS_HEATER_0 NUMTEMPS_4
344
+#define heater_0_temptable temptable_4
345
+#elif THERMISTORHEATER_0 == 5
346
+#define NUMTEMPS_HEATER_0 NUMTEMPS_5
347
+#define heater_0_temptable temptable_5
348
+#elif THERMISTORHEATER_0 == 6
349
+#define NUMTEMPS_HEATER_0 NUMTEMPS_6
350
+#define heater_0_temptable temptable_6
351
+#elif THERMISTORHEATER_0 == 7
352
+#define NUMTEMPS_HEATER_0 NUMTEMPS_7
353
+#define heater_0_temptable temptable_7
354
+#elif defined HEATER_0_USES_THERMISTOR
355
+#error No heater 0 thermistor table specified
356
+#endif
357
+
333 358
 #if THERMISTORHEATER_1 == 1
334 359
 #define NUMTEMPS_HEATER_1 NUMTEMPS_1
335
-#define temptable_1 temptable_1
360
+#define heater_1_temptable temptable_1
336 361
 #elif THERMISTORHEATER_1 == 2
337 362
 #define NUMTEMPS_HEATER_1 NUMTEMPS_2
338
-#define temptable_1 temptable_2
363
+#define heater_1_temptable temptable_2
339 364
 #elif THERMISTORHEATER_1 == 3
340 365
 #define NUMTEMPS_HEATER_1 NUMTEMPS_3
341
-#define temptable_1 temptable_3
366
+#define heater_1_temptable temptable_3
342 367
 #elif THERMISTORHEATER_1 == 4
343 368
 #define NUMTEMPS_HEATER_1 NUMTEMPS_4
344
-#define temptable_1 temptable_4
369
+#define heater_1_temptable temptable_4
345 370
 #elif THERMISTORHEATER_1 == 5
346 371
 #define NUMTEMPS_HEATER_1 NUMTEMPS_5
347
-#define temptable_1 temptable_5
372
+#define heater_1_temptable temptable_5
348 373
 #elif THERMISTORHEATER_1 == 6
349 374
 #define NUMTEMPS_HEATER_1 NUMTEMPS_6
350
-#define temptable_1 temptable_6
375
+#define heater_1_temptable temptable_6
351 376
 #elif THERMISTORHEATER_1 == 7
352 377
 #define NUMTEMPS_HEATER_1 NUMTEMPS_7
353
-#define temptable_1 temptable_7
378
+#define heater_1_temptable temptable_7
354 379
 #elif defined HEATER_1_USES_THERMISTOR
355 380
 #error No heater 1 thermistor table specified
356 381
 #endif
357 382
 
358
-#if THERMISTORHEATER_2 == 1
359
-#define NUMTEMPS_HEATER_2 NUMTEMPS_1
360
-#define temptable_2 temptable_1
361
-#elif THERMISTORHEATER_2 == 2
362
-#define NUMTEMPS_HEATER_2 NUMTEMPS_2
363
-#define temptable_2 temptable_2
364
-#elif THERMISTORHEATER_2 == 3
365
-#define NUMTEMPS_HEATER_2 NUMTEMPS_3
366
-#define temptable_2 temptable_3
367
-#elif THERMISTORHEATER_2 == 4
368
-#define NUMTEMPS_HEATER_2 NUMTEMPS_4
369
-#define temptable_2 temptable_4
370
-#elif THERMISTORHEATER_2 == 5
371
-#define NUMTEMPS_HEATER_2 NUMTEMPS_5
372
-#define temptable_2 temptable_5
373
-#elif THERMISTORHEATER_2 == 6
374
-#define NUMTEMPS_HEATER_2 NUMTEMPS_6
375
-#define temptable_2 temptable_6
376
-#elif THERMISTORHEATER_2 == 7
377
-#define NUMTEMPS_HEATER22 NUMTEMPS_7
378
-#define temptable_2 temptable_7
379
-#elif defined HEATER_2_USES_THERMISTOR
380
-#error No heater 2 thermistor table specified
381
-#endif
382
-
383 383
 
384 384
 #if THERMISTORBED == 1
385 385
 #define BNUMTEMPS NUMTEMPS_1

Loading…
Cancel
Save