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

Add 4th extruder and option for single nozzle #964

Closed
wants to merge 1 commit into from
Closed
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
15 changes: 14 additions & 1 deletion Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@
// This defines the number of extruders
#define EXTRUDERS 1

// Setting for one hotend and more extruder, firmware by MagoKimbra
#if EXTRUDERS > 1
#define SINGLENOZZLE //This is used for singlenozzled multiple extrusion configuration
#endif

//// The following define selects which power supply you have. Please choose the one that matches your setup
// 1 = ATX
// 2 = X-Box 360 203Watts (the blue wire connected to PS_ON and the red wire to VCC)
Expand Down Expand Up @@ -137,12 +142,17 @@
#define TEMP_SENSOR_0 -1
#define TEMP_SENSOR_1 -1
#define TEMP_SENSOR_2 0
#define TEMP_SENSOR_BED 0
#define TEMP_SENSOR_3 0
#define TEMP_SENSOR_BED 1

// This makes temp sensor 1 a redundant sensor for sensor 0. If the temperatures difference between these sensors is to high the print will be aborted.
//#define TEMP_SENSOR_1_AS_REDUNDANT
#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10

#ifdef SINGLENOZZLE
#undef TEMP_SENSOR_1_AS_REDUNDANT
#endif

// Actual temperature must be close to target for this long before M109 returns success
#define TEMP_RESIDENCY_TIME 10 // (seconds)
#define TEMP_HYSTERESIS 3 // (degC) range of +/- temperatures considered "close" to the target one
Expand All @@ -154,6 +164,7 @@
#define HEATER_0_MINTEMP 5
#define HEATER_1_MINTEMP 5
#define HEATER_2_MINTEMP 5
#define HEATER_3_MINTEMP 5
#define BED_MINTEMP 5

// When temperature exceeds max temp, your heater will be switched off.
Expand All @@ -162,6 +173,7 @@
#define HEATER_0_MAXTEMP 275
#define HEATER_1_MAXTEMP 275
#define HEATER_2_MAXTEMP 275
#define HEATER_3_MAXTEMP 275
#define BED_MAXTEMP 150

// If your bed has low resistance e.g. .6 ohm and throws the fuse you can duty cycle it to reduce the
Expand Down Expand Up @@ -314,6 +326,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
#define INVERT_E0_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E1_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E2_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E3_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false

// ENDSTOP SETTINGS:
// Sets direction of endstops when homing; 1=MAX, -1=MIN
Expand Down
15 changes: 15 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ const unsigned int dropsegments=5; //everything with less than this number of st
#error "You cannot use HEATERS_PARALLEL if EXTRUDERS > 1"
#endif

#if defined SINGLENOZZLE && defined TEMP_SENSOR_1_AS_REDUNDANT
#error "You cannot use TEMP_SENSOR_1_AS_REDUNDANT if SINGLENOZZLE"
#endif

#if TEMP_SENSOR_0 > 0
#define THERMISTORHEATER_0 TEMP_SENSOR_0
#define HEATER_0_USES_THERMISTOR
Expand All @@ -457,6 +461,10 @@ const unsigned int dropsegments=5; //everything with less than this number of st
#define THERMISTORHEATER_2 TEMP_SENSOR_2
#define HEATER_2_USES_THERMISTOR
#endif
#if TEMP_SENSOR_3 > 0
#define THERMISTORHEATER_3 TEMP_SENSOR_3
#define HEATER_3_USES_THERMISTOR
#endif
#if TEMP_SENSOR_BED > 0
#define THERMISTORBED TEMP_SENSOR_BED
#define BED_USES_THERMISTOR
Expand All @@ -470,6 +478,9 @@ const unsigned int dropsegments=5; //everything with less than this number of st
#if TEMP_SENSOR_2 == -1
#define HEATER_2_USES_AD595
#endif
#if TEMP_SENSOR_3 == -1
#define HEATER_3_USES_AD595
#endif
#if TEMP_SENSOR_BED == -1
#define BED_USES_AD595
#endif
Expand All @@ -488,6 +499,10 @@ const unsigned int dropsegments=5; //everything with less than this number of st
#undef HEATER_2_MINTEMP
#undef HEATER_2_MAXTEMP
#endif
#if TEMP_SENSOR_3 == 0
#undef HEATER_3_MINTEMP
#undef HEATER_3_MAXTEMP
#endif
#if TEMP_SENSOR_BED == 0
#undef BED_MINTEMP
#undef BED_MAXTEMP
Expand Down
9 changes: 9 additions & 0 deletions Marlin/Marlin.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ void manage_inactivity();
#define disable_e2() /* nothing */
#endif

