Browse Source

TMC2130 dual-stepper Sensorless Homing (#13061)

mattfredwill 6 years ago
parent
commit
c3cb449990

+ 1
- 1
Marlin/src/feature/tmc_util.h View File

278
 #if USE_SENSORLESS
278
 #if USE_SENSORLESS
279
   // Track enabled status of stealthChop and only re-enable where applicable
279
   // Track enabled status of stealthChop and only re-enable where applicable
280
   struct sensorless_t {
280
   struct sensorless_t {
281
-    bool x, y, z;
281
+    bool x, y, z, x2, y2, z2, z3;
282
   };
282
   };
283
 
283
 
284
   bool tmc_enable_stallguard(TMC2130Stepper &st);
284
   bool tmc_enable_stallguard(TMC2130Stepper &st);

+ 13
- 1
Marlin/src/gcode/calibrate/G28.cpp View File

71
                 fr_mm_s = MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)) * SQRT(sq(mlratio) + 1.0);
71
                 fr_mm_s = MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)) * SQRT(sq(mlratio) + 1.0);
72
 
72
 
73
     #if ENABLED(SENSORLESS_HOMING)
73
     #if ENABLED(SENSORLESS_HOMING)
74
-      sensorless_t stealth_states { false, false, false };
74
+      sensorless_t stealth_states { false, false, false, false, false, false, false };
75
       stealth_states.x = tmc_enable_stallguard(stepperX);
75
       stealth_states.x = tmc_enable_stallguard(stepperX);
76
       stealth_states.y = tmc_enable_stallguard(stepperY);
76
       stealth_states.y = tmc_enable_stallguard(stepperY);
77
+      #if AXIS_HAS_STALLGUARD(X2)
78
+        stealth_states.x2 = tmc_enable_stallguard(stepperX2);
79
+      #endif
80
+      #if AXIS_HAS_STALLGUARD(Y2)
81
+        stealth_states.y2 = tmc_enable_stallguard(stepperY2);
82
+      #endif
77
     #endif
83
     #endif
78
 
84
 
79
     do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * home_dir(Y_AXIS), fr_mm_s);
85
     do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * home_dir(Y_AXIS), fr_mm_s);
85
     #if ENABLED(SENSORLESS_HOMING)
91
     #if ENABLED(SENSORLESS_HOMING)
86
       tmc_disable_stallguard(stepperX, stealth_states.x);
92
       tmc_disable_stallguard(stepperX, stealth_states.x);
87
       tmc_disable_stallguard(stepperY, stealth_states.y);
93
       tmc_disable_stallguard(stepperY, stealth_states.y);
94
+      #if AXIS_HAS_STALLGUARD(X2)
95
+        tmc_disable_stallguard(stepperX2, stealth_states.x2);
96
+      #endif
97
+      #if AXIS_HAS_STALLGUARD(Y2)
98
+        tmc_disable_stallguard(stepperY2, stealth_states.y2);
99
+      #endif
88
     #endif
100
     #endif
89
   }
101
   }
90
 
102
 

+ 1
- 1
Marlin/src/module/delta.cpp View File

222
 
222
 
223
   // Disable stealthChop if used. Enable diag1 pin on driver.
223
   // Disable stealthChop if used. Enable diag1 pin on driver.
224
   #if ENABLED(SENSORLESS_HOMING)
224
   #if ENABLED(SENSORLESS_HOMING)
225
-    sensorless_t stealth_states { false, false, false };
225
+    sensorless_t stealth_states { false, false, false, false, false, false, false };
226
     stealth_states.x = tmc_enable_stallguard(stepperX);
226
     stealth_states.x = tmc_enable_stallguard(stepperX);
227
     stealth_states.y = tmc_enable_stallguard(stepperY);
227
     stealth_states.y = tmc_enable_stallguard(stepperY);
228
     stealth_states.z = tmc_enable_stallguard(stepperZ);
228
     stealth_states.z = tmc_enable_stallguard(stepperZ);

+ 25
- 1
Marlin/src/module/motion.cpp View File

1050
    * Set sensorless homing if the axis has it, accounting for Core Kinematics.
1050
    * Set sensorless homing if the axis has it, accounting for Core Kinematics.
1051
    */
1051
    */
