Parcourir la source

Add'l toolchange syncs

Scott Lahteine il y a 5 ans
Parent
révision
68108789d0
1 fichiers modifiés avec 56 ajouts et 63 suppressions
  1. 56
    63
      Marlin/src/module/tool_change.cpp

+ 56
- 63
Marlin/src/module/tool_change.cpp Voir le fichier

@@ -135,11 +135,11 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
135 135
 
136 136
 #if ENABLED(MAGNETIC_PARKING_EXTRUDER)
137 137
 
138
-  float parkingposx[2] ,           // M951 R L
139
-        parkinggrabdistance ,      // M951 I
140
-        parkingslowspeed,          // M951 J
141
-        parkinghighspeed ,         // M951 H
142
-        parkingtraveldistance,     // M951 D
138
+  float parkingposx[2],           // M951 R L
139
+        parkinggrabdistance,      // M951 I
140
+        parkingslowspeed,         // M951 J
141
+        parkinghighspeed,         // M951 H
142
+        parkingtraveldistance,    // M951 D
143 143
         compensationmultiplier;
144 144
 
145 145
   inline void magnetic_parking_extruder_tool_change(const uint8_t tmp_extruder) {
@@ -290,52 +290,50 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
290 290
 
291 291
       // STEP 1
292 292
 
293
-      if (DEBUGGING(LEVELING)) DEBUG_POS("Start Autopark", current_position);
293
+      if (DEBUGGING(LEVELING)) DEBUG_POS("Start PE Tool-Change", current_position);
294 294
 
295 295
       current_position[X_AXIS] = parkingposx[active_extruder] + x_offset;
296
-
297 296
       if (DEBUGGING(LEVELING)) {
298 297
         DEBUG_ECHOLNPAIR("(1) Park extruder ", int(active_extruder));
299 298
         DEBUG_POS("Moving ParkPos", current_position);
300 299
       }
301
-
302 300
       fast_line_to_current(X_AXIS);
303
-      planner.synchronize();
304 301
 
305 302
       // STEP 2
306 303
 
307
-      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(2) Disengage magnet ");
308
-
304
+      planner.synchronize();
305
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(2) Disengage magnet");
309 306
       pe_deactivate_solenoid(active_extruder);
310 307
 
311 308
       // STEP 3
312 309
 
313
-      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(3) Move near new extruder");
314
-
315 310
       current_position[X_AXIS] += active_extruder ? -10 : 10; // move 10mm away from parked extruder
316
-
317
-      if (DEBUGGING(LEVELING)) DEBUG_POS("Move away from parked extruder", current_position);
318
-
311
+      if (DEBUGGING(LEVELING)) {
312
+        DEBUG_ECHOLNPGM("(3) Move near new extruder");
313
+        DEBUG_POS("Move away from parked extruder", current_position);
314
+      }
319 315
       fast_line_to_current(X_AXIS);
320
-      planner.synchronize();
321 316
 
322 317
       // STEP 4
323
-      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Engage magnetic field");
324 318
 
319
+      planner.synchronize();
320
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Engage magnetic field");
325 321
       #if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
326
-        pe_activate_solenoid(active_extruder); //just save power for inverted magnets
322
+        pe_activate_solenoid(active_extruder); // Just save power for inverted magnets
327 323
       #endif
328
-
329 324
       pe_activate_solenoid(tmp_extruder);
330 325
 
331 326
       // STEP 5
332 327
 
333 328
       current_position[X_AXIS] = grabpos + (tmp_extruder ? -10 : 10);
334 329
       fast_line_to_current(X_AXIS);
330
+
335 331
       current_position[X_AXIS] = grabpos;
336
-      if (DEBUGGING(LEVELING)) DEBUG_POS("(5) Unpark extruder", current_position);
332
+      if (DEBUGGING(LEVELING)) {
333
+        planner.synchronize();
334
+        DEBUG_POS("(5) Unpark extruder", current_position);
335
+      }
337 336
       planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS] * 0.5, active_extruder);
338
-      planner.synchronize();
339 337
 
340 338
       // STEP 6
341 339
 
@@ -344,13 +342,14 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
344 342
           - hotend_offset[X_AXIS][tmp_extruder]
345 343
         #endif
346 344
       ;
347
-
348
-      if (DEBUGGING(LEVELING)) DEBUG_POS("(6) Move midway between hotends", current_position);
349
-
345
+      if (DEBUGGING(LEVELING)) {
346
+        planner.synchronize();
347
+        DEBUG_POS("(6) Move midway between hotends", current_position);
348
+      }
350 349
       fast_line_to_current(X_AXIS);
