Browse Source

Merge pull request #383 from dob71/jeff

Hotend offset handling for multi-extruder machines
daid 11 years ago
parent
commit
3e9cd334a4
4 changed files with 1542 additions and 1460 deletions
  1. 7
    1
      Marlin/Configuration.h
  2. 69
    11
      Marlin/Marlin_main.cpp
  3. 1464
    1446
      Marlin/language.h
  4. 2
    2
      Marlin/thermistortables.h

+ 7
- 1
Marlin/Configuration.h View File

@@ -286,7 +286,13 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
286 286
 #define DEFAULT_ACCELERATION          3000    // X, Y, Z and E max acceleration in mm/s^2 for printing moves 
287 287
 #define DEFAULT_RETRACT_ACCELERATION  3000   // X, Y, Z and E max acceleration in mm/s^2 for r retracts
288 288
 
289
-// 
289
+// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
290
+// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
291
+// For the other hotends it is their distance from the extruder 0 hotend.
292
+// #define EXTRUDER_OFFSET_X {0.0, 20.00} // (in mm) for each extruder, offset of the hotend on the X axis
293
+// #define EXTRUDER_OFFSET_Y {0.0, 5.00}  // (in mm) for each extruder, offset of the hotend on the Y axis
294
+
295
+// The speed change that does not require acceleration (i.e. the software might assume it can be done instanteneously)
290 296
 #define DEFAULT_XYJERK                20.0    // (mm/sec)
291 297
 #define DEFAULT_ZJERK                 0.4     // (mm/sec)
292 298
 #define DEFAULT_EJERK                 5.0    // (mm/sec)

+ 69
- 11
Marlin/Marlin_main.cpp View File

@@ -113,6 +113,7 @@
113 113
 // M207 - set retract length S[positive mm] F[feedrate mm/sec] Z[additional zlift/hop]
114 114
 // M208 - set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec]
115 115
 // M209 - S<1=true/0=false> enable automatic retract detect if the slicer did not support G10/11: every normal extrude-only move will be classified as retract depending on the direction.
116
+// M218 - set hotend offset (in mm): T<extruder_number> X<offset_on_X> Y<offset_on_Y>
116 117
 // M220 S<factor in percent>- set speed factor override percentage
117 118
 // M221 S<factor in percent>- set extrude factor override percentage
118 119
 // M240 - Trigger a camera to take a photograph
@@ -124,7 +125,7 @@
124 125
 // M500 - stores paramters in EEPROM
125 126
 // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).  
126 127
 // M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
127
-// M503 - print the current settings (from memory not from eeprom)
128
+// M503 - print the current settings (from memory not from eeprom)
128 129
 // M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
129 130
 // M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
130 131
 // M907 - Set digital trimpot motor current using axis codes.
@@ -155,6 +156,12 @@ float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
155 156
 float add_homeing[3]={0,0,0};
156 157
 float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
157 158
 float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
159
+// Extruder offset, only in XY plane
160
+float extruder_offset[2][EXTRUDERS] = { 
161
+#if defined(EXTRUDER_OFFSET_X) && defined(EXTRUDER_OFFSET_Y)
162
+  EXTRUDER_OFFSET_X, EXTRUDER_OFFSET_Y 
163
+#endif
164
+}; 
158 165
 uint8_t active_extruder = 0;
159 166
 int fanSpeed=0;
160 167
 
@@ -1353,7 +1360,6 @@ void process_commands()
1353 1360
         retract_recover_feedrate = code_value() ;
1354 1361
       }
1355 1362
     }break;
1356
-    
1357 1363
     case 209: // M209 - S<1=true/0=false> enable automatic retract detect if the slicer did not support G10/11: every normal extrude-only move will be classified as retract depending on the direction.
1358 1364
     {
1359 1365
       if(code_seen('S')) 
@@ -1372,7 +1378,31 @@ void process_commands()
1372 1378
       }
1373 1379
       
1374 1380
     }break;
1375
-    #endif
1381
+    #endif // FWRETRACT
1382
+    case 218: // M218 - set hotend offset (in mm), T<extruder_number> X<offset_on_X> Y<offset_on_Y>
1383
+    {
1384
+      if(setTargetedHotend(218)){
1385
+        break;
1386
+      }
1387
+      if(code_seen('X')) 
1388
+      {
1389
+        extruder_offset[X_AXIS][tmp_extruder] = code_value();
1390
+      }
1391
+      if(code_seen('Y'))
1392
+      {
1393
+        extruder_offset[Y_AXIS][tmp_extruder] = code_value();
1394
+      }
1395
+      SERIAL_ECHO_START;
1396
+      SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
1397
+      for(tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++) 
1398
+      {
1399
+         SERIAL_ECHO(" ");
1400
+         SERIAL_ECHO(extruder_offset[X_AXIS][tmp_extruder]);
1401
+         SERIAL_ECHO(",");
1402
+         SERIAL_ECHO(extruder_offset[Y_AXIS][tmp_extruder]);
1403
+      }
1404
+      SERIAL_ECHOLN("");
1405
+    }break;
1376 1406
     case 220: // M220 S<factor in percent>- set speed factor override percentage
