Browse Source

Merge pull request #1896 from thinkyhead/cold_extrude

Homing fixes
Scott Lahteine 9 years ago
parent
commit
e7aae314de

+ 1
- 1
Marlin/Configuration.h View File

70
 
70
 
71
 // Optional custom name for your RepStrap or other custom machine
71
 // Optional custom name for your RepStrap or other custom machine
72
 // Displayed in the LCD "Ready" message
72
 // Displayed in the LCD "Ready" message
73
-// #define CUSTOM_MACHINE_NAME "This RepRap"
73
+// #define CUSTOM_MACHINE_NAME "3D Printer"
74
 
74
 
75
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
75
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
76
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)
76
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)

+ 89
- 74
Marlin/Marlin_main.cpp View File

850
 
850
 
851
 }
851
 }
852
 
852
 
853
+float code_has_value() {
854
+  char c = *(strchr_pointer + 1);
855
+  return (c >= '0' && c <= '9') || c == '-' || c == '+' || c == '.';
856
+}
857
+
853
 float code_value() {
858
 float code_value() {
854
   float ret;
859
   float ret;
855
   char *e = strchr(strchr_pointer, 'E');
860
   char *e = strchr(strchr_pointer, 'E');
1814
 
1819
 
1815
     home_all_axis = !(homeX || homeY || homeZ) || (homeX && homeY && homeZ);
1820
     home_all_axis = !(homeX || homeY || homeZ) || (homeX && homeY && homeZ);
1816
 
1821
 
1817
-    #if Z_HOME_DIR > 0                      // If homing away from BED do Z first
1822
+    if (home_all_axis || homeZ) {
1818
 
1823
 
1819
-      if (home_all_axis || homeZ) HOMEAXIS(Z);
1824
+      #if Z_HOME_DIR > 0  // If homing away from BED do Z first
1820
 
1825
 
1821
-    #elif !defined(Z_SAFE_HOMING) && defined(Z_RAISE_BEFORE_HOMING) && Z_RAISE_BEFORE_HOMING > 0
1826
+        HOMEAXIS(Z);
1822
 
1827
 
1823
-      // Raise Z before homing any other axes
1824
-      if (home_all_axis || homeZ) {
1825
-        destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS);    // Set destination away from bed
1828
+      #elif !defined(Z_SAFE_HOMING) && defined(Z_RAISE_BEFORE_HOMING) && Z_RAISE_BEFORE_HOMING > 0
1829
+
1830
+        // Raise Z before homing any other axes
1831
+        // (Does this need to be "negative home direction?" Why not just use Z_RAISE_BEFORE_HOMING?)
1832
+        destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS);
1826
         feedrate = max_feedrate[Z_AXIS] * 60;
1833
         feedrate = max_feedrate[Z_AXIS] * 60;
1827
         line_to_destination();
1834
         line_to_destination();
1828
         st_synchronize();
1835
         st_synchronize();
1829
-      }
1830
 
1836
 
1831
-    #endif
1837
+      #endif
1838
+
1839
+    } // home_all_axis || homeZ
1832
 
1840
 
1833
     #ifdef QUICK_HOME
1841
     #ifdef QUICK_HOME
1834
 
1842
 
1897
     if (home_all_axis || homeY) HOMEAXIS(Y);
1905
     if (home_all_axis || homeY) HOMEAXIS(Y);
1898
 
1906
 
1899
     // Set the X position, if included
1907
     // Set the X position, if included
1900
-    // Adds the home_offset as well, which may be wrong
1901
-    if (code_seen(axis_codes[X_AXIS])) {
1902
-      float v = code_value();
1903
-      if (v) current_position[X_AXIS] = v
1904
-        #ifndef SCARA
1905
-          + home_offset[X_AXIS]
1906
-        #endif
1907
-      ;
1908
-    }
1908
+    if (code_seen(axis_codes[X_AXIS]) && code_has_value())
1909
+      current_position[X_AXIS] = code_value();
1909
 
1910
 
1910
     // Set the Y position, if included
1911
     // Set the Y position, if included
