Browse Source

Merge pull request #3102 from jbrazio/bugfix-g28-multiple-z-movements

Bugfix: G28 was lifting Z-axis multiple times
Scott Lahteine 9 years ago
parent
commit
fac85f6fa1
1 changed files with 25 additions and 10 deletions
  1. 25
    10
      Marlin/Marlin_main.cpp

+ 25
- 10
Marlin/Marlin_main.cpp View File

2323
 
2323
 
2324
       #elif defined(Z_RAISE_BEFORE_HOMING) && Z_RAISE_BEFORE_HOMING > 0
2324
       #elif defined(Z_RAISE_BEFORE_HOMING) && Z_RAISE_BEFORE_HOMING > 0
2325
 
2325
 
2326
-        // Raise Z before homing any other axes
2326
+        // Consider the current Z-position as zero
2327
+        // !!WARNING!! If the machine has no physical z-max endstops then we
2328
+        // can move the axis more than it can physically travel.
2329
+        current_position[Z_AXIS] = 0;
2330
+        sync_plan_position();
2331
+
2327
         // (Does this need to be "negative home direction?" Why not just use Z_RAISE_BEFORE_HOMING?)
2332
         // (Does this need to be "negative home direction?" Why not just use Z_RAISE_BEFORE_HOMING?)
2328
         destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS);
2333
         destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS);
2334
+        feedrate = max_feedrate[Z_AXIS] * 60;
2335
+
2329
         #if ENABLED(DEBUG_LEVELING_FEATURE)
2336
         #if ENABLED(DEBUG_LEVELING_FEATURE)
2330
           if (marlin_debug_flags & DEBUG_LEVELING) {
2337
           if (marlin_debug_flags & DEBUG_LEVELING) {
2331
             SERIAL_ECHOPAIR("Raise Z (before homing) by ", (float)Z_RAISE_BEFORE_HOMING);
2338
             SERIAL_ECHOPAIR("Raise Z (before homing) by ", (float)Z_RAISE_BEFORE_HOMING);
2332
             SERIAL_EOL;
2339
             SERIAL_EOL;
2340
+            print_xyz("> (home_all_axis || homeZ) > current_position", current_position);
2333
             print_xyz("> (home_all_axis || homeZ) > destination", destination);
2341
             print_xyz("> (home_all_axis || homeZ) > destination", destination);
2334
           }
2342
           }
2335
         #endif
2343
         #endif
2336
-        feedrate = max_feedrate[Z_AXIS] * 60;
2344
+
2345
+        // Raise Z-axis by Z_RAISE_BEFORE_HOMING before homing any other axis
2337
         line_to_destination();
2346
         line_to_destination();
2338
         st_synchronize();
2347
         st_synchronize();
2339
 
2348
 
2349
+        // Update the current Z position even if it currently not real from Z-home
2350
+        // otherwise each call to line_to_destination() will want to move Z-axis
2351
+        // by Z_RAISE_BEFORE_HOMING.
2352
+        current_position[Z_AXIS] = destination[Z_AXIS];
2353
+
2340
       #endif
2354
       #endif
2341
 
2355
 
2342
     } // home_all_axis || homeZ
2356
     } // home_all_axis || homeZ
2453
 
2467
 
2454
           if (home_all_axis) {
2468
           if (home_all_axis) {
2455
 
2469
 
2456
-            current_position[Z_AXIS] = 0;
2470
+            // At this point we already have Z at Z_RAISE_BEFORE_HOMING height
2471
+            // No need to move Z any more as this height should already be safe
2472
+            // enough to reach Z_SAFE_HOMING XY positions; just make sure the
2473
+            // planner is in sync.
2457
             sync_plan_position();
2474
             sync_plan_position();
2458
 
2475
 
2459
             //
2476
             //
2463
             // then this may not work as expected.
2480
             // then this may not work as expected.
2464
             destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER);
2481
             destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER);
2465
             destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER);
2482
             destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER);
2466
-            destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS);    // Set destination away from bed
2467
             feedrate = XY_TRAVEL_SPEED;
2483
             feedrate = XY_TRAVEL_SPEED;
2468
 
2484
 
2469
             #if ENABLED(DEBUG_LEVELING_FEATURE)
2485
             #if ENABLED(DEBUG_LEVELING_FEATURE)
2470
               if (marlin_debug_flags & DEBUG_LEVELING) {
2486
               if (marlin_debug_flags & DEBUG_LEVELING) {
2471
-                SERIAL_ECHOPAIR("Raise Z (before homing) by ", (float)Z_RAISE_BEFORE_HOMING);
2472
-                SERIAL_EOL;
2473
-                print_xyz("> home_all_axis > current_position", current_position);
2474
-                print_xyz("> home_all_axis > destination", destination);
2487
+                print_xyz("> Z_SAFE_HOMING > home_all_axis > current_position", current_position);
2488
+                print_xyz("> Z_SAFE_HOMING > home_all_axis > destination", destination);
2475
               }
2489
               }
2476
             #endif
2490
             #endif
2477
 
2491
 
2478
-            // This could potentially move X, Y, Z all together
2492
+            // Move in the XY plane
2479
             line_to_destination();
2493
             line_to_destination();
2480
             st_synchronize();
2494
             st_synchronize();
2481
 
2495
 
2482
-            // Set current X, Y is the Z_SAFE_HOMING_POINT minus PROBE_OFFSET_FROM_EXTRUDER
2496
+            // Update the current positions for XY, Z is still at
2497
+            // Z_RAISE_BEFORE_HOMING height, no changes there.
2483
             current_position[X_AXIS] = destination[X_AXIS];
2498
             current_position[X_AXIS] = destination[X_AXIS];
2484
             current_position[Y_AXIS] = destination[Y_AXIS];
2499
             current_position[Y_AXIS] = destination[Y_AXIS];
2485
 
2500
 

Loading…
Cancel
Save