Browse Source

Latest upstream commits, mostly

Scott Lahteine 9 years ago
parent
commit
c185912c19
8 changed files with 230 additions and 199 deletions
  1. 75
    31
      Marlin/ConfigurationStore.cpp
  2. 6
    3
      Marlin/Marlin.h
  3. 49
    42
      Marlin/Marlin_main.cpp
  4. 1
    1
      Marlin/planner.cpp
  5. 1
    7
      Marlin/stepper.cpp
  6. 76
    79
      Marlin/temperature.cpp
  7. 17
    31
      Marlin/temperature.h
  8. 5
    5
      README.md

+ 75
- 31
Marlin/ConfigurationStore.cpp View File

@@ -3,7 +3,21 @@
3 3
  *
4 4
  * Configuration and EEPROM storage
5 5
  *
6
- * V16 EEPROM Layout:
6
+ * IMPORTANT:  Whenever there are changes made to the variables stored in EEPROM
7
+ * in the functions below, also increment the version number. This makes sure that
8
+ * the default values are used whenever there is a change to the data, to prevent
9
+ * wrong data being written to the variables.
10
+ *
11
+ * ALSO: Variables in the Store and Retrieve sections must be in the same order.
12
+ *       If a feature is disabled, some data must still be written that, when read,
13
+ *       either sets a Sane Default, or results in No Change to the existing value.
14
+ *
15
+ */
16
+
17
+#define EEPROM_VERSION "V19"
18
+
19
+/**
20
+ * V19 EEPROM Layout:
7 21
  *
8 22
  *  ver
9 23
  *  axis_steps_per_unit (x4)
@@ -47,6 +61,9 @@
47 61
  *  Kp[2], Ki[2], Kd[2], Kc[2]
48 62
  *  Kp[3], Ki[3], Kd[3], Kc[3]
49 63
  *
64
+ * PIDTEMPBED:
65
+ *  bedKp, bedKi, bedKd
66
+ *
50 67
  * DOGLCD:
51 68
  *  lcd_contrast
52 69
  *
@@ -111,15 +128,6 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
111 128
 
112 129
 #define EEPROM_OFFSET 100
113 130
 
114
-
115
-// IMPORTANT:  Whenever there are changes made to the variables stored in EEPROM
116
-// in the functions below, also increment the version number. This makes sure that
117
-// the default values are used whenever there is a change to the data, to prevent
118
-// wrong data being written to the variables.
119
-// ALSO:  always make sure the variables in the Store and retrieve sections are in the same order.
120
-
121
-#define EEPROM_VERSION "V18"
122
-
123 131
 #ifdef EEPROM_SETTINGS
124 132
 
125 133
 void Config_StoreSettings()  {
@@ -194,7 +202,6 @@ void Config_StoreSettings()  {
194 202
   EEPROM_WRITE_VAR(i, absPreheatHPBTemp);
195 203
   EEPROM_WRITE_VAR(i, absPreheatFanSpeed);
196 204
 
197
-
198 205
   for (int e = 0; e < 4; e++) {
199 206
 
200 207
     #ifdef PIDTEMP
@@ -209,12 +216,10 @@ void Config_StoreSettings()  {
209 216
           EEPROM_WRITE_VAR(i, dummy);
210 217
         #endif
211 218
       }
212
-      else {
213
-    #else // !PIDTEMP
214
-      {
219
+      else
215 220
     #endif // !PIDTEMP
216
-
217
-        dummy = DUMMY_PID_VALUE;
221
+      {
222
+        dummy = DUMMY_PID_VALUE; // When read, will not change the existing value
218 223
         EEPROM_WRITE_VAR(i, dummy);
219 224
         dummy = 0.0f;
220 225
         for (int q = 3; q--;) EEPROM_WRITE_VAR(i, dummy);
@@ -222,6 +227,14 @@ void Config_StoreSettings()  {
222 227
 
223 228
   } // Extruders Loop
224 229
 
230
+  #ifndef PIDTEMPBED
231
+    float bedKp = DUMMY_PID_VALUE, bedKi = DUMMY_PID_VALUE, bedKd = DUMMY_PID_VALUE;
232
+  #endif
233
+
234
+  EEPROM_WRITE_VAR(i, bedKp);
235
+  EEPROM_WRITE_VAR(i, bedKi);
236
+  EEPROM_WRITE_VAR(i, bedKd);
237
+
225 238
   #ifndef DOGLCD
226 239
     int lcd_contrast = 32;
227 240
   #endif
@@ -364,7 +377,7 @@ void Config_RetrieveSettings() {
364 377
 
365 378
     #ifdef PIDTEMP
366 379
       for (int e = 0; e < 4; e++) { // 4 = max extruders currently supported by Marlin
367
-        EEPROM_READ_VAR(i, dummy);
380
+        EEPROM_READ_VAR(i, dummy); // Kp
368 381
         if (e < EXTRUDERS && dummy != DUMMY_PID_VALUE) {
369 382
           // do not need to scale PID values as the values in EEPROM are already scaled
370 383
           PID_PARAM(Kp, e) = dummy;
@@ -385,6 +398,20 @@ void Config_RetrieveSettings() {
385 398
       for (int q=16; q--;) EEPROM_READ_VAR(i, dummy);  // 4x Kp, Ki, Kd, Kc
386 399
     #endif // !PIDTEMP
387 400
 
401
+    #ifndef PIDTEMPBED
402
+      float bedKp, bedKi, bedKd;
403
+    #endif
404
+
405
+    EEPROM_READ_VAR(i, dummy); // bedKp
406
+    if (dummy != DUMMY_PID_VALUE) {
407
+      bedKp = dummy;
408
+      EEPROM_READ_VAR(i, bedKi);
409
+      EEPROM_READ_VAR(i, bedKd);
410
+    }
411
+    else {
412
+      for (int q=2; q--;) EEPROM_READ_VAR(i, dummy); // bedKi, bedKd
413
+    }
414
+
388 415
     #ifndef DOGLCD
389 416
       int lcd_contrast;
390 417
     #endif
@@ -517,6 +544,12 @@ void Config_ResetDefault() {
517 544
     updatePID();
518 545
   #endif // PIDTEMP
519 546
 
547
+  #ifdef PIDTEMPBED
548
+    bedKp = DEFAULT_bedKp;
549
+    bedKi = scalePID_i(DEFAULT_bedKi);
550
+    bedKd = scalePID_d(DEFAULT_bedKd);
551
+  #endif
552
+
520 553
   #ifdef FWRETRACT
521 554
     autoretract_enabled = false;
522 555
     retract_length = RETRACT_LENGTH;
@@ -660,17 +693,28 @@ void Config_PrintSettings(bool forReplay) {
660 693
     SERIAL_EOL;  
661 694
   #endif // DELTA
662 695
 
663
-  #ifdef PIDTEMP
696
+  #if defined(PIDTEMP) || defined(PIDTEMPBED)
664 697
     SERIAL_ECHO_START;
665 698
     if (!forReplay) {
666 699
       SERIAL_ECHOLNPGM("PID settings:");
667 700
       SERIAL_ECHO_START;
668 701
     }
669
-    SERIAL_ECHOPAIR("   M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echos values for E0
670
-    SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
671
-    SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
672
-    SERIAL_EOL;
673
-  #endif // PIDTEMP
702
+    #if defined(PIDTEMP) && defined(PIDTEMPBED)
703
+      SERIAL_EOL;
704
+    #endif
705
+    #ifdef PIDTEMP
706
+      SERIAL_ECHOPAIR("  M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echos values for E0
707
+      SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
708
+      SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
709
+      SERIAL_EOL;
710
+    #endif
711
+    #ifdef PIDTEMPBED
712
+      SERIAL_ECHOPAIR("  M304 P", bedKp); // for compatibility with hosts, only echos values for E0
713
+      SERIAL_ECHOPAIR(" I", unscalePID_i(bedKi));
714
+      SERIAL_ECHOPAIR(" D", unscalePID_d(bedKd));
715
+      SERIAL_EOL;
716
+    #endif
717
+  #endif
674 718
 
675 719
   #ifdef FWRETRACT
676 720
 
@@ -679,7 +723,7 @@ void Config_PrintSettings(bool forReplay) {
679 723
       SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
680 724
       SERIAL_ECHO_START;
681 725
     }
682
-    SERIAL_ECHOPAIR("   M207 S", retract_length);
726
+    SERIAL_ECHOPAIR("  M207 S", retract_length);
683 727
     SERIAL_ECHOPAIR(" F", retract_feedrate*60);
684 728
     SERIAL_ECHOPAIR(" Z", retract_zlift);
685 729
     SERIAL_EOL;
@@ -688,7 +732,7 @@ void Config_PrintSettings(bool forReplay) {
688 732
       SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
689 733
       SERIAL_ECHO_START;
690 734
     }
691
-    SERIAL_ECHOPAIR("   M208 S", retract_recover_length);
735
+    SERIAL_ECHOPAIR("  M208 S", retract_recover_length);
692 736
     SERIAL_ECHOPAIR(" F", retract_recover_feedrate*60);
693 737
     SERIAL_EOL;
694 738
     SERIAL_ECHO_START;
@@ -696,7 +740,7 @@ void Config_PrintSettings(bool forReplay) {
696 740
       SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
697 741
       SERIAL_ECHO_START;
698 742
     }
699
-    SERIAL_ECHOPAIR("   M209 S", (unsigned long)(autoretract_enabled ? 1 : 0));
743
+    SERIAL_ECHOPAIR("  M209 S", (unsigned long)(autoretract_enabled ? 1 : 0));
700 744
     SERIAL_EOL;
701 745
 
702 746
     #if EXTRUDERS > 1
@@ -720,20 +764,20 @@ void Config_PrintSettings(bool forReplay) {
720 764
       SERIAL_ECHOLNPGM("Filament settings:");
721 765
       SERIAL_ECHO_START;
722 766
     }
723
-    SERIAL_ECHOPAIR("   M200 D", filament_size[0]);
767
+    SERIAL_ECHOPAIR("  M200 D", filament_size[0]);
724 768
     SERIAL_EOL;
725 769
 
726 770
     #if EXTRUDERS > 1
727 771
       SERIAL_ECHO_START;
728
-      SERIAL_ECHOPAIR("   M200 T1 D", filament_size[1]);
772
+      SERIAL_ECHOPAIR("  M200 T1 D", filament_size[1]);
729 773
       SERIAL_EOL;
730 774
       #if EXTRUDERS > 2
731 775
         SERIAL_ECHO_START;
732
-        SERIAL_ECHOPAIR("   M200 T2 D", filament_size[2]);
776
+        SERIAL_ECHOPAIR("  M200 T2 D", filament_size[2]);
733 777
         SERIAL_EOL;
734 778
         #if EXTRUDERS > 3
735 779
           SERIAL_ECHO_START;
736
-          SERIAL_ECHOPAIR("   M200 T3 D", filament_size[3]);
780
+          SERIAL_ECHOPAIR("  M200 T3 D", filament_size[3]);
737 781
           SERIAL_EOL;
738 782
         #endif
739 783
       #endif
@@ -752,7 +796,7 @@ void Config_PrintSettings(bool forReplay) {
752 796
         SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
753 797
         SERIAL_ECHO_START;
754 798
       }
755
-      SERIAL_ECHOPAIR("   M", (unsigned long)CUSTOM_M_CODE_SET_Z_PROBE_OFFSET);
799
+      SERIAL_ECHOPAIR("  M", (unsigned long)CUSTOM_M_CODE_SET_Z_PROBE_OFFSET);
756 800
       SERIAL_ECHOPAIR(" Z", -zprobe_zoffset);
757 801
     #else
758 802
       if (!forReplay) {

+ 6
- 3
Marlin/Marlin.h View File

@@ -97,10 +97,10 @@ void serial_echopair_P(const char *s_P, unsigned long v);
97 97
 
98 98
 // Things to write to serial from Program memory. Saves 400 to 2k of RAM.
99 99
 FORCE_INLINE void serialprintPGM(const char *str) {
100
-  char ch = pgm_read_byte(str);
101
-  while(ch) {
100
+  char ch;
101
+  while ((ch = pgm_read_byte(str))) {
102 102
     MYSERIAL.write(ch);
103
-    ch = pgm_read_byte(++str);
103
+    str++;
104 104
   }
105 105
 }
106 106
 
@@ -191,6 +191,9 @@ void manage_inactivity(bool ignore_stepper_queue=false);
191 191
  */