1911
-    // Adds the home_offset as well, which may be wrong
1912
-    if (code_seen(axis_codes[Y_AXIS])) {
1913
-      float v = code_value();
1914
-      if (v) current_position[Y_AXIS] = v
1915
-        #ifndef SCARA
1916
-          + home_offset[Y_AXIS]
1917
-        #endif
1918
-      ;
1919
-    }
1912
+    if (code_seen(axis_codes[Y_AXIS]) && code_has_value())
1913
+      current_position[Y_AXIS] = code_value();
1920
 
1914
 
1921
     // Home Z last if homing towards the bed
1915
     // Home Z last if homing towards the bed
1922
     #if Z_HOME_DIR < 0
1916
     #if Z_HOME_DIR < 0
1923
 
1917
 
1924
-      #ifndef Z_SAFE_HOMING
1918
+      if (home_all_axis || homeZ) {
1925
 
1919
 
1926
-        if (home_all_axis || homeZ) HOMEAXIS(Z);
1920
+        #ifdef Z_SAFE_HOMING
1927
 
1921
 
1928
-      #else // Z_SAFE_HOMING
1922
+          if (home_all_axis) {
1929
 
1923
 
1930
-        if (home_all_axis) {
1931
-          destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER);
1932
-          destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER);
1933
-          destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS);    // Set destination away from bed
1934
-          feedrate = XY_TRAVEL_SPEED;
1935
-          current_position[Z_AXIS] = 0;
1924
+            current_position[Z_AXIS] = 0;
1925
+            sync_plan_position();
1936
 
1926
 
1937
-          sync_plan_position();
1938
-          line_to_destination();
1939
-          st_synchronize();
1940
-          current_position[X_AXIS] = destination[X_AXIS];
1941
-          current_position[Y_AXIS] = destination[Y_AXIS];
1927
+            //
1928
+            // Set the probe (or just the nozzle) destination to the safe homing point
1929
+            //
1930
+            // NOTE: If current_position[X_AXIS] or current_position[Y_AXIS] were set above
1931
+            // then this may not work as expected.
1932
+            destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER);
1933
+            destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER);
1934
+            destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS);    // Set destination away from bed
1935
+            feedrate = XY_TRAVEL_SPEED;
1936
+            // This could potentially move X, Y, Z all together
1937
+            line_to_destination();
1938
+            st_synchronize();
1942
 
1939
 
1943
-          HOMEAXIS(Z);
1944
-        }
1940
+            // Set current X, Y is the Z_SAFE_HOMING_POINT minus PROBE_OFFSET_FROM_EXTRUDER
1941
+            current_position[X_AXIS] = destination[X_AXIS];
1942
+            current_position[Y_AXIS] = destination[Y_AXIS];
1945
 
1943
 
