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 option for SINGLENOZZLE #2540

Closed
wants to merge 4 commits 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
25 changes: 25 additions & 0 deletions Marlin/Conditionals.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,16 @@

#define CONDITIONALS_H

/**
* SINGLENOZZLE
*/
#ifdef SINGLENOZZLE
#define HOTENDS 1
#undef TEMP_SENSOR_1_AS_REDUNDANT
#else
#define HOTENDS EXTRUDERS
#endif

#include "pins.h"

#ifndef USBCON
Expand Down Expand Up @@ -408,6 +418,21 @@

#define ARRAY_BY_EXTRUDERS1(v1) ARRAY_BY_EXTRUDERS(v1, v1, v1, v1)

/**
* ARRAY_BY_HOTENDS based on HOTENDS
*/
#if HOTENDS > 3
#define ARRAY_BY_HOTENDS(v1, v2, v3, v4) { v1, v2, v3, v4 }
#elif HOTENDS > 2
#define ARRAY_BY_HOTENDS(v1, v2, v3, v4) { v1, v2, v3 }
#elif HOTENDS > 1
#define ARRAY_BY_HOTENDS(v1, v2, v3, v4) { v1, v2 }
#else
#define ARRAY_BY_HOTENDS(v1, v2, v3, v4) { v1 }
#endif

#define ARRAY_BY_HOTENDS1(v1) ARRAY_BY_HOTENDS(v1, v1, v1, v1)

/**
* Shorthand for pin tests, used wherever needed
*/
Expand Down
16 changes: 10 additions & 6 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,15 @@ Here are some standard links for getting your machine calibrated:
// :[1,2,3,4]
#define EXTRUDERS 1

// This is used for single nozzle and multiple extrusion configuration
// Uncomment below to enable (One Hotend)
//#define SINGLENOZZLE

// 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.
//#define EXTRUDER_OFFSET_X {0.0, 20.00} // (in mm) for each extruder, offset of the hotend on the X axis
//#define EXTRUDER_OFFSET_Y {0.0, 5.00} // (in mm) for each extruder, offset of the hotend on the Y axis
//#define HOTEND_OFFSET_X {0.0, 20.00} // (in mm) for each extruder, offset of the hotend on the X axis
//#define HOTEND_OFFSET_Y {0.0, 5.00} // (in mm) for each extruder, offset of the hotend on the Y axis

//// The following define selects which power supply you have. Please choose the one that matches your setup
// 1 = ATX
Expand Down Expand Up @@ -182,9 +186,9 @@ Here are some standard links for getting your machine calibrated:
// HEATER_BED_DUTY_CYCLE_DIVIDER intervals.
//#define HEATER_BED_DUTY_CYCLE_DIVIDER 4

// If you want the M105 heater power reported in watts, define the BED_WATTS, and (shared for all extruders) EXTRUDER_WATTS
//#define EXTRUDER_WATTS (12.0*12.0/6.7) // P=I^2/R
//#define BED_WATTS (12.0*12.0/1.1) // P=I^2/R
// If you want the M105 heater power reported in watts, define the BED_WATTS, and (shared for all hotend) HOTEND_WATTS
//#define HOTEND_WATTS (12.0*12.0/6.7) // P=I^2/R
//#define BED_WATTS (12.0*12.0/1.1) // P=I^2/R

//===========================================================================
//============================= PID Settings ================================
Expand All @@ -199,7 +203,7 @@ Here are some standard links for getting your machine calibrated:
//#define PID_DEBUG // Sends debug data to the serial port.
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
//#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay
//#define PID_PARAMS_PER_EXTRUDER // Uses separate PID parameters for each extruder (useful for mismatched extruders)
//#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders)
// Set/get with gcode: M301 E[extruder number, 0-2]
#define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature
// is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
Expand Down
78 changes: 43 additions & 35 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,17 +297,18 @@ bool target_direction;
float z_endstop_adj = 0;
#endif

// Extruder offsets
#if EXTRUDERS > 1
#ifndef EXTRUDER_OFFSET_X
#define EXTRUDER_OFFSET_X { 0 }
// Hotend offset
#if HOTENDS > 1
#ifndef DUAL_X_CARRIAGE

