Browse Source

Backlash Compensation for COREnn (#21612)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
Nikolay March 3 years ago
parent
commit
6f5800bd74
No account linked to committer's email address

+ 3
- 0
Marlin/Configuration_adv.h View File

@@ -972,6 +972,9 @@
972 972
   #define BACKLASH_DISTANCE_MM { 0, 0, 0 } // (mm)
973 973
   #define BACKLASH_CORRECTION    0.0       // 0.0 = no correction; 1.0 = full correction
974 974
 
975
+  // Add steps for motor direction changes on CORE kinematics
976
+  //#define CORE_BACKLASH
977
+
975 978
   // Set BACKLASH_SMOOTHING_MM to spread backlash correction over multiple segments
976 979
   // to reduce print artifacts. (Enabling this is costly in memory and computation!)
977 980
   //#define BACKLASH_SMOOTHING_MM 3 // (mm)

+ 39
- 8
Marlin/src/feature/backlash.cpp View File

@@ -63,10 +63,24 @@ Backlash backlash;
63 63
 void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const uint8_t dm, block_t * const block) {
64 64
   static uint8_t last_direction_bits;
65 65
   uint8_t changed_dir = last_direction_bits ^ dm;
66
-  // Ignore direction change if no steps are taken in that direction
67
-  if (da == 0) CBI(changed_dir, X_AXIS);
68
-  if (db == 0) CBI(changed_dir, Y_AXIS);
69
-  if (dc == 0) CBI(changed_dir, Z_AXIS);
66
+  // Ignore direction change unless steps are taken in that direction
67
+  #if DISABLED(CORE_BACKLASH) || ENABLED(MARKFORGED_XY)
68
+    if (!da) CBI(changed_dir, X_AXIS);
69
+    if (!db) CBI(changed_dir, Y_AXIS);
70
+    if (!dc) CBI(changed_dir, Z_AXIS);
71
+  #elif CORE_IS_XY
72
+    if (!(da + db)) CBI(changed_dir, X_AXIS);
73
+    if (!(da - db)) CBI(changed_dir, Y_AXIS);
74
+    if (!dc)        CBI(changed_dir, Z_AXIS);
75
+  #elif CORE_IS_XZ
76
+    if (!(da + dc)) CBI(changed_dir, X_AXIS);
77
+    if (!(da - dc)) CBI(changed_dir, Z_AXIS);
78
+    if (!db)        CBI(changed_dir, Y_AXIS);
79
+  #elif CORE_IS_YZ
80
+    if (!(db + dc)) CBI(changed_dir, Y_AXIS);
81
+    if (!(db - dc)) CBI(changed_dir, Z_AXIS);
82
+    if (!da)        CBI(changed_dir, X_AXIS);
83
+  #endif
70 84
   last_direction_bits ^= changed_dir;
71 85
 
72 86
   if (correction == 0) return;
@@ -105,18 +119,35 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
105 119
           // Take up a portion of the residual_error in this segment, but only when
106 120
           // the current segment travels in the same direction as the correction
107 121
           if (reversing == (error_correction < 0)) {
108
-            if (segment_proportion == 0)
109
-              segment_proportion = _MIN(1.0f, block->millimeters / smoothing_mm);
122
+            if (segment_proportion == 0) segment_proportion = _MIN(1.0f, block->millimeters / smoothing_mm);
110 123
             error_correction = CEIL(segment_proportion * error_correction);
111 124
           }
112 125
           else
113 126
             error_correction = 0; // Don't take up any backlash in this segment, as it would subtract steps
114 127
         }
115 128
       #endif