351
-      planner.synchronize();
350
+      planner.synchronize(); // Always sync the final move
352 351
 
353
-      DEBUG_ECHOLNPGM("Autopark done.");
352
+      DEBUG_ECHOLNPGM("PE Tool-Change done.");
354 353
     }
355 354
     else { // nomove == true
356 355
       // Only engage magnetic field for new extruder
@@ -383,86 +382,80 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
383 382
 
384 383
     // 1. Move to switch position of current toolhead
385 384
 
386
-    if (DEBUGGING(LEVELING)) DEBUG_POS("Starting Toolhead change", current_position);
385
+    if (DEBUGGING(LEVELING)) DEBUG_POS("Start ST Tool-Change", current_position);
387 386
 
388 387
     current_position[X_AXIS] = placexpos;
389
-
390 388
     if (DEBUGGING(LEVELING)) {
391 389
       DEBUG_ECHOLNPAIR("(1) Place old tool ", int(active_extruder));
392 390
       DEBUG_POS("Move X SwitchPos", current_position);
393 391
     }
394
-
395 392
     fast_line_to_current(X_AXIS);
396
-    planner.synchronize();
397
-
398
-    current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
399
-
400
-    if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
401 393
 
394
+    current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - (SWITCHING_TOOLHEAD_Y_SECURITY);
395
+    if (DEBUGGING(LEVELING)) {
396
+      planner.synchronize();
397
+      DEBUG_POS("Move Y SwitchPos + Security", current_position);
398
+    }
402 399
     fast_line_to_current(Y_AXIS);
403
-    planner.synchronize();
404 400
 
405 401
     // 2. Unlock tool and drop it in the dock
406 402
 
403
+    planner.synchronize();
407 404
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(2) Unlock and Place Toolhead");
408
-
409 405
     MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[1]);
410 406
     safe_delay(500);
411 407
 
412 408
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
413
-
414 409
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
410
+    planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5f, active_extruder);
415 411
 
416
-    planner.buffer_line(current_position,(planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5), active_extruder);
412
+    // Wait for move to complete, then another 0.2s
417 413
     planner.synchronize();
418 414
     safe_delay(200);
419
-    current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
420 415
 
416
+    current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
421 417
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
422
-
423 418
     fast_line_to_current(Y_AXIS); // move away from docked toolhead
424
-    planner.synchronize();
425 419
 
426 420
     // 3. Move to the new toolhead
427 421
 
428
-    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(3) Move to new toolhead position");
429
-
430 422
     current_position[X_AXIS] = grabxpos;
431
-
432
-    if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
433
-
423
+    if (DEBUGGING(LEVELING)) {
424
+      planner.synchronize();
425
+      DEBUG_ECHOLNPGM("(3) Move to new toolhead position");
426
+      DEBUG_POS("Move to new toolhead X", current_position);
427
+    }
434 428
     fast_line_to_current(X_AXIS);
435
-    planner.synchronize();
436
-    current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
437
-
438
-    if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
439 429
 
430
+    current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - (SWITCHING_TOOLHEAD_Y_SECURITY);
431
+    if (DEBUGGING(LEVELING)) {
432
+      planner.synchronize();
433
+      DEBUG_POS("Move Y SwitchPos + Security", current_position);
434
+    }
440 435
     fast_line_to_current(Y_AXIS);
441
-    planner.synchronize();
442 436
 
443 437
     // 4. Grab and lock the new toolhead
444 438
 
445
-    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Grab and lock new toolhead ");
446
-
447 439
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
448
-
449
-    if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
450
-
440
+    if (DEBUGGING(LEVELING)) {
441
+      planner.synchronize();
442
+      DEBUG_ECHOLNPGM("(4) Grab and lock new toolhead");
443
+      DEBUG_POS("Move Y SwitchPos", current_position);
444
+    }
451 445
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5, active_extruder);
452
-    planner.synchronize();
453 446
 
447
+    // Wait for move to finish, pause 0.2s, move servo, pause 0.5s
448
+    planner.synchronize();
454 449
     safe_delay(200);
455 450
     MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[0]);
456 451
     safe_delay(500);
457 452
 
458 453
     current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
459
-
460 454
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
455
+    fast_line_to_current(Y_AXIS); // Move away from docked toolhead
456
+    planner.synchronize();        // Always sync the final move
461 457
 
462
-    fast_line_to_current(Y_AXIS); // move away from docked toolhead
463
-    planner.synchronize();
464
-
465
-    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Toolhead change done.");
458
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("ST Tool-Change done.");
466 459
   }
467 460
 
468 461
 #elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)

Chargement…
Annuler
Enregistrer