1052
   sensorless_t start_sensorless_homing_per_axis(const AxisEnum axis) {
1052
   sensorless_t start_sensorless_homing_per_axis(const AxisEnum axis) {
1053
-    sensorless_t stealth_states { false, false, false };
1053
+    sensorless_t stealth_states { false, false, false, false, false, false, false };
1054
 
1054
 
1055
     switch (axis) {
1055
     switch (axis) {
1056
       default: break;
1056
       default: break;
1057
       #if X_SENSORLESS
1057
       #if X_SENSORLESS
1058
         case X_AXIS:
1058
         case X_AXIS:
1059
           stealth_states.x = tmc_enable_stallguard(stepperX);
1059
           stealth_states.x = tmc_enable_stallguard(stepperX);
1060
+          #if AXIS_HAS_STALLGUARD(X2)
1061
+            stealth_states.x2 = tmc_enable_stallguard(stepperX2);
1062
+          #endif
1060
           #if CORE_IS_XY && Y_SENSORLESS
1063
           #if CORE_IS_XY && Y_SENSORLESS
1061
             stealth_states.y = tmc_enable_stallguard(stepperY);
1064
             stealth_states.y = tmc_enable_stallguard(stepperY);
1062
           #elif CORE_IS_XZ && Z_SENSORLESS
1065
           #elif CORE_IS_XZ && Z_SENSORLESS
1067
       #if Y_SENSORLESS
1070
       #if Y_SENSORLESS
1068
         case Y_AXIS:
1071
         case Y_AXIS:
1069
           stealth_states.y = tmc_enable_stallguard(stepperY);
1072
           stealth_states.y = tmc_enable_stallguard(stepperY);
1073
+          #if AXIS_HAS_STALLGUARD(Y2)
1074
+            stealth_states.y2 = tmc_enable_stallguard(stepperY2);
1075
+          #endif
1070
           #if CORE_IS_XY && X_SENSORLESS
1076
           #if CORE_IS_XY && X_SENSORLESS
1071
             stealth_states.x = tmc_enable_stallguard(stepperX);
1077
             stealth_states.x = tmc_enable_stallguard(stepperX);
1072
           #elif CORE_IS_YZ && Z_SENSORLESS
1078
           #elif CORE_IS_YZ && Z_SENSORLESS
1077
       #if Z_SENSORLESS
1083
       #if Z_SENSORLESS
1078
         case Z_AXIS:
1084
         case Z_AXIS:
1079
           stealth_states.z = tmc_enable_stallguard(stepperZ);
1085
           stealth_states.z = tmc_enable_stallguard(stepperZ);
1086
+          #if AXIS_HAS_STALLGUARD(Z2)
1087
+            stealth_states.z2 = tmc_enable_stallguard(stepperZ2);
1088
+          #endif
1089
+          #if AXIS_HAS_STALLGUARD(Z3)
1090
+            stealth_states.z3 = tmc_enable_stallguard(stepperZ3);
1091
+          #endif
1080
           #if CORE_IS_XZ && X_SENSORLESS
1092
           #if CORE_IS_XZ && X_SENSORLESS
1081
             stealth_states.x = tmc_enable_stallguard(stepperX);
1093
             stealth_states.x = tmc_enable_stallguard(stepperX);
1082
           #elif CORE_IS_YZ && Y_SENSORLESS
1094
           #elif CORE_IS_YZ && Y_SENSORLESS
1094
       #if X_SENSORLESS
1106
       #if X_SENSORLESS
1095
         case X_AXIS:
1107
         case X_AXIS:
1096
           tmc_disable_stallguard(stepperX, enable_stealth.x);
1108
           tmc_disable_stallguard(stepperX, enable_stealth.x);
1109
+          #if AXIS_HAS_STALLGUARD(X2)
1110
+            tmc_disable_stallguard(stepperX2, enable_stealth.x2);
1111
+          #endif
1097
           #if CORE_IS_XY && Y_SENSORLESS
1112
           #if CORE_IS_XY && Y_SENSORLESS
1098
             tmc_disable_stallguard(stepperY, enable_stealth.y);
1113
             tmc_disable_stallguard(stepperY, enable_stealth.y);
1099
           #elif CORE_IS_XZ && Z_SENSORLESS
1114
           #elif CORE_IS_XZ && Z_SENSORLESS
1104
       #if Y_SENSORLESS
1119
       #if Y_SENSORLESS
1105
         case Y_AXIS:
1120
         case Y_AXIS:
1106
           tmc_disable_stallguard(stepperY, enable_stealth.y);
1121
           tmc_disable_stallguard(stepperY, enable_stealth.y);
1122
+          #if AXIS_HAS_STALLGUARD(Y2)
1123
+            tmc_disable_stallguard(stepperY2, enable_stealth.y2);
1124
+          #endif
1107
           #if CORE_IS_XY && X_SENSORLESS
1125
           #if CORE_IS_XY && X_SENSORLESS
1108
             tmc_disable_stallguard(stepperX, enable_stealth.x);
1126
             tmc_disable_stallguard(stepperX, enable_stealth.x);
1109
           #elif CORE_IS_YZ && Z_SENSORLESS
1127
           #elif CORE_IS_YZ && Z_SENSORLESS
1114
       #if Z_SENSORLESS
1132
       #if Z_SENSORLESS
1115
         case Z_AXIS:
1133
         case Z_AXIS:
1116
           tmc_disable_stallguard(stepperZ, enable_stealth.z);
1134
           tmc_disable_stallguard(stepperZ, enable_stealth.z);
1135
+          #if AXIS_HAS_STALLGUARD(Z2)
1136
+            tmc_disable_stallguard(stepperZ2, enable_stealth.z2);
1137
+          #endif
1138
+          #if AXIS_HAS_STALLGUARD(Z3)
1139
+            tmc_disable_stallguard(stepperZ3, enable_stealth.z3);
1140
+          #endif
1117
           #if CORE_IS_XZ && X_SENSORLESS
1141
           #if CORE_IS_XZ && X_SENSORLESS
1118
             tmc_disable_stallguard(stepperX, enable_stealth.x);
1142
             tmc_disable_stallguard(stepperX, enable_stealth.x);
1119
           #elif CORE_IS_YZ && Y_SENSORLESS
1143
           #elif CORE_IS_YZ && Y_SENSORLESS

+ 1
- 1
Marlin/src/module/probe.cpp View File

551
 
551
 
552
   // Disable stealthChop if used. Enable diag1 pin on driver.
552
   // Disable stealthChop if used. Enable diag1 pin on driver.
553
   #if ENABLED(SENSORLESS_PROBING)
553
   #if ENABLED(SENSORLESS_PROBING)
554
-    sensorless_t stealth_states { false, false, false };
554
+    sensorless_t stealth_states { false, false, false, false, false, false, false };
555
     #if ENABLED(DELTA)
555
     #if ENABLED(DELTA)
556
       stealth_states.x = tmc_enable_stallguard(stepperX);
556
       stealth_states.x = tmc_enable_stallguard(stepperX);
557
       stealth_states.y = tmc_enable_stallguard(stepperY);
557
       stealth_states.y = tmc_enable_stallguard(stepperY);

Loading…
Cancel
Save