Browse Source

Fixed AUTOTEMP (M109 S215 B260 F1 starts autotemp)

Changed SLOWDOWN. IF this does not work ok OLD_SLOWDOWN is the old algo.
Erik van der Zalm 13 years ago
parent
commit
67cf105bc6
7 changed files with 93 additions and 111 deletions
  1. 3
    3
      Marlin/Configuration.h
  2. 4
    7
      Marlin/Configuration_adv.h
  3. 1
    0
      Marlin/Marlin.h
  4. 26
    12
      Marlin/Marlin.pde
  5. 36
    58
      Marlin/planner.cpp
  6. 2
    8
      Marlin/stepper.cpp
  7. 21
    23
      Marlin/temperature.cpp

+ 3
- 3
Marlin/Configuration.h View File

@@ -121,7 +121,7 @@
121 121
 const bool X_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
122 122
 const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
123 123
 const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
124
-#define DISABLE_MAX_ENDSTOPS
124
+//#define DISABLE_MAX_ENDSTOPS
125 125
 
126 126
 // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
127 127
 #define X_ENABLE_ON 0
@@ -165,7 +165,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
165 165
 
166 166
 // default settings 
167 167
 
168
-#define DEFAULT_AXIS_STEPS_PER_UNIT   {78.7402,78.7402,200*8/3,760*1.1}                    // default steps per unit for ultimaker 
168
+#define DEFAULT_AXIS_STEPS_PER_UNIT   {78.7402,78.7402,200*8/3,760*1.1}  // default steps per unit for ultimaker 
169 169
 #define DEFAULT_MAX_FEEDRATE          {500, 500, 5, 45}    // (mm/sec)    
170 170
 #define DEFAULT_MAX_ACCELERATION      {9000,9000,100,10000}    // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.
171 171
 
@@ -196,7 +196,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
196 196
 //#define ULTRA_LCD  //general lcd support, also 16x2
197 197
 //#define SDSUPPORT // Enable SD Card Support in Hardware Console
198 198
 
199
-//#define ULTIPANEL
199
+#define ULTIPANEL
200 200
 #ifdef ULTIPANEL
201 201
 //  #define NEWPANEL  //enable this if you have a click-encoder panel
202 202
   #define SDSUPPORT

+ 4
- 7
Marlin/Configuration_adv.h View File

@@ -41,8 +41,8 @@
41 41
 // the target temperature is set to mintemp+factor*se[steps/sec] and limited by mintemp and maxtemp
42 42
 // you exit the value by any M109 without F*
43 43
 // Also, if the temperature is set to a value <mintemp, it is not changed by autotemp.
44
-// on an ultimaker, some initial testing worked with M109 S215 T260 F0.1 in the start.gcode
45
-//#define AUTOTEMP
44
+// on an ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode
45
+#define AUTOTEMP
46 46
 #ifdef AUTOTEMP
47 47
   #define AUTOTEMP_OLDWEIGHT 0.98
48 48
 #endif
@@ -94,8 +94,8 @@
94 94
 #define DEFAULT_MINIMUMFEEDRATE       0.0     // minimum feedrate
95 95
 #define DEFAULT_MINTRAVELFEEDRATE     0.0
96 96
 
97
-// minimum time in microseconds that a movement needs to take if the buffer is emptied.   Increase this number if you see blobs while printing high speed & high detail.  It will slowdown on the detailed stuff.
98
-#define DEFAULT_MINSEGMENTTIME        20000   // Obsolete delete this
97
+// minimum time in microseconds that a movement needs to take if the buffer is emptied.
98
+#define DEFAULT_MINSEGMENTTIME        20000
99 99
 
100 100
 // If defined the movements slow down when the look ahead buffer is only half full
101 101
 #define SLOWDOWN
@@ -147,9 +147,6 @@
147 147
 
148 148
 #endif // ADVANCE
149 149
 
150
-// A debugging feature to compare calculated vs performed steps, to see if steps are lost by the software.
151
-//#define DEBUG_STEPS
152
-
153 150
 // Arc interpretation settings:
154 151
 #define MM_PER_ARC_SEGMENT 1
155 152
 #define N_ARC_CORRECTION 25

+ 1
- 0
Marlin/Marlin.h View File

@@ -64,6 +64,7 @@
64 64
 
