Selaa lähdekoodia

Use forwardKinematics in DELTA run_z_probe()

AnHardt 9 vuotta sitten
vanhempi
commit
5db9b940ee
2 muutettua tiedostoa jossa 27 lisäystä ja 6 poistoa
  1. 4
    0
      Marlin/Marlin.h
  2. 23
    6
      Marlin/Marlin_main.cpp

+ 4
- 0
Marlin/Marlin.h Näytä tiedosto

318
   void calculate_delta(float cartesian[3]);
318
   void calculate_delta(float cartesian[3]);
319
   void recalc_delta_settings(float radius, float diagonal_rod);
319
   void recalc_delta_settings(float radius, float diagonal_rod);
320
   float delta_safe_distance_from_top();
320
   float delta_safe_distance_from_top();
321
+  void set_current_from_steppers();
322
+  void set_cartesian_from_steppers();
323
+  void forwardKinematics(float point[3]);
324
+  void forwardKinematics(float z1, float z2, float z3);
321
   #if ENABLED(AUTO_BED_LEVELING_FEATURE)
325
   #if ENABLED(AUTO_BED_LEVELING_FEATURE)
322
     extern int delta_grid_spacing[2];
326
     extern int delta_grid_spacing[2];
323
     void adjust_delta(float cartesian[3]);
327
     void adjust_delta(float cartesian[3]);

+ 23
- 6
Marlin/Marlin_main.cpp Näytä tiedosto

462
   #define TOWER_3 Z_AXIS
462
   #define TOWER_3 Z_AXIS
463
 
463
 
464
   float delta[3] = { 0 };
464
   float delta[3] = { 0 };
465
+  float cartesian[3] = { 0 };
465
   #define SIN_60 0.8660254037844386
466
   #define SIN_60 0.8660254037844386
466
   #define COS_60 0.5
467
   #define COS_60 0.5
467
   float endstop_adj[3] = { 0 };
468
   float endstop_adj[3] = { 0 };
2087
   }
2088
   }
2088
 
2089
 
2089
   #if ENABLED(DELTA)
2090
   #if ENABLED(DELTA)
2090
-    #define Z_FROM_STEPPERS() z_before + stepper.get_axis_position_mm(Z_AXIS) - z_mm
2091
+    #define SET_Z_FROM_STEPPERS() set_current_from_steppers()
2091
   #else
2092
   #else
2092
-    #define Z_FROM_STEPPERS() stepper.get_axis_position_mm(Z_AXIS)
2093
+    #define SET_Z_FROM_STEPPERS() current_position[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS)
2093
   #endif
2094
   #endif
2094
 
2095
 
2095
   // Do a single Z probe and return with current_position[Z_AXIS]
2096
   // Do a single Z probe and return with current_position[Z_AXIS]
2110
 
2111
 
2111
     do_blocking_move_to_z(-(Z_MAX_LENGTH + 10), Z_PROBE_SPEED_FAST);
2112
     do_blocking_move_to_z(-(Z_MAX_LENGTH + 10), Z_PROBE_SPEED_FAST);
2112
     endstops.hit_on_purpose();
2113
     endstops.hit_on_purpose();
2113
-    current_position[Z_AXIS] = Z_FROM_STEPPERS();
2114
+    SET_Z_FROM_STEPPERS();
2114
     SYNC_PLAN_POSITION_KINEMATIC();
2115
     SYNC_PLAN_POSITION_KINEMATIC();
2115
 
2116
 
2116
     // move up the retract distance
2117
     // move up the retract distance
2124
     // move back down slowly to find bed
2125
     // move back down slowly to find bed
2125
     do_blocking_move_to_z(current_position[Z_AXIS] - home_bump_mm(Z_AXIS) * 2, Z_PROBE_SPEED_SLOW);
2126
     do_blocking_move_to_z(current_position[Z_AXIS] - home_bump_mm(Z_AXIS) * 2, Z_PROBE_SPEED_SLOW);
2126
     endstops.hit_on_purpose();
2127
     endstops.hit_on_purpose();
2127
-    current_position[Z_AXIS] = Z_FROM_STEPPERS();
2128
+    SET_Z_FROM_STEPPERS();
2128
     SYNC_PLAN_POSITION_KINEMATIC();
2129
     SYNC_PLAN_POSITION_KINEMATIC();
2129
 
2130
 
2130
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2131
     #if ENABLED(DEBUG_LEVELING_FEATURE)
7780
     return abs(distance - delta[TOWER_3]);
7781
     return abs(distance - delta[TOWER_3]);
7781
   }
7782
   }
7782
 
7783
 
7783
-  float cartesian[3]; // result
7784
   void forwardKinematics(float z1, float z2, float z3) {
7784
   void forwardKinematics(float z1, float z2, float z3) {
7785
     //As discussed in Wikipedia "Trilateration"
7785
     //As discussed in Wikipedia "Trilateration"
7786
     //we are establishing a new coordinate
7786
     //we are establishing a new coordinate
7803
 
7803
 
7804
     // Result is in cartesian[].
7804
     // Result is in cartesian[].
7805
 
7805
 
7806
-    //Create a vector in old coords along x axis of new coord
7806
+    //Create a vector in old coordinates along x axis of new coordinate
7807
     float p12[3] = { delta_tower2_x - delta_tower1_x, delta_tower2_y - delta_tower1_y, z2 - z1 };
7807
     float p12[3] = { delta_tower2_x - delta_tower1_x, delta_tower2_y - delta_tower1_y, z2 - z1 };
7808
 
7808
 
7809
     //Get the Magnitude of vector.
7809
     //Get the Magnitude of vector.
7850
     cartesian[Z_AXIS] = z1             + ex[2]*Xnew + ey[2]*Ynew - ez[2]*Znew;
7850
     cartesian[Z_AXIS] = z1             + ex[2]*Xnew + ey[2]*Ynew - ez[2]*Znew;
7851
   };
7851
   };
7852
 
7852
 
7853
+  void forwardKinematics(float point[3]) {
7854
+    forwardKinematics(point[X_AXIS], point[Y_AXIS], point[Z_AXIS]);
7855
+  }
7856
+
7857
+  void set_cartesian_from_steppers() {
7858
+    forwardKinematics(stepper.get_axis_position_mm(X_AXIS),
7859
+                      stepper.get_axis_position_mm(Y_AXIS),
7860
+                      stepper.get_axis_position_mm(Z_AXIS));
7861
+  }
7862
+
7863
+  void set_current_from_steppers() {
7864
+    set_cartesian_from_steppers();
7865
+    current_position[X_AXIS] = cartesian[X_AXIS];
7866
+    current_position[Y_AXIS] = cartesian[Y_AXIS];
7867
+    current_position[Z_AXIS] = cartesian[Z_AXIS];
7868
+  }
7869
+
7853
   #if ENABLED(AUTO_BED_LEVELING_FEATURE)
7870
   #if ENABLED(AUTO_BED_LEVELING_FEATURE)
7854
 
7871
 
7855
     // Adjust print surface height by linear interpolation over the bed_level array.
7872
     // Adjust print surface height by linear interpolation over the bed_level array.

Loading…
Peruuta
Tallenna