#if (EXTRUDERS > 3) && defined(E3_ENABLE_PIN) && (E3_ENABLE_PIN > -1)
#define enable_e3() WRITE(E3_ENABLE_PIN, E_ENABLE_ON)
#define disable_e3() WRITE(E3_ENABLE_PIN,!E_ENABLE_ON)
#else
#define enable_e3() /* nothing */
#define disable_e3() /* nothing */
#endif



enum AxisEnum {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, E_AXIS=3};

Expand Down
113 changes: 85 additions & 28 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ int extruder_multiply[EXTRUDERS] = {100
, 100
#if EXTRUDERS > 2
, 100
#if EXTRUDERS > 3
, 100
#endif
#endif
#endif
};
Expand All @@ -204,6 +207,9 @@ float volumetric_multiplier[EXTRUDERS] = {1.0
, 1.0
#if EXTRUDERS > 2
, 1.0
#if EXTRUDERS > 3
, 1.0
#endif
#endif
#endif
};
Expand All @@ -219,16 +225,18 @@ float zprobe_zoffset;

// Extruder offset
#if EXTRUDERS > 1
#ifndef DUAL_X_CARRIAGE
#define NUM_EXTRUDER_OFFSETS 2 // only in XY plane
#else
#define NUM_EXTRUDER_OFFSETS 3 // supports offsets in XYZ plane
#endif
float extruder_offset[NUM_EXTRUDER_OFFSETS][EXTRUDERS] = {
#if defined(EXTRUDER_OFFSET_X) && defined(EXTRUDER_OFFSET_Y)
EXTRUDER_OFFSET_X, EXTRUDER_OFFSET_Y
#endif
};
#ifndef SINGLENOZZLE
#ifndef DUAL_X_CARRIAGE
#define NUM_EXTRUDER_OFFSETS 2 // only in XY plane
#else
#define NUM_EXTRUDER_OFFSETS 3 // supports offsets in XYZ plane
#endif
float extruder_offset[NUM_EXTRUDER_OFFSETS][EXTRUDERS] = {
#if defined(EXTRUDER_OFFSET_X) && defined(EXTRUDER_OFFSET_Y)
EXTRUDER_OFFSET_X, EXTRUDER_OFFSET_Y
#endif
};
#endif
#endif
uint8_t active_extruder = 0;
int fanSpeed=0;
Expand Down Expand Up @@ -1829,7 +1837,11 @@ void process_commands()
if(setTargetedHotend(104)){
break;
}
if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
#ifndef SINGLENOZZLE
if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
#else
if (code_seen('S')) setTargetHotend(code_value(), 0);
#endif
#ifdef DUAL_X_CARRIAGE
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
Expand Down Expand Up @@ -1857,7 +1869,13 @@ void process_commands()
SERIAL_PROTOCOLPGM(" /");
SERIAL_PROTOCOL_F(degTargetBed(),1);
#endif //TEMP_BED_PIN
for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {

#ifndef SINGLENOZZLE
for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
#else
for (int8_t cur_extruder = 0; cur_extruder < 1; ++cur_extruder) {
#endif

SERIAL_PROTOCOLPGM(" T");
SERIAL_PROTOCOL(cur_extruder);
SERIAL_PROTOCOLPGM(":");
Expand Down Expand Up @@ -1893,7 +1911,11 @@ void process_commands()
SERIAL_PROTOCOLPGM("C->");
SERIAL_PROTOCOL_F(rawBedTemp()/OVERSAMPLENR,0);
#endif
for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
#ifndef SINGLENOZZLE
for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
#else
for (int8_t cur_extruder = 0; cur_extruder < 1; ++cur_extruder) {
#endif
SERIAL_PROTOCOLPGM(" T");
SERIAL_PROTOCOL(cur_extruder);
SERIAL_PROTOCOLPGM(":");
Expand All @@ -1916,14 +1938,22 @@ void process_commands()
autotemp_enabled=false;
#endif
if (code_seen('S')) {
setTargetHotend(code_value(), tmp_extruder);
#ifndef SINGLENOZZLE
setTargetHotend(code_value(), tmp_extruder);
#else
setTargetHotend(code_value(), 0);
#endif
#ifdef DUAL_X_CARRIAGE
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
#endif
CooldownNoWait = true;
} else if (code_seen('R')) {
setTargetHotend(code_value(), tmp_extruder);
#ifndef SINGLENOZZLE
setTargetHotend(code_value(), tmp_extruder);
#else
setTargetHotend(code_value(), 0);
#endif
#ifdef DUAL_X_CARRIAGE
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
Expand All @@ -1944,8 +1974,12 @@ void process_commands()
codenum = millis();

/* See if we are heating up or cooling down */
target_direction = isHeatingHotend(tmp_extruder); // true if heating, false if cooling

#ifndef SINGLENOZZLE
target_direction = isHeatingHotend(tmp_extruder); // true if heating, false if cooling
#else
target_direction = isHeatingHotend(0); // true if heating, false if cooling
#endif

#ifdef TEMP_RESIDENCY_TIME
long residencyStart;
residencyStart = -1;
Expand All @@ -1954,14 +1988,26 @@ void process_commands()
while((residencyStart == -1) ||
(residencyStart >= 0 && (((unsigned int) (millis() - residencyStart)) < (TEMP_RESIDENCY_TIME * 1000UL))) ) {
#else
while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) ) {
#ifndef SINGLENOZZLE
while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) ) {
#else
while ( target_direction ? (isHeatingHotend(0)) : (isCoolingHotend(0)&&(CooldownNoWait==false)) ) {
#endif
#endif //TEMP_RESIDENCY_TIME
if( (millis() - codenum) > 1000UL )
{ //Print Temp Reading and remaining time every 1 second while heating up/cooling down
SERIAL_PROTOCOLPGM("T:");
SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1);
#ifndef SINGLENOZZLE
SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1);
#else
SERIAL_PROTOCOL_F(degHotend(0),1);
#endif
SERIAL_PROTOCOLPGM(" E:");
SERIAL_PROTOCOL((int)tmp_extruder);
#ifndef SINGLENOZZLE
SERIAL_PROTOCOL((int)tmp_extruder);
#else
SERIAL_PROTOCOL(0); //There's only one nozzle
#endif
#ifdef TEMP_RESIDENCY_TIME
SERIAL_PROTOCOLPGM(" W:");
if(residencyStart > -1)
Expand All @@ -1984,12 +2030,21 @@ void process_commands()
#ifdef TEMP_RESIDENCY_TIME
/* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
or when current temp falls outside the hysteresis after target temp was reached */
if ((residencyStart == -1 && target_direction && (degHotend(tmp_extruder) >= (degTargetHotend(tmp_extruder)-TEMP_WINDOW))) ||
(residencyStart == -1 && !target_direction && (degHotend(tmp_extruder) <= (degTargetHotend(tmp_extruder)+TEMP_WINDOW))) ||
(residencyStart > -1 && labs(degHotend(tmp_extruder) - degTargetHotend(tmp_extruder)) > TEMP_HYSTERESIS) )
{
residencyStart = millis();
}
#ifndef SINGLENOZZLE
if ((residencyStart == -1 && target_direction && (degHotend(tmp_extruder) >= (degTargetHotend(tmp_extruder)-TEMP_WINDOW))) ||
(residencyStart == -1 && !target_direction && (degHotend(tmp_extruder) <= (degTargetHotend(tmp_extruder)+TEMP_WINDOW))) ||
(residencyStart > -1 && labs(degHotend(tmp_extruder) - degTargetHotend(tmp_extruder)) > TEMP_HYSTERESIS) )
{
residencyStart = millis();
}
#else
if ((residencyStart == -1 && target_direction && (degHotend(0) >= (degTargetHotend(0)-TEMP_WINDOW))) ||
(residencyStart == -1 && !target_direction && (degHotend(0) <= (degTargetHotend(0)+TEMP_WINDOW))) ||
(residencyStart > -1 && labs(degHotend(0) - degTargetHotend(0)) > TEMP_HYSTERESIS) )
{
residencyStart = millis();
}
#endif
#endif //TEMP_RESIDENCY_TIME
}
LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
Expand Down Expand Up @@ -2403,7 +2458,7 @@ void process_commands()

}break;
#endif // FWRETRACT
#if EXTRUDERS > 1
#if EXTRUDERS > 1 && !defined(SINGLENOZZLE)
case 218: // M218 - set hotend offset (in mm), T<extruder_number> X<offset_on_X> Y<offset_on_Y>
{
if(setTargetedHotend(218)){
Expand Down Expand Up @@ -2438,7 +2493,7 @@ void process_commands()
}
SERIAL_ECHOLN("");
}break;
#endif
#endif //EXTRUDERS and SINGLENOZZLE
case 220: // M220 S<factor in percent>- set speed factor override percentage
{
if(code_seen('S'))
Expand Down Expand Up @@ -3096,12 +3151,14 @@ void process_commands()
}
#else
// Offset extruder (only by XY)
#ifndef SINGLENOZZLE
int i;
for(i = 0; i < 2; i++) {
current_position[i] = current_position[i] -
extruder_offset[i][active_extruder] +
extruder_offset[i][tmp_extruder];
}
#endif
// Set the new active extruder and position
active_extruder = tmp_extruder;
#endif //else DUAL_X_CARRIAGE
Expand Down
16 changes: 13 additions & 3 deletions Marlin/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -2738,7 +2738,12 @@ DaveX plan for Teensylu/printrboard-type pinouts (ref teensylu & sprinter) for a

#endif


#ifndef HEATER_3_PIN
#define HEATER_3_PIN -1
#endif
#ifndef TEMP_3_PIN
#define TEMP_3_PIN -1
#endif

#ifndef KNOWN_BOARD
#error Unknown MOTHERBOARD value in configuration.h
Expand All @@ -2756,6 +2761,11 @@ DaveX plan for Teensylu/printrboard-type pinouts (ref teensylu & sprinter) for a
#else
#define _E2_PINS
#endif
#if EXTRUDERS > 3
#define _E3_PINS E3_STEP_PIN, E3_DIR_PIN, E3_ENABLE_PIN, HEATER_3_PIN,
#else
#define _E3_PINS
#endif

#ifdef X_STOP_PIN
#if X_HOME_DIR < 0
Expand Down Expand Up @@ -2801,7 +2811,7 @@ DaveX plan for Teensylu/printrboard-type pinouts (ref teensylu & sprinter) for a

#define SENSITIVE_PINS {0, 1, X_STEP_PIN, X_DIR_PIN, X_ENABLE_PIN, X_MIN_PIN, X_MAX_PIN, Y_STEP_PIN, Y_DIR_PIN, Y_ENABLE_PIN, Y_MIN_PIN, Y_MAX_PIN, Z_STEP_PIN, Z_DIR_PIN, Z_ENABLE_PIN, Z_MIN_PIN, Z_MAX_PIN, PS_ON_PIN, \
HEATER_BED_PIN, FAN_PIN, \
_E0_PINS _E1_PINS _E2_PINS \
analogInputToDigitalPin(TEMP_0_PIN), analogInputToDigitalPin(TEMP_1_PIN), analogInputToDigitalPin(TEMP_2_PIN), analogInputToDigitalPin(TEMP_BED_PIN) }
_E0_PINS _E1_PINS _E2_PINS _E3_PINS \
analogInputToDigitalPin(TEMP_0_PIN), analogInputToDigitalPin(TEMP_1_PIN), analogInputToDigitalPin(TEMP_2_PIN), analogInputToDigitalPin(TEMP_3_PIN), analogInputToDigitalPin(TEMP_BED_PIN) }
#endif

10 changes: 6 additions & 4 deletions Marlin/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,16 +664,18 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi
{
switch(extruder)
{
case 0: enable_e0(); disable_e1(); disable_e2(); break;
case 1: disable_e0(); enable_e1(); disable_e2(); break;
case 2: disable_e0(); disable_e1(); enable_e2(); break;
case 0: enable_e0(); disable_e1(); disable_e2(); disable_e3(); break;
case 1: disable_e0(); enable_e1(); disable_e2(); disable_e3(); break;
case 2: disable_e0(); disable_e1(); enable_e2(); disable_e3(); break;
case 3: disable_e0(); disable_e1(); disable_e2(); enable_e3(); break;
}
}
else //enable all
{
enable_e0();
enable_e1();
enable_e2();
enable_e2();
enable_e3();
}
}

Expand Down
Loading