Quellcode durchsuchen

Added support for extruder offset handling

The extruder offset can be specified in the configuration
file or adjusted on the fly using the "M218 T# X# Y#" command.
The EEPROM support is not yet merged in.
The "T#" command can take option "F#" that specifies the feedrate
at which the printing head should be re-positioned. If not
specified the re-positioning move is not preformed immediately,
but the coordinates are adjusted for the printer to properly
position the head when the next movement happens.
Denis B vor 12 Jahren
Ursprung
Commit
70871715e4
3 geänderte Dateien mit 93 neuen und 11 gelöschten Zeilen
  1. 7
    1
      Marlin/Configuration.h
  2. 68
    10
      Marlin/Marlin_main.cpp
  3. 18
    0
      Marlin/language.h

+ 7
- 1
Marlin/Configuration.h Datei anzeigen

@@ -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)

+ 68
- 10
Marlin/Marlin_main.cpp Datei anzeigen

@@ -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
@@ -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;

+ 18
- 0
Marlin/language.h Datei anzeigen

@@ -139,6 +139,7 @@
139 139
 	#define MSG_END_FILE_LIST "End file list"
140 140
 	#define MSG_M104_INVALID_EXTRUDER "M104 Invalid extruder "
141 141
 	#define MSG_M105_INVALID_EXTRUDER "M105 Invalid extruder "
142
+	#define MSG_M218_INVALID_EXTRUDER "M218 Invalid extruder "
142 143
 	#define MSG_ERR_NO_THERMISTORS "No thermistors - no temperature"
143 144
 	#define MSG_M109_INVALID_EXTRUDER "M109 Invalid extruder "
144 145
 	#define MSG_HEATING "Heating..."
@@ -162,6 +163,7 @@
162 163
 	#define MSG_M119_REPORT "Reporting endstop status"
163 164
 	#define MSG_ENDSTOP_HIT "TRIGGERED"
164 165
 	#define MSG_ENDSTOP_OPEN "open"
166
+	#define MSG_HOTEND_OFFSET "Hotend offsets:"
165 167
 
166 168
 	#define MSG_SD_CANT_OPEN_SUBDIR "Cannot open subdir"
167 169
 	#define MSG_SD_INIT_FAIL "SD init fail"
@@ -294,6 +296,7 @@
294 296
 	#define MSG_END_FILE_LIST "Koniec listy plikow"
295 297
 	#define MSG_M104_INVALID_EXTRUDER "M104 Niepoprawny ekstruder "
296 298
 	#define MSG_M105_INVALID_EXTRUDER "M105 Niepoprawny ekstruder "
299
+	#define MSG_M218_INVALID_EXTRUDER "M218 Niepoprawny ekstruder "
297 300
 	#define MSG_ERR_NO_THERMISTORS "Brak termistorow - brak temperatury :("
298 301
 	#define MSG_M109_INVALID_EXTRUDER "M109 Niepoprawny ekstruder "
299 302
 	#define MSG_HEATING "Nagrzewanie ekstrudera..."
@@ -317,6 +320,7 @@
317 320
 	#define MSG_M119_REPORT "Zgloszenie statusu wylacznikow krancowych"
318 321
 	#define MSG_ENDSTOP_HIT "WYZWOLONY"
319 322
 	#define MSG_ENDSTOP_OPEN "otwarty"
323
+	#define MSG_HOTEND_OFFSET "Hotend offsets:"
320 324
 
321 325
 	#define MSG_SD_CANT_OPEN_SUBDIR "Nie mozna otworzyc podkatalogu"
322 326
 	#define MSG_SD_INIT_FAIL "Blad inicjalizacji karty SD"
@@ -454,6 +458,7 @@
454 458
 #define MSG_END_FILE_LIST "Fin de la liste de fichiers"
455 459
 #define MSG_M104_INVALID_EXTRUDER "M104 Extruder invalide"
456 460
 #define MSG_M105_INVALID_EXTRUDER "M105 Extruder invalide"
461
+#define MSG_M218_INVALID_EXTRUDER "M218 Extruder invalide"
457 462
 #define MSG_ERR_NO_THERMISTORS "Pas de thermistor, pas de temperature"
458 463
 #define MSG_M109_INVALID_EXTRUDER "M109 Extruder invalide "
459 464
 #define MSG_HEATING "En chauffe..."
