Kaynağa Gözat

Apply some tool-change cleanup

Scott Lahteine 6 yıl önce
ebeveyn
işleme
5a470d4a49
1 değiştirilmiş dosya ile 71 ekleme ve 9 silme
  1. 71
    9
      Marlin/src/module/tool_change.cpp

+ 71
- 9
Marlin/src/module/tool_change.cpp Dosyayı Görüntüle

@@ -129,10 +129,17 @@
129 129
   inline void parking_extruder_tool_change(const uint8_t tmp_extruder, bool no_move) {
130 130
     if (!no_move) {
131 131
 
132
-      const float parkingposx[] = PARKING_EXTRUDER_PARKING_X,
133
-                  midpos = (parkingposx[0] + parkingposx[1]) * 0.5 + hotend_offset[X_AXIS][active_extruder],
134
-                  grabpos = parkingposx[tmp_extruder] + hotend_offset[X_AXIS][active_extruder]
135
-                            + (tmp_extruder == 0 ? -(PARKING_EXTRUDER_GRAB_DISTANCE) : PARKING_EXTRUDER_GRAB_DISTANCE);
132
+      constexpr float parkingposx[] = PARKING_EXTRUDER_PARKING_X;
133
+
134
+      #if HAS_HOTEND_OFFSET
135
+        const float x_offset = hotend_offset[X_AXIS][active_extruder];
136
+      #else
137
+        constexpr float x_offset = 0;
138
+      #endif
139
+
140
+      const float midpos = (parkingposx[0] + parkingposx[1]) * 0.5 + x_offset,
141
+                  grabpos = parkingposx[tmp_extruder] + (tmp_extruder ? PARKING_EXTRUDER_GRAB_DISTANCE : -(PARKING_EXTRUDER_GRAB_DISTANCE)) + x_offset;
142
+
136 143
       /**
137 144
        * 1. Raise Z-Axis to give enough clearance
138 145
        * 2. Move to park position of old extruder
@@ -144,42 +151,54 @@
144 151
        */
145 152
 
146 153
       // STEP 1
154
+
147 155
       #if ENABLED(DEBUG_LEVELING_FEATURE)
148 156
         if (DEBUGGING(LEVELING)) DEBUG_POS("Start Autopark", current_position);
149 157
       #endif
158
+
150 159
       current_position[Z_AXIS] += toolchange_settings.z_raise;
160
+
151 161
       #if ENABLED(DEBUG_LEVELING_FEATURE)
152 162
         if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
153 163
       #endif
164
+
154 165
       planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
155 166
       planner.synchronize();
156 167
 
157 168
       // STEP 2
158
-      current_position[X_AXIS] = parkingposx[active_extruder] + hotend_offset[X_AXIS][active_extruder];
169
+
170
+      current_position[X_AXIS] = parkingposx[active_extruder] + x_offset;
171
+
159 172
       #if ENABLED(DEBUG_LEVELING_FEATURE)
160 173
         if (DEBUGGING(LEVELING)) {
161 174
           SERIAL_ECHOLNPAIR("(2) Park extruder ", int(active_extruder));
162 175
           DEBUG_POS("Moving ParkPos", current_position);
163 176
         }
164 177
       #endif
178
+
165 179
       planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
166 180
       planner.synchronize();
167 181
 
168 182
       // STEP 3
183
+
169 184
       #if ENABLED(DEBUG_LEVELING_FEATURE)
170 185
         if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Disengage magnet ");
171 186
       #endif
187
+
172 188
       pe_deactivate_magnet(active_extruder);
173 189
 
174 190
       // STEP 4
191
+
175 192
       #if ENABLED(DEBUG_LEVELING_FEATURE)
176 193
         if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Move to position near new extruder");
177 194
       #endif
195
+
178 196
       current_position[X_AXIS] += active_extruder ? -10 : 10; // move 10mm away from parked extruder
179 197
 
180 198
       #if ENABLED(DEBUG_LEVELING_FEATURE)
181 199
         if (DEBUGGING(LEVELING)) DEBUG_POS("Move away from parked extruder", current_position);
182 200
       #endif
201
+
183 202
       planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
184 203
       planner.synchronize();
185 204
 
@@ -191,9 +210,11 @@
191 210
       #if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
192 211
         pe_activate_magnet(active_extruder); //just save power for inverted magnets
193 212
       #endif
213
+
194 214
       pe_activate_magnet(tmp_extruder);
195 215
 
196 216
       // STEP 6
217
+
197 218
       current_position[X_AXIS] = grabpos + (tmp_extruder ? -10 : 10);
198 219
       planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
199 220
       current_position[X_AXIS] = grabpos;
@@ -203,13 +224,21 @@
203 224
       planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS]/2, active_extruder);
204 225
       planner.synchronize();
205 226
 
206
-      // Step 7
207
-      current_position[X_AXIS] = midpos - hotend_offset[X_AXIS][tmp_extruder];
227
+      // STEP 7
228
+
229
+      current_position[X_AXIS] = midpos
230
+        #if HAS_HOTEND_OFFSET
231
+          - hotend_offset[X_AXIS][tmp_extruder]
232
+        #endif
233
+      ;
234
+
208 235
       #if ENABLED(DEBUG_LEVELING_FEATURE)
