Skip to content

Commit

Permalink
✨ Extruder with Dual Stepper Drivers (MarlinFirmware#21403)
Browse files Browse the repository at this point in the history
  • Loading branch information
boelle authored and thinkyhead committed Jun 15, 2021
1 parent 31fd3be commit dba8773
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 10 deletions.
6 changes: 6 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,12 @@
#endif
#endif

// Drive the E axis with two synchronized steppers
//#define E_DUAL_STEPPER_DRIVERS
#if ENABLED(E_DUAL_STEPPER_DRIVERS)
//#define INVERT_E1_VS_E0_DIR // Enable if the E motors need opposite DIR states
#endif

/**
* Dual X Carriage
*
Expand Down
20 changes: 16 additions & 4 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,12 @@
#undef DISABLE_E
#endif

#if ENABLED(SWITCHING_EXTRUDER) // One stepper for every two EXTRUDERS
#if ENABLED(E_DUAL_STEPPER_DRIVERS) // E0/E1 steppers act in tandem as E0

#define E_STEPPERS 2

#elif ENABLED(SWITCHING_EXTRUDER) // One stepper for every two EXTRUDERS

#if EXTRUDERS > 4
#define E_STEPPERS 3
#elif EXTRUDERS > 2
Expand All @@ -569,17 +574,24 @@
#if DISABLED(SWITCHING_NOZZLE)
#define HOTENDS E_STEPPERS
#endif
#elif ENABLED(MIXING_EXTRUDER)

#elif ENABLED(MIXING_EXTRUDER) // Multiple feeds are mixed proportionally

#define E_STEPPERS MIXING_STEPPERS
#define E_MANUAL 1
#if MIXING_STEPPERS == 2
#define HAS_DUAL_MIXING 1
#endif
#elif ENABLED(SWITCHING_TOOLHEAD)

#elif ENABLED(SWITCHING_TOOLHEAD) // Toolchanger

#define E_STEPPERS EXTRUDERS
#define E_MANUAL EXTRUDERS
#elif HAS_PRUSA_MMU2

#elif HAS_PRUSA_MMU2 // Průša Multi-Material Unit v2

#define E_STEPPERS 1

#endif

// No inactive extruders with SWITCHING_NOZZLE or Průša MMU1
Expand Down
13 changes: 13 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,19 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#endif
#endif

/**
* Dual E Steppers requirements
*/
#if ENABLED(E_DUAL_STEPPER_DRIVERS)
#if EXTRUDERS > 1
#error "E_DUAL_STEPPER_DRIVERS can only be used with EXTRUDERS set to 1."
#elif ENABLED(MIXING_EXTRUDER)
#error "E_DUAL_STEPPER_DRIVERS is incompatible with MIXING_EXTRUDER."
#elif ENABLED(SWITCHING_EXTRUDER)
#error "E_DUAL_STEPPER_DRIVERS is incompatible with SWITCHING_EXTRUDER."
#endif
#endif

/**
* Linear Advance 1.5 - Check K value range
*/
Expand Down
12 changes: 12 additions & 0 deletions Marlin/src/module/stepper/indirection.h
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,11 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset

#endif

#elif ENABLED(E_DUAL_STEPPER_DRIVERS)
#define E_STEP_WRITE(E,V) do{ E0_STEP_WRITE(V); E1_STEP_WRITE(V); }while(0)
#define NORM_E_DIR(E) do{ E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E0_DIR ^ ENABLED(INVERT_E1_VS_E0_DIR)); }while(0)
#define REV_E_DIR(E) do{ E0_DIR_WRITE( INVERT_E0_DIR); E1_DIR_WRITE( INVERT_E0_DIR ^ ENABLED(INVERT_E1_VS_E0_DIR)); }while(0)

#elif E_STEPPERS
#define E_STEP_WRITE(E,V) E0_STEP_WRITE(V)
#define NORM_E_DIR(E) E0_DIR_WRITE(!INVERT_E0_DIR)
Expand Down Expand Up @@ -1013,13 +1018,20 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
//

#if ENABLED(MIXING_EXTRUDER)

/**
* Mixing steppers keep all their enable (and direction) states synchronized
*/
#define _CALL_ENA_E(N) ENABLE_STEPPER_E##N () ;
#define _CALL_DIS_E(N) DISABLE_STEPPER_E##N () ;
#define ENABLE_AXIS_E0() { RREPEAT(MIXING_STEPPERS, _CALL_ENA_E) }
#define DISABLE_AXIS_E0() { RREPEAT(MIXING_STEPPERS, _CALL_DIS_E) }

#elif ENABLED(E_DUAL_STEPPER_DRIVERS)

#define ENABLE_AXIS_E0() do{ ENABLE_STEPPER_E0(); ENABLE_STEPPER_E1(); }while(0)
#define DISABLE_AXIS_E0() do{ DISABLE_STEPPER_E0(); DISABLE_STEPPER_E1(); }while(0)

#endif

#ifndef ENABLE_AXIS_E0
Expand Down
12 changes: 10 additions & 2 deletions Marlin/src/pins/pins_postprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,17 @@
#define _EPIN(p,q) __EPIN(p,q)
#define DIAG_REMAPPED(p,q) (PIN_EXISTS(q) && _EPIN(p##_E_INDEX, DIAG) == q##_PIN)

// The X2 axis, if any, should be the next open extruder port
#define X2_E_INDEX E_STEPPERS
// The E0/E1 steppers are always used for Dual E
#if ENABLED(E_DUAL_STEPPER_DRIVERS)
#ifndef E1_STEP_PIN
#error "No E1 stepper available for E_DUAL_STEPPER_DRIVERS!"
#endif
#define X2_E_INDEX INCREMENT(E_STEPPERS)
#else
#define X2_E_INDEX E_STEPPERS
#endif

// The X2 axis, if any, should be the next open extruder port
#if EITHER(DUAL_X_CARRIAGE, X_DUAL_STEPPER_DRIVERS)
#ifndef X2_STEP_PIN
#define X2_STEP_PIN _EPIN(X2_E_INDEX, STEP)
Expand Down
5 changes: 2 additions & 3 deletions buildroot/tests/DUE
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS GCODE_MACROS \
SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE CALIBRATION_GCODE \
BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE BEZIER_CURVE_SUPPORT \
FWRETRACT ARC_SUPPORT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \
PSU_CONTROL AUTO_POWER_CONTROL \
PSU_CONTROL AUTO_POWER_CONTROL E_DUAL_STEPPER_DRIVERS \
PIDTEMPBED SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER \
PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL \
EXTENSIBLE_UI
Expand All @@ -38,10 +38,9 @@ restore_configs
opt_set MOTHERBOARD BOARD_RADDS NUM_Z_STEPPER_DRIVERS 3
opt_enable USE_XMAX_PLUG USE_YMAX_PLUG ENDSTOPPULLUPS BLTOUCH AUTO_BED_LEVELING_BILINEAR \
Z_STEPPER_AUTO_ALIGN Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS Z_SAFE_HOMING
#TOUCH_UI_FTDI_EVE LCD_ALEPHOBJECTS_CLCD_UI OTHER_PIN_LAYOUT
pins_set ramps/RAMPS X_MAX_PIN -1
pins_set ramps/RAMPS Y_MAX_PIN -1
exec_test $1 $2 "RADDS with ABL (Bilinear), Triple Z Axis, Z_STEPPER_AUTO_ALIGN" "$3"
exec_test $1 $2 "RADDS with ABL (Bilinear), Triple Z Axis, Z_STEPPER_AUTO_ALIGN, E_DUAL_STEPPER_DRIVERS" "$3"

#
# Test SWITCHING_EXTRUDER
Expand Down
2 changes: 1 addition & 1 deletion buildroot/tests/LPC1768
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set -e
restore_configs
opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EFB SERIAL_PORT_3 3 \
NEOPIXEL_TYPE NEO_GRB RGB_LED_R_PIN P2_12 RGB_LED_G_PIN P1_23 RGB_LED_B_PIN P1_22 RGB_LED_W_PIN P1_24
opt_enable FYSETC_MINI_12864_2_1 SDSUPPORT SDCARD_READONLY SERIAL_PORT_2 RGBW_LED \
opt_enable FYSETC_MINI_12864_2_1 SDSUPPORT SDCARD_READONLY SERIAL_PORT_2 RGBW_LED E_DUAL_STEPPER_DRIVERS \
NEOPIXEL_LED NEOPIXEL_IS_SEQUENTIAL NEOPIXEL_STARTUP_TEST NEOPIXEL_BKGD_INDEX_FIRST NEOPIXEL_BKGD_INDEX_LAST NEOPIXEL_BKGD_COLOR NEOPIXEL_BKGD_ALWAYS_ON
exec_test $1 $2 "ReARM EFB VIKI2, SDSUPPORT, 2 Serial ports (USB CDC + UART0), NeoPixel" "$3"

Expand Down

0 comments on commit dba8773

Please sign in to comment.