1946
-        // Let's see if X and Y are homed and probe is inside bed area.
1947
-        if (homeZ) {
1948
-
1949
-          if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) {
1950
-
1951
-            float cpx = current_position[X_AXIS], cpy = current_position[Y_AXIS];
1952
-            if (   cpx >= X_MIN_POS - X_PROBE_OFFSET_FROM_EXTRUDER
1953
-                && cpx <= X_MAX_POS - X_PROBE_OFFSET_FROM_EXTRUDER
1954
-                && cpy >= Y_MIN_POS - Y_PROBE_OFFSET_FROM_EXTRUDER
1955
-                && cpy <= Y_MAX_POS - Y_PROBE_OFFSET_FROM_EXTRUDER) {
1956
-              current_position[Z_AXIS] = 0;
1957
-              plan_set_position(cpx, cpy, 0, current_position[E_AXIS]);
1958
-              destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS);    // Set destination away from bed
1959
-              feedrate = max_feedrate[Z_AXIS] * 60;  // max_feedrate is in mm/s. line_to_destination is feedrate/60.
1960
-              line_to_destination();
1961
-              st_synchronize();
1962
-              HOMEAXIS(Z);
1963
-            }
1964
-            else {
1944
+            // Home the Z axis
1945
+            HOMEAXIS(Z);
1946
+          }
1947
+
1948
+          else if (homeZ) { // Don't need to Home Z twice
1949
+
1950
+            // Let's see if X and Y are homed
1951
+            if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) {
1952
+
1953
+              // Make sure the probe is within the physical limits
1954
+              // NOTE: This doesn't necessarily ensure the probe is also within the bed!
1955
+              float cpx = current_position[X_AXIS], cpy = current_position[Y_AXIS];
1956
+              if (   cpx >= X_MIN_POS - X_PROBE_OFFSET_FROM_EXTRUDER
1957
+                  && cpx <= X_MAX_POS - X_PROBE_OFFSET_FROM_EXTRUDER
1958
+                  && cpy >= Y_MIN_POS - Y_PROBE_OFFSET_FROM_EXTRUDER
1959
+                  && cpy <= Y_MAX_POS - Y_PROBE_OFFSET_FROM_EXTRUDER) {
1960
+                // Set the plan current position to X, Y, 0
1961
+                current_position[Z_AXIS] = 0;
1962
+                plan_set_position(cpx, cpy, 0, current_position[E_AXIS]); // = sync_plan_position
1963
+
1964
+                // Set Z destination away from bed and raise the axis
1965
+                // NOTE: This should always just be Z_RAISE_BEFORE_HOMING unless...???
1966
+                destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS);
1967
+                feedrate = max_feedrate[Z_AXIS] * 60;  // feedrate (mm/m) = max_feedrate (mm/s)
1968
+                line_to_destination();
1969
+                st_synchronize();
1970
+
1971
+                // Home the Z axis
1972
+                HOMEAXIS(Z);
1973
+              }
1974
+              else {
1965
                 LCD_MESSAGEPGM(MSG_ZPROBE_OUT);
1975
                 LCD_MESSAGEPGM(MSG_ZPROBE_OUT);
1966
                 SERIAL_ECHO_START;
1976
                 SERIAL_ECHO_START;
1967
                 SERIAL_ECHOLNPGM(MSG_ZPROBE_OUT);
1977
                 SERIAL_ECHOLNPGM(MSG_ZPROBE_OUT);
1978
+              }
1968
             }
1979
             }
1969
-          }
1970
-          else {
1971
-            LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN);
1972
-            SERIAL_ECHO_START;
1973
-            SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN);
1974
-          }
1975
-        }
1980
+            else {
1981
+              LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN);
1982
+              SERIAL_ECHO_START;
1983
+              SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN);
1984
+            }
1985
+
1986
+          } // !home_all_axes && homeZ
1976
 
1987
 
1977
-      #endif // Z_SAFE_HOMING
1988
+        #else // !Z_SAFE_HOMING
1989
+
1990
+          HOMEAXIS(Z);
1991
+
1992
+        #endif // !Z_SAFE_HOMING
1993
+
1994
+      } // home_all_axis || homeZ
1978
 
1995
 
1979
     #endif // Z_HOME_DIR < 0
1996
     #endif // Z_HOME_DIR < 0
1980
 
1997
 
1981
     // Set the Z position, if included
1998
     // Set the Z position, if included
1982
-    // Adds the home_offset as well, which may be wrong
1983
-    if (code_seen(axis_codes[Z_AXIS])) {
1984
-      float v = code_value();
1985
-      if (v) current_position[Z_AXIS] = v + home_offset[Z_AXIS];
1986
-    }
1999
+    if (code_seen(axis_codes[Z_AXIS]) && code_has_value())
2000
+      current_position[Z_AXIS] = code_value();
1987
 
2001
 
1988
     #if defined(ENABLE_AUTO_BED_LEVELING) && (Z_HOME_DIR < 0)
2002
     #if defined(ENABLE_AUTO_BED_LEVELING) && (Z_HOME_DIR < 0)
1989
       if (home_all_axis || homeZ) current_position[Z_AXIS] += zprobe_zoffset;  // Add Z_Probe offset (the distance is negative)
2003
       if (home_all_axis || homeZ) current_position[Z_AXIS] += zprobe_zoffset;  // Add Z_Probe offset (the distance is negative)
1990
     #endif
2004
     #endif
