Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixing and Switching Extruders #4163

Merged
merged 3 commits into from
Jul 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ script:
- opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT M100_FREE_MEMORY_WATCHER INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT
- build_marlin
#
# Mixing Extruder
#
- restore_configs
- opt_enable MIXING_EXTRUDER
- opt_set MIXING_STEPPERS 2
- build_marlin
#
# Test DUAL_X_CARRIAGE
#
- restore_configs
Expand All @@ -153,6 +160,16 @@ script:
- opt_set LCD_FEEDBACK_FREQUENCY_DURATION_MS 10
- opt_set LCD_FEEDBACK_FREQUENCY_HZ 100
- opt_enable BQ_LCD_SMART_CONTROLLER SPEAKER
#
# Test SWITCHING_EXTRUDER
#
- restore_configs
- opt_set MOTHERBOARD BOARD_RUMBA
- opt_set EXTRUDERS 2
- opt_enable NUM_SERVOS
- opt_set NUM_SERVOS 1
- opt_set TEMP_SENSOR_1 1
- opt_enable SWITCHING_EXTRUDER ULTIMAKERCONTROLLER
- build_marlin
#
# Test MINIRAMBO for PWM_MOTOR_CURRENT
Expand Down
50 changes: 42 additions & 8 deletions Marlin/Conditionals.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,18 +540,52 @@
#define HAS_PID_FOR_BOTH (ENABLED(PIDTEMP) && ENABLED(PIDTEMPBED))

/**
* SINGLENOZZLE needs to differentiate EXTRUDERS and HOTENDS
* And all "extruders" are in the same place.
* Extruders have some combination of stepper motors and hotends
* so we separate these concepts into the defines:
*
* EXTRUDERS - Number of Selectable Tools
* HOTENDS - Number of hotends, whether connected or separate
* E_STEPPERS - Number of actual E stepper motors
* TOOL_E_INDEX - Index to use when getting/setting the tool state
*
*/
#if ENABLED(SINGLENOZZLE)
#define HOTENDS 1
#if ENABLED(SINGLENOZZLE) // One hotend, multi-extruder
#define HOTENDS 1
#define E_STEPPERS EXTRUDERS
#define TOOL_E_INDEX current_block->active_extruder
#undef TEMP_SENSOR_1_AS_REDUNDANT
#undef HOTEND_OFFSET_X
#undef HOTEND_OFFSET_Y
#define HOTEND_OFFSET_X { 0 }
#define HOTEND_OFFSET_Y { 0 }
#else
#define HOTENDS EXTRUDERS
#elif ENABLED(SWITCHING_EXTRUDER) // One E stepper, unified E axis, two hotends
#define HOTENDS EXTRUDERS
#define E_STEPPERS 1
#define TOOL_E_INDEX 0
#ifndef HOTEND_OFFSET_Z
#define HOTEND_OFFSET_Z { 0 }
#endif
#elif ENABLED(MIXING_EXTRUDER) // Multi-stepper, unified E axis, one hotend
#define HOTENDS 1
#define E_STEPPERS MIXING_STEPPERS
#define TOOL_E_INDEX 0
#else // One stepper, E axis, and hotend per tool
#define HOTENDS EXTRUDERS
#define E_STEPPERS EXTRUDERS
#define TOOL_E_INDEX current_block->active_extruder
#endif

/**
* Default hotend offsets, if not defined
*/
#if HOTENDS > 1
#ifndef HOTEND_OFFSET_X
#define HOTEND_OFFSET_X { 0 } // X offsets for each extruder
#endif
#ifndef HOTEND_OFFSET_Y
#define HOTEND_OFFSET_Y { 0 } // Y offsets for each extruder
#endif
#if !defined(HOTEND_OFFSET_Z) && (ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_EXTRUDER))
#define HOTEND_OFFSET_Z { 0 }
#endif
#endif

