From 83a9f75abe092cb0afb57045d2d03eb553dc38bd Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Wed, 28 Nov 2018 23:43:16 +0100 Subject: [PATCH 01/40] minTemp correct minTemp detection @ MK2.5 & MK3 --- Firmware/temperature.cpp | 90 +++++++++++-------- .../variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h | 6 +- .../variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h | 6 +- .../variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 2 + 4 files changed, 64 insertions(+), 40 deletions(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index cae3fada7..5ba4824d7 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -41,6 +41,9 @@ #include "adc.h" #include "ConfigurationStore.h" +#include "Timer.h" +#include "Configuration_prusa.h" + //=========================================================================== //=============================public variables============================ @@ -152,6 +155,8 @@ static volatile bool temp_meas_ready = false; # define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1 } #endif +static ShortTimer oTimer4minTempHeater,oTimer4minTempBed; + // Init min and max temp with extreme values to prevent false errors during startup static int minttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP ); static int maxttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP ); @@ -596,6 +601,9 @@ void manage_heater() updateTemperaturesFromRawValues(); + check_max_temp(); + check_min_temp(); + #ifdef TEMP_RUNAWAY_BED_HYSTERESIS temp_runaway_check(0, target_temperature_bed, current_temperature_bed, (int)soft_pwm_bed, true); #endif @@ -669,11 +677,7 @@ void manage_heater() #endif // Check if temperature is within the correct range -#ifdef AMBIENT_THERMISTOR - if(((current_temperature_ambient < MINTEMP_MINAMBIENT) || (current_temperature[e] > minttemp[e])) && (current_temperature[e] < maxttemp[e])) -#else //AMBIENT_THERMISTOR - if((current_temperature[e] > minttemp[e]) && (current_temperature[e] < maxttemp[e])) -#endif //AMBIENT_THERMISTOR + if(current_temperature[e] < maxttemp[e]) { soft_pwm[e] = (int)pid_output >> 1; } @@ -763,11 +767,7 @@ void manage_heater() pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER); #endif //PID_OPENLOOP -#ifdef AMBIENT_THERMISTOR - if(((current_temperature_bed > BED_MINTEMP) || (current_temperature_ambient < MINTEMP_MINAMBIENT)) && (current_temperature_bed < BED_MAXTEMP)) -#else //AMBIENT_THERMISTOR - if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) -#endif //AMBIENT_THERMISTOR + if(current_temperature_bed < BED_MAXTEMP) { soft_pwm_bed = (int)pid_output >> 1; } @@ -777,7 +777,7 @@ void manage_heater() #elif !defined(BED_LIMIT_SWITCHING) // Check if temperature is within the correct range - if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) + if(current_temperature_bed < BED_MAXTEMP) { if(current_temperature_bed >= target_temperature_bed) { @@ -795,7 +795,7 @@ void manage_heater() } #else //#ifdef BED_LIMIT_SWITCHING // Check if temperature is within the correct band - if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) + if(current_temperature_bed < BED_MAXTEMP) { if(current_temperature_bed > target_temperature_bed + BED_HYSTERESIS) { @@ -1526,7 +1526,7 @@ void adc_ready(void) //callback from adc when sampling finished // Timer 0 is shared with millies -ISR(TIMER0_COMPB_vect) +ISR(TIMER0_COMPB_vect) // @ 1kHz ~ 1ms { static bool _lock = false; if (_lock) return; @@ -1534,11 +1534,6 @@ ISR(TIMER0_COMPB_vect) asm("sei"); if (!temp_meas_ready) adc_cycle(); - else - { - check_max_temp(); - check_min_temp(); - } lcd_buttons_update(); static unsigned char pwm_count = (1 << SOFT_PWM_SCALE); @@ -1931,26 +1926,49 @@ void check_min_temp_bed() void check_min_temp() { +static bool bCheckingOnHeater=false; // state variable, which allows to short no-checking delay (is set, when temperature is (first time) over heaterMintemp) +static bool bCheckingOnBed=false; // state variable, which allows to short no-checking delay (is set, when temperature is (first time) over bedMintemp) #ifdef AMBIENT_THERMISTOR - static uint8_t heat_cycles = 0; - if (current_temperature_raw_ambient > OVERSAMPLENR*MINTEMP_MINAMBIENT_RAW) - { - if (READ(HEATER_0_PIN) == HIGH) - { -// if ((heat_cycles % 10) == 0) -// printf_P(PSTR("X%d\n"), heat_cycles); - if (heat_cycles > 50) //reaction time 5-10s - check_min_temp_heater0(); - else - heat_cycles++; - } - else - heat_cycles = 0; - return; - } +if(current_temperature_raw_ambient>(OVERSAMPLENR*MINTEMP_MINAMBIENT_RAW)) // thermistor is NTC type, so operator is ">" ;-) + { // ambient temperature is low +#endif //AMBIENT_THERMISTOR +// *** 'common' part of code for MK2.5 & MK3 +// * nozzle checking +if(target_temperature[active_extruder]>minttemp[active_extruder]) + { // ~ nozzle heating is on + bCheckingOnHeater=bCheckingOnHeater||(current_temperature[active_extruder]>=minttemp[active_extruder]); // for eventually delay cutting + if(oTimer4minTempHeater.expired(HEATER_MINTEMP_DELAY)||(!oTimer4minTempHeater.running())||bCheckingOnHeater) + { + bCheckingOnHeater=true; // not necessary + check_min_temp_heater0(); // delay is elapsed or temperature is/was over minTemp => periodical checking is active + } + } +else { // ~ nozzle heating is off + oTimer4minTempHeater.start(); + bCheckingOnHeater=false; + } +// * bed checking +if(target_temperature_bed>BED_MINTEMP) + { // ~ bed heating is on + bCheckingOnBed=bCheckingOnBed||(current_temperature_bed>=BED_MINTEMP); // for eventually delay cutting + if(oTimer4minTempBed.expired(BED_MINTEMP_DELAY)||(!oTimer4minTempBed.running())||bCheckingOnBed) + { + bCheckingOnBed=true; // not necessary + check_min_temp_bed(); // delay is elapsed or temperature is/was over minTemp => periodical checking is active + } + } +else { // ~ bed heating is off + oTimer4minTempBed.start(); + bCheckingOnBed=false; + } +// *** end of 'common' part +#ifdef AMBIENT_THERMISTOR + } +else { // ambient temperature is standard + check_min_temp_heater0(); + check_min_temp_bed(); + } #endif //AMBIENT_THERMISTOR - check_min_temp_heater0(); - check_min_temp_bed(); } #if (defined(FANCHECK) && defined(TACH_0) && (TACH_0 > -1)) diff --git a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h index f3a5285dd..826204445 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h @@ -153,10 +153,12 @@ *------------------------------------*/ // Mintemps -#define HEATER_0_MINTEMP 15 +#define HEATER_0_MINTEMP 30 #define HEATER_1_MINTEMP 5 #define HEATER_2_MINTEMP 5 -#define BED_MINTEMP 15 +#define HEATER_MINTEMP_DELAY 15000 // [ms] ! if changed, check maximal allowed value @ ShortTimer +#define BED_MINTEMP 30 +#define BED_MINTEMP_DELAY 50000 // [ms] ! if changed, check maximal allowed value @ ShortTimer // Maxtemps #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) diff --git a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h index 2aff81e0c..e080e3986 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h @@ -154,10 +154,12 @@ *------------------------------------*/ // Mintemps -#define HEATER_0_MINTEMP 15 +#define HEATER_0_MINTEMP 30 #define HEATER_1_MINTEMP 5 #define HEATER_2_MINTEMP 5 -#define BED_MINTEMP 15 +#define HEATER_MINTEMP_DELAY 15000 // [ms] ! if changed, check maximal allowed value @ ShortTimer +#define BED_MINTEMP 30 +#define BED_MINTEMP_DELAY 50000 // [ms] ! if changed, check maximal allowed value @ ShortTimer // Maxtemps #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 4655107c0..0fd795104 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -276,7 +276,9 @@ #define HEATER_0_MINTEMP 15 #define HEATER_1_MINTEMP 5 #define HEATER_2_MINTEMP 5 +#define HEATER_MINTEMP_DELAY 15000 // [ms] ! if changed, check maximal allowed value @ ShortTimer #define BED_MINTEMP 15 +#define BED_MINTEMP_DELAY 50000 // [ms] ! if changed, check maximal allowed value @ ShortTimer // Maxtemps #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) From 4e300fd552a9780c177660d47174aa9dab8e44af Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Wed, 2 Jan 2019 18:25:41 +0100 Subject: [PATCH 02/40] minTemp safety heaters management during/after minTemp --- Firmware/Marlin_main.cpp | 1 + Firmware/temperature.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 3496a971c..662003e08 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -7579,6 +7579,7 @@ void Stop() disable_heater(); if(Stopped == false) { Stopped = true; + lcd_print_stop(); Stopped_gcode_LastN = gcode_LastN; // Save last g_code for restart SERIAL_ERROR_START; SERIAL_ERRORLNRPGM(MSG_ERR_STOPPED); diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 5ba4824d7..b651c2737 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -685,6 +685,8 @@ void manage_heater() { soft_pwm[e] = 0; } + if(target_temperature[e]==0) + soft_pwm[e] = 0; #ifdef WATCH_TEMP_PERIOD if(watchmillis[e] && millis() - watchmillis[e] > WATCH_TEMP_PERIOD) @@ -812,6 +814,8 @@ void manage_heater() WRITE(HEATER_BED_PIN,LOW); } #endif + if(target_temperature_bed==0) + soft_pwm_bed = 0; #endif #ifdef HOST_KEEPALIVE_FEATURE From a309ec1b0b7d46c3d7c483d2aecab039c2eae88f Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 3 Jan 2019 22:58:25 +0100 Subject: [PATCH 03/40] Add filament auto deplete engine for multi-material prints with MMUv2. --- Firmware/AutoDeplete.cpp | 78 ++++++++++++++++++++++++++++++++++++++++ Firmware/AutoDeplete.h | 17 +++++++++ 2 files changed, 95 insertions(+) create mode 100644 Firmware/AutoDeplete.cpp create mode 100644 Firmware/AutoDeplete.h diff --git a/Firmware/AutoDeplete.cpp b/Firmware/AutoDeplete.cpp new file mode 100644 index 000000000..bfc090129 --- /dev/null +++ b/Firmware/AutoDeplete.cpp @@ -0,0 +1,78 @@ +//! @file +//! @author: Marek Bel +//! @date Jan 3, 2019 + +#include "AutoDeplete.h" +#include "assert.h" + +//! @brief bit field marking depleted filaments +//! +//! binary 1 marks filament as depleted +//! Zero initialized value means, that no filament is depleted. +static uint8_t depleted; +static const uint8_t filamentCount = 5; + +static constexpr uint8_t allDepleted(uint8_t fCount) +{ + return fCount == 1 ? 1 : ((1 << (fCount - 1)) | allDepleted(fCount - 2)); +} + +//! @brief Is filament available for printing? +//! @par filament Filament number to be checked +//! @retval true Filament is available for printing. +//! @retval false Filament is not available for printing. +static bool loaded(uint8_t filament) +{ + if (depleted & (1 << filament)) return false; + return true; +} + +//! @brief Mark filament as not available for printing. +//! @par filament filament to be marked +void ad_markDepleted(uint8_t filament) +{ + assert(filament < filamentCount); + if (filament < filamentCount) + { + depleted |= 1 << filament; + } +} + +//! @brief Mark filament as available for printing. +//! @par filament filament to be marked +void ad_markLoaded(uint8_t filament) +{ + assert(filament < filamentCount); + if (filament < filamentCount) + { + depleted &= ~(1 << filament); + } +} + +//! @brief Get alternative filament, which is not depleted +//! @par filament filament +//! @return Filament, if it is depleted, returns next available, +//! if all filaments are depleted, returns filament function parameter. +uint8_t ad_getAlternative(uint8_t filament) +{ + assert(filament < filamentCount); + if (ad_allDepleted()) return filament; + for (uint8_t i = 0; i + +void ad_markDepleted(uint8_t filament); +void ad_markLoaded(uint8_t filament); +uint8_t ad_getAlternative(uint8_t filament); +bool ad_allDepleted(); + +#endif /* AUTODEPLETE_H */ From 360a977520c7c0a7ed3a9f7d492c5a3e28c698a8 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 4 Jan 2019 19:34:42 +0100 Subject: [PATCH 04/40] Fix allDepleted(). Add tests. --- CMakeLists.txt | 2 + Firmware/AutoDeplete.cpp | 2 +- Tests/AutoDeplete_test.cpp | 146 +++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 Tests/AutoDeplete_test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b0798404..c0c2aacd0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,9 @@ set(TEST_SOURCES Tests/tests.cpp Tests/Example_test.cpp Tests/Timer_test.cpp + Tests/AutoDeplete_test.cpp Firmware/Timer.cpp + Firmware/AutoDeplete.cpp ) add_executable(tests ${TEST_SOURCES}) target_include_directories(tests PRIVATE Tests) diff --git a/Firmware/AutoDeplete.cpp b/Firmware/AutoDeplete.cpp index bfc090129..e6323dd96 100644 --- a/Firmware/AutoDeplete.cpp +++ b/Firmware/AutoDeplete.cpp @@ -14,7 +14,7 @@ static const uint8_t filamentCount = 5; static constexpr uint8_t allDepleted(uint8_t fCount) { - return fCount == 1 ? 1 : ((1 << (fCount - 1)) | allDepleted(fCount - 2)); + return fCount == 1 ? 1 : ((1 << (fCount - 1)) | allDepleted(fCount - 1)); } //! @brief Is filament available for printing? diff --git a/Tests/AutoDeplete_test.cpp b/Tests/AutoDeplete_test.cpp new file mode 100644 index 000000000..fb2964bc0 --- /dev/null +++ b/Tests/AutoDeplete_test.cpp @@ -0,0 +1,146 @@ +/** + * @file + * @author Marek Bel + */ + +#include "catch.hpp" + +#include "../Firmware/AutoDeplete.h" + +TEST_CASE( "AutoDeplete test.", "[AutoDeplete]" ) +{ + CHECK(ad_allDepleted() == false); + + CHECK(ad_getAlternative(0) == 0); + CHECK(ad_getAlternative(1) == 1); + CHECK(ad_getAlternative(2) == 2); + CHECK(ad_getAlternative(3) == 3); + CHECK(ad_getAlternative(4) == 4); + + ad_markDepleted(1); + + CHECK(ad_getAlternative(0) == 0); + CHECK(ad_getAlternative(1) == 2); + CHECK(ad_getAlternative(2) == 2); + CHECK(ad_getAlternative(3) == 3); + CHECK(ad_getAlternative(4) == 4); + CHECK(ad_allDepleted() == false); + + ad_markDepleted(3); + + CHECK(ad_getAlternative(0) == 0); + CHECK(ad_getAlternative(1) == 2); + CHECK(ad_getAlternative(2) == 2); + CHECK(ad_getAlternative(3) == 4); + CHECK(ad_getAlternative(4) == 4); + CHECK(ad_allDepleted() == false); + + ad_markDepleted(4); + + CHECK(ad_getAlternative(0) == 0); + CHECK(ad_getAlternative(1) == 2); + CHECK(ad_getAlternative(2) == 2); + CHECK(ad_getAlternative(3) == 0); + CHECK(ad_getAlternative(4) == 0); + CHECK(ad_allDepleted() == false); + + ad_markDepleted(4); + + CHECK(ad_getAlternative(0) == 0); + CHECK(ad_getAlternative(1) == 2); + CHECK(ad_getAlternative(2) == 2); + CHECK(ad_getAlternative(3) == 0); + CHECK(ad_getAlternative(4) == 0); + CHECK(ad_allDepleted() == false); + + ad_markDepleted(0); + + CHECK(ad_getAlternative(0) == 2); + CHECK(ad_getAlternative(1) == 2); + CHECK(ad_getAlternative(2) == 2); + CHECK(ad_getAlternative(3) == 2); + CHECK(ad_getAlternative(4) == 2); + CHECK(ad_allDepleted() == false); + + ad_markDepleted(2); + + CHECK(ad_getAlternative(0) == 0); + CHECK(ad_getAlternative(1) == 1); + CHECK(ad_getAlternative(2) == 2); + CHECK(ad_getAlternative(3) == 3); + CHECK(ad_getAlternative(4) == 4); + CHECK(ad_allDepleted() == true); + + ad_markDepleted(2); + + CHECK(ad_getAlternative(0) == 0); + CHECK(ad_getAlternative(1) == 1); + CHECK(ad_getAlternative(2) == 2); + CHECK(ad_getAlternative(3) == 3); + CHECK(ad_getAlternative(4) == 4); + CHECK(ad_allDepleted() == true); + + ad_markLoaded(4); + + CHECK(ad_getAlternative(0) == 4); + CHECK(ad_getAlternative(1) == 4); + CHECK(ad_getAlternative(2) == 4); + CHECK(ad_getAlternative(3) == 4); + CHECK(ad_getAlternative(4) == 4); + CHECK(ad_allDepleted() == false); + + ad_markLoaded(0); + + CHECK(ad_getAlternative(0) == 0); + CHECK(ad_getAlternative(1) == 4); + CHECK(ad_getAlternative(2) == 4); + CHECK(ad_getAlternative(3) == 4); + CHECK(ad_getAlternative(4) == 4); + CHECK(ad_allDepleted() == false); + + ad_markLoaded(3); + + CHECK(ad_getAlternative(0) == 0); + CHECK(ad_getAlternative(1) == 3); + CHECK(ad_getAlternative(2) == 3); + CHECK(ad_getAlternative(3) == 3); + CHECK(ad_getAlternative(4) == 4); + CHECK(ad_allDepleted() == false); + + ad_markLoaded(3); + + CHECK(ad_getAlternative(0) == 0); + CHECK(ad_getAlternative(1) == 3); + CHECK(ad_getAlternative(2) == 3); + CHECK(ad_getAlternative(3) == 3); + CHECK(ad_getAlternative(4) == 4); + CHECK(ad_allDepleted() == false); + + ad_markLoaded(2); + + CHECK(ad_getAlternative(0) == 0); + CHECK(ad_getAlternative(1) == 2); + CHECK(ad_getAlternative(2) == 2); + CHECK(ad_getAlternative(3) == 3); + CHECK(ad_getAlternative(4) == 4); + CHECK(ad_allDepleted() == false); + + ad_markLoaded(1); + + CHECK(ad_getAlternative(0) == 0); + CHECK(ad_getAlternative(1) == 1); + CHECK(ad_getAlternative(2) == 2); + CHECK(ad_getAlternative(3) == 3); + CHECK(ad_getAlternative(4) == 4); + CHECK(ad_allDepleted() == false); + + ad_markLoaded(1); + + CHECK(ad_getAlternative(0) == 0); + CHECK(ad_getAlternative(1) == 1); + CHECK(ad_getAlternative(2) == 2); + CHECK(ad_getAlternative(3) == 3); + CHECK(ad_getAlternative(4) == 4); + CHECK(ad_allDepleted() == false); + +} From 92ff284f82c2955404800a607f454cf0c298c937 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 4 Jan 2019 19:35:33 +0100 Subject: [PATCH 05/40] Remove redundant code. --- Firmware/AutoDeplete.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Firmware/AutoDeplete.cpp b/Firmware/AutoDeplete.cpp index e6323dd96..9593a1fec 100644 --- a/Firmware/AutoDeplete.cpp +++ b/Firmware/AutoDeplete.cpp @@ -56,7 +56,6 @@ void ad_markLoaded(uint8_t filament) uint8_t ad_getAlternative(uint8_t filament) { assert(filament < filamentCount); - if (ad_allDepleted()) return filament; for (uint8_t i = 0; i Date: Fri, 4 Jan 2019 19:56:15 +0100 Subject: [PATCH 06/40] Comment. --- Firmware/AutoDeplete.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Firmware/AutoDeplete.cpp b/Firmware/AutoDeplete.cpp index 9593a1fec..9c4340f09 100644 --- a/Firmware/AutoDeplete.cpp +++ b/Firmware/AutoDeplete.cpp @@ -12,6 +12,8 @@ static uint8_t depleted; static const uint8_t filamentCount = 5; +//! @return binary 1 for all filaments +//! @par fCount number of filaments static constexpr uint8_t allDepleted(uint8_t fCount) { return fCount == 1 ? 1 : ((1 << (fCount - 1)) | allDepleted(fCount - 1)); From 1a219b2372a4e4f3cf697575bbf56aa07bdd209f Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 4 Jan 2019 21:11:42 +0100 Subject: [PATCH 07/40] Mark filament as depleted when detected by MMUv2 FINDA. Do not try to load filament if it is marked depleted, load next filament instead. Force user action when all filaments are marked as depleted. --- Firmware/mmu.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index d8e324581..e904742cb 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -13,6 +13,7 @@ #include "sound.h" #include "printers.h" #include +#include "AutoDeplete.h" #ifdef TMC2130 #include "tmc2130.h" @@ -276,8 +277,15 @@ void mmu_loop(void) if (!mmu_finda && CHECK_FINDA && fsensor_enabled) { fsensor_stop_and_save_print(); enquecommand_front_P(PSTR("FSENSOR_RECOVER")); //then recover - if (lcd_autoDepleteEnabled()) enquecommand_front_P(PSTR("M600 AUTO")); //save print and run M600 command - else enquecommand_front_P(PSTR("M600")); //save print and run M600 command + ad_markDepleted(mmu_extruder); + if (lcd_autoDepleteEnabled() && !ad_allDepleted()) + { + enquecommand_front_P(PSTR("M600 AUTO")); //save print and run M600 command + } + else + { + enquecommand_front_P(PSTR("M600")); //save print and run M600 command + } } mmu_state = 1; if (mmu_cmd == 0) @@ -337,14 +345,19 @@ int8_t mmu_set_filament_type(uint8_t extruder, uint8_t filament) void mmu_command(uint8_t cmd) { -#ifdef TMC2130 if ((cmd >= MMU_CMD_T0) && (cmd <= MMU_CMD_T4)) { //disable extruder motor +#ifdef TMC2130 tmc2130_set_pwr(E_AXIS, 0); - //printf_P(PSTR("E-axis disabled\n")); - } #endif //TMC2130 + //printf_P(PSTR("E-axis disabled\n")); + ad_markLoaded(cmd - MMU_CMD_T0); + } + if ((cmd >= MMU_CMD_L0) && (cmd <= MMU_CMD_L4)) + { + ad_markLoaded(cmd - MMU_CMD_L0); + } mmu_cmd = cmd; mmu_ready = false; @@ -586,7 +599,7 @@ void mmu_M600_load_filament(bool automatic) #endif //MMU_M600_SWITCH_EXTRUDER } else { - tmp_extruder = (tmp_extruder+1)%5; + tmp_extruder = ad_getAlternative(tmp_extruder); } lcd_update_enable(false); lcd_clear(); From d89c03a0f14b23ca392198c6143c09d35d811cc8 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 4 Jan 2019 21:26:13 +0100 Subject: [PATCH 08/40] Documentation. --- Firmware/mmu.cpp | 7 ++++++- Firmware/mmu.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index e904742cb..13c7169e3 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -1,4 +1,4 @@ -//mmu.cpp +//! @file #include "mmu.h" #include "planner.h" @@ -343,6 +343,11 @@ int8_t mmu_set_filament_type(uint8_t extruder, uint8_t filament) return timeout?1:0; } +//! @brief Enqueue MMUv2 command +//! +//! Call manage_response() after enqueuing to process command. +//! If T command is enqueued, it disables current for extruder motor if TMC2130 driver present. +//! If T or L command is enqueued, it marks filament loaded in AutoDeplete module. void mmu_command(uint8_t cmd) { if ((cmd >= MMU_CMD_T0) && (cmd <= MMU_CMD_T4)) diff --git a/Firmware/mmu.h b/Firmware/mmu.h index 2071891ea..b8d609ee3 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -1,4 +1,4 @@ -//mmu.h +//! @file #include From c080b899c3c45b0858d9d9505da88cc21b9c317a Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 4 Jan 2019 22:32:48 +0100 Subject: [PATCH 09/40] Change filament number in T command to alternative if depleted and lcd_autoDepleteEnabled(). --- Firmware/Marlin_main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index dc96673c6..d08c1154a 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -78,6 +78,7 @@ #include #include "Dcodes.h" +#include "AutoDeplete.h" #ifdef SWSPI @@ -6920,6 +6921,10 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) } else { tmp_extruder = code_value(); + if (mmu_enabled && lcd_autoDepleteEnabled()) + { + tmp_extruder = ad_getAlternative(tmp_extruder); + } } st_synchronize(); snmm_filaments_used |= (1 << tmp_extruder); //for stop print From a0904f39e45011d1d434b215323d95b721a48fa7 Mon Sep 17 00:00:00 2001 From: mkbel <35807926+mkbel@users.noreply.github.com> Date: Tue, 8 Jan 2019 22:25:32 +0100 Subject: [PATCH 10/40] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 593f9134e..b7fc1155e 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ The script downloads Arduino with our modifications and Rambo board support inst a. install `"Arduino Software IDE"` for your preferred operating system `https://www.arduino.cc -> Software->Downloads` -it is recommended to use older version `"1.6.9"`, as it is used on out build server to produce official builds. +it is recommended to use version `"1.8.5"`, as it is used on out build server to produce official builds. _note: in the case of persistent compilation problems, check the version of the currently used C/C++ compiler (GCC) - should be `4.8.1`; version can be verified by entering the command `avr-gcc --version` if you are not sure where the file is placed (depends on how `"Arduino Software IDE"` was installed), you can use the search feature within the file system_ From 3b175459b1ab8d34ad1b52f3c5604e390170055e Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 15 Jan 2019 01:28:51 +0100 Subject: [PATCH 11/40] Fix filament loaded to far and MMU idler never disengaged after Tx command on printer with idler sensor. --- Firmware/mmu.cpp | 95 ++++++++++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 39 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 6433eafb5..8892d2fc2 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -241,7 +241,7 @@ void mmu_loop(void) mmu_printf_P(PSTR("T%d\n"), filament); mmu_state = 3; // wait for response mmu_fil_loaded = true; - if(mmu_idler_sensor_detected) mmu_idl_sens = 1; //if idler sensor detected, use it for T-code + mmu_idl_sens = 1; } else if ((mmu_cmd >= MMU_CMD_L0) && (mmu_cmd <= MMU_CMD_L4)) { @@ -259,7 +259,7 @@ void mmu_loop(void) #endif //MMU_DEBUG mmu_puts_P(PSTR("C0\n")); //send 'continue loading' mmu_state = 3; - if(mmu_idler_sensor_detected) mmu_idl_sens = 1; //if idler sensor detected use it for C0 code + mmu_idl_sens = 1; } else if (mmu_cmd == MMU_CMD_U0) { @@ -333,22 +333,20 @@ void mmu_loop(void) } return; case 3: //response to mmu commands - if (mmu_idler_sensor_detected) { - if (mmu_idl_sens) - { - if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0 && mmu_loading_flag) - { + if (mmu_idl_sens) + { + if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0 && mmu_loading_flag) + { #ifdef MMU_DEBUG - printf_P(PSTR("MMU <= 'A'\n")); + printf_P(PSTR("MMU <= 'A'\n")); #endif //MMU_DEBUG - mmu_puts_P(PSTR("A\n")); //send 'abort' request - mmu_idl_sens = 0; - //printf_P(PSTR("MMU IDLER_SENSOR = 0 - ABORT\n")); - } - //else - //printf_P(PSTR("MMU IDLER_SENSOR = 1 - WAIT\n")); - } - } + mmu_puts_P(PSTR("A\n")); //send 'abort' request + mmu_idl_sens = 0; + //printf_P(PSTR("MMU IDLER_SENSOR = 0 - ABORT\n")); + } + //else + //printf_P(PSTR("MMU IDLER_SENSOR = 1 - WAIT\n")); + } if (mmu_rx_ok() > 0) { #ifdef MMU_DEBUG @@ -438,10 +436,30 @@ void mmu_load_step() { st_synchronize(); } +//! @brief Is nozzle hot enough to move extruder wheels and do we have idler sensor? +//! +//! Do load steps only if temperature is higher then min. temp for safe extrusion and +//! idler sensor present. +//! Otherwise "cold extrusion prevented" would be send to serial line periodically +//! and watchdog reset will be triggered by lack of keep_alive processing. +//! +//! @retval true temperature is high enough to move extruder +//! @retval false temperature is not high enough to move extruder, turned +//! off E-stepper to prevent over-heating and allow filament pull-out if necessary +bool can_extrude() +{ + if ((degHotend(active_extruder) < EXTRUDE_MINTEMP) || !mmu_idler_sensor_detected) + { + disable_e0(); + delay_keep_alive(100); + return false; + } + return true; +} + bool mmu_get_response(uint8_t move) { - mmu_loading_flag = false; - if (!mmu_idler_sensor_detected) move = MMU_NO_MOVE; + mmu_loading_flag = false; printf_P(PSTR("mmu_get_response - begin move:%d\n"), move); KEEPALIVE_STATE(IN_PROCESS); @@ -458,28 +476,23 @@ bool mmu_get_response(uint8_t move) if ((mmu_state != 3) && (mmu_last_cmd == 0)) break; - //Do load steps only if temperature is higher then min. temp for safe extrusion. - //Otherwise "cold extrusion prevented" would be send to serial line periodically - if (degHotend(active_extruder) < EXTRUDE_MINTEMP) { - disable_e0(); //turn off E-stepper to prevent overheating and alow filament pull-out if necessary - delay_keep_alive(100); - continue; - } - switch (move) { - case MMU_LOAD_MOVE: - mmu_loading_flag = true; - mmu_load_step(); + case MMU_LOAD_MOVE: + mmu_loading_flag = true; + if (can_extrude()) mmu_load_step(); //don't rely on "ok" signal from mmu unit; if filament detected by idler sensor during loading stop loading movements to prevent infinite loading if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) move = MMU_NO_MOVE; break; case MMU_UNLOAD_MOVE: if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) //filament is still detected by idler sensor, printer helps with unlading - { - printf_P(PSTR("Unload 1\n")); - current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * MMU_LOAD_TIME_MS*0.001; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder); - st_synchronize(); + { + if (can_extrude()) + { + printf_P(PSTR("Unload 1\n")); + current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * MMU_LOAD_TIME_MS*0.001; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder); + st_synchronize(); + } } else //filament was unloaded from idler, no additional movements needed { @@ -490,11 +503,14 @@ bool mmu_get_response(uint8_t move) break; case MMU_TCODE_MOVE: //first do unload and then continue with infinite loading movements if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) //filament detected by idler sensor, we must unload first - { - printf_P(PSTR("Unload 2\n")); - current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * MMU_LOAD_TIME_MS*0.001; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder); - st_synchronize(); + { + if (can_extrude()) + { + printf_P(PSTR("Unload 2\n")); + current_position[E_AXIS] = current_position[E_AXIS] - MMU_LOAD_FEEDRATE * MMU_LOAD_TIME_MS*0.001; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder); + st_synchronize(); + } } else //delay to allow mmu unit to pull out filament from bondtech gears and then start with infinite loading { @@ -502,6 +518,7 @@ bool mmu_get_response(uint8_t move) disable_e0(); //turn off E-stepper to prevent overheating and alow filament pull-out if necessary delay_keep_alive(MMU_LOAD_TIME_MS); move = MMU_LOAD_MOVE; + printf_P(PSTR("mmu_get_response - begin move:%d\n"), move); } break; case MMU_NO_MOVE: From 39b391314fe772c23442b3a906cf8d6aaab6d90a Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 15 Jan 2019 01:29:59 +0100 Subject: [PATCH 12/40] Document meaning of manage_response() move default parameter value. --- Firmware/mmu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/mmu.h b/Firmware/mmu.h index 30f35599f..b6155319a 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -71,7 +71,7 @@ extern void mmu_command(uint8_t cmd); extern bool mmu_get_response(uint8_t move = 0); -extern void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move = 0); +extern void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move = MMU_NO_MOVE); extern void mmu_load_to_nozzle(); From d09ff5c3e738b8d43434fa97de56ddae38f2fa21 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 15 Jan 2019 01:30:54 +0100 Subject: [PATCH 13/40] Remove commented out code. --- Firmware/mmu.cpp | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 8892d2fc2..09d79bed6 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -465,14 +465,11 @@ bool mmu_get_response(uint8_t move) KEEPALIVE_STATE(IN_PROCESS); while (mmu_cmd != 0) { -// mmu_loop(); delay_keep_alive(100); } while (!mmu_ready) { -// mmu_loop(); - if ((mmu_state != 3) && (mmu_last_cmd == 0)) break; @@ -532,25 +529,6 @@ bool mmu_get_response(uint8_t move) mmu_ready = false; // printf_P(PSTR("mmu_get_response - end %d\n"), ret?1:0); return ret; - -/* //waits for "ok" from mmu - //function returns true if "ok" was received - //if timeout is set to true function return false if there is no "ok" received before timeout - bool response = true; - LongTimer mmu_get_reponse_timeout; - KEEPALIVE_STATE(IN_PROCESS); - mmu_get_reponse_timeout.start(); - while (mmu_rx_ok() <= 0) - { - delay_keep_alive(100); - if (timeout && mmu_get_reponse_timeout.expired(5 * 60 * 1000ul)) - { //5 minutes timeout - response = false; - break; - } - } - printf_P(PSTR("mmu_get_response - end %d\n"), response?1:0); - return response;*/ } From 3af1f812693933ebbe0532000a10e9f017ac0e1f Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 15 Jan 2019 21:40:02 +0100 Subject: [PATCH 14/40] Do not disable motor currents when print is paused due to mmu load error. --- Firmware/mmu.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 6433eafb5..0929e3e31 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -1363,6 +1363,7 @@ void mmu_continue_loading() setAllTargetHotends(0); lcd_setstatuspgm(_i("MMU load failed "));////MSG_RECOVERING_PRINT c=20 r=1 mmu_fil_loaded = false; //so we can retry same T-code again + isPrintPaused = true; } } else { //mmu_idler_sensor_detected == false From d9f8e4eb9ed3f54622d74ed580513f7e0aec6130 Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Thu, 17 Jan 2019 02:57:08 +0100 Subject: [PATCH 15/40] PID / manage_heater PSD regulator improvement --- Firmware/Configuration.h | 2 ++ Firmware/temperature.cpp | 73 ++++++++++++++++++++++------------------ Firmware/temperature.h | 8 ++++- 3 files changed, 49 insertions(+), 34 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 3bed653b7..e4eb7e17f 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -131,8 +131,10 @@ //#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 +// :-O :-O :-O #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. +// :-O :-O :-O #define PID_INTEGRAL_DRIVE_MAX PID_MAX //limit for the integral term #define K1 0.95 //smoothing factor within the PID #define PID_dT ((OVERSAMPLENR * 10.0)/(F_CPU / 64.0 / 256.0)) //sampling period of the temperature routine diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index b651c2737..e4315dd49 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -106,15 +106,15 @@ static volatile bool temp_meas_ready = false; #ifdef PIDTEMP //static cannot be external: - static float temp_iState[EXTRUDERS] = { 0 }; - static float temp_dState[EXTRUDERS] = { 0 }; + static float iState_sum[EXTRUDERS] = { 0 }; + static float dState_last[EXTRUDERS] = { 0 }; static float pTerm[EXTRUDERS]; static float iTerm[EXTRUDERS]; static float dTerm[EXTRUDERS]; //int output; static float pid_error[EXTRUDERS]; - static float temp_iState_min[EXTRUDERS]; - static float temp_iState_max[EXTRUDERS]; + static float iState_sum_min[EXTRUDERS]; + static float iState_sum_max[EXTRUDERS]; // static float pid_input[EXTRUDERS]; // static float pid_output[EXTRUDERS]; static bool pid_reset[EXTRUDERS]; @@ -418,7 +418,7 @@ void updatePID() { #ifdef PIDTEMP for(int e = 0; e < EXTRUDERS; e++) { - temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / cs.Ki; + iState_sum_max[e] = PID_INTEGRAL_DRIVE_MAX / cs.Ki; } #endif #ifdef PIDTEMPBED @@ -587,6 +587,10 @@ void checkExtruderAutoFans() #endif // any extruder auto fan pins set +void resetPID(uint8_t extruder) // ready for eventually parameters adjusting +{ +} + void manage_heater() { #ifdef WATCHDOG @@ -598,6 +602,7 @@ void manage_heater() if(temp_meas_ready != true) //better readability return; +// more precisely - this condition partially stabilizes time interval for regulation values evaluation (@ ~ 230ms) updateTemperaturesFromRawValues(); @@ -619,38 +624,42 @@ void manage_heater() pid_input = current_temperature[e]; #ifndef PID_OPENLOOP - pid_error[e] = target_temperature[e] - pid_input; - if(pid_error[e] > PID_FUNCTIONAL_RANGE) { - pid_output = BANG_MAX; - pid_reset[e] = true; - } - else if(pid_error[e] < -PID_FUNCTIONAL_RANGE || target_temperature[e] == 0) { + if(target_temperature[e] == 0) { pid_output = 0; pid_reset[e] = true; - } - else { - if(pid_reset[e] == true) { - temp_iState[e] = 0.0; + } else { + pid_error[e] = target_temperature[e] - pid_input; + if(pid_reset[e]) { + iState_sum[e] = 0.0; + dTerm[e] = 0.0; // 'dState_last[e]' initial setting is not necessary (see end of if-statement) pid_reset[e] = false; } +#ifndef PonM pTerm[e] = cs.Kp * pid_error[e]; - temp_iState[e] += pid_error[e]; - temp_iState[e] = constrain(temp_iState[e], temp_iState_min[e], temp_iState_max[e]); - iTerm[e] = cs.Ki * temp_iState[e]; - - //K1 defined in Configuration.h in the PID settings + iState_sum[e] += pid_error[e]; + iState_sum[e] = constrain(iState_sum[e], iState_sum_min[e], iState_sum_max[e]); + iTerm[e] = cs.Ki * iState_sum[e]; + // K1 defined in Configuration.h in the PID settings #define K2 (1.0-K1) - dTerm[e] = (cs.Kd * (pid_input - temp_dState[e]))*K2 + (K1 * dTerm[e]); - pid_output = pTerm[e] + iTerm[e] - dTerm[e]; + dTerm[e] = (cs.Kd * (pid_input - dState_last[e]))*K2 + (K1 * dTerm[e]); // e.g. digital filtration of derivative term changes + pid_output = pTerm[e] + iTerm[e] - dTerm[e]; // subtraction due to "Derivative on Measurement" method (i.e. derivative of input instead derivative of error is used) if (pid_output > PID_MAX) { - if (pid_error[e] > 0 ) temp_iState[e] -= pid_error[e]; // conditional un-integration + if (pid_error[e] > 0 ) iState_sum[e] -= pid_error[e]; // conditional un-integration pid_output=PID_MAX; - } else if (pid_output < 0){ - if (pid_error[e] < 0 ) temp_iState[e] -= pid_error[e]; // conditional un-integration + } else if (pid_output < 0) { + if (pid_error[e] < 0 ) iState_sum[e] -= pid_error[e]; // conditional un-integration pid_output=0; } +#else // PonM ("Proportional on Measurement" method) + iState_sum[e] += cs.Ki * pid_error[e]; + iState_sum[e] -= cs.Kp * (pid_input - dState_last[e]); + iState_sum[e] = constrain(iState_sum[e], 0, PID_INTEGRAL_DRIVE_MAX); + dTerm[e] = cs.Kd * (pid_input - dState_last[e]); + pid_output = iState_sum[e] - dTerm[e]; // subtraction due to "Derivative on Measurement" method (i.e. derivative of input instead derivative of error is used) + pid_output = constrain(pid_output, 0, PID_MAX); +#endif // PonM } - temp_dState[e] = pid_input; + dState_last[e] = pid_input; #else pid_output = constrain(target_temperature[e], 0, PID_MAX); #endif //PID_OPENLOOP @@ -667,7 +676,7 @@ void manage_heater() SERIAL_ECHO(" iTerm "); SERIAL_ECHO(iTerm[e]); SERIAL_ECHO(" dTerm "); - SERIAL_ECHOLN(dTerm[e]); + SERIAL_ECHOLN(-dTerm[e]); #endif //PID_DEBUG #else /* PID off */ pid_output = 0; @@ -677,16 +686,14 @@ void manage_heater() #endif // Check if temperature is within the correct range - if(current_temperature[e] < maxttemp[e]) + if((current_temperature[e] < maxttemp[e]) && (target_temperature[e] != 0)) { soft_pwm[e] = (int)pid_output >> 1; } else - { + { soft_pwm[e] = 0; } - if(target_temperature[e]==0) - soft_pwm[e] = 0; #ifdef WATCH_TEMP_PERIOD if(watchmillis[e] && millis() - watchmillis[e] > WATCH_TEMP_PERIOD) @@ -1001,8 +1008,8 @@ void tp_init() // populate with the first value maxttemp[e] = maxttemp[0]; #ifdef PIDTEMP - temp_iState_min[e] = 0.0; - temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / cs.Ki; + iState_sum_min[e] = 0.0; + iState_sum_max[e] = PID_INTEGRAL_DRIVE_MAX / cs.Ki; #endif //PIDTEMP #ifdef PIDTEMPBED temp_iState_min_bed = 0.0; diff --git a/Firmware/temperature.h b/Firmware/temperature.h index 9a3cee834..8db41672e 100644 --- a/Firmware/temperature.h +++ b/Firmware/temperature.h @@ -87,6 +87,8 @@ extern int current_voltage_raw_bed; extern volatile int babystepsTodo[3]; #endif +void resetPID(uint8_t extruder); + inline void babystepsTodoZadd(int n) { if (n != 0) { @@ -137,11 +139,15 @@ FORCE_INLINE float degTargetBed() { FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { target_temperature[extruder] = celsius; + resetPID[extruder]; }; static inline void setTargetHotendSafe(const float &celsius, uint8_t extruder) { - if (extruder Date: Fri, 18 Jan 2019 17:11:53 +0100 Subject: [PATCH 16/40] Do not list build environment files being extracted on standard output. --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 45bb9a931..051f1352c 100755 --- a/build.sh +++ b/build.sh @@ -12,7 +12,7 @@ if [ ! -f "PF-build-env-Linux64-$BUILD_ENV.zip" ]; then fi if [ ! -d "../../PF-build-env-$BUILD_ENV" ]; then - unzip PF-build-env-Linux64-$BUILD_ENV.zip -d ../../PF-build-env-$BUILD_ENV || exit 4 + unzip -q PF-build-env-Linux64-$BUILD_ENV.zip -d ../../PF-build-env-$BUILD_ENV || exit 4 fi cd ../../PF-build-env-$BUILD_ENV || exit 5 From ee35ca011c8768bb95a156f50155aff4565058b8 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 18 Jan 2019 20:21:14 +0100 Subject: [PATCH 17/40] Mark build variants in travis build output. --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cb96d2aa8..8dda15bca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,15 +4,20 @@ before_install: script: - bash -x test.sh - bash -x build.sh + - echo "Default variant END" - rm Firmware/Configuration_prusa.h - cp Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h Firmware/Configuration_prusa.h - bash -x build.sh + - echo "1_75mm_MK25-RAMBo13a-E3Dv6full variant END" - rm Firmware/Configuration_prusa.h - cp Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h Firmware/Configuration_prusa.h - bash -x build.sh + - echo "1_75mm_MK25-RAMBo10a-E3Dv6full variant END" - rm Firmware/Configuration_prusa.h - cp Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h Firmware/Configuration_prusa.h - bash -x build.sh + - echo "1_75mm_MK2-RAMBo13a-E3Dv6full variant END" - rm Firmware/Configuration_prusa.h - cp Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh \ No newline at end of file + - bash -x build.sh + - echo "1_75mm_MK2-RAMBo10a-E3Dv6full variant END" \ No newline at end of file From ccde850303d48cc1d8ac7e520e72a64e465d28fc Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 18 Jan 2019 20:46:10 +0100 Subject: [PATCH 18/40] Fix mark build variants in travis - comment on the same line instead of separate echo command. As echo is not executed in case of previous command failure. --- .travis.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8dda15bca..a53a6fa3e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,21 +3,17 @@ before_install: - sudo apt-get install -y ninja-build script: - bash -x test.sh - - bash -x build.sh - - echo "Default variant END" + - cp Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h Firmware/Configuration_prusa.h + - bash -x build.sh #1_75mm_MK3-EINSy10a-E3Dv6full variant - rm Firmware/Configuration_prusa.h - cp Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh - - echo "1_75mm_MK25-RAMBo13a-E3Dv6full variant END" + - bash -x build.sh #1_75mm_MK25-RAMBo13a-E3Dv6full variant - rm Firmware/Configuration_prusa.h - cp Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh - - echo "1_75mm_MK25-RAMBo10a-E3Dv6full variant END" + - bash -x build.sh #1_75mm_MK25-RAMBo10a-E3Dv6full variant - rm Firmware/Configuration_prusa.h - cp Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh - - echo "1_75mm_MK2-RAMBo13a-E3Dv6full variant END" + - bash -x build.sh #1_75mm_MK2-RAMBo13a-E3Dv6full variant - rm Firmware/Configuration_prusa.h - cp Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh - - echo "1_75mm_MK2-RAMBo10a-E3Dv6full variant END" \ No newline at end of file + - bash -x build.sh #1_75mm_MK2-RAMBo10a-E3Dv6full variant \ No newline at end of file From 412ffc5fdf9603dab54b332f27042b791770778b Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 18 Jan 2019 20:54:42 +0100 Subject: [PATCH 19/40] Comment is not shown in travis output, try echo. --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index a53a6fa3e..0b6bc19d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,16 +4,16 @@ before_install: script: - bash -x test.sh - cp Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh #1_75mm_MK3-EINSy10a-E3Dv6full variant + - bash -x build.sh && echo "1_75mm_MK3-EINSy10a-E3Dv6full variant" - rm Firmware/Configuration_prusa.h - cp Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh #1_75mm_MK25-RAMBo13a-E3Dv6full variant + - bash -x build.sh && echo "1_75mm_MK25-RAMBo13a-E3Dv6full variant" - rm Firmware/Configuration_prusa.h - cp Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh #1_75mm_MK25-RAMBo10a-E3Dv6full variant + - bash -x build.sh && echo "1_75mm_MK25-RAMBo10a-E3Dv6full variant" - rm Firmware/Configuration_prusa.h - cp Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh #1_75mm_MK2-RAMBo13a-E3Dv6full variant + - bash -x build.sh && echo "1_75mm_MK2-RAMBo13a-E3Dv6full variant" - rm Firmware/Configuration_prusa.h - cp Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh #1_75mm_MK2-RAMBo10a-E3Dv6full variant \ No newline at end of file + - bash -x build.sh && echo "1_75mm_MK2-RAMBo10a-E3Dv6full variant" \ No newline at end of file From 0b3337d5dfd406f3d14034c256a810219987ed75 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 18 Jan 2019 21:14:50 +0100 Subject: [PATCH 20/40] Echo variant if variant build failed. --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0b6bc19d4..cc420ee79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,16 +4,16 @@ before_install: script: - bash -x test.sh - cp Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh && echo "1_75mm_MK3-EINSy10a-E3Dv6full variant" + - bash -x build.sh || { echo "1_75mm_MK3-EINSy10a-E3Dv6full variant failed" && false; } - rm Firmware/Configuration_prusa.h - cp Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh && echo "1_75mm_MK25-RAMBo13a-E3Dv6full variant" + - bash -x build.sh || { echo "1_75mm_MK25-RAMBo13a-E3Dv6full variant failed" && false; } - rm Firmware/Configuration_prusa.h - cp Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh && echo "1_75mm_MK25-RAMBo10a-E3Dv6full variant" + - bash -x build.sh || { echo "1_75mm_MK25-RAMBo10a-E3Dv6full variant failed" && false; } - rm Firmware/Configuration_prusa.h - cp Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh && echo "1_75mm_MK2-RAMBo13a-E3Dv6full variant" + - bash -x build.sh || { echo "1_75mm_MK2-RAMBo13a-E3Dv6full variant failed" && false; } - rm Firmware/Configuration_prusa.h - cp Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh && echo "1_75mm_MK2-RAMBo10a-E3Dv6full variant" \ No newline at end of file + - bash -x build.sh || { echo "1_75mm_MK2-RAMBo10a-E3Dv6full variant failed" && false; } \ No newline at end of file From d7ac459da76799aeacfea0425d4a4dc856de9a9a Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Sun, 20 Jan 2019 01:23:15 +0100 Subject: [PATCH 21/40] PID / manage_heater build-warnings elimination --- Firmware/temperature.h | 4 ++-- Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h | 2 ++ Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Firmware/temperature.h b/Firmware/temperature.h index 8db41672e..9697f4401 100644 --- a/Firmware/temperature.h +++ b/Firmware/temperature.h @@ -139,14 +139,14 @@ FORCE_INLINE float degTargetBed() { FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { target_temperature[extruder] = celsius; - resetPID[extruder]; + resetPID(extruder); }; static inline void setTargetHotendSafe(const float &celsius, uint8_t extruder) { if (extruder Date: Mon, 21 Jan 2019 17:57:07 +0100 Subject: [PATCH 22/40] Fast PWM for bed - timer2 used as system timer --- Firmware/temperature.cpp | 17 +++++-- Firmware/temperature.h | 4 +- Firmware/timer02.c | 103 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 7 deletions(-) create mode 100644 Firmware/timer02.c diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index cae3fada7..973009559 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -42,6 +42,12 @@ #include "ConfigurationStore.h" +extern "C" { +extern void timer02_init(void); +extern void timer02_set_pwm0(uint8_t pwm0); +} + + //=========================================================================== //=============================public variables============================ //=========================================================================== @@ -983,7 +989,6 @@ static void updateTemperaturesFromRawValues() CRITICAL_SECTION_END; } - void tp_init() { #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1)) @@ -1050,10 +1055,12 @@ void tp_init() adc_init(); + timer02_init(); + // Use timer0 for temperature measurement // Interleave temperature interrupt with millies interrupt - OCR0B = 128; - TIMSK0 |= (1< +#include +#include + + +uint8_t timer02_pwm0 = 0; + +void timer02_set_pwm0(uint8_t pwm0) +{ + if (timer02_pwm0 == pwm0) return; + if (pwm0) + { + TCCR0A |= (2 << COM0B0); + OCR0B = pwm0 - 1; + } + else + { + TCCR0A &= ~(2 << COM0B0); + OCR0B = 0; + } +} + +void timer02_init(void) +{ + //save sreg + uint8_t _sreg = SREG; + //disable interrupts for sure + cli(); + //mask timer0 interrupts - disable all + TIMSK0 &= ~(1<> 3) +#define FRACT_MAX (1000 >> 3) + +extern volatile unsigned long timer0_overflow_count; +extern volatile unsigned long timer0_millis; +unsigned char timer0_fract = 0; + +ISR(TIMER2_OVF_vect) +{ + // copy these to local variables so they can be stored in registers + // (volatile variables must be read from memory on every access) + unsigned long m = timer0_millis; + unsigned char f = timer0_fract; + + m += MILLIS_INC; + f += FRACT_INC; + if (f >= FRACT_MAX) + { + f -= FRACT_MAX; + m += 1; + } + + timer0_fract = f; + timer0_millis = m; + timer0_overflow_count++; +} + From e612eb2a172c7911e484337c380f96702e53907c Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Mon, 21 Jan 2019 18:14:19 +0100 Subject: [PATCH 23/40] Fast PWM for bed - set pwm value from soft_pwm_bed variable. --- Firmware/temperature.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 973009559..b8181b206 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -258,6 +258,7 @@ static void temp_runaway_stop(bool isPreheat, bool isBed); if (extruder<0) { soft_pwm_bed = (MAX_BED_POWER)/2; + timer02_set_pwm0(soft_pwm_bed << 1); bias = d = (MAX_BED_POWER)/2; } else @@ -294,7 +295,10 @@ static void temp_runaway_stop(bool isPreheat, bool isBed); if(millis() - t2 > 5000) { heating=false; if (extruder<0) + { soft_pwm_bed = (bias - d) >> 1; + timer02_set_pwm0(soft_pwm_bed << 1); + } else soft_pwm[extruder] = (bias - d) >> 1; t1=millis(); @@ -348,7 +352,10 @@ static void temp_runaway_stop(bool isPreheat, bool isBed); } } if (extruder<0) + { soft_pwm_bed = (bias + d) >> 1; + timer02_set_pwm0(soft_pwm_bed << 1); + } else soft_pwm[extruder] = (bias + d) >> 1; pid_cycle++; @@ -776,9 +783,11 @@ void manage_heater() #endif //AMBIENT_THERMISTOR { soft_pwm_bed = (int)pid_output >> 1; + timer02_set_pwm0(soft_pwm_bed << 1); } else { soft_pwm_bed = 0; + timer02_set_pwm0(soft_pwm_bed << 1); } #elif !defined(BED_LIMIT_SWITCHING) @@ -788,15 +797,18 @@ void manage_heater() if(current_temperature_bed >= target_temperature_bed) { soft_pwm_bed = 0; + timer02_set_pwm0(soft_pwm_bed << 1); } else { soft_pwm_bed = MAX_BED_POWER>>1; + timer02_set_pwm0(soft_pwm_bed << 1); } } else { soft_pwm_bed = 0; + timer02_set_pwm0(soft_pwm_bed << 1); WRITE(HEATER_BED_PIN,LOW); } #else //#ifdef BED_LIMIT_SWITCHING @@ -806,15 +818,18 @@ void manage_heater() if(current_temperature_bed > target_temperature_bed + BED_HYSTERESIS) { soft_pwm_bed = 0; + timer02_set_pwm0(soft_pwm_bed << 1); } else if(current_temperature_bed <= target_temperature_bed - BED_HYSTERESIS) { soft_pwm_bed = MAX_BED_POWER>>1; + timer02_set_pwm0(soft_pwm_bed << 1); } } else { soft_pwm_bed = 0; + timer02_set_pwm0(soft_pwm_bed << 1); WRITE(HEATER_BED_PIN,LOW); } #endif @@ -1368,6 +1383,7 @@ void disable_heater() #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 target_temperature_bed=0; soft_pwm_bed=0; + timer02_set_pwm0(soft_pwm_bed << 1); #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 WRITE(HEATER_BED_PIN,LOW); #endif From 2c0d62fbf7e9329b329115d2f27db7b189a223d1 Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Mon, 21 Jan 2019 18:20:40 +0100 Subject: [PATCH 24/40] PID / manage_heater some small corrections --- Firmware/Configuration.h | 6 +----- Firmware/temperature.cpp | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index e4eb7e17f..774e64445 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -126,15 +126,11 @@ // Comment the following line to disable PID and enable bang-bang. #define PIDTEMP #define BANG_MAX 255 // limits current to nozzle while in bang-bang mode; 255=full current -#define PID_MAX BANG_MAX // limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current +#define PID_MAX BANG_MAX // limits current to nozzle while PID is active; 255=full current #ifdef PIDTEMP //#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 -// :-O :-O :-O - #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. -// :-O :-O :-O #define PID_INTEGRAL_DRIVE_MAX PID_MAX //limit for the integral term #define K1 0.95 //smoothing factor within the PID #define PID_dT ((OVERSAMPLENR * 10.0)/(F_CPU / 64.0 / 256.0)) //sampling period of the temperature routine diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index e4315dd49..e1e74fac8 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -589,6 +589,7 @@ void checkExtruderAutoFans() void resetPID(uint8_t extruder) // ready for eventually parameters adjusting { +extruder=extruder; // only for compiler-warning elimination (if function do nothing) } void manage_heater() From 50bcfae1838e94ba570440342a3637ab5e49d9b7 Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Mon, 21 Jan 2019 18:21:17 +0100 Subject: [PATCH 25/40] Fast PWM for bed - newer set HEATER_BED_PIN to 1 --- Firmware/temperature.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index b8181b206..a50d75e42 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -1621,7 +1621,7 @@ ISR(TIMER2_COMPB_vect) #endif #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 soft_pwm_b = soft_pwm_bed; - if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1); else WRITE(HEATER_BED_PIN,0); + //if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1); else WRITE(HEATER_BED_PIN,0); #endif #ifdef FAN_SOFT_PWM soft_pwm_fan = fanSpeedSoftPwm / 2; @@ -1755,7 +1755,7 @@ ISR(TIMER2_COMPB_vect) state_timer_heater_b = MIN_STATE_TIME; } state_heater_b = 1; - WRITE(HEATER_BED_PIN, 1); + //WRITE(HEATER_BED_PIN, 1); } } else { // turn OFF heather only if the minimum time is up From f292a6ca7ab532ae0f48f042a3ff26d31c301dd4 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Mon, 21 Jan 2019 21:39:38 +0100 Subject: [PATCH 26/40] Refactor filament sensor selftest call. --- Firmware/ultralcd.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 937ccd5a1..b96050649 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -6418,21 +6418,25 @@ bool lcd_selftest() if (_result) { _progress = lcd_selftest_screen(8, _progress, 3, true, 2000); //bed ok -#ifdef FILAMENT_SENSOR - if (mmu_enabled == false) { - _progress = lcd_selftest_screen(9, _progress, 3, true, 2000); //check filaments sensor - _result = lcd_selftest_fsensor(); - } -#endif // FILAMENT_SENSOR } + +#ifdef FILAMENT_SENSOR + if (mmu_enabled == false) + { + if (_result) + { + _progress = lcd_selftest_screen(9, _progress, 3, true, 2000); //check filaments sensor + _result = lcd_selftest_fsensor(); + } + if (_result) + { + _progress = lcd_selftest_screen(10, _progress, 3, true, 2000); //fil sensor OK + } + } +#endif // FILAMENT_SENSOR + if (_result) { -#ifdef FILAMENT_SENSOR - if (mmu_enabled == false) - { - _progress = lcd_selftest_screen(10, _progress, 3, true, 2000); //fil sensor OK - } -#endif // FILAMENT_SENSOR _progress = lcd_selftest_screen(11, _progress, 3, true, 5000); //all correct } else From a92d9c782b0d3ba379aa78d3ef0ff5b456f98530 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 22 Jan 2019 10:56:07 +0100 Subject: [PATCH 27/40] Add IR sensor test. --- Firmware/mmu.cpp | 23 +++++++++------- Firmware/mmu.h | 8 ++++++ Firmware/ultralcd.cpp | 61 ++++++++++++++++++++++++++++++++++++++----- 3 files changed, 76 insertions(+), 16 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index c8ced41b2..ba80a7fd9 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -450,10 +450,11 @@ void mmu_command(uint8_t cmd) mmu_ready = false; } -void mmu_load_step() { +void mmu_load_step(bool synchronize) +{ current_position[E_AXIS] = current_position[E_AXIS] + MMU_LOAD_FEEDRATE * 0.1; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMU_LOAD_FEEDRATE, active_extruder); - st_synchronize(); + if (synchronize) st_synchronize(); } bool mmu_get_response(uint8_t move) @@ -554,6 +555,14 @@ bool mmu_get_response(uint8_t move) return response;*/ } +void mmu_wait_for_heater_blocking() +{ + while ((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5) + { + delay_keep_alive(1000); + lcd_wait_for_heater(); + } +} void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move) { @@ -648,11 +657,7 @@ void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move) lcd_display_message_fullscreen_P(_i("MMU OK. Resuming temperature...")); delay_keep_alive(3000); } - while ((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5) - { - delay_keep_alive(1000); - lcd_wait_for_heater(); - } + mmu_wait_for_heater_blocking(); } if (move_axes) { lcd_clear(); @@ -955,7 +960,7 @@ static const E_step ramming_sequence[] PROGMEM = }; //! @brief Unload sequence to optimize shape of the tip of the unloaded filament -static void filament_ramming() +void mmu_filament_ramming() { for(uint8_t i = 0; i < (sizeof(ramming_sequence)/sizeof(E_step));++i) { @@ -987,7 +992,7 @@ void extr_unload() if (mmu_extruder == MMU_FILAMENT_UNKNOWN) lcd_print(" "); else lcd_print(mmu_extruder + 1); - filament_ramming(); + mmu_filament_ramming(); mmu_command(MMU_CMD_U0); // get response diff --git a/Firmware/mmu.h b/Firmware/mmu.h index 1861be6dc..8f7f34a33 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -1,5 +1,8 @@ //! @file +#ifndef MMU_H +#define MMU_H + #include @@ -119,3 +122,8 @@ extern void mmu_eject_fil_2(); extern void mmu_eject_fil_3(); extern void mmu_eject_fil_4(); extern void mmu_continue_loading(); +extern void mmu_filament_ramming(); +extern void mmu_wait_for_heater_blocking(); +extern void mmu_load_step(bool synchronize = true); + +#endif //MMU_H diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index b96050649..f9e5c6677 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -163,6 +163,7 @@ static void lcd_selftest_screen_step(int _row, int _col, int _state, const char static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite); static bool lcd_selftest_fan_dialog(int _fan); static bool lcd_selftest_fsensor(); +static bool selftest_irsensor(); static void lcd_selftest_error(int _error_no, const char *_error_1, const char *_error_2); static void lcd_colorprint_change(); #ifdef SNMM @@ -6421,17 +6422,20 @@ bool lcd_selftest() } #ifdef FILAMENT_SENSOR - if (mmu_enabled == false) + if (_result) { - if (_result) + _progress = lcd_selftest_screen(9, _progress, 3, true, 2000); //check filaments sensor + if (mmu_enabled) + { + _result = selftest_irsensor(); + } else { - _progress = lcd_selftest_screen(9, _progress, 3, true, 2000); //check filaments sensor _result = lcd_selftest_fsensor(); } - if (_result) - { - _progress = lcd_selftest_screen(10, _progress, 3, true, 2000); //fil sensor OK - } + } + if (_result) + { + _progress = lcd_selftest_screen(10, _progress, 3, true, 2000); //fil sensor OK } #endif // FILAMENT_SENSOR @@ -6991,6 +6995,49 @@ static bool lcd_selftest_fsensor(void) } return (!fsensor_not_responding); } + +static bool selftest_irsensor() +{ + class TempBackup + { + public: + TempBackup(): + m_temp(degTargetHotend(active_extruder)), + m_extruder(active_extruder){} + ~TempBackup(){setTargetHotend(m_temp,m_extruder);} + private: + float m_temp; + uint8_t m_extruder; + }; + + TempBackup tempBackup; + setTargetHotend(PLA_PREHEAT_HOTEND_TEMP,active_extruder); + mmu_wait_for_heater_blocking(); + lcd_selftest_screen(9, 0, 3, true, 0); + mmu_filament_ramming(); + + for(uint_least8_t i = 0; i < 200; ++i) + { + mmu_load_step(false); + while (blocks_queued()) + { + if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0) return false; +#ifdef TMC2130 + manage_heater(); + // Vojtech: Don't disable motors inside the planner! + if (!tmc2130_update_sg()) + { + manage_inactivity(true); + } +#else //TMC2130 + manage_heater(); + // Vojtech: Don't disable motors inside the planner! + manage_inactivity(true); +#endif //TMC2130 + } + } + return true; +} #endif //FILAMENT_SENSOR static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite) From c371a5ea65679d03de2f54788efd2980c88ab722 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 22 Jan 2019 14:05:08 +0100 Subject: [PATCH 28/40] Document. --- Firmware/mmu.cpp | 8 ++++++++ Firmware/ultralcd.cpp | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index ba80a7fd9..1b1a234d1 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -450,6 +450,10 @@ void mmu_command(uint8_t cmd) mmu_ready = false; } +//! @brief Rotate extruder idler to catch filament +//! @par synchronize +//! * true blocking call +//! * false non-blocking call void mmu_load_step(bool synchronize) { current_position[E_AXIS] = current_position[E_AXIS] + MMU_LOAD_FEEDRATE * 0.1; @@ -555,6 +559,10 @@ bool mmu_get_response(uint8_t move) return response;*/ } +//! @brief Wait for active extruder to reach temperature set +//! +//! This function is blocking and showing lcd_wait_for_heater() screen +//! which is constantly updated with nozzle temperature. void mmu_wait_for_heater_blocking() { while ((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index f9e5c6677..8f10c6cbf 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -6996,6 +6996,17 @@ static bool lcd_selftest_fsensor(void) return (!fsensor_not_responding); } +//! @brief Self-test of infrared barrier filament sensor mounted on MK3S with MMUv2 printer +//! +//! Test whether sensor is not triggering filament presence when extruder idler is moving without filament. +//! +//! Steps: +//! * Backup current active extruder temperature +//! * Pre-heat to PLA extrude temperature. +//! * Unload filament possibly present. +//! +//! @retval true passed +//! @retval false failed static bool selftest_irsensor() { class TempBackup From 3ff8a7c740e6218e2d4ea82121faafbe2bf95d88 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 22 Jan 2019 14:54:06 +0100 Subject: [PATCH 29/40] Unload filament by MMU unit in selftest_irsensor(). Known limitation: If filament was not loaded to nozzle it is sticked completely out of MMU. To be fixed in MMU, as this problem can be reproduced also from printer menu - unload filament. --- Firmware/ultralcd.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 8f10c6cbf..895895dcf 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -7004,6 +7004,9 @@ static bool lcd_selftest_fsensor(void) //! * Backup current active extruder temperature //! * Pre-heat to PLA extrude temperature. //! * Unload filament possibly present. +//! * Move extruder idler same way as during filament load +//! and sample MMU_IDLER_SENSOR_PIN. +//! * Check that pin doesn't go low. //! //! @retval true passed //! @retval false failed @@ -7026,6 +7029,8 @@ static bool selftest_irsensor() mmu_wait_for_heater_blocking(); lcd_selftest_screen(9, 0, 3, true, 0); mmu_filament_ramming(); + mmu_command(MMU_CMD_U0); + manage_response(false, false); for(uint_least8_t i = 0; i < 200; ++i) { From 9cda0b69b89d8af3cd945c7fc8a6472208976219 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 22 Jan 2019 18:03:03 +0100 Subject: [PATCH 30/40] Update IR sensor selftest progress bar. --- Firmware/ultralcd.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 895895dcf..6ad75b6e7 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -7027,13 +7027,15 @@ static bool selftest_irsensor() TempBackup tempBackup; setTargetHotend(PLA_PREHEAT_HOTEND_TEMP,active_extruder); mmu_wait_for_heater_blocking(); - lcd_selftest_screen(9, 0, 3, true, 0); + uint8_t progress = lcd_selftest_screen(9, 0, 1, true, 0); mmu_filament_ramming(); mmu_command(MMU_CMD_U0); manage_response(false, false); for(uint_least8_t i = 0; i < 200; ++i) { + if (0 == (i % 50)) progress = lcd_selftest_screen(9, progress, 1, true, 0); + mmu_load_step(false); while (blocks_queued()) { From 97a46238001c0864752369c6171a08790c9b2fd4 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 22 Jan 2019 19:01:55 +0100 Subject: [PATCH 31/40] Fix lcd_selftest_screen for small _progress_scale. --- Firmware/ultralcd.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 6ad75b6e7..3d5d53421 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -7218,7 +7218,7 @@ static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bo lcd_update_enable(false); int _step_block = 0; - const char *_indicator = (_progress > _progress_scale) ? "-" : "|"; + const char *_indicator = (_progress >= _progress_scale) ? "-" : "|"; if (_clear) lcd_clear(); @@ -7281,7 +7281,7 @@ static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bo if (_delay > 0) delay_keep_alive(_delay); _progress++; - return (_progress > _progress_scale * 2) ? 0 : _progress; + return (_progress >= _progress_scale * 2) ? 0 : _progress; } static void lcd_selftest_screen_step(int _row, int _col, int _state, const char *_name, const char *_indicator) From 1d71c1a5d166eded1f3e516fb74aeac2828ba261 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 22 Jan 2019 19:02:42 +0100 Subject: [PATCH 32/40] Update IR sensor selftest progress bar more frequently. --- Firmware/ultralcd.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 3d5d53421..10d5e561e 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -7029,12 +7029,13 @@ static bool selftest_irsensor() mmu_wait_for_heater_blocking(); uint8_t progress = lcd_selftest_screen(9, 0, 1, true, 0); mmu_filament_ramming(); + progress = lcd_selftest_screen(9, progress, 1, true, 0); mmu_command(MMU_CMD_U0); manage_response(false, false); for(uint_least8_t i = 0; i < 200; ++i) { - if (0 == (i % 50)) progress = lcd_selftest_screen(9, progress, 1, true, 0); + if (0 == (i % 32)) progress = lcd_selftest_screen(9, progress, 1, true, 0); mmu_load_step(false); while (blocks_queued()) From 867182c2661fd93da5db6ae3082a8d794ffd482a Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Wed, 23 Jan 2019 18:50:13 +0100 Subject: [PATCH 33/40] minTemp more user-proof solution --- Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h | 13 +++++++++++-- Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h | 13 +++++++++++-- Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h | 7 +++++++ Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h | 7 +++++++ Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 7 +++++++ 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h index f237e79a6..86023f0ea 100644 --- a/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h @@ -1,6 +1,7 @@ #ifndef CONFIGURATION_PRUSA_H #define CONFIGURATION_PRUSA_H +#include /*------------------------------------ GENERAL SETTINGS *------------------------------------*/ @@ -102,10 +103,18 @@ EXTRUDER SETTINGS *------------------------------------*/ // Mintemps -#define HEATER_0_MINTEMP 15 +#define HEATER_0_MINTEMP 30 #define HEATER_1_MINTEMP 5 #define HEATER_2_MINTEMP 5 -#define BED_MINTEMP 15 +#define HEATER_MINTEMP_DELAY 15000 // [ms] ! if changed, check maximal allowed value @ ShortTimer +#if HEATER_MINTEMP_DELAY>USHRT_MAX +#error "Check maximal allowed value @ ShortTimer (see HEATER_MINTEMP_DELAY definition)" +#endif +#define BED_MINTEMP 30 +#define BED_MINTEMP_DELAY 50000 // [ms] ! if changed, check maximal allowed value @ ShortTimer +#if BED_MINTEMP_DELAY>USHRT_MAX +#error "Check maximal allowed value @ ShortTimer (see BED_MINTEMP_DELAY definition)" +#endif // Maxtemps #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) diff --git a/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h index e09178bbc..8e8212bc5 100644 --- a/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h @@ -1,6 +1,7 @@ #ifndef CONFIGURATION_PRUSA_H #define CONFIGURATION_PRUSA_H +#include /*------------------------------------ GENERAL SETTINGS *------------------------------------*/ @@ -102,10 +103,18 @@ EXTRUDER SETTINGS *------------------------------------*/ // Mintemps -#define HEATER_0_MINTEMP 15 +#define HEATER_0_MINTEMP 30 #define HEATER_1_MINTEMP 5 #define HEATER_2_MINTEMP 5 -#define BED_MINTEMP 15 +#define HEATER_MINTEMP_DELAY 15000 // [ms] ! if changed, check maximal allowed value @ ShortTimer +#if HEATER_MINTEMP_DELAY>USHRT_MAX +#error "Check maximal allowed value @ ShortTimer (see HEATER_MINTEMP_DELAY definition)" +#endif +#define BED_MINTEMP 30 +#define BED_MINTEMP_DELAY 50000 // [ms] ! if changed, check maximal allowed value @ ShortTimer +#if BED_MINTEMP_DELAY>USHRT_MAX +#error "Check maximal allowed value @ ShortTimer (see BED_MINTEMP_DELAY definition)" +#endif // Maxtemps #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) diff --git a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h index 826204445..477b50b8d 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h @@ -1,6 +1,7 @@ #ifndef CONFIGURATION_PRUSA_H #define CONFIGURATION_PRUSA_H +#include /*------------------------------------ GENERAL SETTINGS *------------------------------------*/ @@ -157,8 +158,14 @@ #define HEATER_1_MINTEMP 5 #define HEATER_2_MINTEMP 5 #define HEATER_MINTEMP_DELAY 15000 // [ms] ! if changed, check maximal allowed value @ ShortTimer +#if HEATER_MINTEMP_DELAY>USHRT_MAX +#error "Check maximal allowed value @ ShortTimer (see HEATER_MINTEMP_DELAY definition)" +#endif #define BED_MINTEMP 30 #define BED_MINTEMP_DELAY 50000 // [ms] ! if changed, check maximal allowed value @ ShortTimer +#if BED_MINTEMP_DELAY>USHRT_MAX +#error "Check maximal allowed value @ ShortTimer (see BED_MINTEMP_DELAY definition)" +#endif // Maxtemps #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) diff --git a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h index e080e3986..3ef9895a1 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h @@ -1,6 +1,7 @@ #ifndef CONFIGURATION_PRUSA_H #define CONFIGURATION_PRUSA_H +#include /*------------------------------------ GENERAL SETTINGS *------------------------------------*/ @@ -158,8 +159,14 @@ #define HEATER_1_MINTEMP 5 #define HEATER_2_MINTEMP 5 #define HEATER_MINTEMP_DELAY 15000 // [ms] ! if changed, check maximal allowed value @ ShortTimer +#if HEATER_MINTEMP_DELAY>USHRT_MAX +#error "Check maximal allowed value @ ShortTimer (see HEATER_MINTEMP_DELAY definition)" +#endif #define BED_MINTEMP 30 #define BED_MINTEMP_DELAY 50000 // [ms] ! if changed, check maximal allowed value @ ShortTimer +#if BED_MINTEMP_DELAY>USHRT_MAX +#error "Check maximal allowed value @ ShortTimer (see BED_MINTEMP_DELAY definition)" +#endif // Maxtemps #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 0fd795104..1aafb5b81 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -1,6 +1,7 @@ #ifndef CONFIGURATION_PRUSA_H #define CONFIGURATION_PRUSA_H +#include /*------------------------------------ GENERAL SETTINGS *------------------------------------*/ @@ -277,8 +278,14 @@ #define HEATER_1_MINTEMP 5 #define HEATER_2_MINTEMP 5 #define HEATER_MINTEMP_DELAY 15000 // [ms] ! if changed, check maximal allowed value @ ShortTimer +#if HEATER_MINTEMP_DELAY>USHRT_MAX +#error "Check maximal allowed value @ ShortTimer (see HEATER_MINTEMP_DELAY definition)" +#endif #define BED_MINTEMP 15 #define BED_MINTEMP_DELAY 50000 // [ms] ! if changed, check maximal allowed value @ ShortTimer +#if BED_MINTEMP_DELAY>USHRT_MAX +#error "Check maximal allowed value @ ShortTimer (see BED_MINTEMP_DELAY definition)" +#endif // Maxtemps #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) From 15b45df9fb4edf921363e9dfb43be5f2c6c17787 Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Wed, 23 Jan 2019 20:14:40 +0100 Subject: [PATCH 34/40] PID / manage_heater better build-warnings elimination --- Firmware/temperature.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index e1e74fac8..eb29b8103 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -587,9 +587,10 @@ void checkExtruderAutoFans() #endif // any extruder auto fan pins set -void resetPID(uint8_t extruder) // ready for eventually parameters adjusting +// ready for eventually parameters adjusting +void resetPID(uint8_t) // only for compiler-warning elimination (if function do nothing) +//void resetPID(uint8_t extruder) { -extruder=extruder; // only for compiler-warning elimination (if function do nothing) } void manage_heater() From b2b65475dfd0ab9c2229e26347646fc389956c37 Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Thu, 24 Jan 2019 17:32:57 +0100 Subject: [PATCH 35/40] SD card menu SDcard-menu after card insertion --- Firmware/ultralcd.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 937ccd5a1..e89c04652 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -237,6 +237,8 @@ bool wait_for_unclick; // float raw_Ki, raw_Kd; #endif +bool bMain; // flag (i.e. 'fake parameter') for 'lcd_sdcard_menu()' function + const char STR_SEPARATOR[] PROGMEM = "------------"; @@ -5886,7 +5888,10 @@ static void lcd_main_menu() if (!is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL)) { //if (farm_mode) MENU_ITEM_SUBMENU_P(MSG_FARM_CARD_MENU, lcd_farm_sdcard_menu); - /*else*/ MENU_ITEM_SUBMENU_P(_T(MSG_CARD_MENU), lcd_sdcard_menu); + /*else*/ { + bMain=true; // flag ('fake parameter') for 'lcd_sdcard_menu()' function + MENU_ITEM_SUBMENU_P(_T(MSG_CARD_MENU), lcd_sdcard_menu); + } } #if SDCARDDETECT < 1 MENU_ITEM_GCODE_P(_i("Change SD card"), PSTR("M21")); // SD-card changed by user////MSG_CNG_SDCARD c=0 r=0 @@ -5895,6 +5900,7 @@ static void lcd_main_menu() } else { + bMain=true; // flag (i.e. 'fake parameter') for 'lcd_sdcard_menu()' function MENU_ITEM_SUBMENU_P(_i("No SD card"), lcd_sdcard_menu);////MSG_NO_CARD c=0 r=0 #if SDCARDDETECT < 1 MENU_ITEM_GCODE_P(_i("Init. SD card"), PSTR("M21")); // Manually initialize the SD-card via user interface////MSG_INIT_SDCARD c=0 r=0 @@ -6227,7 +6233,10 @@ void lcd_sdcard_menu() MENU_BEGIN(); - MENU_ITEM_BACK_P(_T(MSG_MAIN)); + if(bMain) // i.e. default menu-item + MENU_ITEM_BACK_P(_T(MSG_MAIN)); + else // i.e. menu-item after card insertion + MENU_ITEM_FUNCTION_P(_T(MSG_WATCH),lcd_return_to_status); card.getWorkDirName(); if (card.filename[0] == '/') { @@ -7519,7 +7528,9 @@ void menu_lcd_lcdupdate_func(void) if (lcd_oldcardstatus) { card.initsd(); - LCD_MESSAGERPGM(_i("Card inserted"));////MSG_SD_INSERTED c=0 r=0 + LCD_MESSAGERPGM(_T(WELCOME_MSG)); + bMain=false; // flag (i.e. 'fake parameter') for 'lcd_sdcard_menu()' function + menu_submenu(lcd_sdcard_menu); //get_description(); } else From 22859800f090f033f15680eaea92205f2f1ebd41 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 24 Jan 2019 19:22:36 +0100 Subject: [PATCH 36/40] Rearrange tests. Move hot end test to the end, to spare time in IR sensor test. Known problems, hot end and bed is swapped. Bed progress indicator is painted to X axis test. --- Firmware/ultralcd.cpp | 61 +++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 10d5e561e..1efb814b4 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -6324,28 +6324,24 @@ bool lcd_selftest() _result = true; #endif } - - if (_result) - { - _progress = lcd_selftest_screen(3, _progress, 3, true, 1000); - _result = lcd_selfcheck_check_heater(false); - } - if (_result) { //current_position[Z_AXIS] += 15; //move Z axis higher to avoid false triggering of Z end stop in case that we are very low - just above heatbed - _progress = lcd_selftest_screen(4, _progress, 3, true, 2000); + _progress = lcd_selftest_screen(3, _progress, 3, true, 2000); #ifdef TMC2130 - _result = lcd_selfcheck_axis_sg(X_AXIS); + _result = lcd_selfcheck_axis_sg(X_AXIS); #else - _result = lcd_selfcheck_axis(X_AXIS, X_MAX_POS); + _result = lcd_selfcheck_axis(X_AXIS, X_MAX_POS); #endif //TMC2130 } + + + if (_result) { - _progress = lcd_selftest_screen(4, _progress, 3, true, 0); + _progress = lcd_selftest_screen(3, _progress, 3, true, 0); #ifndef TMC2130 _result = lcd_selfcheck_pulleys(X_AXIS); @@ -6355,7 +6351,7 @@ bool lcd_selftest() if (_result) { - _progress = lcd_selftest_screen(5, _progress, 3, true, 1500); + _progress = lcd_selftest_screen(4, _progress, 3, true, 1500); #ifdef TMC2130 _result = lcd_selfcheck_axis_sg(Y_AXIS); #else @@ -6365,7 +6361,7 @@ bool lcd_selftest() if (_result) { - _progress = lcd_selftest_screen(5, _progress, 3, true, 0); + _progress = lcd_selftest_screen(4, _progress, 3, true, 0); #ifndef TMC2130 _result = lcd_selfcheck_pulleys(Y_AXIS); #endif // TMC2130 @@ -6386,7 +6382,7 @@ bool lcd_selftest() current_position[Z_AXIS] = current_position[Z_AXIS] + 10; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder); st_synchronize(); - _progress = lcd_selftest_screen(6, _progress, 3, true, 1500); + _progress = lcd_selftest_screen(5, _progress, 3, true, 1500); _result = lcd_selfcheck_axis(2, Z_MAX_POS); if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) != 1) { enquecommand_P(PSTR("G28 W")); @@ -6413,12 +6409,18 @@ bool lcd_selftest() if (_result) { - _progress = lcd_selftest_screen(7, _progress, 3, true, 2000); //check bed - _result = lcd_selfcheck_check_heater(true); + _progress = lcd_selftest_screen(6, _progress, 3, true, 2000); //check bed + _result = lcd_selfcheck_check_heater(false); } + + if (_result) + { + _progress = lcd_selftest_screen(7, _progress, 3, true, 1000); //check nozzle + _result = lcd_selfcheck_check_heater(true); + } if (_result) { - _progress = lcd_selftest_screen(8, _progress, 3, true, 2000); //bed ok + _progress = lcd_selftest_screen(8, _progress, 3, true, 2000); //nozzle ok } #ifdef FILAMENT_SENSOR @@ -7230,12 +7232,12 @@ static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bo if (_step == 0) lcd_puts_P(_T(MSG_SELFTEST_FAN)); if (_step == 1) lcd_puts_P(_T(MSG_SELFTEST_FAN)); if (_step == 2) lcd_puts_P(_i("Checking endstops"));////MSG_SELFTEST_CHECK_ENDSTOPS c=20 r=0 - if (_step == 3) lcd_puts_P(_i("Checking hotend "));////MSG_SELFTEST_CHECK_HOTEND c=20 r=0 - if (_step == 4) lcd_puts_P(_i("Checking X axis "));////MSG_SELFTEST_CHECK_X c=20 r=0 - if (_step == 5) lcd_puts_P(_i("Checking Y axis "));////MSG_SELFTEST_CHECK_Y c=20 r=0 - if (_step == 6) lcd_puts_P(_i("Checking Z axis "));////MSG_SELFTEST_CHECK_Z c=20 r=0 - if (_step == 7) lcd_puts_P(_T(MSG_SELFTEST_CHECK_BED)); - if (_step == 8) lcd_puts_P(_T(MSG_SELFTEST_CHECK_BED)); + if (_step == 3) lcd_puts_P(_i("Checking X axis "));////MSG_SELFTEST_CHECK_X c=20 r=0 + if (_step == 4) lcd_puts_P(_i("Checking Y axis "));////MSG_SELFTEST_CHECK_Y c=20 r=0 + if (_step == 5) lcd_puts_P(_i("Checking Z axis "));////MSG_SELFTEST_CHECK_Z c=20 r=0 + if (_step == 6) lcd_puts_P(_T(MSG_SELFTEST_CHECK_BED)); + if (_step == 7 + || _step == 8) lcd_puts_P(_i("Checking hotend "));////MSG_SELFTEST_CHECK_HOTEND c=20 r=0 if (_step == 9) lcd_puts_P(_T(MSG_SELFTEST_CHECK_FSENSOR)); if (_step == 10) lcd_puts_P(_T(MSG_SELFTEST_CHECK_FSENSOR)); if (_step == 11) lcd_puts_P(_i("All correct "));////MSG_SELFTEST_CHECK_ALLCORRECT c=20 r=0 @@ -7263,20 +7265,21 @@ static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bo else if (_step < 9) { //SERIAL_ECHOLNPGM("Other tests"); - _step_block = 3; - lcd_selftest_screen_step(3, 9, ((_step == _step_block) ? 1 : (_step < _step_block) ? 0 : 2), "Hotend", _indicator); - _step_block = 4; + _step_block = 3; lcd_selftest_screen_step(2, 2, ((_step == _step_block) ? 1 : (_step < _step_block) ? 0 : 2), "X", _indicator); - _step_block = 5; + _step_block = 4; lcd_selftest_screen_step(2, 8, ((_step == _step_block) ? 1 : (_step < _step_block) ? 0 : 2), "Y", _indicator); - _step_block = 6; + _step_block = 5; lcd_selftest_screen_step(2, 14, ((_step == _step_block) ? 1 : (_step < _step_block) ? 0 : 2), "Z", _indicator); - _step_block = 7; + _step_block = 6; lcd_selftest_screen_step(3, 0, ((_step == _step_block) ? 1 : (_step < _step_block) ? 0 : 2), "Bed", _indicator); + + _step_block = 7; + lcd_selftest_screen_step(3, 9, ((_step == _step_block) ? 1 : (_step < _step_block) ? 0 : 2), "Hotend", _indicator); } if (_delay > 0) delay_keep_alive(_delay); From 305598d7f653cc1c33a55c117fff4233b10d847b Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 24 Jan 2019 20:03:37 +0100 Subject: [PATCH 37/40] Fix bed / nozzle test order and progress bar. Known limitation: Z progress shown in bed progress. --- Firmware/ultralcd.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 1efb814b4..85b899dc8 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -6410,13 +6410,13 @@ bool lcd_selftest() if (_result) { _progress = lcd_selftest_screen(6, _progress, 3, true, 2000); //check bed - _result = lcd_selfcheck_check_heater(false); + _result = lcd_selfcheck_check_heater(true); } if (_result) { _progress = lcd_selftest_screen(7, _progress, 3, true, 1000); //check nozzle - _result = lcd_selfcheck_check_heater(true); + _result = lcd_selfcheck_check_heater(false); } if (_result) { @@ -6821,7 +6821,7 @@ static bool lcd_selfcheck_check_heater(bool _isbed) manage_heater(); manage_inactivity(true); - _progress = (_isbed) ? lcd_selftest_screen(7, _progress, 2, false, 400) : lcd_selftest_screen(3, _progress, 2, false, 400); + _progress = (_isbed) ? lcd_selftest_screen(6, _progress, 2, false, 400) : lcd_selftest_screen(7, _progress, 2, false, 400); /*if (_isbed) { MYSERIAL.print("Bed temp:"); MYSERIAL.println(degBed()); From 1c4f3259ea26d7ea8a1899bd6b1a40af3089e994 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 24 Jan 2019 21:02:04 +0100 Subject: [PATCH 38/40] Increase heater check minimum expected temperature rises. Bed increased from 3 to 10 K. Nozzle increased from 10 to 30 K. Measured rises with my MK3 printer: Bed 26K, Nozzle 73K. --- Firmware/ultralcd.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 85b899dc8..0253996c5 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -6847,9 +6847,10 @@ static bool lcd_selfcheck_check_heater(bool _isbed) MYSERIAL.print("Opposite result:"); MYSERIAL.println(_opposite_result); */ - if (_opposite_result < ((_isbed) ? 10 : 3)) + + if (_opposite_result < ((_isbed) ? 30 : 9)) { - if (_checked_result >= ((_isbed) ? 3 : 10)) + if (_checked_result >= ((_isbed) ? 9 : 30)) { _stepresult = true; } From 68ffa95aa9651e7149756f064361b2638d3b9962 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 24 Jan 2019 21:06:03 +0100 Subject: [PATCH 39/40] Fix axis self-test progress visualization. --- Firmware/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 0253996c5..ee97ff6e9 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -6654,7 +6654,7 @@ static bool lcd_selfcheck_axis(int _axis, int _travel) } else { - _progress = lcd_selftest_screen(4 + _axis, _progress, 3, false, 0); + _progress = lcd_selftest_screen(3 + _axis, _progress, 3, false, 0); _lcd_refresh = 0; } From edc412697c56e09f3ea3a4d4eefc0a8d0cbea394 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 24 Jan 2019 21:24:46 +0100 Subject: [PATCH 40/40] Increase selftest_irsensor() filament nozzle unload temperature to ABS. Resume nozzle temperature immediately after unload. --- Firmware/ultralcd.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index ee97ff6e9..64899d398 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -7026,12 +7026,14 @@ static bool selftest_irsensor() float m_temp; uint8_t m_extruder; }; - - TempBackup tempBackup; - setTargetHotend(PLA_PREHEAT_HOTEND_TEMP,active_extruder); - mmu_wait_for_heater_blocking(); - uint8_t progress = lcd_selftest_screen(9, 0, 1, true, 0); - mmu_filament_ramming(); + uint8_t progress; + { + TempBackup tempBackup; + setTargetHotend(ABS_PREHEAT_HOTEND_TEMP,active_extruder); + mmu_wait_for_heater_blocking(); + progress = lcd_selftest_screen(9, 0, 1, true, 0); + mmu_filament_ramming(); + } progress = lcd_selftest_screen(9, progress, 1, true, 0); mmu_command(MMU_CMD_U0); manage_response(false, false);