Browse Source

Merge pull request #4402 from thinkyhead/rc_consistent_positioning

Account for coordinate space offsets
Scott Lahteine 9 years ago
parent
commit
169c21b477
3 changed files with 83 additions and 66 deletions
  1. 16
    4
      Marlin/Marlin.h
  2. 62
    61
      Marlin/Marlin_main.cpp
  3. 5
    1
      Marlin/planner.cpp

+ 16
- 4
Marlin/Marlin.h View File

293
 extern int extruder_multiplier[EXTRUDERS]; // sets extrude multiply factor (in percent) for each extruder individually
293
 extern int extruder_multiplier[EXTRUDERS]; // sets extrude multiply factor (in percent) for each extruder individually
294
 extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder.
294
 extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder.
295
 extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
295
 extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
296
-extern float current_position[NUM_AXIS];
297
-extern float home_offset[3]; // axis[n].home_offset
298
-extern float sw_endstop_min[3]; // axis[n].sw_endstop_min
299
-extern float sw_endstop_max[3]; // axis[n].sw_endstop_max
300
 extern bool axis_known_position[3]; // axis[n].is_known
296
 extern bool axis_known_position[3]; // axis[n].is_known
301
 extern bool axis_homed[3]; // axis[n].is_homed
297
 extern bool axis_homed[3]; // axis[n].is_homed
302
 extern volatile bool wait_for_heatup;
298
 extern volatile bool wait_for_heatup;
303
 
299
 
300
+extern float current_position[NUM_AXIS];
301
+extern float position_shift[3];
302
+extern float home_offset[3];
303
+extern float sw_endstop_min[3];
304
+extern float sw_endstop_max[3];
305
+
306
+#define LOGICAL_POSITION(POS, AXIS) (POS + home_offset[AXIS] + position_shift[AXIS])
307
+#define RAW_POSITION(POS, AXIS)     (POS - home_offset[AXIS] - position_shift[AXIS])
308
+#define LOGICAL_X_POSITION(POS)     LOGICAL_POSITION(POS, X_AXIS)
309
+#define LOGICAL_Y_POSITION(POS)     LOGICAL_POSITION(POS, Y_AXIS)
310
+#define LOGICAL_Z_POSITION(POS)     LOGICAL_POSITION(POS, Z_AXIS)
311
+#define RAW_X_POSITION(POS)         RAW_POSITION(POS, X_AXIS)
312
+#define RAW_Y_POSITION(POS)         RAW_POSITION(POS, Y_AXIS)
313
+#define RAW_Z_POSITION(POS)         RAW_POSITION(POS, Z_AXIS)
314
+#define RAW_CURRENT_POSITION(AXIS)  RAW_POSITION(current_position[AXIS], AXIS)
315
+
304
 // GCode support for external objects
316
 // GCode support for external objects
305
 bool code_seen(char);
317
 bool code_seen(char);
306
 int code_value_int();
318
 int code_value_int();

+ 62
- 61
Marlin/Marlin_main.cpp View File

331
 // Set by M206, M428, or menu item. Saved to EEPROM.
331
 // Set by M206, M428, or menu item. Saved to EEPROM.
332
 float home_offset[3] = { 0 };
332
 float home_offset[3] = { 0 };
333
 
333
 
334
-#define LOGICAL_POSITION(POS, AXIS) (POS + home_offset[AXIS] + position_shift[AXIS])
335
-#define RAW_POSITION(POS, AXIS) (POS - home_offset[AXIS] - position_shift[AXIS])
336
-#define RAW_CURRENT_POSITION(AXIS) (RAW_POSITION(current_position[AXIS], AXIS))
337
-
338
 // Software Endstops. Default to configured limits.
334
 // Software Endstops. Default to configured limits.
