Scott Lahteine 5 роки тому
джерело
коміт
68108789d0
1 змінених файлів з 56 додано та 63 видалено
  1. 56
    63
      Marlin/src/module/tool_change.cpp

+ 56
- 63
Marlin/src/module/tool_change.cpp Переглянути файл

135
 
135
 
136
 #if ENABLED(MAGNETIC_PARKING_EXTRUDER)
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
         compensationmultiplier;
143
         compensationmultiplier;
144
 
144
 
145
   inline void magnetic_parking_extruder_tool_change(const uint8_t tmp_extruder) {
145
   inline void magnetic_parking_extruder_tool_change(const uint8_t tmp_extruder) {
290
 
290
 
291
       // STEP 1
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
       current_position[X_AXIS] = parkingposx[active_extruder] + x_offset;
295
       current_position[X_AXIS] = parkingposx[active_extruder] + x_offset;
296
-
297
       if (DEBUGGING(LEVELING)) {
296
       if (DEBUGGING(LEVELING)) {
298
         DEBUG_ECHOLNPAIR("(1) Park extruder ", int(active_extruder));
297
         DEBUG_ECHOLNPAIR("(1) Park extruder ", int(active_extruder));
299
         DEBUG_POS("Moving ParkPos", current_position);
298
         DEBUG_POS("Moving ParkPos", current_position);
300
       }
299
       }
301
-
302
       fast_line_to_current(X_AXIS);
300
       fast_line_to_current(X_AXIS);
303
-      planner.synchronize();
304
 
301
 
305
       // STEP 2
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
       pe_deactivate_solenoid(active_extruder);
306
       pe_deactivate_solenoid(active_extruder);
310
 
307
 
311
       // STEP 3
308
       // STEP 3
312
 
309
 
313
-      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(3) Move near new extruder");
314
-
315
       current_position[X_AXIS] += active_extruder ? -10 : 10; // move 10mm away from parked extruder
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
       fast_line_to_current(X_AXIS);
315
       fast_line_to_current(X_AXIS);
320
-      planner.synchronize();
321
 
316
 
322
       // STEP 4
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
       #if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
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
       #endif
323
       #endif
328
-
329
       pe_activate_solenoid(tmp_extruder);
324
       pe_activate_solenoid(tmp_extruder);
330
 
325
 
331
       // STEP 5
326
       // STEP 5
332
 
327
 
333
       current_position[X_AXIS] = grabpos + (tmp_extruder ? -10 : 10);
328
       current_position[X_AXIS] = grabpos + (tmp_extruder ? -10 : 10);
334
       fast_line_to_current(X_AXIS);
329
       fast_line_to_current(X_AXIS);
330
+
335
       current_position[X_AXIS] = grabpos;
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
       planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS] * 0.5, active_extruder);
336
       planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS] * 0.5, active_extruder);
338
-      planner.synchronize();
339
 
337
 
340
       // STEP 6
338
       // STEP 6
341
 
339
 
344
           - hotend_offset[X_AXIS][tmp_extruder]
342
           - hotend_offset[X_AXIS][tmp_extruder]
345
         #endif
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
       fast_line_to_current(X_AXIS);
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
     else { // nomove == true
354
     else { // nomove == true
356
       // Only engage magnetic field for new extruder
355
       // Only engage magnetic field for new extruder
383
 
382
 
384
     // 1. Move to switch position of current toolhead
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
     current_position[X_AXIS] = placexpos;
387
     current_position[X_AXIS] = placexpos;
389
-
390
     if (DEBUGGING(LEVELING)) {
388
     if (DEBUGGING(LEVELING)) {
391
       DEBUG_ECHOLNPAIR("(1) Place old tool ", int(active_extruder));
389
       DEBUG_ECHOLNPAIR("(1) Place old tool ", int(active_extruder));
392
       DEBUG_POS("Move X SwitchPos", current_position);
390
       DEBUG_POS("Move X SwitchPos", current_position);
393
     }
391
     }
394
-
395
     fast_line_to_current(X_AXIS);
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
     fast_line_to_current(Y_AXIS);
399
     fast_line_to_current(Y_AXIS);
403
-    planner.synchronize();
404
 
400
 
405
     // 2. Unlock tool and drop it in the dock
401
     // 2. Unlock tool and drop it in the dock
406
 
402
 
403
+    planner.synchronize();
407
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(2) Unlock and Place Toolhead");
404
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(2) Unlock and Place Toolhead");
408
-
409
     MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[1]);
405
     MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[1]);
410
     safe_delay(500);
406
     safe_delay(500);
411
 
407
 
412
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
408
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
413
-
414
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
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
     planner.synchronize();
413
     planner.synchronize();
418
     safe_delay(200);
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
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
417
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
422
-
423
     fast_line_to_current(Y_AXIS); // move away from docked toolhead
418
     fast_line_to_current(Y_AXIS); // move away from docked toolhead
424
-    planner.synchronize();
425
 
419
 
426
     // 3. Move to the new toolhead
420
     // 3. Move to the new toolhead
427
 
421
 
428
-    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(3) Move to new toolhead position");
429
-
430
     current_position[X_AXIS] = grabxpos;
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
     fast_line_to_current(X_AXIS);
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
     fast_line_to_current(Y_AXIS);
435
     fast_line_to_current(Y_AXIS);
441
-    planner.synchronize();
442
 
436
 
443
     // 4. Grab and lock the new toolhead
437
     // 4. Grab and lock the new toolhead
444
 
438
 
445
-    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Grab and lock new toolhead ");
446
-
447
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
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
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5, active_extruder);
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
     safe_delay(200);
449
     safe_delay(200);
455
     MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[0]);
450
     MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[0]);
456
     safe_delay(500);
451
     safe_delay(500);
457
 
452
 
458
     current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
453
     current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
459
-
460
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
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
 #elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
461
 #elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)

Завантаження…
Відмінити
Зберегти