@@ -477,6 +482,7 @@
477 482
 #define MSG_M119_REPORT "Affichage du status des fin de course"
478 483
 #define MSG_ENDSTOP_HIT "DECLENCHE"
479 484
 #define MSG_ENDSTOP_OPEN "OUVERT"
485
+#define MSG_HOTEND_OFFSET "Hotend offsets:"
480 486
 
481 487
 #define MSG_SD_CANT_OPEN_SUBDIR "Impossible d'ouvrir le sous-repertoire"
482 488
 #define MSG_SD_INIT_FAIL "Echec de l'initialisation de la SD"
@@ -612,6 +618,7 @@
612 618
 	#define MSG_END_FILE_LIST "End file list"
613 619
 	#define MSG_M104_INVALID_EXTRUDER "M104 Invalid extruder "
614 620
 	#define MSG_M105_INVALID_EXTRUDER "M105 Invalid extruder "
621
+	#define MSG_M218_INVALID_EXTRUDER "M218 Invalid extruder "
615 622
 	#define MSG_ERR_NO_THERMISTORS "No thermistors - no temp"
616 623
 	#define MSG_M109_INVALID_EXTRUDER "M109 Invalid extruder "
617 624
 	#define MSG_HEATING "Heating..."
@@ -635,6 +642,7 @@
635 642
 	#define MSG_M119_REPORT "Reporting endstop status"
636 643
 	#define MSG_ENDSTOP_HIT "TRIGGERED"
637 644
 	#define MSG_ENDSTOP_OPEN "open"
645
+	#define MSG_HOTEND_OFFSET "Hotend offsets:"
638 646
 
639 647
 	#define MSG_SD_CANT_OPEN_SUBDIR "Cannot open subdir"
640 648
 	#define MSG_SD_INIT_FAIL "SD init fail"
@@ -770,6 +778,7 @@
770 778
 #define MSG_END_FILE_LIST "Fin de la lista de archivos"
771 779
 #define MSG_M104_INVALID_EXTRUDER "M104 Extrusor Invalido "
772 780
 #define MSG_M105_INVALID_EXTRUDER "M105 Extrusor Invalido "
781
+#define MSG_M218_INVALID_EXTRUDER "M218 Extrusor Invalido "
773 782
 #define MSG_ERR_NO_THERMISTORS "No hay termistores - no temp"
774 783
 #define MSG_M109_INVALID_EXTRUDER "M109 Extrusor Invalido "
775 784
 #define MSG_HEATING "Calentando..."
@@ -792,6 +801,7 @@
792 801
 #define MSG_M119_REPORT "Comprobando fines de carrera."
793 802
 #define MSG_ENDSTOP_HIT "PULSADO"
794 803
 #define MSG_ENDSTOP_OPEN "abierto"
804
+#define MSG_HOTEND_OFFSET "Hotend offsets:"
795 805
         
796 806
 #define MSG_SD_CANT_OPEN_SUBDIR "No se pudo abrir la subcarpeta."
797 807
 #define MSG_SD_INIT_FAIL "Fallo al iniciar la SD"
@@ -921,6 +931,7 @@
921 931
 #define MSG_END_FILE_LIST					"Конец списка файлов"
922 932
 #define MSG_M104_INVALID_EXTRUDER			"M104 ошибка экструдера "
923 933
 #define MSG_M105_INVALID_EXTRUDER			"M105 ошибка экструдера "
934
+#define MSG_M218_INVALID_EXTRUDER			"M218 ошибка экструдера "
924 935
 #define MSG_ERR_NO_THERMISTORS				"Нет термистра - нет температуры"
925 936
 #define MSG_M109_INVALID_EXTRUDER			"M109 ошибка экструдера "
926 937
 #define MSG_HEATING							"Нагрев...  "
@@ -944,6 +955,7 @@
944 955
 #define MSG_M119_REPORT						"Статус концевиков"
945 956
 #define MSG_ENDSTOP_HIT						"Срабатывание концевика"
946 957
 #define MSG_ENDSTOP_OPEN					"Концевик освобожден"
958
+#define MSG_HOTEND_OFFSET					"Hotend offsets:"
947 959
 #define MSG_SD_CANT_OPEN_SUBDIR				"Не открыть папку"
948 960
 #define MSG_SD_INIT_FAIL					"Ошибка инициализации SD"
