From bb6174524f5f2382cf77ccec276d2ce7e1eb848e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 31 Mar 2015 02:08:57 -0700 Subject: [PATCH 1/4] Fix EXTRUDER_OFFSET compiler error - Addressing issue #1741 --- Marlin/Marlin_main.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 86138fb8f..caeb628b2 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -229,18 +229,17 @@ bool axis_known_position[3] = { false }; // Extruder offset #if EXTRUDERS > 1 #ifndef EXTRUDER_OFFSET_X - #define EXTRUDER_OFFSET_X 0 + #define EXTRUDER_OFFSET_X { 0 } #endif #ifndef EXTRUDER_OFFSET_Y - #define EXTRUDER_OFFSET_Y 0 + #define EXTRUDER_OFFSET_Y { 0 } #endif #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 - #define _EXY { EXTRUDER_OFFSET_X, EXTRUDER_OFFSET_Y } - float extruder_offset[EXTRUDERS][NUM_EXTRUDER_OFFSETS] = ARRAY_BY_EXTRUDERS(_EXY, _EXY, _EXY, _EXY); + float extruder_offset[EXTRUDERS][NUM_EXTRUDER_OFFSETS]; #endif uint8_t active_extruder = 0; @@ -569,6 +568,13 @@ void servo_init() void setup() { + #if EXTRUDERS > 1 + float offset[3][EXTRUDERS] = { EXTRUDER_OFFSET_X, EXTRUDER_OFFSET_Y, ARRAY_BY_EXTRUDERS(0,0,0,0) }; + for (int e=0; e Date: Tue, 31 Mar 2015 02:10:49 -0700 Subject: [PATCH 2/4] Fix typo in assignment --- Marlin/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index caeb628b2..5c7ff37f3 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -572,7 +572,7 @@ void setup() float offset[3][EXTRUDERS] = { EXTRUDER_OFFSET_X, EXTRUDER_OFFSET_Y, ARRAY_BY_EXTRUDERS(0,0,0,0) }; for (int e=0; e Date: Tue, 31 Mar 2015 02:49:47 -0700 Subject: [PATCH 3/4] Restore extruder_offset, init more simply --- Marlin/Configuration.h | 12 ++++----- Marlin/Marlin_main.cpp | 56 +++++++++++++++++++----------------------- 2 files changed, 31 insertions(+), 37 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index bd1bff6d2..f62509e4a 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -72,6 +72,12 @@ Here are some standard links for getting your machine calibrated: // This defines the number of extruders #define EXTRUDERS 1 +// 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 + //// 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) @@ -516,12 +522,6 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o #define DEFAULT_RETRACT_ACCELERATION 3000 // E acceleration in mm/s^2 for retracts #define DEFAULT_TRAVEL_ACCELERATION 3000 // X, Y, Z acceleration in mm/s^2 for travel (non printing) moves -// 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 - // The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously) #define DEFAULT_XYJERK 20.0 // (mm/sec) #define DEFAULT_ZJERK 0.4 // (mm/sec) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 5c7ff37f3..6b3589d7c 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -226,7 +226,7 @@ float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS }; float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS }; bool axis_known_position[3] = { false }; -// Extruder offset +// Extruder offsets #if EXTRUDERS > 1 #ifndef EXTRUDER_OFFSET_X #define EXTRUDER_OFFSET_X { 0 } @@ -234,12 +234,13 @@ bool axis_known_position[3] = { false }; #ifndef EXTRUDER_OFFSET_Y #define EXTRUDER_OFFSET_Y { 0 } #endif - #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[EXTRUDERS][NUM_EXTRUDER_OFFSETS]; + float extruder_offset[][EXTRUDERS] = { + EXTRUDER_OFFSET_X, + EXTRUDER_OFFSET_Y + #ifdef DUAL_X_CARRIAGE + , { 0 } // supports offsets in XYZ plane + #endif + }; #endif uint8_t active_extruder = 0; @@ -568,13 +569,6 @@ void servo_init() void setup() { - #if EXTRUDERS > 1 - float offset[3][EXTRUDERS] = { EXTRUDER_OFFSET_X, EXTRUDER_OFFSET_Y, ARRAY_BY_EXTRUDERS(0,0,0,0) }; - for (int e=0; e 0) ? extruder_offset[1][X_AXIS] : X2_HOME_POS; + return (extruder_offset[X_AXIS][1] > 0) ? extruder_offset[X_AXIS][1] : X2_HOME_POS; } static int x_home_dir(int extruder) { @@ -965,14 +959,14 @@ static void axis_is_at_home(int axis) { if (active_extruder != 0) { current_position[X_AXIS] = x_home_pos(active_extruder); min_pos[X_AXIS] = X2_MIN_POS; - max_pos[X_AXIS] = max(extruder_offset[1][X_AXIS], X2_MAX_POS); + max_pos[X_AXIS] = max(extruder_offset[X_AXIS][1], X2_MAX_POS); return; } else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE) { float xoff = home_offset[X_AXIS]; current_position[X_AXIS] = base_home_pos(X_AXIS) + xoff; min_pos[X_AXIS] = base_min_pos(X_AXIS) + xoff; - max_pos[X_AXIS] = min(base_max_pos(X_AXIS) + xoff, max(extruder_offset[1][X_AXIS], X2_MAX_POS) - duplicate_extruder_x_offset); + max_pos[X_AXIS] = min(base_max_pos(X_AXIS) + xoff, max(extruder_offset[X_AXIS][1], X2_MAX_POS) - duplicate_extruder_x_offset); return; } } @@ -3786,23 +3780,23 @@ inline void gcode_M206() { inline void gcode_M218() { if (setTargetedHotend(218)) return; - if (code_seen('X')) extruder_offset[tmp_extruder][X_AXIS] = code_value(); - if (code_seen('Y')) extruder_offset[tmp_extruder][Y_AXIS] = code_value(); + if (code_seen('X')) extruder_offset[X_AXIS][tmp_extruder] = code_value(); + if (code_seen('Y')) extruder_offset[Y_AXIS][tmp_extruder] = code_value(); #ifdef DUAL_X_CARRIAGE - if (code_seen('Z')) extruder_offset[tmp_extruder][Z_AXIS] = code_value(); + if (code_seen('Z')) extruder_offset[Z_AXIS][tmp_extruder] = code_value(); #endif SERIAL_ECHO_START; SERIAL_ECHOPGM(MSG_HOTEND_OFFSET); for (tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++) { SERIAL_ECHO(" "); - SERIAL_ECHO(extruder_offset[tmp_extruder][X_AXIS]); + SERIAL_ECHO(extruder_offset[X_AXIS][tmp_extruder]); SERIAL_ECHO(","); - SERIAL_ECHO(extruder_offset[tmp_extruder][Y_AXIS]); + SERIAL_ECHO(extruder_offset[Y_AXIS][tmp_extruder]); #ifdef DUAL_X_CARRIAGE SERIAL_ECHO(","); - SERIAL_ECHO(extruder_offset[tmp_extruder][Z_AXIS]); + SERIAL_ECHO(extruder_offset[Z_AXIS][tmp_extruder]); #endif } SERIAL_EOL; @@ -4493,13 +4487,13 @@ inline void gcode_M503() { SERIAL_ECHO_START; SERIAL_ECHOPGM(MSG_HOTEND_OFFSET); SERIAL_ECHO(" "); - SERIAL_ECHO(extruder_offset[0][X_AXIS]); + SERIAL_ECHO(extruder_offset[X_AXIS][0]); SERIAL_ECHO(","); - SERIAL_ECHO(extruder_offset[0][Y_AXIS]); + SERIAL_ECHO(extruder_offset[Y_AXIS][0]); SERIAL_ECHO(" "); SERIAL_ECHO(duplicate_extruder_x_offset); SERIAL_ECHO(","); - SERIAL_ECHOLN(extruder_offset[1][Y_AXIS]); + SERIAL_ECHOLN(extruder_offset[Y_AXIS][1]); break; case DXC_FULL_CONTROL_MODE: case DXC_AUTO_PARK_MODE: @@ -4634,11 +4628,11 @@ inline void gcode_T() { // apply Y & Z extruder offset (x offset is already used in determining home pos) current_position[Y_AXIS] = current_position[Y_AXIS] - - extruder_offset[active_extruder][Y_AXIS] + - extruder_offset[tmp_extruder][Y_AXIS]; + extruder_offset[Y_AXIS][active_extruder] + + extruder_offset[Y_AXIS][tmp_extruder]; current_position[Z_AXIS] = current_position[Z_AXIS] - - extruder_offset[active_extruder][Z_AXIS] + - extruder_offset[tmp_extruder][Z_AXIS]; + extruder_offset[Z_AXIS][active_extruder] + + extruder_offset[Z_AXIS][tmp_extruder]; active_extruder = tmp_extruder; @@ -4668,7 +4662,7 @@ inline void gcode_T() { #else // !DUAL_X_CARRIAGE // Offset extruder (only by XY) for (int i=X_AXIS; i<=Y_AXIS; i++) - current_position[i] += extruder_offset[tmp_extruder][i] - extruder_offset[active_extruder][i]; + current_position[i] += extruder_offset[i][tmp_extruder] - extruder_offset[i][active_extruder]; // Set the new active extruder and position active_extruder = tmp_extruder; #endif // !DUAL_X_CARRIAGE From 935592cf6a8793e9baaed0d584b5aad84c1a3ff5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 31 Mar 2015 02:50:52 -0700 Subject: [PATCH 4/4] offsets off by default --- Marlin/Configuration.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index f62509e4a..5412cbbea 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -75,8 +75,8 @@ Here are some standard links for getting your machine calibrated: // 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 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 //// The following define selects which power supply you have. Please choose the one that matches your setup // 1 = ATX