From 2065591daf1396040a50727939377e57639128a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Br=C3=A1zio?= Date: Thu, 6 Jul 2017 18:10:06 +0100 Subject: [PATCH] Add support for BQ heated bed kit with Hephestos 2 --- Marlin/Conditionals_post.h | 12 ++- Marlin/Marlin_main.cpp | 18 ++-- .../Hephestos_2/Configuration.h | 82 ++++++++++--------- .../Hephestos_2/Configuration_adv.h | 12 +-- .../Hephestos_2/README.md | 7 ++ Marlin/pins_BQ_ZUM_MEGA_3D.h | 9 ++ Marlin/temperature.cpp | 24 +++--- Marlin/ultralcd_impl_DOGM.h | 21 +++-- 8 files changed, 115 insertions(+), 70 deletions(-) diff --git a/Marlin/Conditionals_post.h b/Marlin/Conditionals_post.h index 4f7272f938..ba7a862ea5 100644 --- a/Marlin/Conditionals_post.h +++ b/Marlin/Conditionals_post.h @@ -616,8 +616,18 @@ #else #define WRITE_HEATER_0(v) WRITE_HEATER_0P(v) #endif + + /** + * Heated bed requires settings + */ #if HAS_HEATER_BED - #define WRITE_HEATER_BED(v) WRITE(HEATER_BED_PIN, v) + #ifndef MAX_BED_POWER + #define MAX_BED_POWER 255 + #endif + #ifndef HEATER_BED_INVERTING + #define HEATER_BED_INVERTING false + #endif + #define WRITE_HEATER_BED(v) WRITE(HEATER_BED_PIN, (v) ^ HEATER_BED_INVERTING) #endif /** diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index c224d17749..26775212a9 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2312,10 +2312,10 @@ static void clean_up_after_endstop_or_probe_move() { const float nx = lx - (X_PROBE_OFFSET_FROM_EXTRUDER), ny = ly - (Y_PROBE_OFFSET_FROM_EXTRUDER); - if (printable) + if (printable) { if (!position_is_reachable_by_probe_xy(lx, ly)) return NAN; - else - if (!position_is_reachable_xy(nx, ny)) return NAN; + } + else if (!position_is_reachable_xy(nx, ny)) return NAN; const float old_feedrate_mm_s = feedrate_mm_s; @@ -4308,7 +4308,7 @@ void home_all_axes() { gcode_G28(true); } #endif ABL_VAR int left_probe_bed_position, right_probe_bed_position, front_probe_bed_position, back_probe_bed_position; - ABL_VAR float xGridSpacing, yGridSpacing; + ABL_VAR float xGridSpacing = 0, yGridSpacing = 0; #if ENABLED(AUTO_BED_LEVELING_LINEAR) ABL_VAR uint8_t abl_grid_points_x = GRID_MAX_POINTS_X, @@ -7081,6 +7081,10 @@ inline void gcode_M104() { #endif const int8_t e=-2 ) { + #if !(HAS_TEMP_BED && HAS_TEMP_HOTEND) && HOTENDS <= 1 + UNUSED(e); + #endif + SERIAL_PROTOCOLCHAR(' '); SERIAL_PROTOCOLCHAR( #if HAS_TEMP_BED && HAS_TEMP_HOTEND @@ -12735,13 +12739,13 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { #if ENABLED(EXTRUDER_RUNOUT_PREVENT) if (ELAPSED(ms, previous_cmd_ms + (EXTRUDER_RUNOUT_SECONDS) * 1000UL) && thermalManager.degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP) { - bool oldstatus; #if ENABLED(SWITCHING_EXTRUDER) - oldstatus = E0_ENABLE_READ; + const bool oldstatus = E0_ENABLE_READ; enable_E0(); #else // !SWITCHING_EXTRUDER + bool oldstatus; switch (active_extruder) { - case 0: oldstatus = E0_ENABLE_READ; enable_E0(); break; + default: oldstatus = E0_ENABLE_READ; enable_E0(); break; #if E_STEPPERS > 1 case 1: oldstatus = E1_ENABLE_READ; enable_E1(); break; #if E_STEPPERS > 2 diff --git a/Marlin/example_configurations/Hephestos_2/Configuration.h b/Marlin/example_configurations/Hephestos_2/Configuration.h index 805ee35ec6..33d6096545 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration.h @@ -20,24 +20,23 @@ * */ +#ifndef CONFIGURATION_H +#define CONFIGURATION_H +#define CONFIGURATION_H_VERSION 010100 + +//=========================================================================== +//================================= README ================================== +//=========================================================================== + /** - * Configuration.h - * - * Basic settings such as: - * - * - Type of electronics - * - Type of temperature sensor - * - Printer geometry - * - Endstop configuration - * - LCD controller - * - Extra features + * BQ Hephestos 2 Configuration * - * Advanced settings can be found in Configuration_adv.h + * This configuration supports the standard Hephestos 2 with or without the + * heated bed kit featured at https://store.bq.com/en/heated-bed-kit-hephestos2 * + * Enable the following option to activate all functionality related to the heated bed. */ -#ifndef CONFIGURATION_H -#define CONFIGURATION_H -#define CONFIGURATION_H_VERSION 010100 +//#define HEPHESTOS2_HEATED_BED_KIT //=========================================================================== //============================= Getting Started ============================= @@ -269,7 +268,13 @@ #define TEMP_SENSOR_2 0 #define TEMP_SENSOR_3 0 #define TEMP_SENSOR_4 0 -#define TEMP_SENSOR_BED 0 + +#if ENABLED(HEPHESTOS2_HEATED_BED_KIT) + #define TEMP_SENSOR_BED 70 + #define HEATER_BED_INVERTING true +#else + #define TEMP_SENSOR_BED 0 +#endif // Dummy thermistor constant temperature readings, for use with 998 and 999 #define DUMMY_THERMISTOR_998_VALUE 25 @@ -293,7 +298,7 @@ // The minimal temperature defines the temperature below which the heater will not be enabled It is used // to check that the wiring to the thermistor is not broken. // Otherwise this would lead to the heater being powered on all the time. -#define HEATER_0_MINTEMP 15 +#define HEATER_0_MINTEMP 5 #define HEATER_1_MINTEMP 5 #define HEATER_2_MINTEMP 5 #define HEATER_3_MINTEMP 5 @@ -303,12 +308,12 @@ // When temperature exceeds max temp, your heater will be switched off. // This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure! // You should use MINTEMP for thermistor short/failure protection. -#define HEATER_0_MAXTEMP 250 +#define HEATER_0_MAXTEMP 275 #define HEATER_1_MAXTEMP 275 #define HEATER_2_MAXTEMP 275 #define HEATER_3_MAXTEMP 275 #define HEATER_4_MAXTEMP 275 -#define BED_MAXTEMP 150 +#define BED_MAXTEMP 110 //=========================================================================== //============================= PID Settings ================================ @@ -362,7 +367,10 @@ // all forms of bed control obey this (PID, bang-bang, bang-bang with hysteresis) // setting this to anything other than 255 enables a form of PWM to the bed just like HEATER_BED_DUTY_CYCLE_DIVIDER did, // so you shouldn't use it unless you are OK with PWM on your bed. (see the comment on enabling PIDTEMPBED) -//#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current + +#if ENABLED(HEPHESTOS2_HEATED_BED_KIT) + #define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current +#endif #if ENABLED(PIDTEMPBED) @@ -414,7 +422,7 @@ */ #define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders -//#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed +#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed //=========================================================================== //============================= Mechanical Settings ========================= @@ -499,14 +507,14 @@ * Override with M92 * X, Y, Z, E0 [, E1[, E2[, E3[, E4]]]] */ -#define DEFAULT_AXIS_STEPS_PER_UNIT { 160, 160, 8000, 204 } +#define DEFAULT_AXIS_STEPS_PER_UNIT { 160, 160, 8000, 210.02 } /** * Default Max Feed Rate (mm/s) * Override with M203 * X, Y, Z, E0 [, E1[, E2[, E3[, E4]]]] */ -#define DEFAULT_MAX_FEEDRATE { 250, 250, 2, 200 } +#define DEFAULT_MAX_FEEDRATE { 167, 167, 3.3, 167 } /** * Default Max Acceleration (change/s) change = mm/s @@ -514,7 +522,7 @@ * Override with M201 * X, Y, Z, E0 [, E1[, E2[, E3[, E4]]]] */ -#define DEFAULT_MAX_ACCELERATION { 800, 800, 20, 1000 } +#define DEFAULT_MAX_ACCELERATION { 1000, 1000, 100, 3000 } /** * Default Acceleration (change/s) change = mm/s @@ -524,8 +532,8 @@ * M204 R Retract Acceleration * M204 T Travel Acceleration */ -#define DEFAULT_ACCELERATION 800 // X, Y, Z and E acceleration for printing moves -#define DEFAULT_RETRACT_ACCELERATION 1000 // E acceleration for retracts +#define DEFAULT_ACCELERATION 1000 // X, Y, Z and E acceleration for printing moves +#define DEFAULT_RETRACT_ACCELERATION 3000 // E acceleration for retracts #define DEFAULT_TRAVEL_ACCELERATION 1000 // X, Y, Z acceleration for travel (non printing) moves /** @@ -536,8 +544,8 @@ * When changing speed and direction, if the difference is less than the * value set here, it may happen instantaneously. */ -#define DEFAULT_XJERK 10.0 -#define DEFAULT_YJERK 10.0 +#define DEFAULT_XJERK 20.0 +#define DEFAULT_YJERK 20.0 #define DEFAULT_ZJERK 0.4 #define DEFAULT_EJERK 1.0 @@ -654,7 +662,7 @@ */ #define X_PROBE_OFFSET_FROM_EXTRUDER 34 // X offset: -left +right [of the nozzle] #define Y_PROBE_OFFSET_FROM_EXTRUDER 15 // Y offset: -front +behind [the nozzle] -#define Z_PROBE_OFFSET_FROM_EXTRUDER 0 // Z offset: -below +above [the nozzle] +#define Z_PROBE_OFFSET_FROM_EXTRUDER 0 // Z offset: -below +above [the nozzle] // X and Y axis travel speed (mm/m) between probes #define XY_PROBE_SPEED 8000 @@ -690,7 +698,7 @@ #define Z_PROBE_OFFSET_RANGE_MAX 0 // Enable the M48 repeatability test to test probe accuracy -//#define Z_MIN_PROBE_REPEATABILITY_TEST +#define Z_MIN_PROBE_REPEATABILITY_TEST // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1 // :{ 0:'Low', 1:'High' } @@ -817,7 +825,7 @@ */ //#define AUTO_BED_LEVELING_3POINT //#define AUTO_BED_LEVELING_LINEAR -//#define AUTO_BED_LEVELING_BILINEAR +#define AUTO_BED_LEVELING_BILINEAR //#define AUTO_BED_LEVELING_UBL //#define MESH_BED_LEVELING @@ -839,12 +847,12 @@ // Set the number of grid points per dimension. #define GRID_MAX_POINTS_X 3 - #define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X + #define GRID_MAX_POINTS_Y 4 // Set the boundaries for probing (where the probe can reach). - #define LEFT_PROBE_BED_POSITION X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER + #define LEFT_PROBE_BED_POSITION X_MIN_POS + (X_PROBE_OFFSET_FROM_EXTRUDER) #define RIGHT_PROBE_BED_POSITION X_MAX_POS - (X_PROBE_OFFSET_FROM_EXTRUDER) - #define FRONT_PROBE_BED_POSITION Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER + #define FRONT_PROBE_BED_POSITION Y_MIN_POS + (Y_PROBE_OFFSET_FROM_EXTRUDER) #define BACK_PROBE_BED_POSITION Y_MAX_POS - (Y_PROBE_OFFSET_FROM_EXTRUDER) // The Z probe minimum outer margin (to validate G29 parameters). @@ -1011,12 +1019,12 @@ // @section temperature // Preheat Constants -#define PREHEAT_1_TEMP_HOTEND 210 -#define PREHEAT_1_TEMP_BED 70 +#define PREHEAT_1_TEMP_HOTEND 205 +#define PREHEAT_1_TEMP_BED 50 #define PREHEAT_1_FAN_SPEED 0 // Value from 0 to 255 -#define PREHEAT_2_TEMP_HOTEND 240 -#define PREHEAT_2_TEMP_BED 110 +#define PREHEAT_2_TEMP_HOTEND 245 +#define PREHEAT_2_TEMP_BED 50 #define PREHEAT_2_FAN_SPEED 0 // Value from 0 to 255 /** diff --git a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h index 8ee2095aae..7748bbf3ce 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h @@ -161,8 +161,8 @@ // then extrude some filament every couple of SECONDS. #define EXTRUDER_RUNOUT_PREVENT #if ENABLED(EXTRUDER_RUNOUT_PREVENT) - #define EXTRUDER_RUNOUT_MINTEMP 190 - #define EXTRUDER_RUNOUT_SECONDS 30 + #define EXTRUDER_RUNOUT_MINTEMP 170 + #define EXTRUDER_RUNOUT_SECONDS 60 #define EXTRUDER_RUNOUT_SPEED 1500 // mm/m #define EXTRUDER_RUNOUT_EXTRUDE 5 // mm #endif @@ -369,7 +369,7 @@ #define DEFAULT_MINIMUMFEEDRATE 0.0 // minimum feedrate #define DEFAULT_MINTRAVELFEEDRATE 0.0 -//#define HOME_AFTER_DEACTIVATE // Require rehoming after steppers are deactivated +#define HOME_AFTER_DEACTIVATE // Require rehoming after steppers are deactivated // @section lcd @@ -447,7 +447,7 @@ #define LCD_INFO_MENU // Scroll a longer status message into view -//#define STATUS_MESSAGE_SCROLLING +#define STATUS_MESSAGE_SCROLLING // On the Info Screen, display XY with one decimal place when possible #define LCD_DECIMAL_SMALL_XY @@ -720,7 +720,7 @@ // enter the serial receive buffer, so they cannot be blocked. // Currently handles M108, M112, M410 // Does not work on boards using AT90USB (USBCON) processors! -//#define EMERGENCY_PARSER +#define EMERGENCY_PARSER // Bad Serial-connections can miss a received command by sending an 'ok' // Therefore some clients abort after 30 seconds in a timeout. @@ -729,7 +729,7 @@ //#define NO_TIMEOUTS 1000 // Milliseconds // Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. -//#define ADVANCED_OK +#define ADVANCED_OK // @section fwretract diff --git a/Marlin/example_configurations/Hephestos_2/README.md b/Marlin/example_configurations/Hephestos_2/README.md index d51f222769..cbe9965eed 100644 --- a/Marlin/example_configurations/Hephestos_2/README.md +++ b/Marlin/example_configurations/Hephestos_2/README.md @@ -5,11 +5,18 @@ NOTE: The look and feel of the Hephestos 2 while navigating the LCD menu will ch ## Changelog * 2016/03/01 - Initial release + * 2016/03/21 - Activated 4-point auto leveling by default Updated miscellaneous z-probe values + * 2016/06/21 - Disabled hot bed related options Activated software endstops SD printing now disables the heater when finished + * 2016/07/13 - Update the `DEFAULT_AXIS_STEPS_PER_UNIT` for the Z axis Increased the `DEFAULT_XYJERK` + * 2016/12/13 - Configuration updated. + + * 2017/07/06 - Configuration updated to the latest Marlin version. + Added support for the official BQ heated bed kit. diff --git a/Marlin/pins_BQ_ZUM_MEGA_3D.h b/Marlin/pins_BQ_ZUM_MEGA_3D.h index 84722f11c9..f20f9b54d9 100644 --- a/Marlin/pins_BQ_ZUM_MEGA_3D.h +++ b/Marlin/pins_BQ_ZUM_MEGA_3D.h @@ -107,3 +107,12 @@ #define Z_MIN_PIN 19 // IND_S_5V #define Z_MAX_PIN 18 // Z-MIN Label #endif + + +// +// This pin is used by the official Hephestos 2 heated bed upgrade kit +// +#if ENABLED(HEPHESTOS2_HEATED_BED_KIT) + #undef HEATER_BED_PIN + #define HEATER_BED_PIN 8 +#endif diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index a4fdcf985c..deaa79ce88 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -1721,33 +1721,33 @@ void Temperature::isr() { #endif } else { - if (soft_pwm_count_0 <= pwm_count_tmp) WRITE_HEATER_0(0); + if (soft_pwm_count_0 <= pwm_count_tmp) WRITE_HEATER_0(LOW); #if HOTENDS > 1 - if (soft_pwm_count_1 <= pwm_count_tmp) WRITE_HEATER_1(0); + if (soft_pwm_count_1 <= pwm_count_tmp) WRITE_HEATER_1(LOW); #if HOTENDS > 2 - if (soft_pwm_count_2 <= pwm_count_tmp) WRITE_HEATER_2(0); + if (soft_pwm_count_2 <= pwm_count_tmp) WRITE_HEATER_2(LOW); #if HOTENDS > 3 - if (soft_pwm_count_3 <= pwm_count_tmp) WRITE_HEATER_3(0); + if (soft_pwm_count_3 <= pwm_count_tmp) WRITE_HEATER_3(LOW); #if HOTENDS > 4 - if (soft_pwm_count_4 <= pwm_count_tmp) WRITE_HEATER_4(0); + if (soft_pwm_count_4 <= pwm_count_tmp) WRITE_HEATER_4(LOW); #endif // HOTENDS > 4 #endif // HOTENDS > 3 #endif // HOTENDS > 2 #endif // HOTENDS > 1 #if HAS_HEATER_BED - if (soft_pwm_count_BED <= pwm_count_tmp) WRITE_HEATER_BED(0); + if (soft_pwm_count_BED <= pwm_count_tmp) WRITE_HEATER_BED(LOW); #endif #if ENABLED(FAN_SOFT_PWM) #if HAS_FAN0 - if (soft_pwm_count_fan[0] <= pwm_count_tmp) WRITE_FAN(0); + if (soft_pwm_count_fan[0] <= pwm_count_tmp) WRITE_FAN(LOW); #endif #if HAS_FAN1 - if (soft_pwm_count_fan[1] <= pwm_count_tmp) WRITE_FAN1(0); + if (soft_pwm_count_fan[1] <= pwm_count_tmp) WRITE_FAN1(LOW); #endif #if HAS_FAN2 - if (soft_pwm_count_fan[2] <= pwm_count_tmp) WRITE_FAN2(0); + if (soft_pwm_count_fan[2] <= pwm_count_tmp) WRITE_FAN2(LOW); #endif #endif } @@ -1856,13 +1856,13 @@ void Temperature::isr() { #endif } #if HAS_FAN0 - if (soft_pwm_count_fan[0] <= pwm_count_tmp) WRITE_FAN(0); + if (soft_pwm_count_fan[0] <= pwm_count_tmp) WRITE_FAN(LOW); #endif #if HAS_FAN1 - if (soft_pwm_count_fan[1] <= pwm_count_tmp) WRITE_FAN1(0); + if (soft_pwm_count_fan[1] <= pwm_count_tmp) WRITE_FAN1(LOW); #endif #if HAS_FAN2 - if (soft_pwm_count_fan[2] <= pwm_count_tmp) WRITE_FAN2(0); + if (soft_pwm_count_fan[2] <= pwm_count_tmp) WRITE_FAN2(LOW); #endif #endif // FAN_SOFT_PWM diff --git a/Marlin/ultralcd_impl_DOGM.h b/Marlin/ultralcd_impl_DOGM.h index a11c9afeb7..28848cdebe 100644 --- a/Marlin/ultralcd_impl_DOGM.h +++ b/Marlin/ultralcd_impl_DOGM.h @@ -369,20 +369,24 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t x, const } FORCE_INLINE void _draw_heater_status(const uint8_t x, const int8_t heater, const bool blink) { + #if !HEATER_IDLE_HANDLER + UNUSED(blink); + #endif + #if HAS_TEMP_BED - bool isBed = heater < 0; + const bool isBed = heater < 0; #else - const bool isBed = false; + constexpr bool isBed = false; #endif if (PAGE_UNDER(7)) { #if HEATER_IDLE_HANDLER const bool is_idle = (!isBed ? thermalManager.is_heater_idle(heater) : - #if HAS_TEMP_BED - thermalManager.is_bed_idle() - #else - false - #endif + #if HAS_TEMP_BED + thermalManager.is_bed_idle() + #else + false + #endif ); if (blink || !is_idle) @@ -852,12 +856,15 @@ static void lcd_implementation_status_screen() { #define DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(_type, _name, _strFunc) \ inline void lcd_implementation_drawmenu_setting_edit_ ## _name (const bool sel, const uint8_t row, const char* pstr, const char* pstr2, _type * const data, ...) { \ + UNUSED(pstr2); \ lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, _strFunc(*(data))); \ } \ inline void lcd_implementation_drawmenu_setting_edit_callback_ ## _name (const bool sel, const uint8_t row, const char* pstr, const char* pstr2, _type * const data, ...) { \ + UNUSED(pstr2); \ lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, _strFunc(*(data))); \ } \ inline void lcd_implementation_drawmenu_setting_edit_accessor_ ## _name (const bool sel, const uint8_t row, const char* pstr, const char* pstr2, _type (*pget)(), void (*pset)(_type), ...) { \ + UNUSED(pstr2); UNUSED(pset); \ lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, _strFunc(pget())); \ } \ typedef void _name##_void