65 65
 
66 66
 #define SERIAL_PROTOCOL(x) MYSERIAL.print(x);
67
+#define SERIAL_PROTOCOL_F(x,y) MYSERIAL.print(x,y);
67 68
 #define SERIAL_PROTOCOLPGM(x) serialprintPGM(MYPGM(x));
68 69
 #define SERIAL_PROTOCOLLN(x) {MYSERIAL.print(x);MYSERIAL.write('\n');}
69 70
 #define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(MYPGM(x));MYSERIAL.write('\n');}

+ 26
- 12
Marlin/Marlin.pde View File

@@ -849,14 +849,14 @@ void process_commands()
849 849
       }
850 850
       #if (TEMP_0_PIN > -1)
851 851
         SERIAL_PROTOCOLPGM("ok T:");
852
-        SERIAL_PROTOCOL(degHotend(tmp_extruder)); 
853
-        //SERIAL_PROTOCOLPGM("/");
854
-        //SERIAL_PROTOCOL(degTargetHotend(tmp_extruder)); 
852
+        SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1); 
853
+        SERIAL_PROTOCOLPGM(" /");
854
+        SERIAL_PROTOCOL_F(degTargetHotend(tmp_extruder),1); 
855 855
         #if TEMP_BED_PIN > -1
856 856
           SERIAL_PROTOCOLPGM(" B:");  
857
-          SERIAL_PROTOCOL(degBed());
858
-          //SERIAL_PROTOCOLPGM("/");
859
-          //SERIAL_PROTOCOL(degTargetBed());
857
+          SERIAL_PROTOCOL_F(degBed(),1);
858
+          SERIAL_PROTOCOLPGM(" /");
859
+          SERIAL_PROTOCOL_F(degTargetBed(),1);
860 860
         #endif //TEMP_BED_PIN
861 861
       #else
862 862
         SERIAL_ERROR_START;
@@ -888,7 +888,7 @@ void process_commands()
888 888
       if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
889 889
       #ifdef AUTOTEMP
890 890
         if (code_seen('S')) autotemp_min=code_value();
891
-        if (code_seen('G')) autotemp_max=code_value();
891
+        if (code_seen('B')) autotemp_max=code_value();
892 892
         if (code_seen('F')) 
893 893
         {
894 894
           autotemp_factor=code_value();
@@ -915,9 +915,9 @@ void process_commands()
915 915
           if( (millis() - codenum) > 1000UL )
916 916
           { //Print Temp Reading and remaining time every 1 second while heating up/cooling down
917 917
             SERIAL_PROTOCOLPGM("T:");
918
-            SERIAL_PROTOCOL( degHotend(tmp_extruder) ); 
918
+            SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1); 
919 919
             SERIAL_PROTOCOLPGM(" E:");
920
-            SERIAL_PROTOCOL( (int)tmp_extruder ); 
920
+            SERIAL_PROTOCOL((int)tmp_extruder); 
921 921
             #ifdef TEMP_RESIDENCY_TIME
922 922
               SERIAL_PROTOCOLPGM(" W:");
923 923
               if(residencyStart > -1)
@@ -966,9 +966,10 @@ void process_commands()
966 966
             SERIAL_PROTOCOLPGM("T:");
967 967
             SERIAL_PROTOCOL(tt);
968 968
             SERIAL_PROTOCOLPGM(" E:");
969
-            SERIAL_PROTOCOL( (int)active_extruder ); 
969
+            SERIAL_PROTOCOL((int)active_extruder); 
970 970
             SERIAL_PROTOCOLPGM(" B:");
971
-            SERIAL_PROTOCOLLN(degBed()); 
971
+            SERIAL_PROTOCOL_F(degBed(),1); 
972
+            SERIAL_PROTOCOLLN(""); 
972 973
             codenum = millis(); 
973 974
           }
974 975
           manage_heater();
@@ -1058,7 +1059,20 @@ void process_commands()
1058 1059
       for(int8_t i=0; i < NUM_AXIS; i++) 
