Browse Source

🐛 Fix IJK axis references, E stepper indices (#22176)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Katelyn Schiesser 4 years ago
parent
commit
de4b3498c7
No account linked to committer's email address

+ 10
- 4
Marlin/src/feature/dac/stepper_dac.cpp View File

85
   if (!dac_present) return;
85
   if (!dac_present) return;
86
   SERIAL_ECHO_MSG("Stepper current values in % (Amps):");
86
   SERIAL_ECHO_MSG("Stepper current values in % (Amps):");
87
   SERIAL_ECHO_START();
87
   SERIAL_ECHO_START();
88
-  SERIAL_ECHOPAIR_P(  SP_X_LBL, dac_perc(X_AXIS), PSTR(" ("), dac_amps(X_AXIS), PSTR(")"));
89
-  SERIAL_ECHOPAIR_P(  SP_Y_LBL, dac_perc(Y_AXIS), PSTR(" ("), dac_amps(Y_AXIS), PSTR(")"));
90
-  SERIAL_ECHOPAIR_P(  SP_Z_LBL, dac_perc(Z_AXIS), PSTR(" ("), dac_amps(Z_AXIS), PSTR(")"));
91
-  SERIAL_ECHOLNPAIR_P(SP_E_LBL, dac_perc(E_AXIS), PSTR(" ("), dac_amps(E_AXIS), PSTR(")"));
88
+  SERIAL_ECHOPAIR_P(SP_X_LBL, dac_perc(X_AXIS), PSTR(" ("), dac_amps(X_AXIS), PSTR(")"));
89
+  #if HAS_Y_AXIS
90
+    SERIAL_ECHOPAIR_P(SP_Y_LBL, dac_perc(Y_AXIS), PSTR(" ("), dac_amps(Y_AXIS), PSTR(")"));
91
+  #endif
92
+  #if HAS_Z_AXIS
93
+    SERIAL_ECHOPAIR_P(SP_Z_LBL, dac_perc(Z_AXIS), PSTR(" ("), dac_amps(Z_AXIS), PSTR(")"));
94
+  #endif
95
+  #if HAS_EXTRUDERS
96
+    SERIAL_ECHOLNPAIR_P(SP_E_LBL, dac_perc(E_AXIS), PSTR(" ("), dac_amps(E_AXIS), PSTR(")"));
97
+  #endif
92
 }
98
 }
93
 
99
 