209 236
         if (DEBUGGING(LEVELING)) DEBUG_POS("(7) Move midway between hotends", current_position);
210 237
       #endif
238
+
211 239
       planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
212 240
       planner.synchronize();
241
+
213 242
       #if ENABLED(DEBUG_LEVELING_FEATURE)
214 243
         SERIAL_ECHOLNPGM("Autopark done.");
215 244
       #endif
@@ -221,7 +250,10 @@
221 250
         pe_activate_magnet(active_extruder); // Just save power for inverted magnets
222 251
       #endif
223 252
     }
224
-    current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
253
+
254
+    #if HAS_HOTEND_OFFSET
255
+      current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
256
+    #endif
225 257
 
226 258
     #if ENABLED(DEBUG_LEVELING_FEATURE)
227 259
       if (DEBUGGING(LEVELING)) DEBUG_POS("Applying Z-offset", current_position);
@@ -251,80 +283,105 @@
251 283
      */
252 284
 
253 285
     // STEP 1
286
+
254 287
     #if ENABLED(DEBUG_LEVELING_FEATURE)
255 288
       if (DEBUGGING(LEVELING)) DEBUG_POS("Starting Toolhead change", current_position);
256 289
     #endif
290
+
257 291
     current_position[Z_AXIS] += toolchange_settings.z_raise;
292
+
258 293
     #if ENABLED(DEBUG_LEVELING_FEATURE)
259 294
       if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
260 295
     #endif
296
+
261 297
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
262 298
     planner.synchronize();
263 299
 
264 300
     // STEP 2
301
+
265 302
     current_position[X_AXIS] = placexpos;
303
+
266 304
     #if ENABLED(DEBUG_LEVELING_FEATURE)
267 305
       if (DEBUGGING(LEVELING)) {
268 306
         SERIAL_ECHOLNPAIR("(2) Place old tool ", int(active_extruder));
269 307
         DEBUG_POS("Move X SwitchPos", current_position);
270 308
       }
271 309
     #endif
310
+
272 311
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
273 312
     planner.synchronize();
274 313
 
275 314
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
315
+
276 316
     #if ENABLED(DEBUG_LEVELING_FEATURE)
277 317
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
278 318
     #endif
319
+
279 320
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
280 321
     planner.synchronize();
281 322
 
282 323
     // STEP 3
324
+
283 325
     #if ENABLED(DEBUG_LEVELING_FEATURE)
284 326
       if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Unlock and Place Toolhead");
285 327
     #endif
328
+
286 329
     MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[1]);
287 330
     safe_delay(500);
288 331
 
289 332
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
333
+
290 334
     #if ENABLED(DEBUG_LEVELING_FEATURE)
291 335
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
292 336
     #endif
337
+
293 338
     planner.buffer_line(current_position,(planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5), active_extruder);
294 339
     planner.synchronize();
295 340
     safe_delay(200);
296 341
     current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
342
+
297 343
     #if ENABLED(DEBUG_LEVELING_FEATURE)
298 344
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
299 345
     #endif
346
+
300 347
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder); // move away from docked toolhead
301 348
     planner.synchronize();
302 349
 
303 350
     // STEP 4
351
+
304 352
     #if ENABLED(DEBUG_LEVELING_FEATURE)
305 353
       if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Move to new toolhead position");
306 354
     #endif
355
+
307 356
     current_position[X_AXIS] = grabxpos;
357
+
308 358
     #if ENABLED(DEBUG_LEVELING_FEATURE)
309 359
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
310 360
     #endif
361
+
311 362
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
312 363
     planner.synchronize();
313 364
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
365
+
314 366
     #if ENABLED(DEBUG_LEVELING_FEATURE)
315 367
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
316 368
     #endif
369
+
317 370
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
318 371
     planner.synchronize();
319 372
 
320 373
     // STEP 5
374
+
321 375
     #if ENABLED(DEBUG_LEVELING_FEATURE)
322 376
       if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(5) Grab and lock new toolhead ");
323 377
     #endif
378
+
324 379
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
380
+
325 381
     #if ENABLED(DEBUG_LEVELING_FEATURE)
326 382
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
327 383
     #endif
384
+
328 385
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5, active_extruder);
329 386
     planner.synchronize();
330 387
 
@@ -333,14 +390,19 @@
333 390
     safe_delay(500);
334 391
 
335 392
     current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
393
+
336 394
     #if ENABLED(DEBUG_LEVELING_FEATURE)
337 395
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
338 396
     #endif
397
+
339 398
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder); // move away from docked toolhead
340 399
     planner.synchronize();
341 400
 
342 401
     // STEP 6
343
-    current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
402
+
403
+    #if HAS_HOTEND_OFFSET
404
+      current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
405
+    #endif
344 406
 
345 407
     #if ENABLED(DEBUG_LEVELING_FEATURE)
346 408
       if (DEBUGGING(LEVELING)) DEBUG_POS("(6) Apply Z offset", current_position);

Loading…
İptal
Kaydet