1059 1060
       {
1060 1061
         if(code_seen(axis_codes[i])) 
1061
-          axis_steps_per_unit[i] = code_value();
1062
+          
1063
+          if(i == 3) { // E
1064
+            float value = code_value();
1065
+            if(value < 20.0) {
1066
+              float factor = axis_steps_per_unit[i] / value; // increase e constants if M92 E14 is given for netfab.
1067
+              max_e_jerk *= factor;
1068
+              max_feedrate[i] *= factor;
1069
+              axis_steps_per_sqr_second[i] *= factor;
1070
+            }
1071
+            axis_steps_per_unit[i] = value;
1072
+          }
1073
+          else {
1074
+            axis_steps_per_unit[i] = code_value();
1075
+          }
1062 1076
       }
1063 1077
       break;
1064 1078
     case 115: // M115

+ 36
- 58
Marlin/planner.cpp View File

@@ -51,9 +51,6 @@
51 51
     IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a)
52 52
 */
53 53
                                                                                                             
54
-
55
-
56
-
57 54
 #include "Marlin.h"
58 55
 #include "planner.h"
59 56
 #include "stepper.h"
@@ -377,20 +374,26 @@ void plan_init() {
377 374
 void getHighESpeed()
378 375
 {
379 376
   static float oldt=0;
380
-  if(!autotemp_enabled)
377
+  if(!autotemp_enabled){
381 378
     return;
382
-  if(degTargetHotend0()+2<autotemp_min)  //probably temperature set to zero.
379
+  }
380
+  if(degTargetHotend0()+2<autotemp_min) {  //probably temperature set to zero.
383 381
     return; //do nothing
382
+  }
384 383
   
385
-  float high=0;
384
+  float high=0.0;
386 385
   uint8_t block_index = block_buffer_tail;
387 386
   
388 387
   while(block_index != block_buffer_head) {
389
-    float se=block_buffer[block_index].steps_e/float(block_buffer[block_index].step_event_count)*block_buffer[block_index].nominal_rate;
390
-    //se; units steps/sec;
391
-    if(se>high)
392
-    {
393
-      high=se;
388
+    if((block_buffer[block_index].steps_x != 0) ||
389
+       (block_buffer[block_index].steps_y != 0) ||
390
+       (block_buffer[block_index].steps_z != 0)) {
391
+      float se=(float(block_buffer[block_index].steps_e)/float(block_buffer[block_index].step_event_count))*block_buffer[block_index].nominal_speed;
392
+      //se; mm/sec;
393
+      if(se>high)
394
+      {
395
+        high=se;
396
+      }
394 397
     }
395 398
     block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
396 399
   }
@@ -407,10 +410,6 @@ void getHighESpeed()
407 410
   }
408 411
   oldt=t;
409 412
   setTargetHotend0(t);
410
-//   SERIAL_ECHO_START;
411
-//   SERIAL_ECHOPAIR("highe",high);
412
-//   SERIAL_ECHOPAIR(" t",t);
413
-//   SERIAL_ECHOLN("");
414 413
 }
415 414
 #endif
416 415
 
@@ -456,6 +455,9 @@ void check_axes_activity() {
456 455
     analogWrite(FAN_PIN,tail_fan_speed);
457 456
   }
458 457
   #endif
458
+  #ifdef AUTOTEMP
459
+    getHighESpeed();
460
+  #endif
459 461
 }
460 462
 
461 463
 
@@ -517,7 +519,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
517 519
   block->step_event_count = max(block->steps_x, max(block->steps_y, max(block->steps_z, block->steps_e)));
518 520
 
519 521
   // Bail if this is a zero-length block
520
-  if (block->step_event_count <=dropsegments) { return; };
522
+  if (block->step_event_count <= dropsegments) { return; };
521 523
 
522 524
   block->fan_speed = FanSpeed;
523 525
   
@@ -540,7 +542,6 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
540 542
   // Enable all
541 543
   if(block->steps_e != 0) { enable_e0();enable_e1();enable_e2(); }
542 544
 
543
-
544 545
   if (block->steps_e == 0) {
545 546
         if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
546 547
   }
@@ -548,12 +549,6 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
548 549
     	if(feed_rate<minimumfeedrate) feed_rate=minimumfeedrate;
549 550
   } 
550 551
   
551
-  // slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill
552
-  int moves_queued=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
553
-  #ifdef SLOWDOWN
554
-    if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5); 
555
-  #endif
556
-
557 552
   float delta_mm[4];