2005
+
1991
     sync_plan_position();
2006
     sync_plan_position();
1992
 
2007
 
1993
   #endif // else DELTA
2008
   #endif // else DELTA

+ 1
- 1
Marlin/configurator/config/Configuration.h View File

70
 
70
 
71
 // Optional custom name for your RepStrap or other custom machine
71
 // Optional custom name for your RepStrap or other custom machine
72
 // Displayed in the LCD "Ready" message
72
 // Displayed in the LCD "Ready" message
73
-// #define CUSTOM_MACHINE_NAME "This RepRap"
73
+// #define CUSTOM_MACHINE_NAME "3D Printer"
74
 
74
 
75
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
75
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
76
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)
76
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)

+ 1
- 1
Marlin/example_configurations/Hephestos/Configuration.h View File

64
 
64
 
65
 // Optional custom name for your RepStrap or other custom machine
65
 // Optional custom name for your RepStrap or other custom machine
66
 // Displayed in the LCD "Ready" message
66
 // Displayed in the LCD "Ready" message
67
-// #define CUSTOM_MACHINE_NAME "This RepRap"
67
+// #define CUSTOM_MACHINE_NAME "3D Printer"
68
  
68
  
69
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
69
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
70
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)
70
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)

+ 1
- 1
Marlin/example_configurations/K8200/Configuration.h View File

64
 
64
 
65
 // Optional custom name for your RepStrap or other custom machine
65
 // Optional custom name for your RepStrap or other custom machine
66
 // Displayed in the LCD "Ready" message
66
 // Displayed in the LCD "Ready" message
67
-// #define CUSTOM_MACHINE_NAME "This RepRap"
67
+// #define CUSTOM_MACHINE_NAME "3D Printer"
68
 
68
 
69
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
69
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
70
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)
70
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)

+ 1
- 1
Marlin/example_configurations/SCARA/Configuration.h View File

82
 
82
 
83
 // Optional custom name for your RepStrap or other custom machine
83
 // Optional custom name for your RepStrap or other custom machine
84
 // Displayed in the LCD "Ready" message
84
 // Displayed in the LCD "Ready" message
85
-// #define CUSTOM_MACHINE_NAME "This RepRap"
85
+// #define CUSTOM_MACHINE_NAME "3D Printer"
86
 
86
 
87
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
87
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
88
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)
88
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)

+ 1
- 1
Marlin/example_configurations/WITBOX/Configuration.h View File

64
 
64
 
65
 // Optional custom name for your RepStrap or other custom machine
65
 // Optional custom name for your RepStrap or other custom machine
66
 // Displayed in the LCD "Ready" message
66
 // Displayed in the LCD "Ready" message
67
-// #define CUSTOM_MACHINE_NAME "This RepRap"
67
+// #define CUSTOM_MACHINE_NAME "3D Printer"
68
 
68
 
69
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
69
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
70
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)
70
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)

+ 1
- 1
Marlin/example_configurations/makibox/Configuration.h View File

64
 
64
 
65
 // Optional custom name for your RepStrap or other custom machine
65
 // Optional custom name for your RepStrap or other custom machine
66
 // Displayed in the LCD "Ready" message
66
 // Displayed in the LCD "Ready" message
67
-// #define CUSTOM_MACHINE_NAME "This RepRap"
67
+// #define CUSTOM_MACHINE_NAME "3D Printer"
68
 
68
 
69
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
69
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
70
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)
70
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)

+ 1
- 1
Marlin/example_configurations/tvrrug/Round2/Configuration.h View File

64
 
64
 
65
 // Optional custom name for your RepStrap or other custom machine
65
 // Optional custom name for your RepStrap or other custom machine
66
 // Displayed in the LCD "Ready" message
66
 // Displayed in the LCD "Ready" message
67
-// #define CUSTOM_MACHINE_NAME "This RepRap"
67
+// #define CUSTOM_MACHINE_NAME "3D Printer"
68
 
68
 
69
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
69
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
70
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)
70
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)

+ 1
- 1
Marlin/language.h View File

70
   #endif
70
   #endif
71
 #else
71
 #else