#define HOTEND_OFFSET_X { 0 }
#endif
#ifndef EXTRUDER_OFFSET_Y
#define EXTRUDER_OFFSET_Y { 0 }
#ifndef HOTEND_OFFSET_Y
#define HOTEND_OFFSET_Y { 0 }
#endif
float extruder_offset[][EXTRUDERS] = {
EXTRUDER_OFFSET_X,
EXTRUDER_OFFSET_Y
float hotend_offset[][HOTENDS] = {
HOTEND_OFFSET_X,
HOTEND_OFFSET_Y
#ifdef DUAL_X_CARRIAGE
, { 0 } // supports offsets in XYZ plane
#endif
Expand Down Expand Up @@ -3361,6 +3362,10 @@ inline void gcode_M104() {
if (setTargetedHotend(104)) return;
if (marlin_debug_flags & DEBUG_DRYRUN) return;

#if HOTENDS == 1
if (target_extruder != active_extruder) return;
#endif

if (code_seen('S')) {
float temp = code_value();
setTargetHotend(temp, target_extruder);
Expand Down Expand Up @@ -3405,8 +3410,8 @@ inline void gcode_M105() {
#endif

SERIAL_PROTOCOLPGM(" @:");
#ifdef EXTRUDER_WATTS
SERIAL_PROTOCOL((EXTRUDER_WATTS * getHeaterPower(target_extruder))/127);
#ifdef HOTEND_WATTS
SERIAL_PROTOCOL((HOTEND_WATTS * getHeaterPower(target_extruder))/127);
SERIAL_PROTOCOLCHAR('W');
#else
SERIAL_PROTOCOL(getHeaterPower(target_extruder));
Expand Down Expand Up @@ -3461,6 +3466,10 @@ inline void gcode_M109() {
if (setTargetedHotend(109)) return;
if (marlin_debug_flags & DEBUG_DRYRUN) return;

#if HOTENDS == 1
if (target_extruder != active_extruder) return;
#endif

LCD_MESSAGEPGM(MSG_HEATING);

no_wait_for_cooling = code_seen('S');
Expand Down Expand Up @@ -4151,43 +4160,43 @@ inline void gcode_M206() {
unknown_command_error();
return;
}
for (int i=0; i<EXTRUDERS; i++) retracted[i] = false;
for (int i = 0; i < EXTRUDERS; i++) retracted[i] = false;
}
}

#endif // FWRETRACT

#if EXTRUDERS > 1
#if HOTENDS > 1

/**
* M218 - set hotend offset (in mm), T<extruder_number> X<offset_on_X> Y<offset_on_Y>
*/
inline void gcode_M218() {
if (setTargetedHotend(218)) return;

if (code_seen('X')) extruder_offset[X_AXIS][target_extruder] = code_value();
if (code_seen('Y')) extruder_offset[Y_AXIS][target_extruder] = code_value();
if (code_seen('X')) hotend_offset[X_AXIS][target_extruder] = code_value();
if (code_seen('Y')) hotend_offset[Y_AXIS][target_extruder] = code_value();

#ifdef DUAL_X_CARRIAGE
if (code_seen('Z')) extruder_offset[Z_AXIS][target_extruder] = code_value();
if (code_seen('Z')) hotend_offset[Z_AXIS][target_extruder] = code_value();
#endif

SERIAL_ECHO_START;
SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
for (int e = 0; e < EXTRUDERS; e++) {
for (int e = 0; e < HOTENDS; e++) {
SERIAL_CHAR(' ');
SERIAL_ECHO(extruder_offset[X_AXIS][e]);
SERIAL_ECHO(hotend_offset[X_AXIS][e]);
SERIAL_CHAR(',');
SERIAL_ECHO(extruder_offset[Y_AXIS][e]);
SERIAL_ECHO(hotend_offset[Y_AXIS][e]);
#ifdef DUAL_X_CARRIAGE
SERIAL_CHAR(',');
SERIAL_ECHO(extruder_offset[Z_AXIS][e]);
SERIAL_ECHO(hotend_offset[Z_AXIS][e]);
#endif
}
SERIAL_EOL;
}

#endif // EXTRUDERS > 1
#endif // HOTENDS > 1

/**
* M220: Set speed percentage factor, aka "Feed Rate" (M220 S95)
Expand Down Expand Up @@ -4314,7 +4323,7 @@ inline void gcode_M226() {
// default behaviour (omitting E parameter) is to update for extruder 0 only
int e = code_seen('E') ? code_value() : 0; // extruder being updated

if (e < EXTRUDERS) { // catch bad input value
if (e < HOTENDS) { // catch bad input value
if (code_seen('P')) PID_PARAM(Kp, e) = code_value();
if (code_seen('I')) PID_PARAM(Ki, e) = scalePID_i(code_value());
if (code_seen('D')) PID_PARAM(Kd, e) = scalePID_d(code_value());
Expand All @@ -4324,10 +4333,10 @@ inline void gcode_M226() {

updatePID();
SERIAL_PROTOCOL(MSG_OK);
#ifdef PID_PARAMS_PER_EXTRUDER
#ifdef PID_PARAMS_PER_HOTEND
SERIAL_PROTOCOL(" e:"); // specify extruder in serial output
SERIAL_PROTOCOL(e);
#endif // PID_PARAMS_PER_EXTRUDER
#endif // PID_PARAMS_PER_HOTEND
SERIAL_PROTOCOL(" p:");
SERIAL_PROTOCOL(PID_PARAM(Kp, e));
SERIAL_PROTOCOL(" i:");
Expand Down Expand Up @@ -4845,7 +4854,7 @@ inline void gcode_M503() {

float lastpos[NUM_AXIS], fr60 = feedrate / 60;

for (int i=0; i<NUM_AXIS; i++)
for (int i = 0; i < NUM_AXIS; i++)
lastpos[i] = destination[i] = current_position[i];

#ifdef DELTA
Expand Down Expand Up @@ -4894,10 +4903,7 @@ inline void gcode_M503() {
//finish moves
st_synchronize();
//disable extruder steppers so filament can be removed
disable_e0();
disable_e1();
disable_e2();
disable_e3();
disable_e();
delay(100);
LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE);
millis_t next_tick = 0;
Expand Down Expand Up @@ -5168,9 +5174,11 @@ inline void gcode_T(uint8_t tmp_extruder) {
delayed_move_time = 0;
}
#else // !DUAL_X_CARRIAGE
// Offset extruder (only by XY)
for (int i=X_AXIS; i<=Y_AXIS; i++)
current_position[i] += extruder_offset[i][tmp_extruder] - extruder_offset[i][active_extruder];
// Offset hotend (only by XY)
#if HOTENDS > 1
for (int i = X_AXIS; i <= Y_AXIS; i++)
current_position[i] += hotend_offset[i][tmp_extruder] - hotend_offset[i][active_extruder];
#endif // HOTENDS > 1
// Set the new active extruder and position
active_extruder = tmp_extruder;
#endif // !DUAL_X_CARRIAGE
Expand Down Expand Up @@ -5557,7 +5565,7 @@ void process_next_command() {
break;
#endif // FWRETRACT

#if EXTRUDERS > 1
#if HOTENDS > 1
case 218: // M218 - set hotend offset (in mm), T<extruder_number> X<offset_on_X> Y<offset_on_Y>
gcode_M218();
break;
Expand Down Expand Up @@ -6380,8 +6388,8 @@ void plan_arc(
float max_temp = 0.0;
if (millis() > next_status_led_update_ms) {
next_status_led_update_ms += 500; // Update every 0.5s
for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder)
max_temp = max(max(max_temp, degHotend(cur_extruder)), degTargetHotend(cur_extruder));
for (int8_t cur_hotend = 0; cur_hotend < HOTENDS; ++cur_hotend)
max_temp = max(max(max_temp, degHotend(cur_hotend)), degTargetHotend(cur_hotend));
#if HAS_TEMP_BED
max_temp = max(max(max_temp, degTargetBed()), degBed());
#endif
Expand Down
47 changes: 27 additions & 20 deletions Marlin/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,58 +281,65 @@
#endif

/**
* Test Heater, Temp Sensor, and Extruder Pins; Sensor Type must also be set.
* Test Heater, Temp Sensor; Sensor Type must also be set.
*/
#if EXTRUDERS > 3
#if HOTENDS > 3
#if !HAS_HEATER_3
#error HEATER_3_PIN not defined for this board.
#elif !PIN_EXISTS(TEMP_3)
#error TEMP_3_PIN not defined for this board.
#elif !PIN_EXISTS(E3_STEP) || !PIN_EXISTS(E3_DIR) || !PIN_EXISTS(E3_ENABLE)
#error E3_STEP_PIN, E3_DIR_PIN, or E3_ENABLE_PIN not defined for this board.
#elif TEMP_SENSOR_3 == 0
#error TEMP_SENSOR_3 is required with 4 EXTRUDERS.
#endif
#elif EXTRUDERS > 2
#elif HOTENDS > 2
#if !HAS_HEATER_2
#error HEATER_2_PIN not defined for this board.
#elif !PIN_EXISTS(TEMP_2)
#error TEMP_2_PIN not defined for this board.
#elif !PIN_EXISTS(E2_STEP) || !PIN_EXISTS(E2_DIR) || !PIN_EXISTS(E2_ENABLE)
#error E2_STEP_PIN, E2_DIR_PIN, or E2_ENABLE_PIN not defined for this board.
#elif TEMP_SENSOR_2 == 0
#error TEMP_SENSOR_2 is required with 3 or more EXTRUDERS.
#endif
#elif EXTRUDERS > 1
#elif HOTENDS > 1
#if !PIN_EXISTS(TEMP_1)
#error TEMP_1_PIN not defined for this board.
#elif !PIN_EXISTS(E1_STEP) || !PIN_EXISTS(E1_DIR) || !PIN_EXISTS(E1_ENABLE)
#error E1_STEP_PIN, E1_DIR_PIN, or E1_ENABLE_PIN not defined for this board.
#endif
#endif

#if EXTRUDERS > 1 || defined(HEATERS_PARALLEL)
#if HOTENDS > 1 || defined(HEATERS_PARALLEL)
#if !HAS_HEATER_1
#error HEATER_1_PIN not defined for this board.
#endif
#endif

#if TEMP_SENSOR_1 == 0
#if EXTRUDERS > 1
#if HOTENDS > 1
#error TEMP_SENSOR_1 is required with 2 or more EXTRUDERS.
#elif ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
#error TEMP_SENSOR_1 is required with TEMP_SENSOR_1_AS_REDUNDANT.
#endif
#endif

#if !HAS_HEATER_0
#error HEATER_0_PIN not defined for this board.
#error HEATER_0_PIN not defined for this board
#elif !PIN_EXISTS(TEMP_0)
#error TEMP_0_PIN not defined for this board.
#elif !PIN_EXISTS(E0_STEP) || !PIN_EXISTS(E0_DIR) || !PIN_EXISTS(E0_ENABLE)
#endif

/**
* Test Extruder Pins;
*/
#if EXTRUDERS > 3
#if !PIN_EXISTS(E3_STEP) || !PIN_EXISTS(E3_DIR) || !PIN_EXISTS(E3_ENABLE)
#error E3_STEP_PIN, E3_DIR_PIN, or E3_ENABLE_PIN not defined for this board.
#endif
#elif EXTRUDERS > 2
#if !PIN_EXISTS(E2_STEP) || !PIN_EXISTS(E2_DIR) || !PIN_EXISTS(E2_ENABLE)
#error E2_STEP_PIN, E2_DIR_PIN, or E2_ENABLE_PIN not defined for this board.
#endif
#elif EXTRUDERS > 1
#if !PIN_EXISTS(E1_STEP) || !PIN_EXISTS(E1_DIR) || !PIN_EXISTS(E1_ENABLE)
#error E1_STEP_PIN, E1_DIR_PIN, or E1_ENABLE_PIN not defined for this board.
#endif
#endif

#if !PIN_EXISTS(E0_STEP) || !PIN_EXISTS(E0_DIR) || !PIN_EXISTS(E0_ENABLE)
#error E0_STEP_PIN, E0_DIR_PIN, or E0_ENABLE_PIN not defined for this board.
#elif TEMP_SENSOR_0 == 0
#error TEMP_SENSOR_0 is required.
#endif

/**
Expand Down
8 changes: 4 additions & 4 deletions Marlin/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#define BOARD_CHEAPTRONIC 2 // Cheaptronic v1.0
#define BOARD_SETHI 20 // Sethi 3D_1
#define BOARD_RAMPS_OLD 3 // MEGA/RAMPS up to 1.2
#define BOARD_RAMPS_13_EFB 33 // RAMPS 1.3 / 1.4 (Power outputs: Extruder, Fan, Bed)
#define BOARD_RAMPS_13_EEB 34 // RAMPS 1.3 / 1.4 (Power outputs: Extruder0, Extruder1, Bed)
#define BOARD_RAMPS_13_EFF 35 // RAMPS 1.3 / 1.4 (Power outputs: Extruder, Fan, Fan)
#define BOARD_RAMPS_13_EEF 36 // RAMPS 1.3 / 1.4 (Power outputs: Extruder0, Extruder1, Fan)
#define BOARD_RAMPS_13_EFB 33 // RAMPS 1.3 / 1.4 (Power outputs: Hotend, Fan, Bed)
#define BOARD_RAMPS_13_EEB 34 // RAMPS 1.3 / 1.4 (Power outputs: Hotend0, Hotend1, Bed)
#define BOARD_RAMPS_13_EFF 35 // RAMPS 1.3 / 1.4 (Power outputs: Hotend, Fan, Fan)
#define BOARD_RAMPS_13_EEF 36 // RAMPS 1.3 / 1.4 (Power outputs: Hotend0, Hotend1, Fan)
#define BOARD_RAMPS_13_SF 38 // RAMPS 1.3 / 1.4 (Power outputs: Spindle, Controller Fan)
#define BOARD_FELIX2 37 // Felix 2.0+ Electronics Board (RAMPS like)
#define BOARD_RIGIDBOARD 42 // Invent-A-Part RigidBoard
Expand Down
Loading