/**
Expand Down
25 changes: 24 additions & 1 deletion Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,30 @@
// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

// A dual extruder that uses a single stepper motor
// Don't forget to set SSDE_SERVO_ANGLES and HOTEND_OFFSET_X/Y/Z
//#define SWITCHING_EXTRUDER
#if ENABLED(SWITCHING_EXTRUDER)
#define SWITCHING_EXTRUDER_SERVO_NR 0
#define SWITCHING_EXTRUDER_SERVO_ANGLES { 0, 90 } // Angles for E0, E1
//#define HOTEND_OFFSET_Z {0.0, 0.0}
#endif

/**
* "Mixing Extruder"
* - Adds a new code, M165, to set the current mix factors.
* - Extends the stepping routines to move multiple steppers in proportion to the mix.
* - Optional support for Repetier Host M163, M164, and virtual extruder.
* - This implementation supports only a single extruder.
* - Enable DIRECT_MIXING_IN_G1 for Pia Taubert's reference implementation
*/
//#define MIXING_EXTRUDER
#if ENABLED(MIXING_EXTRUDER)
#define MIXING_STEPPERS 2 // Number of steppers in your mixing extruder
#define MIXING_VIRTUAL_TOOLS 16 // Use the Virtual Tool method with M163 and M164
//#define DIRECT_MIXING_IN_G1 // Allow ABCDHI mix factors in G1 movement commands
#endif

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
Expand All @@ -162,7 +186,6 @@
// 1 = ATX
// 2 = X-Box 360 203Watts (the blue wire connected to PS_ON and the red wire to VCC)
// :{1:'ATX',2:'X-Box 360'}

#define POWER_SUPPLY 1

// Define this to have the electronics keep the power supply off on startup. If you don't know what this is leave it.
Expand Down
80 changes: 55 additions & 25 deletions Marlin/Marlin.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,37 +167,63 @@ void manage_inactivity(bool ignore_stepper_queue = false);
#define disable_z() NOOP
#endif

#if HAS_E0_ENABLE
#define enable_e0() E0_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e0() E0_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e0() NOOP
#define disable_e0() NOOP
#endif

#if (EXTRUDERS > 1) && HAS_E1_ENABLE
#define enable_e1() E1_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e1() E1_ENABLE_WRITE(!E_ENABLE_ON)
#else
#if ENABLED(MIXING_EXTRUDER)

/**
* Mixing steppers synchronize their enable (and direction) together
*/
#if MIXING_STEPPERS > 3
#define enable_e0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); E3_ENABLE_WRITE( E_ENABLE_ON); }
#define disable_e0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); E3_ENABLE_WRITE(!E_ENABLE_ON); }
#elif MIXING_STEPPERS > 2
#define enable_e0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); }
#define disable_e0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); }
#else
#define enable_e0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); }
#define disable_e0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); }
#endif
#define enable_e1() NOOP
#define disable_e1() NOOP
#endif

#if (EXTRUDERS > 2) && HAS_E2_ENABLE
#define enable_e2() E2_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e2() E2_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e2() NOOP
#define disable_e2() NOOP
#endif

#if (EXTRUDERS > 3) && HAS_E3_ENABLE
#define enable_e3() E3_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e3() E3_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e3() NOOP
#define disable_e3() NOOP
#endif

#else // !MIXING_EXTRUDER

#if HAS_E0_ENABLE
#define enable_e0() E0_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e0() E0_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e0() NOOP
#define disable_e0() NOOP
#endif

#if E_STEPPERS > 1 && HAS_E1_ENABLE
#define enable_e1() E1_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e1() E1_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e1() NOOP
#define disable_e1() NOOP
#endif

#if E_STEPPERS > 2 && HAS_E2_ENABLE
#define enable_e2() E2_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e2() E2_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e2() NOOP
#define disable_e2() NOOP
#endif

#if E_STEPPERS > 3 && HAS_E3_ENABLE
#define enable_e3() E3_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e3() E3_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define enable_e3() NOOP
#define disable_e3() NOOP
#endif

#endif // !MIXING_EXTRUDER

/**
* The axis order in all axis related arrays is X, Y, Z, E
Expand Down Expand Up @@ -376,6 +402,10 @@ extern uint8_t active_extruder;
void print_heaterstates();
#endif

#if ENABLED(MIXING_EXTRUDER)
extern float mixing_factor[MIXING_STEPPERS];
#endif

void calculate_volumetric_multipliers();

// Buzzer
Expand Down
Loading