Browse Source

🐛 Fix MMU compile with >5 EXTRUDERS (#22036)

Giuliano Zaro 4 years ago
parent
commit
eea9b6d8ae
No account linked to committer's email address

+ 2
- 5
Marlin/src/MarlinCore.cpp View File

317
 void disable_e_stepper(const uint8_t e) {
317
 void disable_e_stepper(const uint8_t e) {
318
   #define _CASE_DIS_E(N) case N: DISABLE_AXIS_E##N(); break;
318
   #define _CASE_DIS_E(N) case N: DISABLE_AXIS_E##N(); break;
319
   switch (e) {
319
   switch (e) {
320
-    REPEAT(EXTRUDERS, _CASE_DIS_E)
320
+    REPEAT(E_STEPPERS, _CASE_DIS_E)
321
   }
321
   }
322
 }
322
 }
323
 
323
 
1423
   #endif
1423
   #endif
1424
 
1424
 
1425
   #if HAS_PRUSA_MMU1
1425
   #if HAS_PRUSA_MMU1
1426
-    SETUP_LOG("Prusa MMU1");
1427
-    SET_OUTPUT(E_MUX0_PIN);
1428
-    SET_OUTPUT(E_MUX1_PIN);
1429
-    SET_OUTPUT(E_MUX2_PIN);
1426
+    SETUP_RUN(mmu_init());
1430
   #endif
1427
   #endif
1431
 
1428
 
1432
   #if HAS_FANMUX
1429
   #if HAS_FANMUX

+ 8
- 1
Marlin/src/feature/mmu/mmu.cpp View File

24
 
24
 
25
 #if HAS_PRUSA_MMU1
25
 #if HAS_PRUSA_MMU1
26
 
26
 
27
-#include "../module/stepper.h"
27
+#include "../MarlinCore.h"
28
+#include "../module/planner.h"
29
+
30
+void mmu_init() {
31
+  SET_OUTPUT(E_MUX0_PIN);
32
+  SET_OUTPUT(E_MUX1_PIN);
33
+  SET_OUTPUT(E_MUX2_PIN);
34
+}
28
 
35
 
29
 void select_multiplexed_stepper(const uint8_t e) {
36
 void select_multiplexed_stepper(const uint8_t e) {
30
   planner.synchronize();
37
   planner.synchronize();

+ 1
- 0
Marlin/src/feature/mmu/mmu.h View File

21
  */
21
  */
22
 #pragma once
22
 #pragma once
23
 
23
 
24
+void mmu_init();
24
 void select_multiplexed_stepper(const uint8_t e);
25
 void select_multiplexed_stepper(const uint8_t e);

+ 1
- 1
Marlin/src/inc/Conditionals_LCD.h View File

517
     #define HAS_PRUSA_MMU2 1
517
     #define HAS_PRUSA_MMU2 1
518
     #define HAS_PRUSA_MMU2S 1
518
     #define HAS_PRUSA_MMU2S 1
519
   #endif
519
   #endif
520
-  #if MMU_MODEL == EXTENDABLE_EMU_MMU2 || MMU_MODEL == EXTENDABLE_EMU_MMU2S
520
+  #if MMU_MODEL >= EXTENDABLE_EMU_MMU2
521
     #define HAS_EXTENDABLE_MMU 1
521
     #define HAS_EXTENDABLE_MMU 1
522
   #endif
522
   #endif
523
 #endif
523
 #endif

+ 9
- 6
Marlin/src/inc/SanityCheck.h View File

954
  * Multi-Material-Unit 2 / EXTENDABLE_EMU_MMU2 requirements
954
  * Multi-Material-Unit 2 / EXTENDABLE_EMU_MMU2 requirements
955
  */
955
  */
956
 #if HAS_PRUSA_MMU2
956
 #if HAS_PRUSA_MMU2
957
-  #if EXTRUDERS != 5
957
+  #if !HAS_EXTENDABLE_MMU && EXTRUDERS != 5
958
     #undef SINGLENOZZLE
958
     #undef SINGLENOZZLE
959
     #error "PRUSA_MMU2(S) requires exactly 5 EXTRUDERS. Please update your Configuration."
959
     #error "PRUSA_MMU2(S) requires exactly 5 EXTRUDERS. Please update your Configuration."
960
+  #elif HAS_EXTENDABLE_MMU && EXTRUDERS > 15
961
+    #error "EXTRUDERS is too large for MMU(S) emulation mode. The maximum value is 15."
960
   #elif DISABLED(NOZZLE_PARK_FEATURE)
962
   #elif DISABLED(NOZZLE_PARK_FEATURE)
961
     #error "PRUSA_MMU2(S) requires NOZZLE_PARK_FEATURE. Enable it to continue."
963
     #error "PRUSA_MMU2(S) requires NOZZLE_PARK_FEATURE. Enable it to continue."
962
   #elif HAS_PRUSA_MMU2S && DISABLED(FILAMENT_RUNOUT_SENSOR)
964
   #elif HAS_PRUSA_MMU2S && DISABLED(FILAMENT_RUNOUT_SENSOR)
969
     static_assert(nullptr == strstr(MMU2_FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with PRUSA_MMU2(S) / HAS_EXTENDABLE_MMU(S).");
971
     static_assert(nullptr == strstr(MMU2_FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with PRUSA_MMU2(S) / HAS_EXTENDABLE_MMU(S).");
970
   #endif
972
   #endif
971
 #endif
973
 #endif
972
-#if HAS_EXTENDABLE_MMU && EXTRUDERS > 15
973
-  #error "Too many extruders for MMU(S) emulation mode. (15 maximum)."
974
-#endif
975
 
974
 
976
 /**
975
 /**
977
  * Options only for EXTRUDERS > 1
976
  * Options only for EXTRUDERS > 1
978
  */
977
  */
979
 #if HAS_MULTI_EXTRUDER
978
 #if HAS_MULTI_EXTRUDER
980
 
979
 
981
-  #if EXTRUDERS > 8
982
-    #error "Marlin supports a maximum of 8 EXTRUDERS."
980
+  #if HAS_EXTENDABLE_MMU
981
+    #define MAX_EXTRUDERS 15
982
+  #else
983
+    #define MAX_EXTRUDERS  8
983
   #endif
984
   #endif
985
+  static_assert(EXTRUDERS <= MAX_EXTRUDERS, "Marlin supports a maximum of " STRINGIFY(MAX_EXTRUDERS) " EXTRUDERS.");
986
+  #undef MAX_EXTRUDERS
984
 
987
 
985
   #if ENABLED(HEATERS_PARALLEL)
988
   #if ENABLED(HEATERS_PARALLEL)
986
     #error "EXTRUDERS must be 1 with HEATERS_PARALLEL."
989
     #error "EXTRUDERS must be 1 with HEATERS_PARALLEL."

+ 6
- 4
Marlin/src/module/planner.cpp View File

213
 float Planner::previous_nominal_speed_sqr;
213
 float Planner::previous_nominal_speed_sqr;
214
 
214
 
215
 #if ENABLED(DISABLE_INACTIVE_EXTRUDER)
215
 #if ENABLED(DISABLE_INACTIVE_EXTRUDER)
216
-  last_move_t Planner::g_uc_extruder_last_move[EXTRUDERS] = { 0 };
216
+  last_move_t Planner::g_uc_extruder_last_move[E_STEPPERS] = { 0 };
217
 #endif
217
 #endif
218
 
218
 
219
 #ifdef XY_FREQUENCY_LIMIT
219
 #ifdef XY_FREQUENCY_LIMIT
2122
 
2122
 
2123
       #if ENABLED(DISABLE_INACTIVE_EXTRUDER) // Enable only the selected extruder
2123
       #if ENABLED(DISABLE_INACTIVE_EXTRUDER) // Enable only the selected extruder
2124
 
2124
 
2125
-        LOOP_L_N(i, EXTRUDERS)
2125
+        LOOP_L_N(i, E_STEPPERS)
2126
           if (g_uc_extruder_last_move[i]) g_uc_extruder_last_move[i]--;
2126
           if (g_uc_extruder_last_move[i]) g_uc_extruder_last_move[i]--;
2127
 
2127
 
2128
+        #define E_STEPPER_INDEX(E) TERN(SWITCHING_EXTRUDER, (E) / 2, E)
2129
+
2128
         #define ENABLE_ONE_E(N) do{ \
2130
         #define ENABLE_ONE_E(N) do{ \
2129
-          if (extruder == N) { \
2131
+          if (E_STEPPER_INDEX(extruder) == N) { \
2130
             ENABLE_AXIS_E##N(); \
2132
             ENABLE_AXIS_E##N(); \
2131
             g_uc_extruder_last_move[N] = (BLOCK_BUFFER_SIZE) * 2; \
2133
             g_uc_extruder_last_move[N] = (BLOCK_BUFFER_SIZE) * 2; \
2132
             if ((N) == 0 && TERN0(HAS_DUPLICATION_MODE, extruder_duplication_enabled)) \
2134
             if ((N) == 0 && TERN0(HAS_DUPLICATION_MODE, extruder_duplication_enabled)) \
2145
 
2147
 
2146
       #endif
2148
       #endif
2147
 
2149
 
2148
-      REPEAT(EXTRUDERS, ENABLE_ONE_E); // (ENABLE_ONE_E must end with semicolon)
2150
+      REPEAT(E_STEPPERS, ENABLE_ONE_E); // (ENABLE_ONE_E must end with semicolon)
2149
     }
2151
     }
2150
   #endif // EXTRUDERS
2152
   #endif // EXTRUDERS
2151
 
2153
 

+ 2
- 2
Marlin/src/module/planner.h View File

450
     #endif
450
     #endif
451
 
451
 
452
     #if ENABLED(DISABLE_INACTIVE_EXTRUDER)
452
     #if ENABLED(DISABLE_INACTIVE_EXTRUDER)
453
-       // Counters to manage disabling inactive extruders
454
-      static last_move_t g_uc_extruder_last_move[EXTRUDERS];
453
+      // Counters to manage disabling inactive extruder steppers
454
+      static last_move_t g_uc_extruder_last_move[E_STEPPERS];
455
     #endif
455
     #endif
456
 
456
 
457
     #if HAS_WIRED_LCD
457
     #if HAS_WIRED_LCD

+ 1
- 1
Marlin/src/module/stepper/indirection.h View File

418
     #define    REV_E_DIR(E)   do{ E0_DIR_WRITE(E ? !INVERT_E0_DIR :  INVERT_E0_DIR); }while(0)
418
     #define    REV_E_DIR(E)   do{ E0_DIR_WRITE(E ? !INVERT_E0_DIR :  INVERT_E0_DIR); }while(0)
419
   #endif
419
   #endif
420
 
420
 
421
-#elif HAS_PRUSA_MMU2
421
+#elif HAS_PRUSA_MMU2  // One multiplexed stepper driver
422
 
422
 
423
   #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V)
423
   #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V)
424
   #define   NORM_E_DIR(E)   E0_DIR_WRITE(!INVERT_E0_DIR)
424
   #define   NORM_E_DIR(E)   E0_DIR_WRITE(!INVERT_E0_DIR)

+ 0
- 5
Marlin/src/pins/pins.h View File

35
  *    These numbers are the same in any pin mapping.
35
  *    These numbers are the same in any pin mapping.
36
  */
36
  */
37
 
37
 
38
-#if HAS_EXTENDABLE_MMU
39
-  #define MAX_EXTRUDERS 15
40
-#else
41
-  #define MAX_EXTRUDERS 8
42
-#endif
43
 #define MAX_E_STEPPERS 8
38
 #define MAX_E_STEPPERS 8
44
 
39
 
45
 #if   MB(RAMPS_13_EFB, RAMPS_14_EFB, RAMPS_PLUS_EFB, RAMPS_14_RE_ARM_EFB, RAMPS_SMART_EFB, RAMPS_DUO_EFB, RAMPS4DUE_EFB)
40
 #if   MB(RAMPS_13_EFB, RAMPS_14_EFB, RAMPS_PLUS_EFB, RAMPS_14_RE_ARM_EFB, RAMPS_SMART_EFB, RAMPS_DUO_EFB, RAMPS4DUE_EFB)

+ 3
- 3
Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h View File

23
 
23
 
24
 #include "env_validate.h"
24
 #include "env_validate.h"
25
 
25
 
26
-#if HOTENDS > 8 || E_STEPPERS > 8
27
-  #error "BIGTREE GTR V1.0 supports up to 8 hotends / E-steppers."
28
-#elif HOTENDS > MAX_E_STEPPERS || E_STEPPERS > MAX_E_STEPPERS
26
+#if E_STEPPERS > MAX_E_STEPPERS
29
   #error "Marlin extruder/hotends limit! Increase MAX_E_STEPPERS to continue."
27
   #error "Marlin extruder/hotends limit! Increase MAX_E_STEPPERS to continue."
28
+#elif HOTENDS > 8 || E_STEPPERS > 8
29
+  #error "BIGTREE GTR V1.0 supports up to 8 hotends / E-steppers."
30
 #endif
30
 #endif
31
 
31
 
32
 #define BOARD_INFO_NAME "BTT GTR V1.0"
32
 #define BOARD_INFO_NAME "BTT GTR V1.0"

Loading…
Cancel
Save