116
-      // Making a correction reduces the residual error and adds block steps
129
+
130
+      // This correction reduces the residual error and adds block steps
117 131
       if (error_correction) {
118 132
         block->steps[axis] += ABS(error_correction);
119
-        residual_error[axis] -= error_correction;
133
+        #if ENABLED(CORE_BACKLASH)
134
+          switch (axis) {
135
+            case CORE_AXIS_1:
136
+              //block->steps[CORE_AXIS_2] += influence_distance_mm[axis] * planner.settings.axis_steps_per_mm[CORE_AXIS_2];
137
+              //SERIAL_ECHOLNPAIR("CORE_AXIS_1 dir change. distance=", distance_mm[axis], " r.err=", residual_error[axis],
138
+              //  " da=", da, " db=", db, " block->steps[axis]=", block->steps[axis], " err_corr=", error_correction);
139
+              break;
140
+            case CORE_AXIS_2:
141
+              //block->steps[CORE_AXIS_1] += influence_distance_mm[axis] * planner.settings.axis_steps_per_mm[CORE_AXIS_1];;
142
+              //SERIAL_ECHOLNPAIR("CORE_AXIS_2 dir change. distance=", distance_mm[axis], " r.err=", residual_error[axis],
143
+              //  " da=", da, " db=", db, " block->steps[axis]=", block->steps[axis], " err_corr=", error_correction);
144
+              break;
145
+            case NORMAL_AXIS: break;
146
+          }
147
+          residual_error[axis] = 0; // No residual_error needed for next CORE block, I think...
148
+        #else
149
+          residual_error[axis] -= error_correction;
150
+        #endif
120 151
       }
121 152
     }
122 153
   }

+ 8
- 3
Marlin/src/lcd/menu/menu_backlash.cpp View File

@@ -38,10 +38,15 @@ void menu_backlash() {
38 38
 
39 39
   EDIT_ITEM_FAST(percent, MSG_BACKLASH_CORRECTION, &backlash.correction, all_off, all_on);
40 40
 
41
+  #if DISABLED(CORE_BACKLASH) || ENABLED(MARKFORGED_XY)
42
+    #define _CAN_CALI AXIS_CAN_CALIBRATE
43
+  #else
44
+    #define _CAN_CALI(A) true
45
+  #endif
41 46
   #define EDIT_BACKLASH_DISTANCE(N) EDIT_ITEM_FAST(float43, MSG_BACKLASH_##N, &backlash.distance_mm[_AXIS(N)], 0.0f, 9.9f);
42
-  if (AXIS_CAN_CALIBRATE(A)) EDIT_BACKLASH_DISTANCE(A);
43
-  if (AXIS_CAN_CALIBRATE(B)) EDIT_BACKLASH_DISTANCE(B);
44
-  if (AXIS_CAN_CALIBRATE(C)) EDIT_BACKLASH_DISTANCE(C);
47
+  if (_CAN_CALI(A)) EDIT_BACKLASH_DISTANCE(A);
48
+  if (_CAN_CALI(B)) EDIT_BACKLASH_DISTANCE(B);
49
+  if (_CAN_CALI(C)) EDIT_BACKLASH_DISTANCE(C);
45 50
 
46 51
   #ifdef BACKLASH_SMOOTHING_MM
47 52
     EDIT_ITEM_FAST(float43, MSG_BACKLASH_SMOOTHING, &backlash.smoothing_mm, 0.0f, 9.9f);

+ 2
- 2
buildroot/tests/teensy35 View File

@@ -93,8 +93,8 @@ exec_test $1 $2 "Teensy 3.5/3.6 COREXY" "$3"
93 93
 #
94 94
 restore_configs
95 95
 opt_set MOTHERBOARD BOARD_TEENSY35_36
96
-opt_enable COREXZ
97
-exec_test $1 $2 "Teensy 3.5/3.6 COREXZ" "$3"
96
+opt_enable COREXZ BACKLASH_COMPENSATION BACKLASH_GCODE CORE_BACKLASH
97
+exec_test $1 $2 "Teensy 3.5/3.6 COREXZ | BACKLASH" "$3"
98 98
 
99 99
 #
100 100
 # Enable Dual Z with Dual Z endstops

Loading…
Cancel
Save