94
 void StepperDAC::commit_eeprom() {
100
 void StepperDAC::commit_eeprom() {

+ 26
- 29
Marlin/src/gcode/feature/L6470/M906.cpp View File

33
 #include "../../../core/debug_out.h"
33
 #include "../../../core/debug_out.h"
34
 
34
 
35
 /**
35
 /**
36
- * M906: report or set KVAL_HOLD which sets the maximum effective voltage provided by the
37
- *       PWMs to the steppers
38
- *
39
- * On L6474 this sets the TVAL register (same address).
40
- *
41
- * I - select which driver(s) to change on multi-driver axis
42
- *     0 - (default) all drivers on the axis or E0
43
- *     1 - monitor only X, Y, Z or E1
44
- *     2 - monitor only X2, Y2, Z2 or E2
45
- *     3 - monitor only Z3 or E3
46
- *     4 - monitor only Z4 or E4
47
- *     5 - monitor only E5
48
- * Xxxx, Yxxx, Zxxx, Exxx - axis to change (optional)
49
- *     L6474 - current in mA (4A max)
50
- *     All others - 0-255
51
- */
52
-
53
-/**
54
- * Sets KVAL_HOLD wich affects the current being driven through the stepper.
55
- *
56
- * L6470 is used in the STEP-CLOCK mode.  KVAL_HOLD is the only KVAL_xxx
57
- * that affects the effective voltage seen by the stepper.
58
- */
59
-
60
-/**
61
  * MACRO to fetch information on the items associated with current limiting
36
  * MACRO to fetch information on the items associated with current limiting
62
  * and maximum voltage output.
37
  * and maximum voltage output.
63
  *
38
  *
220
   }
195
   }
221
 }
196
 }
222
 
197
 
198
+/**
199
+ * M906: report or set KVAL_HOLD which sets the maximum effective voltage provided by the
200
+ *       PWMs to the steppers
201
+ *
202
+ * On L6474 this sets the TVAL register (same address).
203
+ *
204
+ * I - select which driver(s) to change on multi-driver axis
205
+ *     0 - (default) all drivers on the axis or E0
206
+ *     1 - monitor only X, Y, Z or E1
207
+ *     2 - monitor only X2, Y2, Z2 or E2
208
+ *     3 - monitor only Z3 or E3
209
+ *     4 - monitor only Z4 or E4
210
+ *     5 - monitor only E5
211
+ * Xxxx, Yxxx, Zxxx, Exxx - axis to change (optional)
212
+ *     L6474 - current in mA (4A max)
213
+ *     All others - 0-255
214
+ *
215
+ * Sets KVAL_HOLD wich affects the current being driven through the stepper.
216
+ *
217
+ * L6470 is used in the STEP-CLOCK mode.  KVAL_HOLD is the only KVAL_xxx
218
+ * that affects the effective voltage seen by the stepper.
219
+ */
223
 void GcodeSuite::M906() {
220
 void GcodeSuite::M906() {
224
 
221
 
225
   L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status
222
   L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status
281
           break;
278
           break;
282
       #endif
279
       #endif
283
 
280
 
284
-      #if HAS_EXTRUDERS
281
+      #if E_STEPPERS
285
         case E_AXIS: {
282
         case E_AXIS: {
286
-          const int8_t target_extruder = get_target_extruder_from_command();
287
-          if (target_extruder < 0) return;
288
-          switch (target_extruder) {
283
+          const int8_t target_e_stepper = get_target_e_stepper_from_command();
284
+          if (target_e_stepper < 0) return;
285
+          switch (target_e_stepper) {
289
             #if AXIS_IS_L64XX(E0)
286
             #if AXIS_IS_L64XX(E0)
290
               case 0: L6470_SET_KVAL_HOLD(E0); break;
287
               case 0: L6470_SET_KVAL_HOLD(E0); break;
291
             #endif
288
             #endif

+ 1
- 1
Marlin/src/gcode/feature/pause/M125.cpp View File

56
  */
56
  */
57
 void GcodeSuite::M125() {
57
 void GcodeSuite::M125() {
58
   // Initial retract before move to filament change position
58
   // Initial retract before move to filament change position
59
-  const float retract = -ABS(parser.axisunitsval('L', E_AXIS, PAUSE_PARK_RETRACT_LENGTH));
59
+  const float retract = TERN0(HAS_EXTRUDERS, -ABS(parser.axisunitsval('L', E_AXIS, PAUSE_PARK_RETRACT_LENGTH)));
60
 
60
 
61
   xyz_pos_t park_point = NOZZLE_PARK_POINT;
61
   xyz_pos_t park_point = NOZZLE_PARK_POINT;
62
 
62
 

+ 14
- 12
Marlin/src/gcode/feature/trinamic/M569.cpp View File

40
   st.refresh_stepping_mode();
40
   st.refresh_stepping_mode();
41
 }
41
 }
42
 
42
 
43
-static void set_stealth_status(const bool enable, const int8_t target_extruder) {
43
+static void set_stealth_status(const bool enable, const int8_t target_e_stepper) {
44
   #define TMC_SET_STEALTH(Q) tmc_set_stealthChop(stepper##Q, enable)
44
   #define TMC_SET_STEALTH(Q) tmc_set_stealthChop(stepper##Q, enable)
45
 
45
 
46
   #if    X_HAS_STEALTHCHOP  || Y_HAS_STEALTHCHOP  || Z_HAS_STEALTHCHOP \
46
   #if    X_HAS_STEALTHCHOP  || Y_HAS_STEALTHCHOP  || Z_HAS_STEALTHCHOP \
82
         case K_AXIS: TMC_SET_STEALTH(K); break;
82
         case K_AXIS: TMC_SET_STEALTH(K); break;
83
       #endif
83
       #endif
84
 
84
 
85
-      #if HAS_EXTRUDERS
85
+      #if E_STEPPERS
86
         case E_AXIS: {
86
         case E_AXIS: {
87
-          if (target_extruder < 0) return;
88
-          OPTCODE(E0_HAS_STEALTHCHOP, else if (target_extruder == 0) TMC_SET_STEALTH(E0))
89
-          OPTCODE(E1_HAS_STEALTHCHOP, else if (target_extruder == 1) TMC_SET_STEALTH(E1))
90
-          OPTCODE(E2_HAS_STEALTHCHOP, else if (target_extruder == 2) TMC_SET_STEALTH(E2))
91
-          OPTCODE(E3_HAS_STEALTHCHOP, else if (target_extruder == 3) TMC_SET_STEALTH(E3))
92
-          OPTCODE(E4_HAS_STEALTHCHOP, else if (target_extruder == 4) TMC_SET_STEALTH(E4))
93
-          OPTCODE(E5_HAS_STEALTHCHOP, else if (target_extruder == 5) TMC_SET_STEALTH(E5))
94
-          OPTCODE(E6_HAS_STEALTHCHOP, else if (target_extruder == 6) TMC_SET_STEALTH(E6))
95
-          OPTCODE(E7_HAS_STEALTHCHOP, else if (target_extruder == 7) TMC_SET_STEALTH(E7))
87
+          if (target_e_stepper < 0) return;
88
+          switch (target_e_stepper) {
89
+            TERN_(E0_HAS_STEALTHCHOP, case 0: TMC_SET_STEALTH(E0); break;)
90
+            TERN_(E1_HAS_STEALTHCHOP, case 1: TMC_SET_STEALTH(E1); break;)
91
+            TERN_(E2_HAS_STEALTHCHOP, case 2: TMC_SET_STEALTH(E2); break;)
92
+            TERN_(E3_HAS_STEALTHCHOP, case 3: TMC_SET_STEALTH(E3); break;)
93
+            TERN_(E4_HAS_STEALTHCHOP, case 4: TMC_SET_STEALTH(E4); break;)
94
+            TERN_(E5_HAS_STEALTHCHOP, case 5: TMC_SET_STEALTH(E5); break;)
95
+            TERN_(E6_HAS_STEALTHCHOP, case 6: TMC_SET_STEALTH(E6); break;)
96
+            TERN_(E7_HAS_STEALTHCHOP, case 7: TMC_SET_STEALTH(E7); break;)
97
+          }
96
         } break;
98
         } break;
97
       #endif
99
       #endif
98
     }
100
     }
131
  */
133
  */
132
 void GcodeSuite::M569() {
134
 void GcodeSuite::M569() {
133
   if (parser.seen('S'))
135
   if (parser.seen('S'))
134
-    set_stealth_status(parser.value_bool(), get_target_extruder_from_command());
136
+    set_stealth_status(parser.value_bool(), get_target_e_stepper_from_command());
135
   else
137
   else
136
     say_stealth_status();
138
     say_stealth_status();
137
 }
139
 }

+ 4
- 4
Marlin/src/gcode/feature/trinamic/M906.cpp View File

102
         case K_AXIS: TMC_SET_CURRENT(K); break;
102
         case K_AXIS: TMC_SET_CURRENT(K); break;
103
       #endif
103
       #endif
104
 
104
 
105
-      #if HAS_EXTRUDERS
105
+      #if E_STEPPERS
106
         case E_AXIS: {
106
         case E_AXIS: {
107
-          const int8_t target_extruder = get_target_extruder_from_command();
108
-          if (target_extruder < 0) return;
109
-          switch (target_extruder) {
107
+          const int8_t target_e_stepper = get_target_e_stepper_from_command();
108
+          if (target_e_stepper < 0) return;
109
+          switch (target_e_stepper) {
110
             #if AXIS_IS_TMC(E0)
110
             #if AXIS_IS_TMC(E0)
111
               case 0: TMC_SET_CURRENT(E0); break;
111
               case 0: TMC_SET_CURRENT(E0); break;
112
             #endif
112
             #endif

+ 16
- 14
Marlin/src/gcode/feature/trinamic/M911-M914.cpp View File

265
           TERN_(Z3_HAS_STEALTCHOP, if (index == 0 || index == 3) TMC_SET_PWMTHRS(Z,Z3));
265
           TERN_(Z3_HAS_STEALTCHOP, if (index == 0 || index == 3) TMC_SET_PWMTHRS(Z,Z3));
266
           TERN_(Z4_HAS_STEALTCHOP, if (index == 0 || index == 4) TMC_SET_PWMTHRS(Z,Z4));
266
           TERN_(Z4_HAS_STEALTCHOP, if (index == 0 || index == 4) TMC_SET_PWMTHRS(Z,Z4));
267
           break;
267
           break;
268
-        case E_AXIS: {
269
-          #if E_STEPPERS
270
-            const int8_t target_extruder = get_target_extruder_from_command();
271
-            if (target_extruder < 0) return;
272
-            TERN_(E0_HAS_STEALTHCHOP, else if (target_extruder == 0) TMC_SET_PWMTHRS_E(0));
273
-            TERN_(E1_HAS_STEALTHCHOP, else if (target_extruder == 1) TMC_SET_PWMTHRS_E(1));
274
-            TERN_(E2_HAS_STEALTHCHOP, else if (target_extruder == 2) TMC_SET_PWMTHRS_E(2));
275
-            TERN_(E3_HAS_STEALTHCHOP, else if (target_extruder == 3) TMC_SET_PWMTHRS_E(3));
276
-            TERN_(E4_HAS_STEALTHCHOP, else if (target_extruder == 4) TMC_SET_PWMTHRS_E(4));
277
-            TERN_(E5_HAS_STEALTHCHOP, else if (target_extruder == 5) TMC_SET_PWMTHRS_E(5));
278
-            TERN_(E6_HAS_STEALTHCHOP, else if (target_extruder == 6) TMC_SET_PWMTHRS_E(6));
279
-            TERN_(E7_HAS_STEALTHCHOP, else if (target_extruder == 7) TMC_SET_PWMTHRS_E(7));
280
-          #endif // E_STEPPERS
281
-        } break;
268
+        #if E_STEPPERS
269
+          case E_AXIS: {
270
+            const int8_t target_e_stepper = get_target_e_stepper_from_command();
271
+            if (target_e_stepper < 0) return;
272
+            switch (target_e_stepper) {
273
+              TERN_(E0_HAS_STEALTHCHOP, case 0: TMC_SET_PWMTHRS_E(0); break;)
274
+              TERN_(E1_HAS_STEALTHCHOP, case 1: TMC_SET_PWMTHRS_E(1); break;)
275
+              TERN_(E2_HAS_STEALTHCHOP, case 2: TMC_SET_PWMTHRS_E(2); break;)
276
+              TERN_(E3_HAS_STEALTHCHOP, case 3: TMC_SET_PWMTHRS_E(3); break;)
277
+              TERN_(E4_HAS_STEALTHCHOP, case 4: TMC_SET_PWMTHRS_E(4); break;)
278
+              TERN_(E5_HAS_STEALTHCHOP, case 5: TMC_SET_PWMTHRS_E(5); break;)
279
+              TERN_(E6_HAS_STEALTHCHOP, case 6: TMC_SET_PWMTHRS_E(6); break;)
280
+              TERN_(E7_HAS_STEALTHCHOP, case 7: TMC_SET_PWMTHRS_E(7); break;)
281
+            }
282
+          } break;
283
+        #endif // E_STEPPERS
282
       }
284
       }
283
     }
285
     }
284
 
286
 

+ 6
- 4
Marlin/src/gcode/host/M114.cpp View File

216
       report_current_position_detail();
216
       report_current_position_detail();
217
       return;
217
       return;
218
     }
218
     }
219
-    if (parser.seen_test('E')) {
220
-      SERIAL_ECHOLNPAIR("Count E:", stepper.position(E_AXIS));
221
-      return;
222
-    }
219
+    #if HAS_EXTRUDERS
220
+      if (parser.seen_test('E')) {
221
+        SERIAL_ECHOLNPAIR("Count E:", stepper.position(E_AXIS));
222
+        return;
223
+      }
224
+    #endif
223
   #endif
225
   #endif
224
 
226
 
225
   #if ENABLED(M114_REALTIME)
227
   #if ENABLED(M114_REALTIME)

+ 7
- 1
Marlin/src/gcode/parser.h View File

311
     }
311
     }
312
 
312
 
313
     static inline float axis_unit_factor(const AxisEnum axis) {
313
     static inline float axis_unit_factor(const AxisEnum axis) {
314
-      return (axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor);
314
+      return (
315
+        #if HAS_EXTRUDERS
316
+          axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor
317
+        #else
318
+          linear_unit_factor
319
+        #endif
320
+      );
315
     }
321
     }
316
 
322
 
317
     static inline float linear_value_to_mm(const_float_t v)                  { return v * linear_unit_factor; }
323
     static inline float linear_value_to_mm(const_float_t v)                  { return v * linear_unit_factor; }

+ 14
- 3
Marlin/src/module/motion.cpp View File

266
 
266
 
267
     get_cartesian_from_steppers();
267
     get_cartesian_from_steppers();
268
     const xyz_pos_t lpos = cartes.asLogical();
268
     const xyz_pos_t lpos = cartes.asLogical();
269
-    SERIAL_ECHOPAIR("X:", lpos.x, " Y:", lpos.y, " Z:", lpos.z, " E:", current_position.e);
269
+    SERIAL_ECHOPAIR(
270
+      "X:", lpos.x
271
+      #if HAS_Y_AXIS
272
+        , " Y:", lpos.y
273
+      #endif
274
+      #if HAS_Z_AXIS
275
+        , " Z:", lpos.z
276
+      #endif
277
+      #if HAS_EXTRUDERS
278
+        , " E:", current_position.e
279
+      #endif
280
+    );
270
 
281
 
271
     stepper.report_positions();
282
     stepper.report_positions();
272
     #if IS_SCARA
283
     #if IS_SCARA
929
     float cartesian_mm = diff.magnitude();
940
     float cartesian_mm = diff.magnitude();
930
 
941
 
931
     // If the move is very short, check the E move distance
942
     // If the move is very short, check the E move distance
932
-    if (UNEAR_ZERO(cartesian_mm)) cartesian_mm = ABS(diff.e);
943
+    TERN_(HAS_EXTRUDERS, if (UNEAR_ZERO(cartesian_mm)) cartesian_mm = ABS(diff.e));
933
 
944
 
934
     // No E move either? Game over.
945
     // No E move either? Game over.
935
     if (UNEAR_ZERO(cartesian_mm)) return true;
946
     if (UNEAR_ZERO(cartesian_mm)) return true;
1008
       // If the move is very short, check the E move distance
1019
       // If the move is very short, check the E move distance
1009
       // No E move either? Game over.
1020
       // No E move either? Game over.
1010
       float cartesian_mm = diff.magnitude();
1021
       float cartesian_mm = diff.magnitude();
1011
-      if (UNEAR_ZERO(cartesian_mm)) cartesian_mm = ABS(diff.e);
1022
+      TERN_(HAS_EXTRUDERS, if (UNEAR_ZERO(cartesian_mm)) cartesian_mm = ABS(diff.e));
1012
       if (UNEAR_ZERO(cartesian_mm)) return;
1023
       if (UNEAR_ZERO(cartesian_mm)) return;
1013
 
1024
 
1014
       // The length divided by the segment size
1025
       // The length divided by the segment size

Loading…
Cancel
Save