192 192
 enum AxisEnum {X_AXIS=0, Y_AXIS=1, A_AXIS=0, B_AXIS=1, Z_AXIS=2, E_AXIS=3, X_HEAD=4, Y_HEAD=5};
193 193
 
194
+void enable_all_steppers();
195
+void disable_all_steppers();
196
+
194 197
 void FlushSerialRequestResend();
195 198
 void ClearToSend();
196 199
 

+ 49
- 42
Marlin/Marlin_main.cpp View File

@@ -110,6 +110,7 @@
110 110
 //        Call gcode file : "M32 P !filename#" and return to caller file after finishing (similar to #include).
111 111
 //        The '#' is necessary when calling from within sd files, as it stops buffer prereading
112 112
 // M42  - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used.
113
+// M48  - Measure Z_Probe repeatability. M48 [n # of points] [X position] [Y position] [V_erboseness #] [E_ngage Probe] [L # of legs of travel]
113 114
 // M80  - Turn on Power Supply
114 115
 // M81  - Turn off Power Supply
115 116
 // M82  - Set E codes absolute (default)
@@ -1814,7 +1815,7 @@ inline void gcode_G28() {
1814 1815
       // Raise Z before homing any other axes
1815 1816
       if (home_all_axis || homeZ) {
1816 1817
         destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS);    // Set destination away from bed
1817
-        feedrate = max_feedrate[Z_AXIS];
1818
+        feedrate = max_feedrate[Z_AXIS] * 60;
1818 1819
         line_to_destination();
1819 1820
         st_synchronize();
1820 1821
       }
