diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 85b2725d6f..598ad38f85 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -775,6 +775,10 @@ #define DOUBLECLICK_MAX_INTERVAL 1250 // Maximum interval between clicks, in milliseconds. // Note: Extra time may be added to mitigate controller latency. //#define BABYSTEP_ZPROBE_GFX_OVERLAY // Enable graphical overlay on Z-offset editor + + // Allow babystepping tool z offsets, allowing compensation for tools at different heights. + // Ignored in Independent X Carriage Duplicate mode, where tool 0 Z probe offset will be used. + //#define BABYSTEP_HOTEND_Z_OFFSET #endif // @section extruder diff --git a/Marlin/src/config/examples/Formbot/T-Rex_2+/Configuration.h b/Marlin/src/config/examples/Formbot/T-Rex_2+/Configuration.h index 25f78eeb43..66b9d32869 100644 --- a/Marlin/src/config/examples/Formbot/T-Rex_2+/Configuration.h +++ b/Marlin/src/config/examples/Formbot/T-Rex_2+/Configuration.h @@ -138,7 +138,7 @@ // The following define selects which electronics board you have. // Please choose the name from boards.h that matches your setup #ifndef MOTHERBOARD - #define MOTHERBOARD BOARD_FORMBOT_TREX2 + #define MOTHERBOARD BOARD_FORMBOT_TREX2PLUS #endif // Optional custom name for your RepStrap or other custom machine diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index d52af3594f..9b45f0669d 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -75,8 +75,9 @@ #define BOARD_AZTEEG_X3_PRO 68 // Azteeg X3 Pro #define BOARD_ULTIMAIN_2 72 // Ultimainboard 2.x (Uses TEMP_SENSOR 20) #define BOARD_RUMBA 80 // Rumba -#define BOARD_FORMBOT_TREX2 81 // Formbot version 1 -#define BOARD_FORMBOT_TREX3 82 // Formbot T-Rex 3 revision +#define BOARD_FORMBOT_TREX2PLUS 95 // Formbot version 1 +#define BOARD_FORMBOT_TREX3 96 // Formbot T-Rex 3 revision +#define BOARD_FORMBOT_RAPTOR 97 // Formbot version 1 #define BOARD_BQ_ZUM_MEGA_3D 503 // bq ZUM Mega 3D #define BOARD_MAKEBOARD_MINI 431 // MakeBoard Mini v2.1.2 is a control board sold by MicroMake #define BOARD_TRIGORILLA_13 343 // TriGorilla Anycubic version 1.3 based on RAMPS EFB diff --git a/Marlin/src/gcode/motion/M290.cpp b/Marlin/src/gcode/motion/M290.cpp index 00426ad231..965ce2d343 100644 --- a/Marlin/src/gcode/motion/M290.cpp +++ b/Marlin/src/gcode/motion/M290.cpp @@ -36,9 +36,23 @@ #if ENABLED(BABYSTEP_ZPROBE_OFFSET) FORCE_INLINE void mod_zprobe_zoffset(const float &offs) { - zprobe_zoffset += offs; - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(MSG_PROBE_Z_OFFSET ": ", zprobe_zoffset); + #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET) + if (active_extruder == 0) + { + zprobe_zoffset += offs; + SERIAL_ECHO_START(); + SERIAL_ECHOLNPAIR(MSG_PROBE_Z_OFFSET ": ", zprobe_zoffset); + } else { + hotend_offset[Z_AXIS][active_extruder] -= offs; + SERIAL_ECHO_START(); + SERIAL_ECHOLNPAIR(MSG_IDEX_Z_OFFSET ": ", hotend_offset[Z_AXIS][active_extruder]); + } + #else + zprobe_zoffset += offs; + SERIAL_ECHO_START(); + SERIAL_ECHOLNPAIR(MSG_PROBE_Z_OFFSET ": ", zprobe_zoffset); + #endif + } #endif diff --git a/Marlin/src/gcode/probe/M851.cpp b/Marlin/src/gcode/probe/M851.cpp index 36f7162371..7699b5b5de 100644 --- a/Marlin/src/gcode/probe/M851.cpp +++ b/Marlin/src/gcode/probe/M851.cpp @@ -32,7 +32,9 @@ void GcodeSuite::M851() { if (parser.seenval('Z')) { const float value = parser.value_linear_units(); if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) + { zprobe_zoffset = value; + } else { SERIAL_ERROR_START(); SERIAL_ERRORLNPGM("?Z out of range (" STRINGIFY(Z_PROBE_OFFSET_RANGE_MIN) " to " STRINGIFY(Z_PROBE_OFFSET_RANGE_MAX) ")"); diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 34dc1c8cc5..9efd47d24f 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -1317,15 +1317,35 @@ void lcd_quick_feedback(const bool clear_buttons) { const float new_zoffset = zprobe_zoffset + planner.steps_to_mm[Z_AXIS] * babystep_increment; if (WITHIN(new_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { - thermalManager.babystep_axis(Z_AXIS, babystep_increment); - zprobe_zoffset = new_zoffset; + + + #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET) + if (active_extruder == 0) + { + thermalManager.babystep_axis(Z_AXIS, babystep_increment); + zprobe_zoffset = new_zoffset; + } else { + thermalManager.babystep_axis(Z_AXIS, babystep_increment); + hotend_offset[Z_AXIS][active_extruder] -= (planner.steps_to_mm[Z_AXIS] * babystep_increment); + } + #else + zprobe_zoffset = new_zoffset; + #endif lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; } } if (lcdDrawUpdate) { - lcd_implementation_drawedit(PSTR(MSG_ZPROBE_ZOFFSET), ftostr43sign(zprobe_zoffset)); + #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET) + if (active_extruder == 0) { + lcd_implementation_drawedit(PSTR(MSG_ZPROBE_ZOFFSET), ftostr43sign(zprobe_zoffset)); + } else { + lcd_implementation_drawedit(PSTR(MSG_IDEX_Z_OFFSET), ftostr43sign(hotend_offset[Z_AXIS][active_extruder])); + } + #endif #if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY) - _lcd_zoffset_overlay_gfx(zprobe_zoffset); + if (active_extruder == 0) { + _lcd_zoffset_overlay_gfx(zprobe_zoffset); + } #endif } } diff --git a/Marlin/src/lcd/ultralcd.h b/Marlin/src/lcd/ultralcd.h index 2db4db0910..2cff09f0ed 100644 --- a/Marlin/src/lcd/ultralcd.h +++ b/Marlin/src/lcd/ultralcd.h @@ -46,6 +46,7 @@ #include "../module/motion.h" // for active_extruder #endif + void lcd_return_to_status(); bool lcd_hasstatus(); void lcd_setstatus(const char* message, const bool persist=false); void lcd_setstatusPGM(const char* message, const int8_t level=0); diff --git a/Marlin/src/module/configuration_store.cpp b/Marlin/src/module/configuration_store.cpp index 10c0b66962..ba007afd28 100644 --- a/Marlin/src/module/configuration_store.cpp +++ b/Marlin/src/module/configuration_store.cpp @@ -153,7 +153,8 @@ typedef struct SettingsDataStruct { // // HAS_BED_PROBE // - float zprobe_zoffset; // M851 Z + + float zprobe_zoffset; // // ABL_PLANAR @@ -494,12 +495,12 @@ void MarlinSettings::postprocess() { for (uint8_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_WRITE(dummy); #endif // MESH_BED_LEVELING - _FIELD_TEST(zprobe_zoffset); - #if !HAS_BED_PROBE const float zprobe_zoffset = 0; #endif - EEPROM_WRITE(zprobe_zoffset); + + _FIELD_TEST(zprobe_zoffset); + EEPROM_WRITE(zprobe_zoffset); // // Planar Bed Leveling matrix @@ -1180,12 +1181,12 @@ void MarlinSettings::postprocess() { for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy); #endif // MESH_BED_LEVELING - _FIELD_TEST(zprobe_zoffset); - #if !HAS_BED_PROBE float zprobe_zoffset; #endif - EEPROM_READ(zprobe_zoffset); + + _FIELD_TEST(zprobe_zoffset); + EEPROM_READ(zprobe_zoffset); // // Planar Bed Leveling matrix diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index caab4f73ab..a08482166a 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1502,15 +1502,15 @@ void homeaxis(const AxisEnum axis) { soft_endstop_max[X_AXIS] = dual_max_x; } else if (dxc_is_duplicating()) { - // In Duplication Mode, T0 can move as far left as X_MIN_POS + // In Duplication Mode, T0 can move as far left as X1_MIN_POS // but not so far to the right that T1 would move past the end - soft_endstop_min[X_AXIS] = base_min_pos(X_AXIS); - soft_endstop_max[X_AXIS] = MIN(base_max_pos(X_AXIS), dual_max_x - duplicate_extruder_x_offset); + soft_endstop_min[X_AXIS] = X1_MIN_POS; + soft_endstop_max[X_AXIS] = MIN(X1_MAX_POS, dual_max_x - duplicate_extruder_x_offset); } else { - // In other modes, T0 can move from X_MIN_POS to X_MAX_POS - soft_endstop_min[axis] = base_min_pos(axis); - soft_endstop_max[axis] = base_max_pos(axis); + // In other modes, T0 can move from X1_MIN_POS to X1_MAX_POS + soft_endstop_min[X_AXIS] = X1_MIN_POS; + soft_endstop_max[X_AXIS] = X1_MAX_POS; } } #elif ENABLED(DELTA) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 3b66da2217..2b840491c8 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -22,13 +22,12 @@ #include "tool_change.h" +#include "probe.h" #include "motion.h" #include "planner.h" #include "../Marlin.h" -#include "../inc/MarlinConfig.h" - #if ENABLED(PARKING_EXTRUDER) && PARKING_EXTRUDER_SOLENOIDS_DELAY > 0 #include "../gcode/gcode.h" // for dwell() #endif @@ -57,6 +56,10 @@ #include "../feature/fanmux.h" #endif +#if ENABLED(ULTIPANEL) + #include "../lcd/ultralcd.h" +#endif + #if DO_SWITCH_EXTRUDER #if EXTRUDERS > 3 @@ -498,11 +501,24 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n active_extruder = tmp_extruder; update_software_endstops(X_AXIS); active_extruder = !tmp_extruder; + + // Don't move the new extruder out of bounds + if (!WITHIN(current_position[X_AXIS], soft_endstop_min[X_AXIS], soft_endstop_max[X_AXIS])) + no_move = true; + + #else + // No software endstops? Use the configured limits + if (active_extruder == 0) { + if (!WITHIN(current_position[X_AXIS], X2_MIN_POS, X2_MAX_POS)) + no_move = true; + } + else if (!WITHIN(current_position[X_AXIS], X1_MIN_POS, X1_MAX_POS)) + no_move = true; #endif - // Don't move the new extruder out of bounds - if (!WITHIN(current_position[X_AXIS], soft_endstop_min[X_AXIS], soft_endstop_max[X_AXIS])) - no_move = true; + #if ENABLED(ULTIPANEL) + lcd_return_to_status(); + #endif if (!no_move) set_destination_from_current(); dualx_tool_change(tmp_extruder, no_move); // Can modify no_move @@ -569,6 +585,13 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("Move back", destination); #endif + #if ENABLED(DUAL_X_CARRIAGE) + // Dual x carriage does not properly apply these to current position due to command ordering + // So we apply the offsets for y and z to the destination here. X cannot have an offset in this mode + // as it is utilized for X2 home position. + destination[Y_AXIS] -= hotend_offset[Y_AXIS][active_extruder] - hotend_offset[Y_AXIS][tmp_extruder]; + destination[Z_AXIS] -= hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder]; + #endif // Move back to the original (or tweaked) position do_blocking_move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS]); #if ENABLED(DUAL_X_CARRIAGE) diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 03d336baa5..26d828ef53 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -132,8 +132,10 @@ #include "pins_AZTEEG_X3_PRO.h" // ATmega2560 env:megaatmega2560 #elif MB(ULTIMAIN_2) #include "pins_ULTIMAIN_2.h" // ATmega2560 env:megaatmega2560 -#elif MB(FORMBOT_TREX2) - #include "pins_FORMBOT_TREX2.h" // ATmega2560 env:megaatmega2560 +#elif MB(FORMBOT_RAPTOR) + #include "pins_FORMBOT_RAPTOR.h" // ATmega2560 env:megaatmega2560 +#elif MB(FORMBOT_TREX2PLUS) + #include "pins_FORMBOT_TREX2PLUS.h" // ATmega2560 env:megaatmega2560 #elif MB(FORMBOT_TREX3) #include "pins_FORMBOT_TREX3.h" // ATmega2560 env:megaatmega2560 #elif MB(RUMBA) diff --git a/Marlin/src/pins/pins_FORMBOT_RAPTOR.h b/Marlin/src/pins/pins_FORMBOT_RAPTOR.h new file mode 100644 index 0000000000..28c92394ad --- /dev/null +++ b/Marlin/src/pins/pins_FORMBOT_RAPTOR.h @@ -0,0 +1,184 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * Formbot pin assignments + */ + +#ifndef __AVR_ATmega2560__ + #error "Oops! Make sure you have 'Arduino Mega' selected from the 'Tools -> Boards' menu." +#endif + +#if E_STEPPERS > 3 || HOTENDS > 3 + #error "Formbot supports up to 3 hotends / E-steppers. Comment this line to keep going." +#endif + +#define DEFAULT_MACHINE_NAME "Formbot Raptor" +#define BOARD_NAME "Formbot Raptor" + +// +// Servos +// +#define SERVO0_PIN 11 +#define SERVO1_PIN 6 +#define SERVO2_PIN 5 +#define SERVO3_PIN -1 + +// +// Limit Switches +// +#define X_MIN_PIN 3 +#ifndef X_MAX_PIN + #define X_MAX_PIN 2 +#endif +#define Y_MIN_PIN 14 +#define Y_MAX_PIN 15 +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 32 +#endif + +// +// Steppers +// +#define X_STEP_PIN 54 +#define X_DIR_PIN 55 +#define X_ENABLE_PIN 38 +#ifndef X_CS_PIN + #define X_CS_PIN 53 +#endif + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 +#ifndef Y_CS_PIN + #define Y_CS_PIN 49 +#endif + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 62 +#ifndef Z_CS_PIN + #define Z_CS_PIN 40 +#endif + +#define E0_STEP_PIN 26 +#define E0_DIR_PIN 28 +#define E0_ENABLE_PIN 24 +#ifndef E0_CS_PIN + #define E0_CS_PIN 42 +#endif + +#define E1_STEP_PIN 36 +#define E1_DIR_PIN 34 +#define E1_ENABLE_PIN 30 +#ifndef E1_CS_PIN + #define E1_CS_PIN 44 +#endif + +#define E2_STEP_PIN 42 +#define E2_DIR_PIN 43 +#define E2_ENABLE_PIN 44 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 13 // Analog Input +#define TEMP_1_PIN 15 // Analog Input +#define TEMP_BED_PIN 14 // Analog Input + +// SPI for Max6675 or Max31855 Thermocouple +#if DISABLED(SDSUPPORT) + #define MAX6675_SS 66 // Do not use pin 53 if there is even the remote possibility of using Display/SD card +#else + #define MAX6675_SS 66 // Do not use pin 49 as this is tied to the switch inside the SD card socket to detect if there is an SD card present +#endif + +// +// Augmentation for auto-assigning RAMPS plugs +// +#if DISABLED(IS_RAMPS_EEB) && DISABLED(IS_RAMPS_EEF) && DISABLED(IS_RAMPS_EFB) && DISABLED(IS_RAMPS_EFF) && DISABLED(IS_RAMPS_SF) && !PIN_EXISTS(MOSFET_D) + #if HOTENDS > 1 + #if TEMP_SENSOR_BED + #define IS_RAMPS_EEB + #else + #define IS_RAMPS_EEF + #endif + #elif TEMP_SENSOR_BED + #define IS_RAMPS_EFB + #else + #define IS_RAMPS_EFF + #endif +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN 10 +#define HEATER_1_PIN 7 +#define HEATER_BED_PIN 8 + +#define LED4_PIN 5 + +#define FAN_PIN 9 + +#if DISABLED(FILAMENT_RUNOUT_SENSOR) + #define FAN1_PIN 4 +#endif + +// +// Misc. Functions +// +#define SDSS 53 +#define LED_PIN 13 + +// Use the RAMPS 1.4 Analog input 5 on the AUX2 connector +#define FILWIDTH_PIN 5 // Analog Input + +#ifndef PS_ON_PIN + #define PS_ON_PIN 12 +#endif + +// +// LCD / Controller +// +// Formbot only supports REPRAP_DISCOUNT_SMART_CONTROLLER +// +#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) + #define LCD_PINS_RS 16 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 23 + #define LCD_PINS_D5 25 + #define LCD_PINS_D6 27 + #define LCD_PINS_D7 29 + #define BEEPER_PIN 37 + #define BTN_EN1 31 + #define BTN_EN2 33 + #define BTN_ENC 35 + #define SD_DETECT_PIN 49 + #define KILL_PIN 41 +#endif diff --git a/Marlin/src/pins/pins_FORMBOT_TREX2.h b/Marlin/src/pins/pins_FORMBOT_TREX2PLUS.h similarity index 93% rename from Marlin/src/pins/pins_FORMBOT_TREX2.h rename to Marlin/src/pins/pins_FORMBOT_TREX2PLUS.h index f98bb37a13..1b7502e15b 100644 --- a/Marlin/src/pins/pins_FORMBOT_TREX2.h +++ b/Marlin/src/pins/pins_FORMBOT_TREX2PLUS.h @@ -143,15 +143,15 @@ #define HEATER_BED_PIN 58 #define FAN_PIN 9 -//#define FAN1_PIN 4 - +#if(DISABLED(FILAMENT_RUNOUT_SENSOR)) + // Though defined as a fan pin, it is utilized as a dedicated laser pin by Formbot. May + // swapped plug and play with a fil;ament runout sensor. + #define FAN1_PIN 4 +#endif -#if DISABLED(ICSP_PORT_SWITCHES) - //#define FIL_RUNOUT_PIN 22 - //#define FIL_RUNOUT2_PIN 21 -#elif ENABLED(FILAMENT_RUNOUT_SENSOR) - #define FIL_RUNOUT_PIN 52 - #define FIL_RUNOUT2_PIN 50 +#if ENABLED(FILAMENT_RUNOUT_SENSOR) + #define FIL_RUNOUT_PIN 4 + //#define FIL_RUNOUT2_PIN -1 #endif //