72
   #ifndef MACHINE_NAME
72
   #ifndef MACHINE_NAME
73
-    #define MACHINE_NAME "Mendel"
73
+    #define MACHINE_NAME "3D Printer"
74
   #endif
74
   #endif
75
 #endif
75
 #endif
76
 
76
 

+ 4
- 4
Marlin/planner.cpp View File

504
 
504
 
505
   #ifdef PREVENT_DANGEROUS_EXTRUDE
505
   #ifdef PREVENT_DANGEROUS_EXTRUDE
506
     if (de) {
506
     if (de) {
507
-      if (degHotend(active_extruder) < extrude_min_temp) {
507
+      if (degHotend(extruder) < extrude_min_temp) {
508
         position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
508
         position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
509
         de = 0; // no difference
509
         de = 0; // no difference
510
         SERIAL_ECHO_START;
510
         SERIAL_ECHO_START;
541
 
541
 
542
   block->steps[Z_AXIS] = labs(dz);
542
   block->steps[Z_AXIS] = labs(dz);
543
   block->steps[E_AXIS] = labs(de);
543
   block->steps[E_AXIS] = labs(de);
544
-  block->steps[E_AXIS] *= volumetric_multiplier[active_extruder];
545
-  block->steps[E_AXIS] *= extruder_multiply[active_extruder];
544
+  block->steps[E_AXIS] *= volumetric_multiplier[extruder];
545
+  block->steps[E_AXIS] *= extruder_multiply[extruder];
546
   block->steps[E_AXIS] /= 100;
546
   block->steps[E_AXIS] /= 100;
547
   block->step_event_count = max(block->steps[X_AXIS], max(block->steps[Y_AXIS], max(block->steps[Z_AXIS], block->steps[E_AXIS])));
547
   block->step_event_count = max(block->steps[X_AXIS], max(block->steps[Y_AXIS], max(block->steps[Z_AXIS], block->steps[E_AXIS])));
548
 
548
 
676
     delta_mm[Y_AXIS] = dy / axis_steps_per_unit[Y_AXIS];
676
     delta_mm[Y_AXIS] = dy / axis_steps_per_unit[Y_AXIS];
677
   #endif
677
   #endif
678
   delta_mm[Z_AXIS] = dz / axis_steps_per_unit[Z_AXIS];
678
   delta_mm[Z_AXIS] = dz / axis_steps_per_unit[Z_AXIS];
679
-  delta_mm[E_AXIS] = (de / axis_steps_per_unit[E_AXIS]) * volumetric_multiplier[active_extruder] * extruder_multiply[active_extruder] / 100.0;
679
+  delta_mm[E_AXIS] = (de / axis_steps_per_unit[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiply[extruder] / 100.0;
680
 
680
 
681
   if (block->steps[X_AXIS] <= dropsegments && block->steps[Y_AXIS] <= dropsegments && block->steps[Z_AXIS] <= dropsegments) {
681
   if (block->steps[X_AXIS] <= dropsegments && block->steps[Y_AXIS] <= dropsegments && block->steps[Z_AXIS] <= dropsegments) {
682
     block->millimeters = fabs(delta_mm[E_AXIS]);
682
     block->millimeters = fabs(delta_mm[E_AXIS]);

+ 1
- 4
Marlin/stepper.cpp View File

1072
       TCCR0A &= ~BIT(WGM01);
1072
       TCCR0A &= ~BIT(WGM01);
1073
       TCCR0A &= ~BIT(WGM00);
1073
       TCCR0A &= ~BIT(WGM00);
1074
     #endif
1074
     #endif
1075
-    e_steps[0] = 0;
1076
-    e_steps[1] = 0;
1077
-    e_steps[2] = 0;
1078
-    e_steps[3] = 0;
1075
+    e_steps[0] = e_steps[1] = e_steps[2] = e_steps[3] = 0;
1079
     TIMSK0 |= BIT(OCIE0A);
1076
     TIMSK0 |= BIT(OCIE0A);
1080
   #endif //ADVANCE
1077
   #endif //ADVANCE
1081
 
1078
 

Loading…
Cancel
Save