558 553
   delta_mm[X_AXIS] = (target[X_AXIS]-position[X_AXIS])/axis_steps_per_unit[X_AXIS];
559 554
   delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS];
@@ -569,34 +564,33 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
569 564
   // Calculate speed in mm/second for each axis. No divide by zero due to previous checks.
570 565
   float inverse_second = feed_rate * inverse_millimeters;
571 566
   
572
-  block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
573
-  block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
574
-
567
+  int moves_queued=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
568
+ 
569
+  // slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill
570
+  #ifdef OLD_SLOWDOWN
571
+    if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5); 
572
+  #endif
575 573
 
576
-/*
574
+  #ifdef SLOWDOWN
577 575
   //  segment time im micro seconds
578
-  long segment_time = lround(1000000.0/inverse_second);
579
-  if ((blockcount>0) && (blockcount < (BLOCK_BUFFER_SIZE - 4))) {
580
-    if (segment_time<minsegmenttime)  { // buffer is draining, add extra time.  The amount of time added increases if the buffer is still emptied more.
581
-        segment_time=segment_time+lround(2*(minsegmenttime-segment_time)/blockcount);
576
+  unsigned long segment_time = lround(1000000.0/inverse_second);
577
+  if ((moves_queued > 1) && (moves_queued < (BLOCK_BUFFER_SIZE * 0.5))) {
578
+    if (segment_time < minsegmenttime)  { // buffer is draining, add extra time.  The amount of time added increases if the buffer is still emptied more.
579
+        inverse_second=1000000.0/(segment_time+lround(2*(minsegmenttime-segment_time)/moves_queued));
582 580
     }
583 581
   }
584
-  else {
585
-    if (segment_time<minsegmenttime) segment_time=minsegmenttime;
586
-  }
582
+  #endif
587 583
   //  END OF SLOW DOWN SECTION    
588
-*/
589 584
 
585
+  
586
+  block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
587
+  block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
590 588
 
591
- // Calculate speed in mm/sec for each axis
589
+ // Calculate and limit speed in mm/sec for each axis
592 590
   float current_speed[4];
593
-  for(int i=0; i < 4; i++) {
594
-    current_speed[i] = delta_mm[i] * inverse_second;
595
-  }
596
-
597
-  // Limit speed per axis
598 591
   float speed_factor = 1.0; //factor <=1 do decrease speed
599 592
   for(int i=0; i < 4; i++) {
593
+    current_speed[i] = delta_mm[i] * inverse_second;
600 594
     if(abs(current_speed[i]) > max_feedrate[i])
601 595
       speed_factor = min(speed_factor, max_feedrate[i] / abs(current_speed[i]));
602 596
   }
@@ -633,17 +627,6 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
633 627
 
634 628
   // Correct the speed  
635 629
   if( speed_factor < 1.0) {
636
-//    Serial.print("speed factor : "); Serial.println(speed_factor);
637
-    for(int i=0; i < 4; i++) {
638
-    if(abs(current_speed[i]) > max_feedrate[i])
639
-      speed_factor = min(speed_factor, max_feedrate[i] / abs(current_speed[i]));
640
- /*     
641
-      if(speed_factor < 0.1) {
642
-        Serial.print("speed factor : "); Serial.println(speed_factor);
643
-        Serial.print("current_speed"); Serial.print(i); Serial.print(" : "); Serial.println(current_speed[i]);
644
-      }
645
- */
646
-  }
647 630
     for(unsigned char i=0; i < 4; i++) {
648 631
       current_speed[i] *= speed_factor;
649 632
     }
@@ -784,9 +767,6 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
784 767
     */
785 768
   #endif // ADVANCE
786 769
 
787
-
788
-
789
-
790 770
   calculate_trapezoid_for_block(block, block->entry_speed/block->nominal_speed,
791 771
     MINIMUM_PLANNER_SPEED/block->nominal_speed);
792 772
     
@@ -797,9 +777,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
797 777
   memcpy(position, target, sizeof(target)); // position[] = target[]
798 778
 
799 779
   planner_recalculate();
800
-  #ifdef AUTOTEMP
801
-    getHighESpeed();
802
-  #endif
780
+
803 781
   st_wake_up();
804 782
 }
805 783
 

+ 2
- 8
Marlin/stepper.cpp View File