@@ -1947,7 +1948,7 @@ inline void gcode_G28() {
1947 1948
               current_position[Z_AXIS] = 0;
1948 1949
               plan_set_position(cpx, cpy, 0, current_position[E_AXIS]);
1949 1950
               destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS);    // Set destination away from bed
1950
-              feedrate = max_feedrate[Z_AXIS];
1951
+              feedrate = max_feedrate[Z_AXIS] * 60;  // max_feedrate is in mm/s. line_to_destination is feedrate/60.
1951 1952
               line_to_destination();
1952 1953
               st_synchronize();
1953 1954
               HOMEAXIS(Z);
@@ -2571,13 +2572,7 @@ inline void gcode_G92() {
2571 2572
  */
2572 2573
 inline void gcode_M17() {
2573 2574
   LCD_MESSAGEPGM(MSG_NO_MOVE);
2574
-  enable_x();
2575
-  enable_y();
2576
-  enable_z();
2577
-  enable_e0();
2578
-  enable_e1();
2579
-  enable_e2();
2580
-  enable_e3();
2575
+  enable_all_steppers();
2581 2576
 }
2582 2577
 
2583 2578
 #ifdef SDSUPPORT
@@ -3060,26 +3055,29 @@ inline void gcode_M104() {
3060 3055
 inline void gcode_M105() {
3061 3056
   if (setTargetedHotend(105)) return;
3062 3057
 
3063
-  #if HAS_TEMP_0
3064
-    SERIAL_PROTOCOLPGM("ok T:");
3065
-    SERIAL_PROTOCOL_F(degHotend(target_extruder),1);
3066
-    SERIAL_PROTOCOLPGM(" /");
3067
-    SERIAL_PROTOCOL_F(degTargetHotend(target_extruder),1);
3058
+  #if HAS_TEMP_0 || HAS_TEMP_BED
3059
+    SERIAL_PROTOCOLPGM("ok");
3060
+    #if HAS_TEMP_0
3061
+      SERIAL_PROTOCOLPGM(" T:");
3062
+      SERIAL_PROTOCOL_F(degHotend(tmp_extruder), 1);
3063
+      SERIAL_PROTOCOLPGM(" /");
3064
+      SERIAL_PROTOCOL_F(degTargetHotend(tmp_extruder), 1);
3065
+    #endif
3068 3066
     #if HAS_TEMP_BED
3069 3067
       SERIAL_PROTOCOLPGM(" B:");
3070
-      SERIAL_PROTOCOL_F(degBed(),1);
3068
+      SERIAL_PROTOCOL_F(degBed(), 1);
3071 3069
       SERIAL_PROTOCOLPGM(" /");
3072
-      SERIAL_PROTOCOL_F(degTargetBed(),1);
3073
-    #endif // HAS_TEMP_BED
3074
-    for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
3070
+      SERIAL_PROTOCOL_F(degTargetBed(), 1);
3071
+    #endif
3072
+    for (int8_t e = 0; e < EXTRUDERS; ++e) {
3075 3073
       SERIAL_PROTOCOLPGM(" T");
3076
-      SERIAL_PROTOCOL(cur_extruder);
3074
+      SERIAL_PROTOCOL(e);
3077 3075
       SERIAL_PROTOCOLCHAR(':');
3078
-      SERIAL_PROTOCOL_F(degHotend(cur_extruder),1);
3076
+      SERIAL_PROTOCOL_F(degHotend(e), 1);
3079 3077
       SERIAL_PROTOCOLPGM(" /");
3080
-      SERIAL_PROTOCOL_F(degTargetHotend(cur_extruder),1);
3078
+      SERIAL_PROTOCOL_F(degTargetHotend(e), 1);
3081 3079
     }
3082
-  #else // !HAS_TEMP_0
3080
+  #else // !HAS_TEMP_0 && !HAS_TEMP_BED
3083 3081
     SERIAL_ERROR_START;
3084 3082
     SERIAL_ERRORLNPGM(MSG_ERR_NO_THERMISTORS);
3085 3083
   #endif
@@ -3117,7 +3115,7 @@ inline void gcode_M105() {
3117 3115
     }
3118 3116
   #endif
3119 3117
 
3120
-  SERIAL_PROTOCOLLN("");
3118
+  SERIAL_EOL;
3121 3119
 }
3122 3120
 
3123 3121
 #if HAS_FAN
@@ -3132,7 +3130,7 @@ inline void gcode_M105() {
3132 3130
    */
3133 3131
   inline void gcode_M107() { fanSpeed = 0; }
3134 3132
 
3135
-#endif //FAN_PIN
3133
+#endif // HAS_FAN
3136 3134
 
3137 3135
 /**
3138 3136
  * M109: Wait for extruder(s) to reach temperature
@@ -3191,10 +3189,10 @@ inline void gcode_M109() {
3191 3189
             SERIAL_PROTOCOLLN( timetemp );
3192 3190
           }
3193 3191
           else {
3194
-            SERIAL_PROTOCOLLN( "?" );
3192
+            SERIAL_PROTOCOLLNPGM("?");
3195 3193
           }
3196 3194
         #else
3197
-          SERIAL_PROTOCOLLN("");
3195
+          SERIAL_EOL;
3198 3196
         #endif
3199 3197
         timetemp = millis();
3200 3198
       }
@@ -3246,7 +3244,7 @@ inline void gcode_M109() {
3246 3244
         SERIAL_PROTOCOL((int)active_extruder);
3247 3245
         SERIAL_PROTOCOLPGM(" B:");
3248 3246
         SERIAL_PROTOCOL_F(degBed(), 1);
3249
-        SERIAL_PROTOCOLLN("");
3247
+        SERIAL_EOL;
3250 3248
       }
3251 3249
       manage_heater();
3252 3250
       manage_inactivity();
@@ -3447,27 +3445,26 @@ inline void gcode_M114() {
3447 3445
   SERIAL_PROTOCOLPGM(" Z:");
3448 3446
   SERIAL_PROTOCOL(float(st_get_position(Z_AXIS))/axis_steps_per_unit[Z_AXIS]);
3449 3447
 
3450
-  SERIAL_PROTOCOLLN("");
3448
+  SERIAL_EOL;
3451 3449
 
3452 3450
   #ifdef SCARA
3453 3451
     SERIAL_PROTOCOLPGM("SCARA Theta:");
3454 3452
     SERIAL_PROTOCOL(delta[X_AXIS]);
3455 3453
     SERIAL_PROTOCOLPGM("   Psi+Theta:");
3456 3454
     SERIAL_PROTOCOL(delta[Y_AXIS]);
3457
-    SERIAL_PROTOCOLLN("");
3455
+    SERIAL_EOL;
3458 3456
     
3459 3457
     SERIAL_PROTOCOLPGM("SCARA Cal - Theta:");
3460 3458
     SERIAL_PROTOCOL(delta[X_AXIS]+home_offset[X_AXIS]);
3461 3459
     SERIAL_PROTOCOLPGM("   Psi+Theta (90):");
3462 3460
     SERIAL_PROTOCOL(delta[Y_AXIS]-delta[X_AXIS]-90+home_offset[Y_AXIS]);
3463
-    SERIAL_PROTOCOLLN("");
3461
+    SERIAL_EOL;
3464 3462
     
3465 3463
     SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:");
3466 3464
     SERIAL_PROTOCOL(delta[X_AXIS]/90*axis_steps_per_unit[X_AXIS]);
3467 3465
     SERIAL_PROTOCOLPGM("   Psi+Theta:");
3468 3466
     SERIAL_PROTOCOL((delta[Y_AXIS]-delta[X_AXIS])/90*axis_steps_per_unit[Y_AXIS]);
3469
-    SERIAL_PROTOCOLLN("");
3470
-    SERIAL_PROTOCOLLN("");
3467
+    SERIAL_EOL; SERIAL_EOL;
3471 3468
   #endif
3472 3469
 }
3473 3470
 
@@ -3909,7 +3906,7 @@ inline void gcode_M226() {
3909 3906
       SERIAL_PROTOCOL(servo_index);
3910 3907
       SERIAL_PROTOCOL(": ");
3911 3908
       SERIAL_PROTOCOL(servos[servo_index].read());
3912
-      SERIAL_PROTOCOLLN("");
3909
+      SERIAL_EOL;
3913 3910
     }
3914 3911
   }
3915 3912
 
@@ -3977,7 +3974,7 @@ inline void gcode_M226() {
3977 3974
         //Kc does not have scaling applied above, or in resetting defaults
3978 3975
         SERIAL_PROTOCOL(PID_PARAM(Kc, e));
3979 3976
       #endif
3980
-      SERIAL_PROTOCOLLN("");    
3977
+      SERIAL_EOL;    
3981 3978
     }
3982 3979
     else {
3983 3980
       SERIAL_ECHO_START;
@@ -4002,7 +3999,7 @@ inline void gcode_M226() {
4002 3999
     SERIAL_PROTOCOL(unscalePID_i(bedKi));
4003 4000
     SERIAL_PROTOCOL(" d:");
4004 4001
     SERIAL_PROTOCOL(unscalePID_d(bedKd));
4005
-    SERIAL_PROTOCOLLN("");
4002
+    SERIAL_EOL;
4006 4003
   }
4007 4004
 
4008 4005
 #endif // PIDTEMPBED
@@ -4052,7 +4049,7 @@ inline void gcode_M226() {
4052 4049
     if (code_seen('C')) lcd_setcontrast(code_value_short() & 0x3F);
4053 4050
     SERIAL_PROTOCOLPGM("lcd contrast value: ");
4054 4051
     SERIAL_PROTOCOL(lcd_contrast);
4055
-    SERIAL_PROTOCOLLN("");
4052
+    SERIAL_EOL;
4056 4053
   }
4057 4054
 
4058 4055
 #endif // DOGLCD
@@ -4325,7 +4322,7 @@ inline void gcode_M503() {
4325 4322
         zprobe_zoffset = -value; // compare w/ line 278 of ConfigurationStore.cpp
4326 4323
         SERIAL_ECHO_START;
4327 4324
         SERIAL_ECHOLNPGM(MSG_ZPROBE_ZOFFSET " " MSG_OK);
4328
-        SERIAL_PROTOCOLLN("");
4325
+        SERIAL_EOL;
4329 4326
       }
4330 4327
       else {
4331 4328
         SERIAL_ECHO_START;
@@ -4334,14 +4331,14 @@ inline void gcode_M503() {
4334 4331
         SERIAL_ECHO(Z_PROBE_OFFSET_RANGE_MIN);
4335 4332
         SERIAL_ECHOPGM(MSG_Z_MAX);
4336 4333
         SERIAL_ECHO(Z_PROBE_OFFSET_RANGE_MAX);
4337
-        SERIAL_PROTOCOLLN("");
4334
+        SERIAL_EOL;
4338 4335
       }
4339 4336
     }
4340 4337
     else {
4341 4338
       SERIAL_ECHO_START;
4342 4339
       SERIAL_ECHOLNPGM(MSG_ZPROBE_ZOFFSET " : ");
4343 4340
       SERIAL_ECHO(-zprobe_zoffset);
4344
-      SERIAL_PROTOCOLLN("");
4341
+      SERIAL_EOL;
4345 4342
     }
4346 4343
   }
4347 4344
 
@@ -5700,7 +5697,17 @@ void handle_status_leds(void) {
5700 5697
 }
5701 5698
 #endif
5702 5699
 
5703
-void disable_all_axes() {
5700
+void enable_all_steppers() {
5701
+  enable_x();
5702
+  enable_y();
5703
+  enable_z();
5704
+  enable_e0();
5705
+  enable_e1();
5706
+  enable_e2();
5707
+  enable_e3();
5708
+}
5709
+
5710
+void disable_all_steppers() {
5704 5711
   disable_x();
5705 5712
   disable_y();
5706 5713
   disable_z();
@@ -5728,7 +5735,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
5728 5735
 
5729 5736
   if (stepper_inactive_time && ms > previous_millis_cmd + stepper_inactive_time
5730 5737
       && !ignore_stepper_queue && !blocks_queued())
5731
-    disable_all_axes();
5738
+    disable_all_steppers();
5732 5739
 
5733 5740
   #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH
5734 5741
     if (chdkActive && ms > chdkHigh + CHDK_DELAY) {
@@ -5816,7 +5823,7 @@ void kill()
5816 5823
   cli(); // Stop interrupts
5817 5824
   disable_heater();
5818 5825
 
5819
-  disable_all_axes();
5826
+  disable_all_steppers();
5820 5827
 
5821 5828
   #if HAS_POWER_SWITCH
5822 5829
     pinMode(PS_ON_PIN, INPUT);

+ 1
- 1
Marlin/planner.cpp View File

@@ -67,7 +67,7 @@
67 67
 //===========================================================================
68 68
 
69 69
 unsigned long minsegmenttime;
70
-float max_feedrate[NUM_AXIS]; // set the max speeds
70
+float max_feedrate[NUM_AXIS]; // Max speeds in mm per minute
71 71
 float axis_steps_per_unit[NUM_AXIS];
72 72
 unsigned long max_acceleration_units_per_sq_second[NUM_AXIS]; // Use M201 to override by software
73 73
 float minimumfeedrate;

+ 1
- 7
Marlin/stepper.cpp View File

@@ -1127,13 +1127,7 @@ long st_get_position(uint8_t axis) {
1127 1127
 
1128 1128
 void finishAndDisableSteppers() {
1129 1129
   st_synchronize();
1130
-  disable_x();
1131
-  disable_y();
1132
-  disable_z();
1133
-  disable_e0();
1134
-  disable_e1();
1135
-  disable_e2();
1136
-  disable_e3();
1130
+  disable_all_steppers();
1137 1131
 }
1138 1132
 
1139 1133
 void quickStop() {

+ 76
- 79
Marlin/temperature.cpp View File

@@ -1,5 +1,5 @@
1 1
 /*
2
-  temperature.c - temperature control
2
+  temperature.cpp - temperature control
3 3
   Part of Marlin
4 4
   
5 5
  Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
@@ -16,18 +16,7 @@
16 16
  
17 17
  You should have received a copy of the GNU General Public License
18 18
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
- */
20
-
21
-/*
22
- This firmware is a mashup between Sprinter and grbl.
23
-  (https://github.com/kliment/Sprinter)
24
-  (https://github.com/simen/grbl/tree)
25
- 
26
- It has preliminary support for Matthew Roberts advance algorithm 
27
-    http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
28
-
29
- */
30
-
19
+*/
31 20
 
32 21
 #include "Marlin.h"
33 22
 #include "ultralcd.h"
@@ -87,14 +76,15 @@ unsigned char soft_pwm_bed;
87 76
 #define HAS_HEATER_THERMAL_PROTECTION (defined(THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0)
88 77
 #define HAS_BED_THERMAL_PROTECTION (defined(THERMAL_RUNAWAY_PROTECTION_BED_PERIOD) && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0 && TEMP_SENSOR_BED != 0)
89 78
 #if HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION
79
+  enum TRState { TRInactive, TRFirstHeating, TRStable };
90 80
   static bool thermal_runaway = false;
91
-  void thermal_runaway_protection(int *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc);
81
+  void thermal_runaway_protection(TRState *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc);
92 82
   #if HAS_HEATER_THERMAL_PROTECTION
93
-    static int thermal_runaway_state_machine[4]; // = {0,0,0,0};
83
+    static TRState thermal_runaway_state_machine[4] = { TRInactive, TRInactive, TRInactive, TRInactive };
94 84
     static unsigned long thermal_runaway_timer[4]; // = {0,0,0,0};
95 85
   #endif
96 86
   #if HAS_BED_THERMAL_PROTECTION
97
-    static int thermal_runaway_bed_state_machine;
87
+    static TRState thermal_runaway_bed_state_machine = { TRInactive, TRInactive, TRInactive, TRInactive };
98 88
     static unsigned long thermal_runaway_bed_timer;
99 89
   #endif
100 90
 #endif
@@ -238,7 +228,7 @@ void PID_autotune(float temp, int extruder, int ncycles)
238 228
     soft_pwm[extruder] = bias = d = PID_MAX / 2;
239 229
 
240 230
   // PID Tuning loop
241
-  for(;;) {
231
+  for (;;) {
242 232
 
243 233
     unsigned long ms = millis();
244 234
 
@@ -609,7 +599,7 @@ void manage_heater() {
609 599
   // Loop through all extruders
610 600
   for (int e = 0; e < EXTRUDERS; e++) {
611 601
 
612
-    #if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0
602
+    #if HAS_HEATER_THERMAL_PROTECTION
613 603
       thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_RUNAWAY_PROTECTION_PERIOD, THERMAL_RUNAWAY_PROTECTION_HYSTERESIS);
614 604
     #endif
615 605
 
@@ -637,7 +627,7 @@ void manage_heater() {
637 627
         disable_heater();
638 628
         _temp_error(0, PSTR(MSG_EXTRUDER_SWITCHED_OFF), PSTR(MSG_ERR_REDUNDANT_TEMP));
639 629
       }
640
-    #endif //TEMP_SENSOR_1_AS_REDUNDANT
630
+    #endif // TEMP_SENSOR_1_AS_REDUNDANT
641 631
 
642 632
   } // Extruders Loop
643 633
 
@@ -656,7 +646,7 @@ void manage_heater() {
656 646
   #if TEMP_SENSOR_BED != 0
657 647
   
658 648
     #if HAS_BED_THERMAL_PROTECTION
659
-      thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, 9, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS);
649
+      thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, -1, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS);
660 650
     #endif
661 651
 
662 652
     #ifdef PIDTEMPBED
@@ -1014,69 +1004,76 @@ void setWatch() {
1014 1004
 }
1015 1005
 
1016 1006
 #if HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION
1017
-void thermal_runaway_protection(int *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc)
1018
-{
1019
-/*
1020
-      SERIAL_ECHO_START;
1021
-      SERIAL_ECHO("Thermal Thermal Runaway Running. Heater ID:");
1022
-      SERIAL_ECHO(heater_id);
1023
-      SERIAL_ECHO(" ;  State:");
1024
-      SERIAL_ECHO(*state);
1025
-      SERIAL_ECHO(" ;  Timer:");
1026
-      SERIAL_ECHO(*timer);
1027
-      SERIAL_ECHO(" ;  Temperature:");
1028
-      SERIAL_ECHO(temperature);
1029
-      SERIAL_ECHO(" ;  Target Temp:");
1030
-      SERIAL_ECHO(target_temperature);
1031
-      SERIAL_ECHOLN("");    
1032
-*/
1033
-  if ((target_temperature == 0) || thermal_runaway)
1034
-  {
1035
-    *state = 0;
1036
-    *timer = 0;
1037
-    return;
1038
-  }
1039
-  switch (*state)
1040
-  {
1041
-    case 0: // "Heater Inactive" state
1042
-      if (target_temperature > 0) *state = 1;
1043
-      break;
1044
-    case 1: // "First Heating" state
1045
-      if (temperature >= target_temperature) *state = 2;
1046
-      break;
1047
-    case 2: // "Temperature Stable" state
1048
-    {
1049
-      unsigned long ms = millis();
1050
-      if (temperature >= (target_temperature - hysteresis_degc))
1051
-      {
1052
-        *timer = ms;
1053
-      } 
1054
-      else if ( (ms - *timer) > ((unsigned long) period_seconds) * 1000)
1007
+
1008
+  void thermal_runaway_protection(TRState *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) {
1009
+
1010
+    static int tr_target_temperature[EXTRUDERS+1];
1011
+
1012
+    /*
1013
+        SERIAL_ECHO_START;
1014
+        SERIAL_ECHOPGM("Thermal Thermal Runaway Running. Heater ID: ");
1015
+        if (heater_id < 0) SERIAL_ECHOPGM("bed"); else SERIAL_ECHOPGM(heater_id);
1016
+        SERIAL_ECHOPGM(" ;  State:");
1017
+        SERIAL_ECHOPGM(*state);
1018
+        SERIAL_ECHOPGM(" ;  Timer:");
1019
+        SERIAL_ECHOPGM(*timer);
1020
+        SERIAL_ECHOPGM(" ;  Temperature:");
1021
+        SERIAL_ECHOPGM(temperature);
1022
+        SERIAL_ECHOPGM(" ;  Target Temp:");
1023
+        SERIAL_ECHOPGM(target_temperature);
1024
+        SERIAL_EOL;
1025
+    */
1026
+    if (target_temperature == 0 || thermal_runaway) {
1027
+      *state = TRInactive;
1028
+      *timer = 0;
1029
+      return;
1030
+    }
1031
+
1032
+    int heater_index = heater_id >= 0 ? heater_id : EXTRUDERS;
1033
+
1034
+    switch (*state) {
1035
+      // Inactive state waits for a target temperature to be set
1036
+      case TRInactive:
1037
+        if (target_temperature > 0) {
1038
+          *state = TRFirstHeating;
1039
+          tr_target_temperature[heater_index] = target_temperature;
1040
+        }
1041
+        break;
1042
+      // When first heating, wait for the temperature to be reached then go to Stable state
1043
+      case TRFirstHeating:
1044
+        if (temperature >= tr_target_temperature[heater_index]) *state = TRStable;
1045
+        break;
1046
+      // While the temperature is stable watch for a bad temperature
1047
+      case TRStable:
1055 1048
       {
1056
-        SERIAL_ERROR_START;
1057
-        SERIAL_ERRORLNPGM(MSG_THERMAL_RUNAWAY_STOP);
1058
-        SERIAL_ERRORLN((int)heater_id);
1059
-        LCD_ALERTMESSAGEPGM(MSG_THERMAL_RUNAWAY); // translatable
1060
-        thermal_runaway = true;
1061
-        while(1)
1062
-        {
1063
-          disable_heater();
1064
-          disable_x();
1065
-          disable_y();
1066
-          disable_z();
1067
-          disable_e0();
1068
-          disable_e1();
1069
-          disable_e2();
1070
-          disable_e3();
1071
-          manage_heater();
1072
-          lcd_update();
1049
+        // If the target temperature changes, restart
1050
+        if (tr_target_temperature[heater_index] != target_temperature) {
1051
+          *state = TRInactive;
1052
+          break;
1073 1053
         }
1074
-      }
1075
-    } break;
1054
+
1055
+        // If the temperature is over the target (-hysteresis) restart the timer
1056
+        if (temperature >= tr_target_temperature[heater_index] - hysteresis_degc) *timer = millis();
1057
+
1058
+        // If the timer goes too long without a reset, trigger shutdown
1059
+        else if (millis() > *timer + period_seconds * 1000UL) {
1060
+          SERIAL_ERROR_START;
1061
+          SERIAL_ERRORLNPGM(MSG_THERMAL_RUNAWAY_STOP);
1062
+          if (heater_id < 0) SERIAL_ERRORLNPGM("bed"); else SERIAL_ERRORLN(heater_id);
1063
+          LCD_ALERTMESSAGEPGM(MSG_THERMAL_RUNAWAY);
1064
+          thermal_runaway = true;
1065
+          for (;;) {
1066
+            disable_heater();
1067
+            disable_all_steppers();
1068
+            manage_heater();
1069
+            lcd_update();
1070
+          }
1071
+        }
1072
+      } break;
1073
+    }
1076 1074
   }
1077
-}
1078
-#endif //THERMAL_RUNAWAY_PROTECTION_PERIOD
1079 1075
 
1076
+#endif // HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION
1080 1077
 
1081 1078
 void disable_heater() {
1082 1079
   for (int i=0; i<EXTRUDERS; i++) setTargetHotend(0, i);

+ 17
- 31
Marlin/temperature.h View File

@@ -18,8 +18,8 @@
18 18
   along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
19 19
 */
20 20
 
21
-#ifndef temperature_h
22
-#define temperature_h 
21
+#ifndef TEMPERATURE_H
22
+#define TEMPERATURE_H 
23 23
 
24 24
 #include "Marlin.h"
25 25
 #include "planner.h"
@@ -72,11 +72,11 @@ extern float current_temperature_bed;
72 72
   float unscalePID_d(float d);
73 73
 
74 74
 #endif
75
+
75 76
 #ifdef PIDTEMPBED
76 77
   extern float bedKp,bedKi,bedKd;
77 78
 #endif
78 79
   
79
-  
80 80
 #ifdef BABYSTEPPING
81 81
   extern volatile int babystepsTodo[3];
82 82
 #endif
@@ -105,40 +105,27 @@ FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_tempe
105 105
 FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { return target_temperature[extruder] < current_temperature[extruder]; }
106 106
 FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; }
107 107
 
108
-#define degHotend0() degHotend(0)
109
-#define degTargetHotend0() degTargetHotend(0)
110
-#define setTargetHotend0(_celsius) setTargetHotend((_celsius), 0)
111
-#define isHeatingHotend0() isHeatingHotend(0)
112
-#define isCoolingHotend0() isCoolingHotend(0)
108
+#define HOTEND_ROUTINES(NR) \
109
+  FORCE_INLINE float degHotend##NR() { return degHotend(NR); } \
110
+  FORCE_INLINE float degTargetHotend##NR() { return degTargetHotend(NR); } \
111
+  FORCE_INLINE void setTargetHotend##NR(const float c) { setTargetHotend(c, NR); } \
112
+  FORCE_INLINE bool isHeatingHotend##NR() { return isHeatingHotend(NR); } \
113
+  FORCE_INLINE bool isCoolingHotend##NR() { return isCoolingHotend(NR); }
114
+HOTEND_ROUTINES(0);
113 115
 #if EXTRUDERS > 1
114
-  #define degHotend1() degHotend(1)
115
-  #define degTargetHotend1() degTargetHotend(1)
116
-  #define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1)
117
-  #define isHeatingHotend1() isHeatingHotend(1)
118
-  #define isCoolingHotend1() isCoolingHotend(1)
116
+  HOTEND_ROUTINES(1);
119 117
 #else
120
-  #define setTargetHotend1(_celsius) do{}while(0)
118
+  #define setTargetHotend1(c) do{}while(0)
121 119
 #endif
122 120
 #if EXTRUDERS > 2
123
-  #define degHotend2() degHotend(2)
124
-  #define degTargetHotend2() degTargetHotend(2)
125
-  #define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2)
126
-  #define isHeatingHotend2() isHeatingHotend(2)
127
-  #define isCoolingHotend2() isCoolingHotend(2)
121
+  HOTEND_ROUTINES(2);
128 122
 #else
129
-  #define setTargetHotend2(_celsius) do{}while(0)
123
+  #define setTargetHotend2(c) do{}while(0)
130 124
 #endif
131 125
 #if EXTRUDERS > 3
132
-  #define degHotend3() degHotend(3)
133
-  #define degTargetHotend3() degTargetHotend(3)
134
-  #define setTargetHotend3(_celsius) setTargetHotend((_celsius), 3)
135
-  #define isHeatingHotend3() isHeatingHotend(3)
136
-  #define isCoolingHotend3() isCoolingHotend(3)
126
+  HOTEND_ROUTINES(3);
137 127
 #else
138
-  #define setTargetHotend3(_celsius) do{}while(0)
139
-#endif
140
-#if EXTRUDERS > 4
141
-  #error Invalid number of extruders
128
+  #define setTargetHotend3(c) do{}while(0)
142 129
 #endif
143 130
 
144 131
 int getHeaterPower(int heater);
@@ -161,5 +148,4 @@ FORCE_INLINE void autotempShutdown() {
161 148
   #endif
162 149
 }
163 150
 
164
-
165
-#endif
151
+#endif // TEMPERATURE_H

+ 5
- 5
README.md View File

@@ -18,8 +18,8 @@
18 18
 ## Quick Information
19 19
 
20 20
 This is a firmware for reprap single-processor electronics setups.
21
-It also works on the Ultimaker PCB. It supports printing from SD card+Folders, and look-ahead trajectory planning.
22
-This firmware is a mashup between [Sprinter](https://github.com/kliment/Sprinter), [grbl](https://github.com/simen/grbl) and many original parts.
21
+It also works on the Ultimaker PCB. It supports printing from SD card+Folders and look-ahead trajectory planning.
22
+This firmware is a mashup between [Sprinter](https://github.com/kliment/Sprinter), [grbl](https://github.com/simen/grbl), and many original parts.
23 23
 
24 24
 ## Current Status: Bug Fixing
25 25
 
@@ -31,7 +31,7 @@ We are actively looking for testers. So please try the current development versi
31 31
 
32 32
 ## Contact
33 33
 
34
-__IRC:__ #marlin-firmware @freenode ([WebChat Client](https://webchat.freenode.net/?channels=marlin-firmware)
34
+__IRC:__ #marlin-firmware @freenode ([WebChat Client](https://webchat.freenode.net/?channels=marlin-firmware))
35 35
 
36 36
 ## Credits
37 37
 
@@ -41,8 +41,8 @@ The current Marlin dev team consists of:
41 41
  - [@daid](https://github.com/daid)
42 42
 
43 43
 Sprinters lead developers are Kliment and caru.
44
-Grbls lead developer is Simen Svale Skogsrud.
45
-Sonney Jeon (Chamnit) improved some parts of grbl
44
+Grbl's lead developer is Simen Svale Skogsrud.
45
+Sonney Jeon (Chamnit) improved some parts of grbl.
46 46
 A fork by bkubicek for the Ultimaker was merged.
47 47
 
48 48
 More features have been added by:

Loading…
Cancel
Save