1377 1407
     {
1378 1408
       if(code_seen('S')) 
@@ -1499,13 +1529,13 @@ void process_commands()
1499 1529
     {
1500 1530
         Config_PrintSettings();
1501 1531
     }
1502
-    break;
1503
-    #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
1504
-    case 540:
1505
-    {
1506
-        if(code_seen('S')) abort_on_endstop_hit = code_value() > 0;
1507
-    }
1508
-    break;
1532
+    break;
1533
+    #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
1534
+    case 540:
1535
+    {
1536
+        if(code_seen('S')) abort_on_endstop_hit = code_value() > 0;
1537
+    }
1538
+    break;
1509 1539
     #endif
1510 1540
     #ifdef FILAMENTCHANGEENABLE
1511 1541
     case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
@@ -1696,7 +1726,32 @@ void process_commands()
1696 1726
       SERIAL_ECHOLN(MSG_INVALID_EXTRUDER);
1697 1727
     }
1698 1728
     else {
1699
-      active_extruder = tmp_extruder;
1729
+      boolean make_move = false;
1730
+      if(code_seen('F')) {
1731
+        make_move = true;
1732
+        next_feedrate = code_value();
1733
+        if(next_feedrate > 0.0) {
1734
+          feedrate = next_feedrate;
1735
+        }
1736
+      }
1737
+      if(tmp_extruder != active_extruder) {
1738
+        // Save current position to return to after applying extruder offset
1739
+        memcpy(destination, current_position, sizeof(destination));
1740
+        // Offset extruder (only by XY)
1741
+        int i;
1742
+        for(i = 0; i < 2; i++) {
1743
+           current_position[i] = current_position[i] - 
1744
+                                 extruder_offset[i][active_extruder] +
1745
+                                 extruder_offset[i][tmp_extruder];
1746
+        }
1747
+        // Set the new active extruder and position
1748
+        active_extruder = tmp_extruder;
1749
+        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1750
+        // Move to the old position if 'F' was in the parameters
1751
+        if(make_move && Stopped == false) {
1752
+           prepare_move();
1753
+        }
1754
+      }
1700 1755
       SERIAL_ECHO_START;
1701 1756
       SERIAL_ECHO(MSG_ACTIVE_EXTRUDER);
1702 1757
       SERIAL_PROTOCOLLN((int)active_extruder);
@@ -2059,6 +2114,9 @@ bool setTargetedHotend(int code){
2059 2114
         case 109:
2060 2115
           SERIAL_ECHO(MSG_M109_INVALID_EXTRUDER);
2061 2116
           break;
2117
+        case 218:
2118
+          SERIAL_ECHO(MSG_M218_INVALID_EXTRUDER);
2119
+          break;
2062 2120
       }
2063 2121
       SERIAL_ECHOLN(tmp_extruder);
2064 2122
       return true;

+ 1464
- 1446
Marlin/language.h
File diff suppressed because it is too large
View File


+ 2
- 2
Marlin/thermistortables.h View File

@@ -248,7 +248,7 @@ const short temptable_6[][2] PROGMEM = {
248 248
    {970*OVERSAMPLENR, 25},
249 249
    {978*OVERSAMPLENR, 22},
250 250
    {1008*OVERSAMPLENR, 3},
251
-   {1023*OVERSAMPLENR, 0}  //to allow internal 0C
251
+   {1023*OVERSAMPLENR, 0}  //to allow internal 0 degrees C
252 252
 };
253 253
 #endif
254 254
 
@@ -309,7 +309,7 @@ const short temptable_7[][2] PROGMEM = {
309 309
    {994*OVERSAMPLENR, 15},
310 310
    {1001*OVERSAMPLENR, 10},
311 311
    {1005*OVERSAMPLENR, 5},
312
-   {1023*OVERSAMPLENR, 0}  //to allow internal 0C
312
+   {1023*OVERSAMPLENR, 0}  //to allow internal 0 degrees C
313 313
 };
314 314
 #endif
315 315
 #if (THERMISTORHEATER_0 == 8) || (THERMISTORHEATER_1 == 8) || (THERMISTORHEATER_2 == 8) || (THERMISTORBED == 8)

Loading…
Cancel
Save