339
 float sw_endstop_min[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
335
 float sw_endstop_min[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
340
 float sw_endstop_max[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
336
 float sw_endstop_max[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
1421
 
1417
 
1422
   static float x_home_pos(int extruder) {
1418
   static float x_home_pos(int extruder) {
1423
     if (extruder == 0)
1419
     if (extruder == 0)
1424
-      return LOGICAL_POSITION(base_home_pos(X_AXIS), X_AXIS);
1420
+      return LOGICAL_X_POSITION(base_home_pos(X_AXIS));
1425
     else
1421
     else
1426
       /**
1422
       /**
1427
        * In dual carriage mode the extruder offset provides an override of the
1423
        * In dual carriage mode the extruder offset provides an override of the
1437
   }
1433
   }
1438
 
1434
 
1439
   static float inactive_extruder_x_pos = X2_MAX_POS; // used in mode 0 & 1
1435
   static float inactive_extruder_x_pos = X2_MAX_POS; // used in mode 0 & 1
1440
-  static bool active_extruder_parked = false; // used in mode 1 & 2
1441
-  static float raised_parked_position[NUM_AXIS]; // used in mode 1
1442
-  static millis_t delayed_move_time = 0; // used in mode 1
1436
+  static bool active_extruder_parked = false;        // used in mode 1 & 2
1437
+  static float raised_parked_position[NUM_AXIS];     // used in mode 1
1438
+  static millis_t delayed_move_time = 0;             // used in mode 1
1443
   static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2
1439
   static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2
1444
-  static float duplicate_extruder_temp_offset = 0; // used in mode 2
1440
+  static float duplicate_extruder_temp_offset = 0;   // used in mode 2
1445
 
1441
 
1446
 #endif //DUAL_X_CARRIAGE
1442
 #endif //DUAL_X_CARRIAGE
1447
 
1443
 
1526
       if (active_extruder != 0)
1522
       if (active_extruder != 0)
1527
         current_position[X_AXIS] = x_home_pos(active_extruder);
1523
         current_position[X_AXIS] = x_home_pos(active_extruder);
1528
       else
1524
       else
1529
-        current_position[X_AXIS] = LOGICAL_POSITION(base_home_pos(X_AXIS), X_AXIS);
1525
+        current_position[X_AXIS] = LOGICAL_X_POSITION(base_home_pos(X_AXIS));
1530
       update_software_endstops(X_AXIS);
1526
       update_software_endstops(X_AXIS);
1531
       return;
1527
       return;
1532
     }
1528
     }
1803
         SERIAL_ECHOLNPGM(")");
1799
         SERIAL_ECHOLNPGM(")");
1804
       }
1800
       }
1805
     #endif
1801
     #endif
1806
-    float z_dest = LOGICAL_POSITION(z_raise, Z_AXIS);
1802
+    float z_dest = LOGICAL_Z_POSITION(z_raise);
1807
 
1803
 
1808
     if (zprobe_zoffset < 0)
1804
     if (zprobe_zoffset < 0)
1809
       z_dest -= zprobe_zoffset;
1805
       z_dest -= zprobe_zoffset;
2964
 
2960
 
2965
       if (home_all_axis || homeX || homeY) {
2961
       if (home_all_axis || homeX || homeY) {
2966
         // Raise Z before homing any other axes and z is not already high enough (never lower z)
2962
         // Raise Z before homing any other axes and z is not already high enough (never lower z)
2967
-        destination[Z_AXIS] = LOGICAL_POSITION(MIN_Z_HEIGHT_FOR_HOMING, Z_AXIS);
2963
+        destination[Z_AXIS] = LOGICAL_Z_POSITION(MIN_Z_HEIGHT_FOR_HOMING);
2968
         if (destination[Z_AXIS] > current_position[Z_AXIS]) {
2964
         if (destination[Z_AXIS] > current_position[Z_AXIS]) {
2969
 
2965
 
2970
           #if ENABLED(DEBUG_LEVELING_FEATURE)
2966
           #if ENABLED(DEBUG_LEVELING_FEATURE)
3004
         int tmp_extruder = active_extruder;
3000
         int tmp_extruder = active_extruder;
3005
         active_extruder = !active_extruder;
3001
         active_extruder = !active_extruder;
3006
         HOMEAXIS(X);
3002
         HOMEAXIS(X);
3007
-        inactive_extruder_x_pos = current_position[X_AXIS];
3003
+        inactive_extruder_x_pos = RAW_X_POSITION(current_position[X_AXIS]);
3008
         active_extruder = tmp_extruder;
3004
         active_extruder = tmp_extruder;
3009
         HOMEAXIS(X);
3005
         HOMEAXIS(X);
3010
         // reset state used by the different modes
3006
         // reset state used by the different modes
3079
            * NOTE: This doesn't necessarily ensure the Z probe is also
3075
            * NOTE: This doesn't necessarily ensure the Z probe is also
3080
            * within the bed!
3076
            * within the bed!
3081
            */
3077
            */
3082
-          float cpx = current_position[X_AXIS], cpy = current_position[Y_AXIS];
3078
+          float cpx = RAW_CURRENT_POSITION(X_AXIS), cpy = RAW_CURRENT_POSITION(Y_AXIS);
3083
           if (   cpx >= X_MIN_POS - (X_PROBE_OFFSET_FROM_EXTRUDER)
3079
           if (   cpx >= X_MIN_POS - (X_PROBE_OFFSET_FROM_EXTRUDER)
3084
               && cpx <= X_MAX_POS - (X_PROBE_OFFSET_FROM_EXTRUDER)
3080
               && cpx <= X_MAX_POS - (X_PROBE_OFFSET_FROM_EXTRUDER)
3085
               && cpy >= Y_MIN_POS - (Y_PROBE_OFFSET_FROM_EXTRUDER)
3081
               && cpy >= Y_MIN_POS - (Y_PROBE_OFFSET_FROM_EXTRUDER)
3218
     ;
3214
     ;
3219
     line_to_current_position();
3215
     line_to_current_position();
3220
 
3216
 
3221
-    current_position[X_AXIS] = LOGICAL_POSITION(x, X_AXIS);
3222
-    current_position[Y_AXIS] = LOGICAL_POSITION(y, Y_AXIS);
3217
+    current_position[X_AXIS] = LOGICAL_X_POSITION(x);
3218
+    current_position[Y_AXIS] = LOGICAL_Y_POSITION(y);
3223
     line_to_current_position();
3219
     line_to_current_position();
3224
 
3220
 
3225
     #if Z_RAISE_BETWEEN_PROBINGS > 0 || MIN_Z_HEIGHT_FOR_HOMING > 0
3221
     #if Z_RAISE_BETWEEN_PROBINGS > 0 || MIN_Z_HEIGHT_FOR_HOMING > 0
3226
-      current_position[Z_AXIS] = LOGICAL_POSITION(MESH_HOME_SEARCH_Z, Z_AXIS);
3222
+      current_position[Z_AXIS] = LOGICAL_Z_POSITION(MESH_HOME_SEARCH_Z);
3227
       line_to_current_position();
3223
       line_to_current_position();
3228
     #endif
3224
     #endif
3229
 
3225
 
3476
 
3472
 
3477
       xy_probe_feedrate_mm_m = code_seen('S') ? (int)code_value_linear_units() : XY_PROBE_SPEED;
3473
       xy_probe_feedrate_mm_m = code_seen('S') ? (int)code_value_linear_units() : XY_PROBE_SPEED;
3478
 
3474
 
3479
-      int left_probe_bed_position = code_seen('L') ? (int)code_value_axis_units(X_AXIS) : LEFT_PROBE_BED_POSITION,
3480
-          right_probe_bed_position = code_seen('R') ? (int)code_value_axis_units(X_AXIS) : RIGHT_PROBE_BED_POSITION,
3481
-          front_probe_bed_position = code_seen('F') ? (int)code_value_axis_units(Y_AXIS) : FRONT_PROBE_BED_POSITION,
3482
-          back_probe_bed_position = code_seen('B') ? (int)code_value_axis_units(Y_AXIS) : BACK_PROBE_BED_POSITION;
3475
+      int left_probe_bed_position = code_seen('L') ? (int)code_value_axis_units(X_AXIS) : LOGICAL_X_POSITION(LEFT_PROBE_BED_POSITION),
3476
+          right_probe_bed_position = code_seen('R') ? (int)code_value_axis_units(X_AXIS) : LOGICAL_X_POSITION(RIGHT_PROBE_BED_POSITION),
3477
+          front_probe_bed_position = code_seen('F') ? (int)code_value_axis_units(Y_AXIS) : LOGICAL_Y_POSITION(FRONT_PROBE_BED_POSITION),
3478
+          back_probe_bed_position = code_seen('B') ? (int)code_value_axis_units(Y_AXIS) : LOGICAL_Y_POSITION(BACK_PROBE_BED_POSITION);
3483
 
3479
 
3484
-      bool left_out_l = left_probe_bed_position < MIN_PROBE_X,
3480
+      bool left_out_l = left_probe_bed_position < LOGICAL_X_POSITION(MIN_PROBE_X),
3485
            left_out = left_out_l || left_probe_bed_position > right_probe_bed_position - (MIN_PROBE_EDGE),
3481
            left_out = left_out_l || left_probe_bed_position > right_probe_bed_position - (MIN_PROBE_EDGE),
3486
-           right_out_r = right_probe_bed_position > MAX_PROBE_X,
3482
+           right_out_r = right_probe_bed_position > LOGICAL_X_POSITION(MAX_PROBE_X),
3487
            right_out = right_out_r || right_probe_bed_position < left_probe_bed_position + MIN_PROBE_EDGE,
3483
            right_out = right_out_r || right_probe_bed_position < left_probe_bed_position + MIN_PROBE_EDGE,
3488
-           front_out_f = front_probe_bed_position < MIN_PROBE_Y,
3484
+           front_out_f = front_probe_bed_position < LOGICAL_Y_POSITION(MIN_PROBE_Y),
3489
            front_out = front_out_f || front_probe_bed_position > back_probe_bed_position - (MIN_PROBE_EDGE),
3485
            front_out = front_out_f || front_probe_bed_position > back_probe_bed_position - (MIN_PROBE_EDGE),
3490
-           back_out_b = back_probe_bed_position > MAX_PROBE_Y,
3486
+           back_out_b = back_probe_bed_position > LOGICAL_Y_POSITION(MAX_PROBE_Y),
3491
            back_out = back_out_b || back_probe_bed_position < front_probe_bed_position + MIN_PROBE_EDGE;
3487
            back_out = back_out_b || back_probe_bed_position < front_probe_bed_position + MIN_PROBE_EDGE;
3492
 
3488
 
3493
       if (left_out || right_out || front_out || back_out) {
3489
       if (left_out || right_out || front_out || back_out) {
3494
         if (left_out) {
3490
         if (left_out) {
3495
           out_of_range_error(PSTR("(L)eft"));
3491
           out_of_range_error(PSTR("(L)eft"));
3496
-          left_probe_bed_position = left_out_l ? MIN_PROBE_X : right_probe_bed_position - (MIN_PROBE_EDGE);
3492
+          left_probe_bed_position = left_out_l ? LOGICAL_X_POSITION(MIN_PROBE_X) : right_probe_bed_position - (MIN_PROBE_EDGE);
3497
         }
3493
         }
3498
         if (right_out) {
3494
         if (right_out) {
3499
           out_of_range_error(PSTR("(R)ight"));
3495
           out_of_range_error(PSTR("(R)ight"));
3500
-          right_probe_bed_position = right_out_r ? MAX_PROBE_X : left_probe_bed_position + MIN_PROBE_EDGE;
3496
+          right_probe_bed_position = right_out_r ? LOGICAL_Y_POSITION(MAX_PROBE_X) : left_probe_bed_position + MIN_PROBE_EDGE;
3501
         }
3497
         }
3502
         if (front_out) {
3498
         if (front_out) {
3503
           out_of_range_error(PSTR("(F)ront"));
3499
           out_of_range_error(PSTR("(F)ront"));
3504
-          front_probe_bed_position = front_out_f ? MIN_PROBE_Y : back_probe_bed_position - (MIN_PROBE_EDGE);
3500
+          front_probe_bed_position = front_out_f ? LOGICAL_Y_POSITION(MIN_PROBE_Y) : back_probe_bed_position - (MIN_PROBE_EDGE);
3505
         }
3501
         }
3506
         if (back_out) {
3502
         if (back_out) {
3507
           out_of_range_error(PSTR("(B)ack"));
3503
           out_of_range_error(PSTR("(B)ack"));
3508
-          back_probe_bed_position = back_out_b ? MAX_PROBE_Y : front_probe_bed_position + MIN_PROBE_EDGE;
3504
+          back_probe_bed_position = back_out_b ? LOGICAL_Y_POSITION(MAX_PROBE_Y) : front_probe_bed_position + MIN_PROBE_EDGE;
3509
         }
3505
         }
3510
         return;
3506
         return;
3511
       }
3507
       }
3641
       #endif
3637
       #endif
3642
 
3638
 
3643
       // Probe at 3 arbitrary points
3639
       // Probe at 3 arbitrary points
3644
-      float z_at_pt_1 = probe_pt( LOGICAL_POSITION(ABL_PROBE_PT_1_X, X_AXIS),
3645
-                                  LOGICAL_POSITION(ABL_PROBE_PT_1_Y, Y_AXIS),
3640
+      float z_at_pt_1 = probe_pt( LOGICAL_X_POSITION(ABL_PROBE_PT_1_X, X_AXIS),
3641
+                                  LOGICAL_Y_POSITION(ABL_PROBE_PT_1_Y, Y_AXIS),
3646
                                   stow_probe_after_each, verbose_level),
3642
                                   stow_probe_after_each, verbose_level),
3647
-            z_at_pt_2 = probe_pt( LOGICAL_POSITION(ABL_PROBE_PT_2_X, X_AXIS),
3648
-                                  LOGICAL_POSITION(ABL_PROBE_PT_2_Y, Y_AXIS),
3643
+            z_at_pt_2 = probe_pt( LOGICAL_X_POSITION(ABL_PROBE_PT_2_X, X_AXIS),
3644
+                                  LOGICAL_Y_POSITION(ABL_PROBE_PT_2_Y, Y_AXIS),
3649
                                   stow_probe_after_each, verbose_level),
3645
                                   stow_probe_after_each, verbose_level),
3650
-            z_at_pt_3 = probe_pt( LOGICAL_POSITION(ABL_PROBE_PT_3_X, X_AXIS),
3651
-                                  LOGICAL_POSITION(ABL_PROBE_PT_3_Y, Y_AXIS),
3646
+            z_at_pt_3 = probe_pt( LOGICAL_X_POSITION(ABL_PROBE_PT_3_X, X_AXIS),
3647
+                                  LOGICAL_Y_POSITION(ABL_PROBE_PT_3_Y, Y_AXIS),
3652
                                   stow_probe_after_each, verbose_level);
3648
                                   stow_probe_after_each, verbose_level);
3653
 
3649
 
3654
       if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
3650
       if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
4212
 
4208
 
4213
     float X_probe_location = code_seen('X') ? code_value_axis_units(X_AXIS) : X_current + X_PROBE_OFFSET_FROM_EXTRUDER;
4209
     float X_probe_location = code_seen('X') ? code_value_axis_units(X_AXIS) : X_current + X_PROBE_OFFSET_FROM_EXTRUDER;
4214
     #if DISABLED(DELTA)
4210
     #if DISABLED(DELTA)
4215
-      if (X_probe_location < MIN_PROBE_X || X_probe_location > MAX_PROBE_X) {
4211
+      if (X_probe_location < LOGICAL_X_POSITION(MIN_PROBE_X) || X_probe_location > LOGICAL_X_POSITION(MAX_PROBE_X)) {
4216
         out_of_range_error(PSTR("X"));
4212
         out_of_range_error(PSTR("X"));
4217
         return;
4213
         return;
4218
       }
4214
       }
4220
 
4216
 
4221
     float Y_probe_location = code_seen('Y') ? code_value_axis_units(Y_AXIS) : Y_current + Y_PROBE_OFFSET_FROM_EXTRUDER;
4217
     float Y_probe_location = code_seen('Y') ? code_value_axis_units(Y_AXIS) : Y_current + Y_PROBE_OFFSET_FROM_EXTRUDER;
4222
     #if DISABLED(DELTA)
4218
     #if DISABLED(DELTA)
4223
-      if (Y_probe_location < MIN_PROBE_Y || Y_probe_location > MAX_PROBE_Y) {
4219
+      if (Y_probe_location < LOGICAL_Y_POSITION(MIN_PROBE_Y) || Y_probe_location > LOGICAL_Y_POSITION(MAX_PROBE_Y)) {
4224
         out_of_range_error(PSTR("Y"));
4220
         out_of_range_error(PSTR("Y"));
4225
         return;
4221
         return;
4226
       }
4222
       }
4227
     #else
4223
     #else
4228
-      if (HYPOT(X_probe_location, Y_probe_location) > DELTA_PROBEABLE_RADIUS) {
4224
+      if (HYPOT(RAW_X_POSITION(X_probe_location), RAW_Y_POSITION(Y_probe_location)) > DELTA_PROBEABLE_RADIUS) {
4229
         SERIAL_PROTOCOLLNPGM("? (X,Y) location outside of probeable radius.");
4225
         SERIAL_PROTOCOLLNPGM("? (X,Y) location outside of probeable radius.");
4230
         return;
4226
         return;
4231
       }
4227
       }
6751
 
6747
 
6752
           switch (dual_x_carriage_mode) {
6748
           switch (dual_x_carriage_mode) {
6753
             case DXC_FULL_CONTROL_MODE:
6749
             case DXC_FULL_CONTROL_MODE:
6754
-              current_position[X_AXIS] = inactive_extruder_x_pos;
6755
-              inactive_extruder_x_pos = destination[X_AXIS];
6750
+              current_position[X_AXIS] = LOGICAL_X_POSITION(inactive_extruder_x_pos);
6751
+              inactive_extruder_x_pos = RAW_X_POSITION(destination[X_AXIS]);
6756
               break;
6752
               break;
6757
             case DXC_DUPLICATION_MODE:
6753
             case DXC_DUPLICATION_MODE:
6758
               active_extruder_parked = (active_extruder == 0); // this triggers the second extruder to move into the duplication position
6754
               active_extruder_parked = (active_extruder == 0); // this triggers the second extruder to move into the duplication position
6759
               if (active_extruder_parked)
6755
               if (active_extruder_parked)
6760
-                current_position[X_AXIS] = inactive_extruder_x_pos;
6756
+                current_position[X_AXIS] = LOGICAL_X_POSITION(inactive_extruder_x_pos);
6761
               else
6757
               else
6762
                 current_position[X_AXIS] = destination[X_AXIS] + duplicate_extruder_x_offset;
6758
                 current_position[X_AXIS] = destination[X_AXIS] + duplicate_extruder_x_offset;
6763
-              inactive_extruder_x_pos = destination[X_AXIS];
6759
+              inactive_extruder_x_pos = RAW_X_POSITION(destination[X_AXIS]);
6764
               extruder_duplication_enabled = false;
6760
               extruder_duplication_enabled = false;
6765
               break;
6761
               break;
6766
             default:
6762
             default:
7749
   void inverse_kinematics(const float in_cartesian[3]) {
7745
   void inverse_kinematics(const float in_cartesian[3]) {
7750
 
7746
 
7751
     const float cartesian[3] = {
7747
     const float cartesian[3] = {
7752
-      RAW_POSITION(in_cartesian[X_AXIS], X_AXIS),
7753
-      RAW_POSITION(in_cartesian[Y_AXIS], Y_AXIS),
7754
-      RAW_POSITION(in_cartesian[Z_AXIS], Z_AXIS)
7748
+      RAW_X_POSITION(in_cartesian[X_AXIS]),
7749
+      RAW_Y_POSITION(in_cartesian[Y_AXIS]),
7750
+      RAW_Z_POSITION(in_cartesian[Z_AXIS])
7755
     };
7751
     };
7756
 
7752
 
7757
     delta[TOWER_1] = sqrt(delta_diagonal_rod_2_tower_1
7753
     delta[TOWER_1] = sqrt(delta_diagonal_rod_2_tower_1
7779
 
7775
 
7780
   float delta_safe_distance_from_top() {
7776
   float delta_safe_distance_from_top() {
7781
     float cartesian[3] = {
7777
     float cartesian[3] = {
7782
-      LOGICAL_POSITION(0, X_AXIS),
7783
-      LOGICAL_POSITION(0, Y_AXIS),
7784
-      LOGICAL_POSITION(0, Z_AXIS)
7778
+      LOGICAL_X_POSITION(0),
7779
+      LOGICAL_Y_POSITION(0),
7780
+      LOGICAL_Z_POSITION(0)
7785
     };
7781
     };
7786
     inverse_kinematics(cartesian);
7782
     inverse_kinematics(cartesian);
7787
     float distance = delta[TOWER_3];
7783
     float distance = delta[TOWER_3];
7788
-    cartesian[Y_AXIS] = LOGICAL_POSITION(DELTA_PRINTABLE_RADIUS, Y_AXIS);
7784
+    cartesian[Y_AXIS] = LOGICAL_Y_POSITION(DELTA_PRINTABLE_RADIUS);
7789
     inverse_kinematics(cartesian);
7785
     inverse_kinematics(cartesian);
7790
     return abs(distance - delta[TOWER_3]);
7786
     return abs(distance - delta[TOWER_3]);
7791
   }
7787
   }
7877
 
7873
 
7878
       int half = (AUTO_BED_LEVELING_GRID_POINTS - 1) / 2;
7874
       int half = (AUTO_BED_LEVELING_GRID_POINTS - 1) / 2;
7879
       float h1 = 0.001 - half, h2 = half - 0.001,
7875
       float h1 = 0.001 - half, h2 = half - 0.001,
7880
-            grid_x = max(h1, min(h2, RAW_POSITION(cartesian[X_AXIS], X_AXIS) / delta_grid_spacing[0])),
7881
-            grid_y = max(h1, min(h2, RAW_POSITION(cartesian[Y_AXIS], Y_AXIS) / delta_grid_spacing[1]));
7876
+            grid_x = max(h1, min(h2, RAW_X_POSITION(cartesian[X_AXIS]) / delta_grid_spacing[0])),
7877
+            grid_y = max(h1, min(h2, RAW_Y_POSITION(cartesian[Y_AXIS]) / delta_grid_spacing[1]));
7882
       int floor_x = floor(grid_x), floor_y = floor(grid_y);
7878
       int floor_x = floor(grid_x), floor_y = floor(grid_y);
7883
       float ratio_x = grid_x - floor_x, ratio_y = grid_y - floor_y,
7879
       float ratio_x = grid_x - floor_x, ratio_y = grid_y - floor_y,
7884
             z1 = bed_level[floor_x + half][floor_y + half],
7880
             z1 = bed_level[floor_x + half][floor_y + half],
7919
     current_position[axis] = LOGICAL_POSITION(cartesian_position[axis], axis);
7915
     current_position[axis] = LOGICAL_POSITION(cartesian_position[axis], axis);
7920
   #elif ENABLED(AUTO_BED_LEVELING_FEATURE)
7916
   #elif ENABLED(AUTO_BED_LEVELING_FEATURE)
7921
     vector_3 pos = planner.adjusted_position();
7917
     vector_3 pos = planner.adjusted_position();
7922
-    current_position[axis] = LOGICAL_POSITION(axis == X_AXIS ? pos.x : axis == Y_AXIS ? pos.y : pos.z, axis);
7918
+    current_position[axis] = axis == X_AXIS ? pos.x : axis == Y_AXIS ? pos.y : pos.z;
7923
   #else
7919
   #else
7924
-    current_position[axis] = LOGICAL_POSITION(stepper.get_axis_position_mm(axis), axis); // CORE handled transparently
7920
+    current_position[axis] = stepper.get_axis_position_mm(axis); // CORE handled transparently
7925
   #endif
7921
   #endif
7926
 }
7922
 }
7927
 
7923
 
7931
 void mesh_line_to_destination(float fr_mm_m, uint8_t x_splits = 0xff, uint8_t y_splits = 0xff) {
7927
 void mesh_line_to_destination(float fr_mm_m, uint8_t x_splits = 0xff, uint8_t y_splits = 0xff) {
7932
   int cx1 = mbl.cell_index_x(RAW_CURRENT_POSITION(X_AXIS)),
7928
   int cx1 = mbl.cell_index_x(RAW_CURRENT_POSITION(X_AXIS)),
7933
       cy1 = mbl.cell_index_y(RAW_CURRENT_POSITION(Y_AXIS)),
7929
       cy1 = mbl.cell_index_y(RAW_CURRENT_POSITION(Y_AXIS)),
7934
-      cx2 = mbl.cell_index_x(RAW_POSITION(destination[X_AXIS], X_AXIS)),
7935
-      cy2 = mbl.cell_index_y(RAW_POSITION(destination[Y_AXIS], Y_AXIS));
7930
+      cx2 = mbl.cell_index_x(RAW_X_POSITION(destination[X_AXIS])),
7931
+      cy2 = mbl.cell_index_y(RAW_Y_POSITION(destination[Y_AXIS]));
7936
   NOMORE(cx1, MESH_NUM_X_POINTS - 2);
7932
   NOMORE(cx1, MESH_NUM_X_POINTS - 2);
7937
   NOMORE(cy1, MESH_NUM_Y_POINTS - 2);
7933
   NOMORE(cy1, MESH_NUM_Y_POINTS - 2);
7938
   NOMORE(cx2, MESH_NUM_X_POINTS - 2);
7934
   NOMORE(cx2, MESH_NUM_X_POINTS - 2);
7953
   int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);
7949
   int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);
7954
   if (cx2 != cx1 && TEST(x_splits, gcx)) {
7950
   if (cx2 != cx1 && TEST(x_splits, gcx)) {
7955
     memcpy(end, destination, sizeof(end));
7951
     memcpy(end, destination, sizeof(end));
7956
-    destination[X_AXIS] = LOGICAL_POSITION(mbl.get_probe_x(gcx), X_AXIS);
7952
+    destination[X_AXIS] = LOGICAL_X_POSITION(mbl.get_probe_x(gcx));
7957
     normalized_dist = (destination[X_AXIS] - current_position[X_AXIS]) / (end[X_AXIS] - current_position[X_AXIS]);
7953
     normalized_dist = (destination[X_AXIS] - current_position[X_AXIS]) / (end[X_AXIS] - current_position[X_AXIS]);
7958
     destination[Y_AXIS] = MBL_SEGMENT_END(Y);
7954
     destination[Y_AXIS] = MBL_SEGMENT_END(Y);
7959
     CBI(x_splits, gcx);
7955
     CBI(x_splits, gcx);
7960
   }
7956
   }
7961
   else if (cy2 != cy1 && TEST(y_splits, gcy)) {
7957
   else if (cy2 != cy1 && TEST(y_splits, gcy)) {
7962
     memcpy(end, destination, sizeof(end));
7958
     memcpy(end, destination, sizeof(end));
7963
-    destination[Y_AXIS] = LOGICAL_POSITION(mbl.get_probe_y(gcy), Y_AXIS);
7959
+    destination[Y_AXIS] = LOGICAL_Y_POSITION(mbl.get_probe_y(gcy));
7964
     normalized_dist = (destination[Y_AXIS] - current_position[Y_AXIS]) / (end[Y_AXIS] - current_position[Y_AXIS]);
7960
     normalized_dist = (destination[Y_AXIS] - current_position[Y_AXIS]) / (end[Y_AXIS] - current_position[Y_AXIS]);
7965
     destination[X_AXIS] = MBL_SEGMENT_END(X);
7961
     destination[X_AXIS] = MBL_SEGMENT_END(X);
7966
     CBI(y_splits, gcy);
7962
     CBI(y_splits, gcy);
8031
     if (active_extruder_parked) {
8027
     if (active_extruder_parked) {
8032
       if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) {
8028
       if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) {
8033
         // move duplicate extruder into correct duplication position.
8029
         // move duplicate extruder into correct duplication position.
8034
-        planner.set_position_mm(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
8030
+        planner.set_position_mm(
8031
+          LOGICAL_X_POSITION(inactive_extruder_x_pos),
8032
+          current_position[Y_AXIS],
8033
+          current_position[Z_AXIS],
8034
+          current_position[E_AXIS]
8035
+        );
8035
         planner.buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset,
8036
         planner.buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset,
8036
                          current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], planner.max_feedrate_mm_s[X_AXIS], 1);
8037
                          current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], planner.max_feedrate_mm_s[X_AXIS], 1);
8037
         SYNC_PLAN_POSITION_KINEMATIC();
8038
         SYNC_PLAN_POSITION_KINEMATIC();
8375
     float SCARA_pos[2];
8376
     float SCARA_pos[2];
8376
     static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi;
8377
     static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi;
8377
 
8378
 
8378
-    SCARA_pos[X_AXIS] = RAW_POSITION(cartesian[X_AXIS], X_AXIS) * axis_scaling[X_AXIS] - SCARA_offset_x;  //Translate SCARA to standard X Y
8379
-    SCARA_pos[Y_AXIS] = RAW_POSITION(cartesian[Y_AXIS], Y_AXIS) * axis_scaling[Y_AXIS] - SCARA_offset_y;  // With scaling factor.
8379
+    SCARA_pos[X_AXIS] = RAW_X_POSITION(cartesian[X_AXIS]) * axis_scaling[X_AXIS] - SCARA_offset_x;  //Translate SCARA to standard X Y
8380
+    SCARA_pos[Y_AXIS] = RAW_Y_POSITION(cartesian[Y_AXIS]) * axis_scaling[Y_AXIS] - SCARA_offset_y;  // With scaling factor.
8380
 
8381
 
8381
     #if (Linkage_1 == Linkage_2)
8382
     #if (Linkage_1 == Linkage_2)
8382
       SCARA_C2 = ((sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS])) / (2 * (float)L1_2)) - 1;
8383
       SCARA_C2 = ((sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS])) / (2 * (float)L1_2)) - 1;
8394
 
8395
 
8395
     delta[X_AXIS] = SCARA_theta * SCARA_RAD2DEG;  // Multiply by 180/Pi  -  theta is support arm angle
8396
     delta[X_AXIS] = SCARA_theta * SCARA_RAD2DEG;  // Multiply by 180/Pi  -  theta is support arm angle
8396
     delta[Y_AXIS] = (SCARA_theta + SCARA_psi) * SCARA_RAD2DEG;  //       -  equal to sub arm angle (inverted motor)
8397
     delta[Y_AXIS] = (SCARA_theta + SCARA_psi) * SCARA_RAD2DEG;  //       -  equal to sub arm angle (inverted motor)
8397
-    delta[Z_AXIS] = RAW_POSITION(cartesian[Z_AXIS], Z_AXIS);
8398
+    delta[Z_AXIS] = RAW_Z_POSITION(cartesian[Z_AXIS]);
8398
 
8399
 
8399
     /**
8400
     /**
8400
     SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]);
8401
     SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]);

+ 5
- 1
Marlin/planner.cpp View File

1157
 #endif // AUTO_BED_LEVELING_FEATURE || MESH_BED_LEVELING
1157
 #endif // AUTO_BED_LEVELING_FEATURE || MESH_BED_LEVELING
1158
   {
1158
   {
1159
     #if ENABLED(MESH_BED_LEVELING)
1159
     #if ENABLED(MESH_BED_LEVELING)
1160
+
1160
       if (mbl.active())
1161
       if (mbl.active())
1161
-        z += mbl.get_z(x - home_offset[X_AXIS], y - home_offset[Y_AXIS]);
1162
+        z += mbl.get_z(RAW_X_POSITION(x), RAW_Y_POSITION(y));
1163
+
1162
     #elif ENABLED(AUTO_BED_LEVELING_FEATURE)
1164
     #elif ENABLED(AUTO_BED_LEVELING_FEATURE)
1165
+
1163
       apply_rotation_xyz(bed_level_matrix, x, y, z);
1166
       apply_rotation_xyz(bed_level_matrix, x, y, z);
1167
+
1164
     #endif
1168
     #endif
1165
 
1169
 
1166
     long nx = position[X_AXIS] = lround(x * axis_steps_per_mm[X_AXIS]),
1170
     long nx = position[X_AXIS] = lround(x * axis_steps_per_mm[X_AXIS]),

Loading…
Cancel
Save