@@ -54,7 +54,6 @@ volatile static unsigned long step_events_completed; // The number of step event
54 54
   static long old_advance = 0;
55 55
 #endif
56 56
 static long e_steps[3];
57
-static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
58 57
 static long acceleration_time, deceleration_time;
59 58
 //static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
60 59
 static unsigned short acc_step_rate; // needed for deccelaration start point
@@ -216,7 +215,6 @@ void enable_endstops(bool check)
216 215
 
217 216
 void st_wake_up() {
218 217
   //  TCNT1 = 0;
219
-  if(busy == false) 
220 218
   ENABLE_STEPPER_DRIVER_INTERRUPT();  
221 219
 }
222 220
 
@@ -295,6 +293,7 @@ ISR(TIMER1_COMPA_vect)
295 293
     // Anything in the buffer?
296 294
     current_block = plan_get_current_block();
297 295
     if (current_block != NULL) {
296
+      current_block->busy = true;
298 297
       trapezoid_generator_reset();
299 298
       counter_x = -(current_block->step_event_count >> 1);
300 299
       counter_y = counter_x;
@@ -773,12 +772,7 @@ void st_init()
773 772
     TIMSK0 |= (1<<OCIE0A);
774 773
   #endif //ADVANCE
775 774
   
776
-  #ifdef ENDSTOPS_ONLY_FOR_HOMING
777
-    enable_endstops(false);
778
-  #else
779
-    enable_endstops(true);
780
-  #endif
781
-  
775
+  enable_endstops(true); // Start with endstops active. After homing they can be disabled
782 776
   sei();
783 777
 }
784 778
 

+ 21
- 23
Marlin/temperature.cpp View File

@@ -95,17 +95,6 @@ static unsigned long  previous_millis_bed_heater;
95 95
   static int maxttemp[EXTRUDERS] = { 16383 }; // the first value used for all
96 96
   static int bed_minttemp = 0;
97 97
   static int bed_maxttemp = 16383;
98
-  static int heater_pin_map[EXTRUDERS] = { HEATER_0_PIN
99
-#if EXTRUDERS > 1
100
-                                         , HEATER_1_PIN
101
-#endif
102
-#if EXTRUDERS > 2
103
-                                         , HEATER_2_PIN
104
-#endif
105
-#if EXTRUDERS > 3
106
-  #error Unsupported number of extruders
107
-#endif
108
-  };
109 98
   static void *heater_ttbl_map[EXTRUDERS] = { (void *)heater_0_temptable
110 99
 #if EXTRUDERS > 1
111 100
                                             , (void *)heater_1_temptable
@@ -138,7 +127,6 @@ void PID_autotune(float temp)
138 127
   float input;
139 128
   int cycles=0;
140 129
   bool heating = true;
141
-  soft_pwm[0] = 255>>1;
142 130
 
143 131
   unsigned long temp_millis = millis();
144 132
   unsigned long t1=temp_millis;
@@ -154,8 +142,10 @@ void PID_autotune(float temp)
154 142
   
155 143
   SERIAL_ECHOLN("PID Autotune start");
156 144
   
157
-  //disable_heater(); // switch off all heaters.
145
+  disable_heater(); // switch off all heaters.
158 146
   
147
+  soft_pwm[0] = 255>>1;
148
+    
159 149
   for(;;) {
160 150
 
161 151
     if(temp_meas_ready == true) { // temp sample ready
@@ -202,6 +192,7 @@ void PID_autotune(float temp)
202 192
               SERIAL_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(Kp);
203 193
               SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(Ki);
204 194
               SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(Kd);
195
+              /*
205 196
               Kp = 0.33*Ku;
206 197
               Ki = Kp/Tu;
207 198
               Kd = Kp*Tu/3;
@@ -216,6 +207,7 @@ void PID_autotune(float temp)
216 207
               SERIAL_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(Kp);
217 208
               SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(Ki);
218 209
               SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(Kd);
210
+              */
219 211
             }
220 212
           }
221 213
           soft_pwm[0] = (bias + d) >> 1;
@@ -225,7 +217,7 @@ void PID_autotune(float temp)
225 217
       } 
226 218
     }