949 961
 #define MSG_SD_VOL_INIT_FAIL				"Ошибка инициализации раздела"
@@ -1080,6 +1092,7 @@
1080 1092
 	#define MSG_END_FILE_LIST        "Fine Lista File"
1081 1093
 	#define MSG_M104_INVALID_EXTRUDER "M104 Estrusore non valido "
1082 1094
 	#define MSG_M105_INVALID_EXTRUDER "M105 Estrusore non valido "
1095
+	#define MSG_M218_INVALID_EXTRUDER "M218 Estrusore non valido "
1083 1096
 	#define MSG_ERR_NO_THERMISTORS   "Nessun Termistore - nessuna temperatura"
1084 1097
 	#define MSG_M109_INVALID_EXTRUDER "M109 Estrusore non valido "
1085 1098
 	#define MSG_HEATING              "Riscaldamento..."
@@ -1103,6 +1116,7 @@
1103 1116
 	#define MSG_M119_REPORT          "Segnalazione stato degli endstop"
1104 1117
 	#define MSG_ENDSTOP_HIT          "INNESCATO"
1105 1118
 	#define MSG_ENDSTOP_OPEN         "aperto"
1119
+	#define MSG_HOTEND_OFFSET        "Hotend offsets:"
1106 1120
 
1107 1121
 	#define MSG_SD_CANT_OPEN_SUBDIR  "Impossibile aprire sottocartella"
1108 1122
 	#define MSG_SD_INIT_FAIL         "Fallita Inizializzazione SD"
@@ -1242,6 +1256,7 @@
1242 1256
 	#define MSG_END_FILE_LIST "Fim da lista de arquivos"
1243 1257
 	#define MSG_M104_INVALID_EXTRUDER "M104 Extrusor inválido "
1244 1258
 	#define MSG_M105_INVALID_EXTRUDER "M105 Extrusor inválido "
1259
+	#define MSG_M218_INVALID_EXTRUDER "M218 Extrusor inválido "
1245 1260
 	#define MSG_ERR_NO_THERMISTORS "Nao ha termistor - no temp"
1246 1261
 	#define MSG_M109_INVALID_EXTRUDER "M109 Extrusor inválido "
1247 1262
 	#define MSG_HEATING "Aquecendo..."
@@ -1265,6 +1280,7 @@
1265 1280
 	#define MSG_M119_REPORT "Relatando estado do ponto final"
1266 1281
 	#define MSG_ENDSTOP_HIT "PULSADO"
1267 1282
 	#define MSG_ENDSTOP_OPEN "Aberto"
1283
+	#define MSG_HOTEND_OFFSET "Hotend offsets:"
1268 1284
 
1269 1285
 	#define MSG_SD_CANT_OPEN_SUBDIR "Nao pode abrir sub diretorio"
1270 1286
 	#define MSG_SD_INIT_FAIL "Falha ao iniciar SD"
@@ -1399,6 +1415,7 @@
1399 1415
 	#define MSG_END_FILE_LIST "Tiedostolistauksen loppu"
1400 1416
 	#define MSG_M104_INVALID_EXTRUDER "M104 Virheellinen suutin "
1401 1417
 	#define MSG_M105_INVALID_EXTRUDER "M105 Virheellinen suutin "
1418
+	#define MSG_M218_INVALID_EXTRUDER "M218 Virheellinen suutin "
1402 1419
 	#define MSG_ERR_NO_THERMISTORS "Ei termistoreja - ei lampotiloja"
1403 1420
 	#define MSG_M109_INVALID_EXTRUDER "M109 Virheellinen suutin "
1404 1421
 	#define MSG_HEATING "Lammitan..."
@@ -1422,6 +1439,7 @@
1422 1439
 	#define MSG_M119_REPORT "Rajakytkimien tilaraportti"
1423 1440
 	#define MSG_ENDSTOP_HIT "AKTIIVISENA"
1424 1441
 	#define MSG_ENDSTOP_OPEN "avoinna"
1442
+	#define MSG_HOTEND_OFFSET "Hotend offsets:"
1425 1443
 
1426 1444
 	#define MSG_SD_CANT_OPEN_SUBDIR "Alihakemistoa ei voitu avata"
1427 1445
 	#define MSG_SD_INIT_FAIL "SD alustus epaonnistui"

Laden…
Abbrechen
Speichern