227 219
     if(input > (temp + 20)) {
228
-      SERIAL_PROTOCOLLNPGM("PID Autotune failed !, Temperature to high");
220
+      SERIAL_PROTOCOLLNPGM("PID Autotune failed! Temperature to high");
229 221
       return;
230 222
     }
231 223
     if(millis() - temp_millis > 2000) {
@@ -235,6 +227,14 @@ void PID_autotune(float temp)
235 227
       SERIAL_PROTOCOLPGM(" @:");
236 228
       SERIAL_PROTOCOLLN(getHeaterPower(0));       
237 229
     }
230
+    if(((millis() - t1) + (millis() - t2)) > (10L*60L*1000L*2L)) {
231
+      SERIAL_PROTOCOLLNPGM("PID Autotune failed! timeout");
232
+      return;
233
+    }
234
+    if(cycles > 5) {
235
+      SERIAL_PROTOCOLLNPGM("PID Autotune finished ! Place the Kp, Ki and Kd constants in the configuration.h");
236
+      return;
237
+    }
238 238
     LCD_STATUS;
239 239
   }
240 240
 }
@@ -313,11 +313,9 @@ void manage_heater()
313 313
     // Check if temperature is within the correct range
314 314
     if((current_raw[e] > minttemp[e]) && (current_raw[e] < maxttemp[e])) 
315 315
     {
316
-      //analogWrite(heater_pin_map[e], pid_output);
317 316
       soft_pwm[e] = (int)pid_output >> 1;
318 317
     }
319 318
     else {
320
-      //analogWrite(heater_pin_map[e], 0);
321 319
       soft_pwm[e] = 0;
322 320
     }
323 321
   } // End extruder for loop
@@ -680,7 +678,7 @@ void disable_heater()
680 678
   target_raw[0]=0;
681 679
   soft_pwm[0]=0;
682 680
    #if HEATER_0_PIN > -1  
683
-     digitalWrite(HEATER_0_PIN,LOW);
681
+     WRITE(HEATER_0_PIN,LOW);
684 682
    #endif
685 683
   #endif
686 684
      
@@ -688,7 +686,7 @@ void disable_heater()
688 686
     target_raw[1]=0;
689 687
     soft_pwm[1]=0;
690 688
     #if HEATER_1_PIN > -1 
691
-      digitalWrite(HEATER_1_PIN,LOW);
689
+      WRITE(HEATER_1_PIN,LOW);
692 690
     #endif
693 691
   #endif
694 692
       
@@ -696,20 +694,20 @@ void disable_heater()
696 694
     target_raw[2]=0;
697 695
     soft_pwm[2]=0;
698 696
     #if HEATER_2_PIN > -1  
699
-      digitalWrite(HEATER_2_PIN,LOW);
697
+      WRITE(HEATER_2_PIN,LOW);
700 698
     #endif
701 699
   #endif 
702 700
 
703 701
   #if TEMP_BED_PIN > -1
704 702
     target_raw_bed=0;
705 703
     #if HEATER_BED_PIN > -1  
706
-      digitalWrite(HEATER_BED_PIN,LOW);
704
+      WRITE(HEATER_BED_PIN,LOW);
707 705
     #endif
708 706
   #endif 
709 707
 }
710 708
 
711 709
 void max_temp_error(uint8_t e) {
712
-  digitalWrite(heater_pin_map[e], 0);
710
+  disable_heater();
713 711
   if(IsStopped() == false) {
714 712
     SERIAL_ERROR_START;
715 713
     SERIAL_ERRORLN(e);
@@ -718,7 +716,7 @@ void max_temp_error(uint8_t e) {
718 716
 }
719 717
 
720 718
 void min_temp_error(uint8_t e) {
721
-  digitalWrite(heater_pin_map[e], 0);
719
+  disable_heater();
722 720
   if(IsStopped() == false) {
723 721
     SERIAL_ERROR_START;
724 722
     SERIAL_ERRORLN(e);
@@ -727,7 +725,7 @@ void min_temp_error(uint8_t e) {
727 725
 }
728 726
 
729 727
 void bed_max_temp_error(void) {
730
-  digitalWrite(HEATER_BED_PIN, 0);
728
+  WRITE(HEATER_BED_PIN, 0);
731 729
   if(IsStopped() == false) {
732 730
     SERIAL_ERROR_START;
733 731
     SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !!");

Loading…
Cancel
Save