From a220c97f94832de2b71bec5a962df505e788ebdf Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 6 Feb 2019 16:19:30 +0100 Subject: [PATCH 01/25] Revert "variant files" This reverts commit 850d3316b6ab048bfa869383628d5b2fd7f3b75b. --- .../1_75mm_MK25S-RAMBo10a-E3Dv6full.h | 505 ++++++++++++++ .../1_75mm_MK25S-RAMBo13a-E3Dv6full.h | 506 ++++++++++++++ .../variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h | 631 ++++++++++++++++++ 3 files changed, 1642 insertions(+) create mode 100644 Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h create mode 100644 Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h create mode 100644 Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h diff --git a/Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h new file mode 100644 index 000000000..53b545e8b --- /dev/null +++ b/Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h @@ -0,0 +1,505 @@ +#ifndef CONFIGURATION_PRUSA_H +#define CONFIGURATION_PRUSA_H + +#include +/*------------------------------------ + GENERAL SETTINGS + *------------------------------------*/ + +// Printer revision +#define PRINTER_TYPE PRINTER_MK25S +#define FILAMENT_SIZE "1_75mm_MK25S" +#define NOZZLE_TYPE "E3Dv6full" + +// Developer flag +#define DEVELOPER + +// Printer name +#define CUSTOM_MENDEL_NAME "Prusa i3 MK2.5S" + +// Electronics +#define MOTHERBOARD BOARD_RAMBO_MINI_1_0 + +#define HEATBED_V2 +#define STEEL_SHEET +#define TACH0PULLUP + +// Uncomment the below for the E3D PT100 temperature sensor (with or without PT100 Amplifier) +//#define E3D_PT100_EXTRUDER_WITH_AMP +//#define E3D_PT100_EXTRUDER_NO_AMP +//#define E3D_PT100_BED_WITH_AMP +//#define E3D_PT100_BED_NO_AMP + + +/*------------------------------------ + AXIS SETTINGS + *------------------------------------*/ + +// Steps per unit {X,Y,Z,E} +#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,133} + +// Endstop inverting +#define X_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop. +#define Y_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop. +#define Z_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop. + +// Direction inverting +#define INVERT_X_DIR 0 // for Mendel set to 0, for Orca set to 1 +#define INVERT_Y_DIR 0 // for Mendel set to 1, for Orca set to 0 +#define INVERT_Z_DIR 0 // for Mendel set to 0, for Orca set to 1 +#define INVERT_E0_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0 +#define INVERT_E1_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0 +#define INVERT_E2_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0 + +// Home position +#define MANUAL_X_HOME_POS 0 +#define MANUAL_Y_HOME_POS -2.2 +#define MANUAL_Z_HOME_POS 0.2 + +// Travel limits after homing +#define X_MAX_POS 250 +#define X_MIN_POS 0 +#define Y_MAX_POS 210 +#define Y_MIN_POS -4 +#define Z_MAX_POS 210 +#define Z_MIN_POS 0.15 + +// Canceled home position +#define X_CANCEL_POS 50 +#define Y_CANCEL_POS 190 + +//Pause print position +#define X_PAUSE_POS 50 +#define Y_PAUSE_POS 190 +#define Z_PAUSE_LIFT 20 + +#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E +#define HOMING_FEEDRATE {3000, 3000, 800, 0} // set the homing speeds (mm/min) // 3000 is also valid for stallGuard homing. Valid range: 2200 - 3000 + +/** + * [0,0] steel sheet print area point X coordinate in bed print area coordinates + */ +#define SHEET_PRINT_ZERO_REF_X 0.f +/** + * [0,0] steel sheet print area point Y coordinate in bed print area coordinates + */ +#define SHEET_PRINT_ZERO_REF_Y 0.f + +#define DEFAULT_MAX_FEEDRATE {200, 200, 12, 120} // (mm/sec) max feedrate (M203) +#define DEFAULT_MAX_FEEDRATE_SILENT {172, 172, 12, 120} // (mm/sec) max feedrate (M203), silent mode +#define DEFAULT_MAX_ACCELERATION {1000, 1000, 200, 5000} // (mm/sec^2) max acceleration (M201) +#define DEFAULT_MAX_ACCELERATION_SILENT {960, 960, 200, 5000} // (mm/sec^2) max acceleration (M201), silent mode + +#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204S) +#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts (M204T) + +#define MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min) + +//number of bytes from end of the file to start check +#define END_FILE_SECTION 20000 + +#define Z_AXIS_ALWAYS_ON 1 + +// New XYZ calibration +#define NEW_XYZCAL + +// Fan check +#define FANCHECK + +// Safety timer +#define SAFETYTIMER +#define DEFAULT_SAFETYTIMER_TIME_MINS 30 + +// Filament sensor +#define FILAMENT_SENSOR +#define IR_SENSOR + + +#define DEBUG_DCODE3 + +//#define DEBUG_BUILD +#ifdef DEBUG_BUILD +//#define _NO_ASM +#define DEBUG_DCODES //D codes +#define DEBUG_STACK_MONITOR //Stack monitor in stepper ISR +//#define DEBUG_FSENSOR_LOG //Reports fsensor status to serial +//#define DEBUG_CRASHDET_COUNTERS //Display crash-detection counters on LCD +//#define DEBUG_RESUME_PRINT //Resume/save print debug enable +//#define DEBUG_UVLO_AUTOMATIC_RECOVER // Power panic automatic recovery debug output +//#define DEBUG_DISABLE_XMINLIMIT //x min limit ignored +//#define DEBUG_DISABLE_XMAXLIMIT //x max limit ignored +//#define DEBUG_DISABLE_YMINLIMIT //y min limit ignored +//#define DEBUG_DISABLE_YMAXLIMIT //y max limit ignored +//#define DEBUG_DISABLE_ZMINLIMIT //z min limit ignored +//#define DEBUG_DISABLE_ZMAXLIMIT //z max limit ignored +//#define DEBUG_DISABLE_STARTMSGS //no startup messages +//#define DEBUG_DISABLE_MINTEMP //mintemp error ignored +//#define DEBUG_DISABLE_SWLIMITS //sw limits ignored +//#define DEBUG_DISABLE_LCD_STATUS_LINE //empty four lcd line +//#define DEBUG_DISABLE_PREVENT_EXTRUDER //cold extrusion and long extrusion allowed +//#define DEBUG_DISABLE_PRUSA_STATISTICS //disable prusa_statistics() mesages +//#define DEBUG_XSTEP_DUP_PIN 21 //duplicate x-step output to pin 21 (SCL on P3) +//#define DEBUG_YSTEP_DUP_PIN 21 //duplicate y-step output to pin 21 (SCL on P3) +//#define DEBUG_DISABLE_FANCHECK //disable fan check (no ISR INT7, check disabled) +//#define DEBUG_DUMP_TO_2ND_SERIAL //dump received characters to 2nd serial line +//#define DEBUG_STEPPER_TIMER_MISSED // Stop on stepper timer overflow, beep and display a message. +//#define PLANNER_DIAGNOSTICS // Show the planner queue status on printer display. +//#define CMD_DIAGNOSTICS //Show cmd queue length on printer display +#endif /* DEBUG_BUILD */ + +//#define FSENSOR_QUALITY + + +/*------------------------------------ + EXTRUDER SETTINGS + *------------------------------------*/ + +// Mintemps +#define HEATER_0_MINTEMP 30 +#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) +#define HEATER_0_MAXTEMP 410 +#else +#define HEATER_0_MAXTEMP 305 +#endif +#define HEATER_1_MAXTEMP 305 +#define HEATER_2_MAXTEMP 305 +#define BED_MAXTEMP 125 + +#if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) +// Define PID constants for extruder with PT100 +#define DEFAULT_Kp 21.70 +#define DEFAULT_Ki 1.60 +#define DEFAULT_Kd 73.76 +#else +// Define PID constants for extruder +//#define DEFAULT_Kp 40.925 +//#define DEFAULT_Ki 4.875 +//#define DEFAULT_Kd 86.085 +#define DEFAULT_Kp 16.13 +#define DEFAULT_Ki 1.1625 +#define DEFAULT_Kd 56.23 +#endif + +// Extrude mintemp +#define EXTRUDE_MINTEMP 175 + +// Extruder cooling fans +#define EXTRUDER_0_AUTO_FAN_PIN 8 +#define EXTRUDER_1_AUTO_FAN_PIN -1 +#define EXTRUDER_2_AUTO_FAN_PIN -1 +#define EXTRUDER_AUTO_FAN_TEMPERATURE 50 +#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed + + +/*------------------------------------ + LOAD/UNLOAD FILAMENT SETTINGS + *------------------------------------*/ + +// Load filament commands +#define LOAD_FILAMENT_0 "M83" +#define LOAD_FILAMENT_1 "G1 E70 F400" +#define LOAD_FILAMENT_2 "G1 E40 F100" + +// Unload filament commands +#define UNLOAD_FILAMENT_0 "M83" +#define UNLOAD_FILAMENT_1 "G1 E-80 F7000" + +/*------------------------------------ + CHANGE FILAMENT SETTINGS + *------------------------------------*/ + +// Filament change configuration +#define FILAMENTCHANGEENABLE +#ifdef FILAMENTCHANGEENABLE +#define FILAMENTCHANGE_XPOS 211 +#define FILAMENTCHANGE_YPOS 0 +#define FILAMENTCHANGE_ZADD 2 +#define FILAMENTCHANGE_FIRSTRETRACT -2 +#define FILAMENTCHANGE_FINALRETRACT -80 + +#define FILAMENTCHANGE_FIRSTFEED 70 //E distance in mm for fast filament loading sequence used used in filament change (M600) +#define FILAMENTCHANGE_FINALFEED 25 //E distance in mm for slow filament loading sequence used used in filament change (M600) and filament load (M701) +#define FILAMENTCHANGE_RECFEED 5 + +#define FILAMENTCHANGE_XYFEED 50 +#define FILAMENTCHANGE_EFEED_FIRST 20 // feedrate in mm/s for fast filament loading sequence used in filament change (M600) +#define FILAMENTCHANGE_EFEED_FINAL 3.3f // feedrate in mm/s for slow filament loading sequence used in filament change (M600) and filament load (M701) +//#define FILAMENTCHANGE_RFEED 400 +#define FILAMENTCHANGE_RFEED 7000 / 60 +#define FILAMENTCHANGE_EXFEED 2 +#define FILAMENTCHANGE_ZFEED 15 + +#endif + +/*------------------------------------ + ADDITIONAL FEATURES SETTINGS + *------------------------------------*/ + +// Define Prusa filament runout sensor +//#define FILAMENT_RUNOUT_SUPPORT + +#ifdef FILAMENT_RUNOUT_SUPPORT +#define FILAMENT_RUNOUT_SENSOR 1 +#endif + +// temperature runaway +#define TEMP_RUNAWAY_BED_HYSTERESIS 5 +#define TEMP_RUNAWAY_BED_TIMEOUT 360 + +#define TEMP_RUNAWAY_EXTRUDER_HYSTERESIS 15 +#define TEMP_RUNAWAY_EXTRUDER_TIMEOUT 45 + +/*------------------------------------ + MOTOR CURRENT SETTINGS + *------------------------------------*/ + +// Motor Current setting for BIG RAMBo +#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +#define DIGIPOT_MOTOR_CURRENT_LOUD {135,135,135,135,135} + +// Motor Current settings for RAMBo mini PWM value = MotorCurrentSetting * 255 / range +#if MOTHERBOARD == BOARD_RAMBO_MINI_1_0 || MOTHERBOARD == BOARD_RAMBO_MINI_1_3 +#define MOTOR_CURRENT_PWM_RANGE 2000 +#define DEFAULT_PWM_MOTOR_CURRENT {270, 830, 450} // {XY,Z,E} +#define DEFAULT_PWM_MOTOR_CURRENT_LOUD {540, 830, 500} // {XY,Z,E} +#define Z_SILENT 0 +#define Z_HIGH_POWER 200 +#endif + +/*------------------------------------ + BED SETTINGS + *------------------------------------*/ + +// Define Mesh Bed Leveling system to enable it +#define MESH_BED_LEVELING +#ifdef MESH_BED_LEVELING + +#define MBL_Z_STEP 0.01 + +// Mesh definitions +#define MESH_MIN_X 35 +#define MESH_MAX_X 238 +#define MESH_MIN_Y 6 +#define MESH_MAX_Y 202 + +// Mesh upsample definition +#define MESH_NUM_X_POINTS 7 +#define MESH_NUM_Y_POINTS 7 +// Mesh measure definition +#define MESH_MEAS_NUM_X_POINTS 3 +#define MESH_MEAS_NUM_Y_POINTS 3 + +// Maximum bed level correction value +#define BED_ADJUSTMENT_UM_MAX 100 + +#define MESH_HOME_Z_CALIB 0.2 +#define MESH_HOME_Z_SEARCH 5 //Z lift for homing, mesh bed leveling etc. + +#define X_PROBE_OFFSET_FROM_EXTRUDER 23 // Z probe to nozzle X offset: -left +right +#define Y_PROBE_OFFSET_FROM_EXTRUDER 5 // Z probe to nozzle Y offset: -front +behind +#define Z_PROBE_OFFSET_FROM_EXTRUDER -0.4 // Z probe to nozzle Z offset: -below (always!) +#endif + +// Bed Temperature Control +// Select PID or bang-bang with PIDTEMPBED. If bang-bang, BED_LIMIT_SWITCHING will enable hysteresis +// +// Uncomment this to enable PID on the bed. It uses the same frequency PWM as the extruder. +// If your PID_dT above is the default, and correct for your hardware/configuration, that means 7.689Hz, +// which is fine for driving a square wave into a resistive load and does not significantly impact you FET heating. +// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater. +// If your configuration is significantly different than this and you don't understand the issues involved, you probably +// shouldn't use bed PID until someone else verifies your hardware works. +// If this is enabled, find your own PID constants below. +#define PIDTEMPBED +// +//#define BED_LIMIT_SWITCHING + +// This sets the max power delivered to the bed, and replaces the HEATER_BED_DUTY_CYCLE_DIVIDER option. +// 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 + +// Bed temperature compensation settings +#define BED_OFFSET 10 +#define BED_OFFSET_START 40 +#define BED_OFFSET_CENTER 50 + + +#ifdef PIDTEMPBED +//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) +//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) +#if defined(E3D_PT100_BED_WITH_AMP) || defined(E3D_PT100_BED_NO_AMP) +// Define PID constants for extruder with PT100 +#define DEFAULT_bedKp 21.70 +#define DEFAULT_bedKi 1.60 +#define DEFAULT_bedKd 73.76 +#else +#define DEFAULT_bedKp 126.13 +#define DEFAULT_bedKi 4.30 +#define DEFAULT_bedKd 924.76 +#endif + +//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) +//from pidautotune +// #define DEFAULT_bedKp 97.1 +// #define DEFAULT_bedKi 1.41 +// #define DEFAULT_bedKd 1675.16 + +// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles. +#endif // PIDTEMPBED + + +/*----------------------------------- + PREHEAT SETTINGS + *------------------------------------*/ + +#define FARM_PREHEAT_HOTEND_TEMP 250 +#define FARM_PREHEAT_HPB_TEMP 40 +#define FARM_PREHEAT_FAN_SPEED 0 + +#define PLA_PREHEAT_HOTEND_TEMP 215 +#define PLA_PREHEAT_HPB_TEMP 60 +#define PLA_PREHEAT_FAN_SPEED 0 + +#define ABS_PREHEAT_HOTEND_TEMP 255 +#define ABS_PREHEAT_HPB_TEMP 100 +#define ABS_PREHEAT_FAN_SPEED 0 + +#define HIPS_PREHEAT_HOTEND_TEMP 220 +#define HIPS_PREHEAT_HPB_TEMP 100 +#define HIPS_PREHEAT_FAN_SPEED 0 + +#define PP_PREHEAT_HOTEND_TEMP 254 +#define PP_PREHEAT_HPB_TEMP 100 +#define PP_PREHEAT_FAN_SPEED 0 + +#define PET_PREHEAT_HOTEND_TEMP 230 +#define PET_PREHEAT_HPB_TEMP 85 +#define PET_PREHEAT_FAN_SPEED 0 + +#define FLEX_PREHEAT_HOTEND_TEMP 240 +#define FLEX_PREHEAT_HPB_TEMP 50 +#define FLEX_PREHEAT_FAN_SPEED 0 + +/*------------------------------------ + THERMISTORS SETTINGS + *------------------------------------*/ + +// +//--NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table +// +//// Temperature sensor settings: +// -2 is thermocouple with MAX6675 (only for sensor 0) +// -1 is thermocouple with AD595 +// 0 is not used +// 1 is 100k thermistor - best choice for EPCOS 100k (4.7k pullup) +// 2 is 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup) +// 3 is Mendel-parts thermistor (4.7k pullup) +// 4 is 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !! +// 5 is 100K thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (4.7k pullup) +// 6 is 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup) +// 7 is 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup) +// 71 is 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup) +// 8 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) +// 9 is 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup) +// 10 is 100k RS thermistor 198-961 (4.7k pullup) +// 11 is 100k beta 3950 1% thermistor (4.7k pullup) +// 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) +// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" +// 20 is the PT100 circuit found in the Ultimainboard V2.x +// 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 +// +// 1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k +// (but gives greater accuracy and more stable PID) +// 51 is 100k thermistor - EPCOS (1k pullup) +// 52 is 200k thermistor - ATC Semitec 204GT-2 (1k pullup) +// 55 is 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (1k pullup) +// +// 1047 is Pt1000 with 4k7 pullup +// 1010 is Pt1000 with 1k pullup (non standard) +// 147 is Pt100 with 4k7 pullup +// 148 is E3D Pt100 with 4k7 pullup and no PT100 Amplifier on a MiniRambo 1.3a +// 247 is Pt100 with 4k7 pullup and PT100 Amplifier +// 110 is Pt100 with 1k pullup (non standard) + +#if defined(E3D_PT100_EXTRUDER_WITH_AMP) +#define TEMP_SENSOR_0 247 +#elif defined(E3D_PT100_EXTRUDER_NO_AMP) +#define TEMP_SENSOR_0 148 +#else +#define TEMP_SENSOR_0 5 +#endif +#define TEMP_SENSOR_1 0 +#define TEMP_SENSOR_2 0 +#if defined(E3D_PT100_BED_WITH_AMP) +#define TEMP_SENSOR_BED 247 +#elif defined(E3D_PT100_BED_NO_AMP) +#define TEMP_SENSOR_BED 148 +#else +#define TEMP_SENSOR_BED 1 +#endif +#define TEMP_SENSOR_PINDA 1 + +#define STACK_GUARD_TEST_VALUE 0xA2A2 + +#define MAX_BED_TEMP_CALIBRATION 50 +#define MAX_HOTEND_TEMP_CALIBRATION 50 + +#define MAX_E_STEPS_PER_UNIT 250 +#define MIN_E_STEPS_PER_UNIT 100 + +#define Z_BABYSTEP_MIN -3999 +#define Z_BABYSTEP_MAX 0 + +#define PINDA_PREHEAT_X 20 +#define PINDA_PREHEAT_Y 60 +#define PINDA_PREHEAT_Z 0.15 +/* +#define PINDA_PREHEAT_X 70 +#define PINDA_PREHEAT_Y -3 +#define PINDA_PREHEAT_Z 1*/ +#define PINDA_HEAT_T 120 //time in s + +#define PINDA_MIN_T 50 +#define PINDA_STEP_T 10 +#define PINDA_MAX_T 100 + +#define PING_TIME 60 //time in s +#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid 0 triggering when dealing with long gcodes +#define PING_ALLERT_PERIOD 60 //time in s + +#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring +#define NC_BUTTON_LONG_PRESS 15 //time in s + +#define LONG_PRESS_TIME 1000 //time in ms for button long press +#define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release + +#define DEFAULT_PID_TEMP 210 + +#define MIN_PRINT_FAN_SPEED 75 + + +#define M600_TIMEOUT 600 //seconds + +//#define SUPPORT_VERBOSITY + +#define MMU_REQUIRED_FW_BUILDNR 132 +//#define MMU_DEBUG //print communication between MMU2 and printer on serial + +#define MMU_IDLER_SENSOR_ATTEMPTS_NR 21 //max. number of attempts to load filament if first load failed; value for max bowden length and case when loading fails right at the beginning + +#endif //__CONFIGURATION_PRUSA_H diff --git a/Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h new file mode 100644 index 000000000..e786b70ff --- /dev/null +++ b/Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h @@ -0,0 +1,506 @@ +#ifndef CONFIGURATION_PRUSA_H +#define CONFIGURATION_PRUSA_H + +#include +/*------------------------------------ + GENERAL SETTINGS + *------------------------------------*/ + +// Printer revision +#define PRINTER_TYPE PRINTER_MK25S +#define FILAMENT_SIZE "1_75mm_MK25" +#define NOZZLE_TYPE "E3Dv6full" + +// Developer flag +#define DEVELOPER + +// Printer name +#define CUSTOM_MENDEL_NAME "Prusa i3 MK2.5S" + +// Electronics +#define MOTHERBOARD BOARD_RAMBO_MINI_1_3 + +#define HEATBED_V2 +#define STEEL_SHEET +#define TACH0PULLUP + +// Uncomment the below for the E3D PT100 temperature sensor (with or without PT100 Amplifier) +//#define E3D_PT100_EXTRUDER_WITH_AMP +//#define E3D_PT100_EXTRUDER_NO_AMP +//#define E3D_PT100_BED_WITH_AMP +//#define E3D_PT100_BED_NO_AMP + + +/*------------------------------------ + AXIS SETTINGS + *------------------------------------*/ + +// Steps per unit {X,Y,Z,E} +#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,133} + +// Endstop inverting +#define X_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop. +#define Y_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop. +#define Z_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop. + +// Direction inverting +#define INVERT_X_DIR 0 // for Mendel set to 0, for Orca set to 1 +#define INVERT_Y_DIR 0 // for Mendel set to 1, for Orca set to 0 +#define INVERT_Z_DIR 0 // for Mendel set to 0, for Orca set to 1 +#define INVERT_E0_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0 +#define INVERT_E1_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0 +#define INVERT_E2_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0 + +// Home position +#define MANUAL_X_HOME_POS 0 +#define MANUAL_Y_HOME_POS -2.2 +#define MANUAL_Z_HOME_POS 0.2 + +// Travel limits after homing +#define X_MAX_POS 250 +#define X_MIN_POS 0 +#define Y_MAX_POS 210 +#define Y_MIN_POS -4 +#define Z_MAX_POS 210 +#define Z_MIN_POS 0.15 + +// Canceled home position +#define X_CANCEL_POS 50 +#define Y_CANCEL_POS 190 + +//Pause print position +#define X_PAUSE_POS 50 +#define Y_PAUSE_POS 190 +#define Z_PAUSE_LIFT 20 + +#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E +#define HOMING_FEEDRATE {3000, 3000, 800, 0} // set the homing speeds (mm/min) // 3000 is also valid for stallGuard homing. Valid range: 2200 - 3000 + +/** + * [0,0] steel sheet print area point X coordinate in bed print area coordinates + */ +#define SHEET_PRINT_ZERO_REF_X 0.f +/** + * [0,0] steel sheet print area point Y coordinate in bed print area coordinates + */ +#define SHEET_PRINT_ZERO_REF_Y 0.f + +#define DEFAULT_MAX_FEEDRATE {200, 200, 12, 120} // (mm/sec) max feedrate (M203) +#define DEFAULT_MAX_FEEDRATE_SILENT {172, 172, 12, 120} // (mm/sec) max feedrate (M203), silent mode +#define DEFAULT_MAX_ACCELERATION {1000, 1000, 200, 5000} // (mm/sec^2) max acceleration (M201) +#define DEFAULT_MAX_ACCELERATION_SILENT {960, 960, 200, 5000} // (mm/sec^2) max acceleration (M201), silent mode + + +#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204S) +#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts (M204T) + +#define MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min) + +//number of bytes from end of the file to start check +#define END_FILE_SECTION 20000 + +#define Z_AXIS_ALWAYS_ON 1 + +// New XYZ calibration +#define NEW_XYZCAL + +// Fan check +#define FANCHECK + +// Safety timer +#define SAFETYTIMER +#define DEFAULT_SAFETYTIMER_TIME_MINS 30 + +// Filament sensor +#define FILAMENT_SENSOR +#define IR_SENSOR + + +#define DEBUG_DCODE3 + +//#define DEBUG_BUILD +#ifdef DEBUG_BUILD +//#define _NO_ASM +#define DEBUG_DCODES //D codes +#define DEBUG_STACK_MONITOR //Stack monitor in stepper ISR +//#define DEBUG_FSENSOR_LOG //Reports fsensor status to serial +//#define DEBUG_CRASHDET_COUNTERS //Display crash-detection counters on LCD +//#define DEBUG_RESUME_PRINT //Resume/save print debug enable +//#define DEBUG_UVLO_AUTOMATIC_RECOVER // Power panic automatic recovery debug output +//#define DEBUG_DISABLE_XMINLIMIT //x min limit ignored +//#define DEBUG_DISABLE_XMAXLIMIT //x max limit ignored +//#define DEBUG_DISABLE_YMINLIMIT //y min limit ignored +//#define DEBUG_DISABLE_YMAXLIMIT //y max limit ignored +//#define DEBUG_DISABLE_ZMINLIMIT //z min limit ignored +//#define DEBUG_DISABLE_ZMAXLIMIT //z max limit ignored +//#define DEBUG_DISABLE_STARTMSGS //no startup messages +//#define DEBUG_DISABLE_MINTEMP //mintemp error ignored +//#define DEBUG_DISABLE_SWLIMITS //sw limits ignored +//#define DEBUG_DISABLE_LCD_STATUS_LINE //empty four lcd line +//#define DEBUG_DISABLE_PREVENT_EXTRUDER //cold extrusion and long extrusion allowed +//#define DEBUG_DISABLE_PRUSA_STATISTICS //disable prusa_statistics() mesages +//#define DEBUG_XSTEP_DUP_PIN 21 //duplicate x-step output to pin 21 (SCL on P3) +//#define DEBUG_YSTEP_DUP_PIN 21 //duplicate y-step output to pin 21 (SCL on P3) +//#define DEBUG_DISABLE_FANCHECK //disable fan check (no ISR INT7, check disabled) +//#define DEBUG_DUMP_TO_2ND_SERIAL //dump received characters to 2nd serial line +//#define DEBUG_STEPPER_TIMER_MISSED // Stop on stepper timer overflow, beep and display a message. +//#define PLANNER_DIAGNOSTICS // Show the planner queue status on printer display. +//#define CMD_DIAGNOSTICS //Show cmd queue length on printer display +#endif /* DEBUG_BUILD */ + +//#define FSENSOR_QUALITY + + +/*------------------------------------ + EXTRUDER SETTINGS + *------------------------------------*/ + +// Mintemps +#define HEATER_0_MINTEMP 30 +#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) +#define HEATER_0_MAXTEMP 410 +#else +#define HEATER_0_MAXTEMP 305 +#endif +#define HEATER_1_MAXTEMP 305 +#define HEATER_2_MAXTEMP 305 +#define BED_MAXTEMP 125 + +#if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) +// Define PID constants for extruder with PT100 +#define DEFAULT_Kp 21.70 +#define DEFAULT_Ki 1.60 +#define DEFAULT_Kd 73.76 +#else +// Define PID constants for extruder +//#define DEFAULT_Kp 40.925 +//#define DEFAULT_Ki 4.875 +//#define DEFAULT_Kd 86.085 +#define DEFAULT_Kp 16.13 +#define DEFAULT_Ki 1.1625 +#define DEFAULT_Kd 56.23 +#endif + +// Extrude mintemp +#define EXTRUDE_MINTEMP 175 + +// Extruder cooling fans +#define EXTRUDER_0_AUTO_FAN_PIN 8 +#define EXTRUDER_1_AUTO_FAN_PIN -1 +#define EXTRUDER_2_AUTO_FAN_PIN -1 +#define EXTRUDER_AUTO_FAN_TEMPERATURE 50 +#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed + + +/*------------------------------------ + LOAD/UNLOAD FILAMENT SETTINGS + *------------------------------------*/ + +// Load filament commands +#define LOAD_FILAMENT_0 "M83" +#define LOAD_FILAMENT_1 "G1 E70 F400" +#define LOAD_FILAMENT_2 "G1 E40 F100" + +// Unload filament commands +#define UNLOAD_FILAMENT_0 "M83" +#define UNLOAD_FILAMENT_1 "G1 E-80 F7000" + +/*------------------------------------ + CHANGE FILAMENT SETTINGS + *------------------------------------*/ + +// Filament change configuration +#define FILAMENTCHANGEENABLE +#ifdef FILAMENTCHANGEENABLE +#define FILAMENTCHANGE_XPOS 211 +#define FILAMENTCHANGE_YPOS 0 +#define FILAMENTCHANGE_ZADD 2 +#define FILAMENTCHANGE_FIRSTRETRACT -2 +#define FILAMENTCHANGE_FINALRETRACT -80 + +#define FILAMENTCHANGE_FIRSTFEED 70 //E distance in mm for fast filament loading sequence used used in filament change (M600) +#define FILAMENTCHANGE_FINALFEED 25 //E distance in mm for slow filament loading sequence used used in filament change (M600) and filament load (M701) +#define FILAMENTCHANGE_RECFEED 5 + +#define FILAMENTCHANGE_XYFEED 50 +#define FILAMENTCHANGE_EFEED_FIRST 20 // feedrate in mm/s for fast filament loading sequence used in filament change (M600) +#define FILAMENTCHANGE_EFEED_FINAL 3.3f // feedrate in mm/s for slow filament loading sequence used in filament change (M600) and filament load (M701) +//#define FILAMENTCHANGE_RFEED 400 +#define FILAMENTCHANGE_RFEED 7000 / 60 +#define FILAMENTCHANGE_EXFEED 2 +#define FILAMENTCHANGE_ZFEED 15 + +#endif + +/*------------------------------------ + ADDITIONAL FEATURES SETTINGS + *------------------------------------*/ + +// Define Prusa filament runout sensor +//#define FILAMENT_RUNOUT_SUPPORT + +#ifdef FILAMENT_RUNOUT_SUPPORT +#define FILAMENT_RUNOUT_SENSOR 1 +#endif + +// temperature runaway +#define TEMP_RUNAWAY_BED_HYSTERESIS 5 +#define TEMP_RUNAWAY_BED_TIMEOUT 360 + +#define TEMP_RUNAWAY_EXTRUDER_HYSTERESIS 15 +#define TEMP_RUNAWAY_EXTRUDER_TIMEOUT 45 + +/*------------------------------------ + MOTOR CURRENT SETTINGS + *------------------------------------*/ + +// Motor Current setting for BIG RAMBo +#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +#define DIGIPOT_MOTOR_CURRENT_LOUD {135,135,135,135,135} + +// Motor Current settings for RAMBo mini PWM value = MotorCurrentSetting * 255 / range +#if MOTHERBOARD == BOARD_RAMBO_MINI_1_0 || MOTHERBOARD == BOARD_RAMBO_MINI_1_3 +#define MOTOR_CURRENT_PWM_RANGE 2000 +#define DEFAULT_PWM_MOTOR_CURRENT {270, 830, 450} // {XY,Z,E} +#define DEFAULT_PWM_MOTOR_CURRENT_LOUD {540, 830, 500} // {XY,Z,E} +#define Z_SILENT 0 +#define Z_HIGH_POWER 200 +#endif + +/*------------------------------------ + BED SETTINGS + *------------------------------------*/ + +// Define Mesh Bed Leveling system to enable it +#define MESH_BED_LEVELING +#ifdef MESH_BED_LEVELING + +#define MBL_Z_STEP 0.01 + +// Mesh definitions +#define MESH_MIN_X 35 +#define MESH_MAX_X 238 +#define MESH_MIN_Y 6 +#define MESH_MAX_Y 202 + +// Mesh upsample definition +#define MESH_NUM_X_POINTS 7 +#define MESH_NUM_Y_POINTS 7 +// Mesh measure definition +#define MESH_MEAS_NUM_X_POINTS 3 +#define MESH_MEAS_NUM_Y_POINTS 3 + +// Maximum bed level correction value +#define BED_ADJUSTMENT_UM_MAX 100 + +#define MESH_HOME_Z_CALIB 0.2 +#define MESH_HOME_Z_SEARCH 5 //Z lift for homing, mesh bed leveling etc. + +#define X_PROBE_OFFSET_FROM_EXTRUDER 23 // Z probe to nozzle X offset: -left +right +#define Y_PROBE_OFFSET_FROM_EXTRUDER 5 // Z probe to nozzle Y offset: -front +behind +#define Z_PROBE_OFFSET_FROM_EXTRUDER -0.4 // Z probe to nozzle Z offset: -below (always!) +#endif + +// Bed Temperature Control +// Select PID or bang-bang with PIDTEMPBED. If bang-bang, BED_LIMIT_SWITCHING will enable hysteresis +// +// Uncomment this to enable PID on the bed. It uses the same frequency PWM as the extruder. +// If your PID_dT above is the default, and correct for your hardware/configuration, that means 7.689Hz, +// which is fine for driving a square wave into a resistive load and does not significantly impact you FET heating. +// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater. +// If your configuration is significantly different than this and you don't understand the issues involved, you probably +// shouldn't use bed PID until someone else verifies your hardware works. +// If this is enabled, find your own PID constants below. +#define PIDTEMPBED +// +//#define BED_LIMIT_SWITCHING + +// This sets the max power delivered to the bed, and replaces the HEATER_BED_DUTY_CYCLE_DIVIDER option. +// 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 + +// Bed temperature compensation settings +#define BED_OFFSET 10 +#define BED_OFFSET_START 40 +#define BED_OFFSET_CENTER 50 + + +#ifdef PIDTEMPBED +//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) +//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) +#if defined(E3D_PT100_BED_WITH_AMP) || defined(E3D_PT100_BED_NO_AMP) +// Define PID constants for extruder with PT100 +#define DEFAULT_bedKp 21.70 +#define DEFAULT_bedKi 1.60 +#define DEFAULT_bedKd 73.76 +#else +#define DEFAULT_bedKp 126.13 +#define DEFAULT_bedKi 4.30 +#define DEFAULT_bedKd 924.76 +#endif + +//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) +//from pidautotune +// #define DEFAULT_bedKp 97.1 +// #define DEFAULT_bedKi 1.41 +// #define DEFAULT_bedKd 1675.16 + +// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles. +#endif // PIDTEMPBED + + +/*----------------------------------- + PREHEAT SETTINGS + *------------------------------------*/ + +#define FARM_PREHEAT_HOTEND_TEMP 250 +#define FARM_PREHEAT_HPB_TEMP 40 +#define FARM_PREHEAT_FAN_SPEED 0 + +#define PLA_PREHEAT_HOTEND_TEMP 215 +#define PLA_PREHEAT_HPB_TEMP 60 +#define PLA_PREHEAT_FAN_SPEED 0 + +#define ABS_PREHEAT_HOTEND_TEMP 255 +#define ABS_PREHEAT_HPB_TEMP 100 +#define ABS_PREHEAT_FAN_SPEED 0 + +#define HIPS_PREHEAT_HOTEND_TEMP 220 +#define HIPS_PREHEAT_HPB_TEMP 100 +#define HIPS_PREHEAT_FAN_SPEED 0 + +#define PP_PREHEAT_HOTEND_TEMP 254 +#define PP_PREHEAT_HPB_TEMP 100 +#define PP_PREHEAT_FAN_SPEED 0 + +#define PET_PREHEAT_HOTEND_TEMP 230 +#define PET_PREHEAT_HPB_TEMP 85 +#define PET_PREHEAT_FAN_SPEED 0 + +#define FLEX_PREHEAT_HOTEND_TEMP 240 +#define FLEX_PREHEAT_HPB_TEMP 50 +#define FLEX_PREHEAT_FAN_SPEED 0 + +/*------------------------------------ + THERMISTORS SETTINGS + *------------------------------------*/ + +// +//--NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table +// +//// Temperature sensor settings: +// -2 is thermocouple with MAX6675 (only for sensor 0) +// -1 is thermocouple with AD595 +// 0 is not used +// 1 is 100k thermistor - best choice for EPCOS 100k (4.7k pullup) +// 2 is 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup) +// 3 is Mendel-parts thermistor (4.7k pullup) +// 4 is 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !! +// 5 is 100K thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (4.7k pullup) +// 6 is 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup) +// 7 is 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup) +// 71 is 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup) +// 8 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) +// 9 is 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup) +// 10 is 100k RS thermistor 198-961 (4.7k pullup) +// 11 is 100k beta 3950 1% thermistor (4.7k pullup) +// 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) +// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" +// 20 is the PT100 circuit found in the Ultimainboard V2.x +// 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 +// +// 1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k +// (but gives greater accuracy and more stable PID) +// 51 is 100k thermistor - EPCOS (1k pullup) +// 52 is 200k thermistor - ATC Semitec 204GT-2 (1k pullup) +// 55 is 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (1k pullup) +// +// 1047 is Pt1000 with 4k7 pullup +// 1010 is Pt1000 with 1k pullup (non standard) +// 147 is Pt100 with 4k7 pullup +// 148 is E3D Pt100 with 4k7 pullup and no PT100 Amplifier on a MiniRambo 1.3a +// 247 is Pt100 with 4k7 pullup and PT100 Amplifier +// 110 is Pt100 with 1k pullup (non standard) + +#if defined(E3D_PT100_EXTRUDER_WITH_AMP) +#define TEMP_SENSOR_0 247 +#elif defined(E3D_PT100_EXTRUDER_NO_AMP) +#define TEMP_SENSOR_0 148 +#else +#define TEMP_SENSOR_0 5 +#endif +#define TEMP_SENSOR_1 0 +#define TEMP_SENSOR_2 0 +#if defined(E3D_PT100_BED_WITH_AMP) +#define TEMP_SENSOR_BED 247 +#elif defined(E3D_PT100_BED_NO_AMP) +#define TEMP_SENSOR_BED 148 +#else +#define TEMP_SENSOR_BED 1 +#endif +#define TEMP_SENSOR_PINDA 1 + +#define STACK_GUARD_TEST_VALUE 0xA2A2 + +#define MAX_BED_TEMP_CALIBRATION 50 +#define MAX_HOTEND_TEMP_CALIBRATION 50 + +#define MAX_E_STEPS_PER_UNIT 250 +#define MIN_E_STEPS_PER_UNIT 100 + +#define Z_BABYSTEP_MIN -3999 +#define Z_BABYSTEP_MAX 0 + +#define PINDA_PREHEAT_X 20 +#define PINDA_PREHEAT_Y 60 +#define PINDA_PREHEAT_Z 0.15 +/* +#define PINDA_PREHEAT_X 70 +#define PINDA_PREHEAT_Y -3 +#define PINDA_PREHEAT_Z 1*/ +#define PINDA_HEAT_T 120 //time in s + +#define PINDA_MIN_T 50 +#define PINDA_STEP_T 10 +#define PINDA_MAX_T 100 + +#define PING_TIME 60 //time in s +#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid 0 triggering when dealing with long gcodes +#define PING_ALLERT_PERIOD 60 //time in s + +#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring +#define NC_BUTTON_LONG_PRESS 15 //time in s + +#define LONG_PRESS_TIME 1000 //time in ms for button long press +#define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release + +#define DEFAULT_PID_TEMP 210 + +#define MIN_PRINT_FAN_SPEED 75 + + +#define M600_TIMEOUT 600 //seconds + +//#define SUPPORT_VERBOSITY + +#define MMU_REQUIRED_FW_BUILDNR 132 +//#define MMU_DEBUG //print communication between MMU2 and printer on serial + +#define MMU_IDLER_SENSOR_ATTEMPTS_NR 21 //max. number of attempts to load filament if first load failed; value for max bowden length and case when loading fails right at the beginning + +#endif //__CONFIGURATION_PRUSA_H diff --git a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h new file mode 100644 index 000000000..37512071c --- /dev/null +++ b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h @@ -0,0 +1,631 @@ +#ifndef CONFIGURATION_PRUSA_H +#define CONFIGURATION_PRUSA_H + +#include +/*------------------------------------ + GENERAL SETTINGS + *------------------------------------*/ + +// Printer revision +#define PRINTER_TYPE PRINTER_MK3S +#define FILAMENT_SIZE "1_75mm_MK3" +#define NOZZLE_TYPE "E3Dv6full" + +// Developer flag +#define DEVELOPER + +// Printer name +#define CUSTOM_MENDEL_NAME "Prusa i3 MK3S" + +// Electronics +#define MOTHERBOARD BOARD_EINSY_1_0a +#define STEEL_SHEET +#define HAS_SECOND_SERIAL_PORT + + +// Uncomment the below for the E3D PT100 temperature sensor (with or without PT100 Amplifier) +//#define E3D_PT100_EXTRUDER_WITH_AMP +//#define E3D_PT100_EXTRUDER_NO_AMP +//#define E3D_PT100_BED_WITH_AMP +//#define E3D_PT100_BED_NO_AMP + + +/*------------------------------------ + AXIS SETTINGS + *------------------------------------*/ + +// Steps per unit {X,Y,Z,E} +//#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,140} +#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,280} +//#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,560} + +// Endstop inverting +#define X_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop. +#define Y_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop. +#define Z_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop. + +// Direction inverting +#define INVERT_X_DIR 1 // for Mendel set to 0, for Orca set to 1 +#define INVERT_Y_DIR 0 // for Mendel set to 1, for Orca set to 0 +#define INVERT_Z_DIR 1 // for Mendel set to 0, for Orca set to 1 +#define INVERT_E0_DIR 0 // for direct drive extruder v9 set to 1, for geared extruder set to 0 +#define INVERT_E1_DIR 0 // for direct drive extruder v9 set to 1, for geared extruder set to 0 +#define INVERT_E2_DIR 0 // for direct drive extruder v9 set to 1, for geared extruder set to 0 + +// Home position +#define MANUAL_X_HOME_POS 0 +#define MANUAL_Y_HOME_POS -2.2 +#define MANUAL_Z_HOME_POS 0.2 + +// Travel limits after homing +#define X_MAX_POS 255 +#define X_MIN_POS 0 +#define Y_MAX_POS 212.5 +#define Y_MIN_POS -4 //orig -4 +#define Z_MAX_POS 210 +#define Z_MIN_POS 0.15 + +// Canceled home position +#define X_CANCEL_POS 50 +#define Y_CANCEL_POS 190 + +//Pause print position +#define X_PAUSE_POS 50 +#define Y_PAUSE_POS 190 +#define Z_PAUSE_LIFT 20 + +#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E +#define HOMING_FEEDRATE {3000, 3000, 800, 0} // set the homing speeds (mm/min) // 3000 is also valid for stallGuard homing. Valid range: 2200 - 3000 + +//#define DEFAULT_Y_OFFSET 4.f // Default distance of Y_MIN_POS point from endstop, when the printer is not calibrated. +/** + * [0,0] steel sheet print area point X coordinate in bed print area coordinates + */ +#define SHEET_PRINT_ZERO_REF_X 0.f +/** + * [0,0] steel sheet print area point Y coordinate in bed print area coordinates + */ +#define SHEET_PRINT_ZERO_REF_Y -2.f + +#define DEFAULT_MAX_FEEDRATE {200, 200, 12, 120} // (mm/sec) max feedrate (M203) +#define DEFAULT_MAX_FEEDRATE_SILENT {100, 100, 12, 120} // (mm/sec) max feedrate (M203), silent mode + +#define DEFAULT_MAX_ACCELERATION {1000, 1000, 200, 5000} // (mm/sec^2) max acceleration (M201) +#define DEFAULT_MAX_ACCELERATION_SILENT {960, 960, 200, 5000} // (mm/sec^2) max acceleration (M201), silent mode + + +#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204S) +#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts (M204T) + +#define MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min) + +//Silent mode limits +#define SILENT_MAX_ACCEL_XY 960ul // max acceleration in silent mode in mm/s^2 +#define SILENT_MAX_FEEDRATE_XY 100 // max feedrate in mm/s + +//Normal mode limits +#define NORMAL_MAX_ACCEL_XY 2500ul // max acceleration in normal mode in mm/s^2 +#define NORMAL_MAX_FEEDRATE_XY 200 // max feedrate in mm/s + +//number of bytes from end of the file to start check +#define END_FILE_SECTION 20000 + +#define Z_AXIS_ALWAYS_ON 1 + +//Crash detection +#define CRASHDET_TIMER 45 //seconds +#define CRASHDET_COUNTER_MAX 3 + +// New XYZ calibration +#define NEW_XYZCAL + +// Watchdog support +#define WATCHDOG + +// Power panic +#define UVLO_SUPPORT + +// Fan check +#define FANCHECK + +// Safety timer +#define SAFETYTIMER +#define DEFAULT_SAFETYTIMER_TIME_MINS 30 + +// Filament sensor +#define FILAMENT_SENSOR +#define IR_SENSOR + +// Backlash - +//#define BACKLASH_X +//#define BACKLASH_Y + + +// Minimum ambient temperature limit to start triggering MINTEMP errors [C] +// this value is litlebit higher that real limit, because ambient termistor is on the board and is temperated from it, +// temperature inside the case is around 31C for ambient temperature 25C, when the printer is powered on long time and idle +// the real limit is 15C (same as MINTEMP limit), this is because 15C is end of scale for both used thermistors (bed, heater) +#define MINTEMP_MINAMBIENT 25 +#define MINTEMP_MINAMBIENT_RAW 978 + +#define DEBUG_DCODE3 + +//#define DEBUG_BUILD +//#define DEBUG_SEC_LANG //secondary language debug output at startup +//#define DEBUG_W25X20CL //debug external spi flash +#ifdef DEBUG_BUILD +//#define _NO_ASM +#define DEBUG_DCODES //D codes +#define DEBUG_STACK_MONITOR //Stack monitor in stepper ISR +//#define DEBUG_FSENSOR_LOG //Reports fsensor status to serial +//#define DEBUG_CRASHDET_COUNTERS //Display crash-detection counters on LCD +//#define DEBUG_RESUME_PRINT //Resume/save print debug enable +//#define DEBUG_UVLO_AUTOMATIC_RECOVER // Power panic automatic recovery debug output +//#define DEBUG_DISABLE_XMINLIMIT //x min limit ignored +//#define DEBUG_DISABLE_XMAXLIMIT //x max limit ignored +//#define DEBUG_DISABLE_YMINLIMIT //y min limit ignored +//#define DEBUG_DISABLE_YMAXLIMIT //y max limit ignored +//#define DEBUG_DISABLE_ZMINLIMIT //z min limit ignored +//#define DEBUG_DISABLE_ZMAXLIMIT //z max limit ignored +#define DEBUG_DISABLE_STARTMSGS //no startup messages +//#define DEBUG_DISABLE_MINTEMP //mintemp error ignored +//#define DEBUG_DISABLE_SWLIMITS //sw limits ignored +//#define DEBUG_DISABLE_LCD_STATUS_LINE //empty four lcd line +//#define DEBUG_DISABLE_PREVENT_EXTRUDER //cold extrusion and long extrusion allowed +//#define DEBUG_DISABLE_PRUSA_STATISTICS //disable prusa_statistics() mesages +//#define DEBUG_DISABLE_FORCE_SELFTEST //disable force selftest +//#define DEBUG_XSTEP_DUP_PIN 21 //duplicate x-step output to pin 21 (SCL on P3) +//#define DEBUG_YSTEP_DUP_PIN 21 //duplicate y-step output to pin 21 (SCL on P3) +//#define DEBUG_DISABLE_FANCHECK //disable fan check (no ISR INT7, check disabled) +//#define DEBUG_DISABLE_FSENSORCHECK //disable fsensor check (no ISR INT7, check disabled) +#define DEBUG_DUMP_TO_2ND_SERIAL //dump received characters to 2nd serial line +#define DEBUG_STEPPER_TIMER_MISSED // Stop on stepper timer overflow, beep and display a message. +#define PLANNER_DIAGNOSTICS // Show the planner queue status on printer display. +#define CMD_DIAGNOSTICS //Show cmd queue length on printer display +#endif /* DEBUG_BUILD */ + +//#define FSENSOR_QUALITY + + +#define LINEARITY_CORRECTION +#define TMC2130_LINEARITY_CORRECTION +#define TMC2130_LINEARITY_CORRECTION_XYZ +//#define TMC2130_VARIABLE_RESOLUTION + + + +/*------------------------------------ + TMC2130 default settings + *------------------------------------*/ + +#define TMC2130_FCLK 12000000 // fclk = 12MHz + +#define TMC2130_USTEPS_XY 16 // microstep resolution for XY axes +#define TMC2130_USTEPS_Z 16 // microstep resolution for Z axis +#define TMC2130_USTEPS_E 32 // microstep resolution for E axis +#define TMC2130_INTPOL_XY 1 // extrapolate 256 for XY axes +#define TMC2130_INTPOL_Z 1 // extrapolate 256 for Z axis +#define TMC2130_INTPOL_E 1 // extrapolate 256 for E axis + +#define TMC2130_PWM_GRAD_X 2 // PWMCONF +#define TMC2130_PWM_AMPL_X 230 // PWMCONF +#define TMC2130_PWM_AUTO_X 1 // PWMCONF +#define TMC2130_PWM_FREQ_X 2 // PWMCONF + +#define TMC2130_PWM_GRAD_Y 2 // PWMCONF +#define TMC2130_PWM_AMPL_Y 235 // PWMCONF +#define TMC2130_PWM_AUTO_Y 1 // PWMCONF +#define TMC2130_PWM_FREQ_Y 2 // PWMCONF + +#define TMC2130_PWM_GRAD_Z 4 // PWMCONF +#define TMC2130_PWM_AMPL_Z 200 // PWMCONF +#define TMC2130_PWM_AUTO_Z 1 // PWMCONF +#define TMC2130_PWM_FREQ_Z 2 // PWMCONF + +#define TMC2130_PWM_GRAD_E 4 // PWMCONF +#define TMC2130_PWM_AMPL_E 240 // PWMCONF +#define TMC2130_PWM_AUTO_E 1 // PWMCONF +#define TMC2130_PWM_FREQ_E 2 // PWMCONF + +#define TMC2130_TOFF_XYZ 3 // CHOPCONF // fchop = 27.778kHz +#define TMC2130_TOFF_E 3 // CHOPCONF // fchop = 27.778kHz +//#define TMC2130_TOFF_E 4 // CHOPCONF // fchop = 21.429kHz +//#define TMC2130_TOFF_E 5 // CHOPCONF // fchop = 17.442kHz + +//#define TMC2130_STEALTH_E // Extruder stealthChop mode +//#define TMC2130_CNSTOFF_E // Extruder constant-off-time mode (similar to MK2) + +//#define TMC2130_PWM_DIV 683 // PWM frequency divider (1024, 683, 512, 410) +#define TMC2130_PWM_DIV 512 // PWM frequency divider (1024, 683, 512, 410) +#define TMC2130_PWM_CLK (2 * TMC2130_FCLK / TMC2130_PWM_DIV) // PWM frequency (23.4kHz, 35.1kHz, 46.9kHz, 58.5kHz for 12MHz fclk) + +#define TMC2130_TPWMTHRS 0 // TPWMTHRS - Sets the switching speed threshold based on TSTEP from stealthChop to spreadCycle mode +#define TMC2130_THIGH 0 // THIGH - unused + +//#define TMC2130_TCOOLTHRS_X 450 // TCOOLTHRS - coolstep treshold +//#define TMC2130_TCOOLTHRS_Y 450 // TCOOLTHRS - coolstep treshold +#define TMC2130_TCOOLTHRS_X 430 // TCOOLTHRS - coolstep treshold +#define TMC2130_TCOOLTHRS_Y 430 // TCOOLTHRS - coolstep treshold +#define TMC2130_TCOOLTHRS_Z 500 // TCOOLTHRS - coolstep treshold +#define TMC2130_TCOOLTHRS_E 500 // TCOOLTHRS - coolstep treshold + +#define TMC2130_SG_HOMING 1 // stallguard homing +#define TMC2130_SG_THRS_X 3 // stallguard sensitivity for X axis +#define TMC2130_SG_THRS_Y 3 // stallguard sensitivity for Y axis +#define TMC2130_SG_THRS_Z 4 // stallguard sensitivity for Z axis +#define TMC2130_SG_THRS_E 3 // stallguard sensitivity for E axis + +//new settings is possible for vsense = 1, running current value > 31 set vsense to zero and shift both currents by 1 bit right (Z axis only) +#define TMC2130_CURRENTS_H {16, 20, 35, 30} // default holding currents for all axes +#define TMC2130_CURRENTS_R {16, 20, 35, 30} // default running currents for all axes +#define TMC2130_UNLOAD_CURRENT_R 12 // lowe current for M600 to protect filament sensor + +#define TMC2130_STEALTH_Z + +//#define TMC2130_SERVICE_CODES_M910_M918 + +//#define TMC2130_DEBUG +//#define TMC2130_DEBUG_WR +//#define TMC2130_DEBUG_RD + + +/*------------------------------------ + EXTRUDER SETTINGS + *------------------------------------*/ + +// Mintemps +#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 +#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) +#define HEATER_0_MAXTEMP 410 +#else +#define HEATER_0_MAXTEMP 305 +#endif +#define HEATER_1_MAXTEMP 305 +#define HEATER_2_MAXTEMP 305 +#define BED_MAXTEMP 125 + +#if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) +// Define PID constants for extruder with PT100 +#define DEFAULT_Kp 21.70 +#define DEFAULT_Ki 1.60 +#define DEFAULT_Kd 73.76 +#else +// Define PID constants for extruder +//#define DEFAULT_Kp 40.925 +//#define DEFAULT_Ki 4.875 +//#define DEFAULT_Kd 86.085 +#define DEFAULT_Kp 16.13 +#define DEFAULT_Ki 1.1625 +#define DEFAULT_Kd 56.23 +#endif + +// Extrude mintemp +#define EXTRUDE_MINTEMP 175 + +// Extruder cooling fans +#define EXTRUDER_0_AUTO_FAN_PIN 8 +#define EXTRUDER_1_AUTO_FAN_PIN -1 +#define EXTRUDER_2_AUTO_FAN_PIN -1 +#define EXTRUDER_AUTO_FAN_TEMPERATURE 50 +#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed + + + +/*------------------------------------ + LOAD/UNLOAD FILAMENT SETTINGS + *------------------------------------*/ + +// Load filament commands +#define LOAD_FILAMENT_0 "M83" +#define LOAD_FILAMENT_1 "G1 E70 F400" +#define LOAD_FILAMENT_2 "G1 E40 F100" + +// Unload filament commands +#define UNLOAD_FILAMENT_0 "M83" +#define UNLOAD_FILAMENT_1 "G1 E-80 F7000" + +/*------------------------------------ + CHANGE FILAMENT SETTINGS + *------------------------------------*/ + +// Filament change configuration +#define FILAMENTCHANGEENABLE +#ifdef FILAMENTCHANGEENABLE +#define FILAMENTCHANGE_XPOS 211 +#define FILAMENTCHANGE_YPOS 0 +#define FILAMENTCHANGE_ZADD 2 +#define FILAMENTCHANGE_FIRSTRETRACT -2 +#define FILAMENTCHANGE_FINALRETRACT -80 + +#define FILAMENTCHANGE_FIRSTFEED 70 //E distance in mm for fast filament loading sequence used used in filament change (M600) +#define FILAMENTCHANGE_FINALFEED 25 //E distance in mm for slow filament loading sequence used used in filament change (M600) and filament load (M701) +#define FILAMENTCHANGE_RECFEED 5 + +#define FILAMENTCHANGE_XYFEED 50 +#define FILAMENTCHANGE_EFEED_FIRST 20 // feedrate in mm/s for fast filament loading sequence used in filament change (M600) +#define FILAMENTCHANGE_EFEED_FINAL 3.3f // feedrate in mm/s for slow filament loading sequence used in filament change (M600) and filament load (M701) +//#define FILAMENTCHANGE_RFEED 400 +#define FILAMENTCHANGE_RFEED 7000 / 60 +#define FILAMENTCHANGE_EXFEED 2 +#define FILAMENTCHANGE_ZFEED 15 + +#endif + +/*------------------------------------ + ADDITIONAL FEATURES SETTINGS + *------------------------------------*/ + +// Define Prusa filament runout sensor +//#define FILAMENT_RUNOUT_SUPPORT + +#ifdef FILAMENT_RUNOUT_SUPPORT +#define FILAMENT_RUNOUT_SENSOR 1 +#endif + +// temperature runaway +#define TEMP_RUNAWAY_BED_HYSTERESIS 5 +#define TEMP_RUNAWAY_BED_TIMEOUT 360 + +#define TEMP_RUNAWAY_EXTRUDER_HYSTERESIS 15 +#define TEMP_RUNAWAY_EXTRUDER_TIMEOUT 45 + +/*------------------------------------ + MOTOR CURRENT SETTINGS + *------------------------------------*/ + +// Motor Current settings for Einsy/tmc = 0..63 +#define MOTOR_CURRENT_PWM_RANGE 63 + +/*------------------------------------ + BED SETTINGS + *------------------------------------*/ + +// Define Mesh Bed Leveling system to enable it +#define MESH_BED_LEVELING +#ifdef MESH_BED_LEVELING + +#define MBL_Z_STEP 0.01 + +// Mesh definitions +#define MESH_MIN_X 35 +#define MESH_MAX_X 238 +#define MESH_MIN_Y 6 +#define MESH_MAX_Y 202 + +// Mesh upsample definition +#define MESH_NUM_X_POINTS 7 +#define MESH_NUM_Y_POINTS 7 +// Mesh measure definition +#define MESH_MEAS_NUM_X_POINTS 3 +#define MESH_MEAS_NUM_Y_POINTS 3 + +// Maximum bed level correction value +#define BED_ADJUSTMENT_UM_MAX 100 + +#define MESH_HOME_Z_CALIB 0.2 +#define MESH_HOME_Z_SEARCH 5 //Z lift for homing, mesh bed leveling etc. + +#define X_PROBE_OFFSET_FROM_EXTRUDER 23 // Z probe to nozzle X offset: -left +right +#define Y_PROBE_OFFSET_FROM_EXTRUDER 5 // Z probe to nozzle Y offset: -front +behind +#define Z_PROBE_OFFSET_FROM_EXTRUDER -0.4 // Z probe to nozzle Z offset: -below (always!) +#endif + +// Bed Temperature Control +// Select PID or bang-bang with PIDTEMPBED. If bang-bang, BED_LIMIT_SWITCHING will enable hysteresis +// +// Uncomment this to enable PID on the bed. It uses the same frequency PWM as the extruder. +// If your PID_dT above is the default, and correct for your hardware/configuration, that means 7.689Hz, +// which is fine for driving a square wave into a resistive load and does not significantly impact you FET heating. +// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater. +// If your configuration is significantly different than this and you don't understand the issues involved, you probably +// shouldn't use bed PID until someone else verifies your hardware works. +// If this is enabled, find your own PID constants below. +#define PIDTEMPBED +// +//#define BED_LIMIT_SWITCHING + +// This sets the max power delivered to the bed, and replaces the HEATER_BED_DUTY_CYCLE_DIVIDER option. +// 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 + +// Bed temperature compensation settings +#define BED_OFFSET 10 +#define BED_OFFSET_START 40 +#define BED_OFFSET_CENTER 50 + + +#ifdef PIDTEMPBED +//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) +//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) +#if defined(E3D_PT100_BED_WITH_AMP) || defined(E3D_PT100_BED_NO_AMP) +// Define PID constants for extruder with PT100 +#define DEFAULT_bedKp 21.70 +#define DEFAULT_bedKi 1.60 +#define DEFAULT_bedKd 73.76 +#else +#define DEFAULT_bedKp 126.13 +#define DEFAULT_bedKi 4.30 +#define DEFAULT_bedKd 924.76 +#endif + +//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) +//from pidautotune +// #define DEFAULT_bedKp 97.1 +// #define DEFAULT_bedKi 1.41 +// #define DEFAULT_bedKd 1675.16 + +// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles. +#endif // PIDTEMPBED + +//connect message when communication with monitoring broken +//#define FARM_CONNECT_MESSAGE + +/*----------------------------------- + PREHEAT SETTINGS + *------------------------------------*/ + +#define FARM_PREHEAT_HOTEND_TEMP 250 +#define FARM_PREHEAT_HPB_TEMP 60 +#define FARM_PREHEAT_FAN_SPEED 0 + +#define PLA_PREHEAT_HOTEND_TEMP 215 +#define PLA_PREHEAT_HPB_TEMP 60 +#define PLA_PREHEAT_FAN_SPEED 0 + +#define ABS_PREHEAT_HOTEND_TEMP 255 +#define ABS_PREHEAT_HPB_TEMP 100 +#define ABS_PREHEAT_FAN_SPEED 0 + +#define HIPS_PREHEAT_HOTEND_TEMP 220 +#define HIPS_PREHEAT_HPB_TEMP 100 +#define HIPS_PREHEAT_FAN_SPEED 0 + +#define PP_PREHEAT_HOTEND_TEMP 254 +#define PP_PREHEAT_HPB_TEMP 100 +#define PP_PREHEAT_FAN_SPEED 0 + +#define PET_PREHEAT_HOTEND_TEMP 230 +#define PET_PREHEAT_HPB_TEMP 85 +#define PET_PREHEAT_FAN_SPEED 0 + +#define FLEX_PREHEAT_HOTEND_TEMP 240 +#define FLEX_PREHEAT_HPB_TEMP 50 +#define FLEX_PREHEAT_FAN_SPEED 0 + +/*------------------------------------ + THERMISTORS SETTINGS + *------------------------------------*/ + +// +//--NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table +// +//// Temperature sensor settings: +// -2 is thermocouple with MAX6675 (only for sensor 0) +// -1 is thermocouple with AD595 +// 0 is not used +// 1 is 100k thermistor - best choice for EPCOS 100k (4.7k pullup) +// 2 is 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup) +// 3 is Mendel-parts thermistor (4.7k pullup) +// 4 is 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !! +// 5 is 100K thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (4.7k pullup) +// 6 is 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup) +// 7 is 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup) +// 71 is 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup) +// 8 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) +// 9 is 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup) +// 10 is 100k RS thermistor 198-961 (4.7k pullup) +// 11 is 100k beta 3950 1% thermistor (4.7k pullup) +// 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) +// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" +// 20 is the PT100 circuit found in the Ultimainboard V2.x +// 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 +// +// 1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k +// (but gives greater accuracy and more stable PID) +// 51 is 100k thermistor - EPCOS (1k pullup) +// 52 is 200k thermistor - ATC Semitec 204GT-2 (1k pullup) +// 55 is 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (1k pullup) +// +// 1047 is Pt1000 with 4k7 pullup +// 1010 is Pt1000 with 1k pullup (non standard) +// 147 is Pt100 with 4k7 pullup +// 148 is E3D Pt100 with 4k7 pullup and no PT100 Amplifier on a MiniRambo 1.3a +// 247 is Pt100 with 4k7 pullup and PT100 Amplifier +// 110 is Pt100 with 1k pullup (non standard) + +#if defined(E3D_PT100_EXTRUDER_WITH_AMP) +#define TEMP_SENSOR_0 247 +#elif defined(E3D_PT100_EXTRUDER_NO_AMP) +#define TEMP_SENSOR_0 148 +#else +#define TEMP_SENSOR_0 5 +#endif +#define TEMP_SENSOR_1 0 +#define TEMP_SENSOR_2 0 +#if defined(E3D_PT100_BED_WITH_AMP) +#define TEMP_SENSOR_BED 247 +#elif defined(E3D_PT100_BED_NO_AMP) +#define TEMP_SENSOR_BED 148 +#else +#define TEMP_SENSOR_BED 1 +#endif +#define TEMP_SENSOR_PINDA 1 +#define TEMP_SENSOR_AMBIENT 2000 + +#define STACK_GUARD_TEST_VALUE 0xA2A2 + +#define MAX_BED_TEMP_CALIBRATION 50 +#define MAX_HOTEND_TEMP_CALIBRATION 50 + +#define MAX_E_STEPS_PER_UNIT 250 +#define MIN_E_STEPS_PER_UNIT 100 + +#define Z_BABYSTEP_MIN -3999 +#define Z_BABYSTEP_MAX 0 + +#define PINDA_PREHEAT_X 20 +#define PINDA_PREHEAT_Y 60 +#define PINDA_PREHEAT_Z 0.15 +/* +#define PINDA_PREHEAT_X 70 +#define PINDA_PREHEAT_Y -3 +#define PINDA_PREHEAT_Z 1*/ +#define PINDA_HEAT_T 120 //time in s + +#define PINDA_MIN_T 50 +#define PINDA_STEP_T 10 +#define PINDA_MAX_T 100 + +#define PING_TIME 60 //time in s +#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid 0 triggering when dealing with long gcodes +#define PING_ALLERT_PERIOD 60 //time in s + +#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring +#define NC_BUTTON_LONG_PRESS 15 //time in s + +#define LONG_PRESS_TIME 1000 //time in ms for button long press +#define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release + +#define DEFAULT_PID_TEMP 210 + +#define MIN_PRINT_FAN_SPEED 75 + + +// How much shall the print head be lifted on power panic? +// Ideally the Z axis will reach a zero phase of the stepper driver on power outage. To simplify this, +// UVLO_Z_AXIS_SHIFT shall be an integer multiply of the stepper driver cycle, that is 4x full step. +// For example, the Prusa i3 MK2 with 16 microsteps per full step has Z stepping of 400 microsteps per mm. +// At 400 microsteps per mm, a full step lifts the Z axis by 0.04mm, and a stepper driver cycle is 0.16mm. +// The following example, 12 * (4 * 16 / 400) = 12 * 0.16mm = 1.92mm. +//#define UVLO_Z_AXIS_SHIFT 1.92 +#define UVLO_Z_AXIS_SHIFT 0.64 +// If power panic occured, and the current temperature is higher then target temperature before interrupt minus this offset, print will be recovered automatically. +#define AUTOMATIC_UVLO_BED_TEMP_OFFSET 5 + +#define HEATBED_V2 + +#define M600_TIMEOUT 600 //seconds + +//#define SUPPORT_VERBOSITY + +#define MMU_REQUIRED_FW_BUILDNR 83 +#define MMU_HWRESET +#define MMU_DEBUG //print communication between MMU2 and printer on serial +#define MMU_IDLER_SENSOR_ATTEMPTS_NR 21 //max. number of attempts to load filament if first load failed; value for max bowden length and case when loading fails right at the beginning + +#endif //__CONFIGURATION_PRUSA_H From 63c8a361853c45ad98c10dd4faf5fa4b38d632b7 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 6 Feb 2019 16:27:44 +0100 Subject: [PATCH 02/25] typo fixed --- Firmware/ultralcd.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 16b077dae..b26b1c96c 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -181,9 +181,9 @@ enum class testScreen static int lcd_selftest_screen(testScreen screen, int _progress, int _progress_scale, bool _clear, int _delay); static void lcd_selftest_screen_step(int _row, int _col, int _state, const char *_name, const char *_indicator); static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite); -#ifdef FAN_CHECK +#ifdef FANCHECK static bool lcd_selftest_fan_dialog(int _fan); -#endif //FAN_CHECk +#endif //FANCHECK 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); From de9c87c5925bf53e3f1f1dab43b0e53489dcf295 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 6 Feb 2019 19:38:52 +0100 Subject: [PATCH 03/25] welcome message changed --- Firmware/messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/messages.c b/Firmware/messages.c index 4cac4f2d0..7943d2208 100644 --- a/Firmware/messages.c +++ b/Firmware/messages.c @@ -96,7 +96,7 @@ const char MSG_WIZARD_DONE[] PROGMEM_I1 = ISTR("All is done. Happy printing!"); const char MSG_WIZARD_HEATING[] PROGMEM_I1 = ISTR("Preheating nozzle. Please wait."); ////c=20 r=3 const char MSG_WIZARD_QUIT[] PROGMEM_I1 = ISTR("You can always resume the Wizard from Calibration -> Wizard."); ////c=20 r=8 const char MSG_YES[] PROGMEM_I1 = ISTR("Yes"); ////c=0 r=0 -const char WELCOME_MSG[] PROGMEM_I1 = ISTR(CUSTOM_MENDEL_NAME " ready."); ////c=20 r=0 +const char WELCOME_MSG[] PROGMEM_I1 = ISTR(CUSTOM_MENDEL_NAME " OK."); ////c=20 r=0 //not internationalized messages const char MSG_SD_WORKDIR_FAIL[] PROGMEM_N1 = "workDir open failed"; ////c=0 r=0 const char MSG_BROWNOUT_RESET[] PROGMEM_N1 = " Brown out Reset"; ////c=0 r=0 From a85d8e7f97863c992cec6695998e4861619d7fe7 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 6 Feb 2019 21:36:21 +0100 Subject: [PATCH 04/25] message change --- Firmware/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index b26b1c96c..8c2b52813 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2264,7 +2264,7 @@ static void lcd_support_menu() MENU_ITEM_BACK_P(STR_SEPARATOR); MENU_ITEM_SUBMENU_P(_i("XYZ cal. details"), lcd_menu_xyz_y_min);////MSG_XYZ_DETAILS c=19 r=1 MENU_ITEM_SUBMENU_P(_i("Extruder info"), lcd_menu_extruder_info);////MSG_INFO_EXTRUDER c=18 r=1 - MENU_ITEM_SUBMENU_P(_i("Sensors info"), lcd_menu_show_sensors_state);////MSG_INFO_SENSORS c=18 r=1 + MENU_ITEM_SUBMENU_P(_i("Sensor info"), lcd_menu_show_sensors_state);////MSG_INFO_SENSORS c=18 r=1 #ifdef TMC2130 MENU_ITEM_SUBMENU_P(_i("Belt status"), lcd_menu_belt_status);////MSG_MENU_BELT_STATUS c=18 r=1 From ff52499bdc9839936e81fc0ea35b81c466953f9d Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 6 Feb 2019 22:56:10 +0100 Subject: [PATCH 05/25] extr fan RPM measuring fix --- Firmware/temperature.cpp | 7 +++++++ Firmware/ultralcd.cpp | 8 +++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 8dcfc9a9c..e156734b8 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -2070,10 +2070,17 @@ else { // ambient temperature is stan #if (defined(FANCHECK) && defined(TACH_0) && (TACH_0 > -1)) void check_fans() { +#ifdef FAN_SOFT_PWM + if (READ(TACH_0) != fan_state[0]) { + if(fan_measuring) fan_edge_counter[0] ++; + fan_state[0] = !fan_state[0]; + } +#else //FAN_SOFT_PWM if (READ(TACH_0) != fan_state[0]) { fan_edge_counter[0] ++; fan_state[0] = !fan_state[0]; } +#endif //if (READ(TACH_1) != fan_state[1]) { // fan_edge_counter[1] ++; // fan_state[1] = !fan_state[1]; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 8c2b52813..9614c9a4d 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -7352,15 +7352,13 @@ static bool lcd_selftest_fan_dialog(int _fan) setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, 1); //extruder fan #ifdef FAN_SOFT_PWM extruder_autofan_last_check = _millis(); + fan_measuring = true; #endif //FAN_SOFT_PWM _delay(2000); //delay_keep_alive would turn off extruder fan, because temerature is too low -#ifdef FAN_SOFT_PWM - countFanSpeed(); - if (!fan_speed[0]) _result = false; -#else //FAN_SOFT_PWM + manage_heater(); //count average fan speed from 2s delay and turn off fans if (!fan_speed[0]) _result = false; -#endif //FAN_SOFT_PWM + printf_P(PSTR("Test 1:\n")); printf_P(PSTR("Print fan speed: %d \n"), fan_speed[1]); From e028db7bf906fbc2707569168d758acf41676066 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 6 Feb 2019 23:30:01 +0100 Subject: [PATCH 06/25] version change --- Firmware/Configuration.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 37b7f6be9..48b99140f 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -7,13 +7,13 @@ #define STR(x) STR_HELPER(x) // Firmware version -#define FW_VERSION "3.5.1" -#define FW_COMMIT_NR 1778 +#define FW_VERSION "3.5.3" +#define FW_COMMIT_NR 1971 // FW_VERSION_UNKNOWN means this is an unofficial build. // The firmware should only be checked into github with this symbol. #define FW_DEV_VERSION FW_VERSION_UNKNOWN #define FW_REPOSITORY "Unknown" -#define FW_VERSION_FULL FW_VERSION "-" STR(FW_COMMIT_NR) +#define FW_VERSION_FULL FW_VERSION //"-" STR(FW_COMMIT_NR) // Debug version has debugging enabled (the symbol DEBUG_BUILD is set). // The debug build may be a bit slower than the non-debug build, therefore the debug build should From 38b0e5439b910c21d45cdd78e9a8ee1b757dea26 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 6 Feb 2019 23:52:24 +0100 Subject: [PATCH 07/25] version change --- Firmware/Configuration.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 48b99140f..ee7c1e93d 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -8,12 +8,12 @@ // Firmware version #define FW_VERSION "3.5.3" -#define FW_COMMIT_NR 1971 +#define FW_COMMIT_NR 1990 // FW_VERSION_UNKNOWN means this is an unofficial build. // The firmware should only be checked into github with this symbol. -#define FW_DEV_VERSION FW_VERSION_UNKNOWN +#define FW_DEV_VERSION FW_VERSION_GOLD #define FW_REPOSITORY "Unknown" -#define FW_VERSION_FULL FW_VERSION //"-" STR(FW_COMMIT_NR) +#define FW_VERSION_FULL FW_VERSION "-" STR(FW_COMMIT_NR) // Debug version has debugging enabled (the symbol DEBUG_BUILD is set). // The debug build may be a bit slower than the non-debug build, therefore the debug build should From 065d56b2c6404ab2280f83e8b9088f1675e908ff Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 6 Feb 2019 23:58:30 +0100 Subject: [PATCH 08/25] version change --- Firmware/Configuration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index ee7c1e93d..9b00b7962 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -13,7 +13,7 @@ // The firmware should only be checked into github with this symbol. #define FW_DEV_VERSION FW_VERSION_GOLD #define FW_REPOSITORY "Unknown" -#define FW_VERSION_FULL FW_VERSION "-" STR(FW_COMMIT_NR) +#define FW_VERSION_FULL FW_VERSION // "-" STR(FW_COMMIT_NR) // Debug version has debugging enabled (the symbol DEBUG_BUILD is set). // The debug build may be a bit slower than the non-debug build, therefore the debug build should From ccc542d74aa3c0c662e31e14ead796014507255d Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Mon, 11 Feb 2019 14:32:21 +0100 Subject: [PATCH 09/25] MK2.5 IR_SENSOR_PIN modified --- Firmware/pins_Rambo_1_0.h | 2 +- Firmware/pins_Rambo_1_3.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/pins_Rambo_1_0.h b/Firmware/pins_Rambo_1_0.h index b973fd302..bb6eb026d 100644 --- a/Firmware/pins_Rambo_1_0.h +++ b/Firmware/pins_Rambo_1_0.h @@ -102,7 +102,7 @@ #define SDCARDDETECT 72 -#define IR_SENSOR_PIN 62 //idler sensor @PK0 (digital pin 62/A8) +#define IR_SENSOR_PIN 20 //idler sensor // Support for an 8 bit logic analyzer, for example the Saleae. // Channels 0-2 are fast, they could generate 2.667Mhz waveform with a software loop. diff --git a/Firmware/pins_Rambo_1_3.h b/Firmware/pins_Rambo_1_3.h index d684519e2..c1adf5969 100644 --- a/Firmware/pins_Rambo_1_3.h +++ b/Firmware/pins_Rambo_1_3.h @@ -102,7 +102,7 @@ #define SDCARDDETECT 15 -#define IR_SENSOR_PIN 62 //idler sensor @PK0 (digital pin 62/A8) +#define IR_SENSOR_PIN 20 //idler sensor // Support for an 8 bit logic analyzer, for example the Saleae. // Channels 0-2 are fast, they could generate 2.667Mhz waveform with a software loop. From b85661309feb4b1e0405e95d2598b1a4755771cc Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Mon, 11 Feb 2019 16:38:36 +0100 Subject: [PATCH 10/25] configuration change --- Firmware/Configuration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 9b00b7962..2a33e9418 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -11,7 +11,7 @@ #define FW_COMMIT_NR 1990 // FW_VERSION_UNKNOWN means this is an unofficial build. // The firmware should only be checked into github with this symbol. -#define FW_DEV_VERSION FW_VERSION_GOLD +#define FW_DEV_VERSION FW_VERSION_UNKNOWN #define FW_REPOSITORY "Unknown" #define FW_VERSION_FULL FW_VERSION // "-" STR(FW_COMMIT_NR) From d33b24c2816df1fc763231fb9696f5e9d3c1c1cb Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Mon, 4 Feb 2019 20:19:34 +0100 Subject: [PATCH 11/25] Unload filament after MMU load failed so MMU unit can be controlled by its buttons. --- Firmware/mmu.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 5d4b9eecd..36dd5a360 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -1394,7 +1394,10 @@ void mmu_continue_loading() current_position[Y_AXIS] = Y_PAUSE_POS; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder); st_synchronize(); - //set nozzle target temperature to 0 + + mmu_command(MMU_CMD_U0); + manage_response(false, true, MMU_UNLOAD_MOVE); + 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 From 6c8d9c6fb4b03543e355efffb0a2c4f8360acb38 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 5 Feb 2019 18:25:11 +0100 Subject: [PATCH 12/25] Retry filament load on MMU load failure once. --- Firmware/mmu.cpp | 70 +++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 36dd5a360..833d1fde2 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -1362,46 +1362,60 @@ void mmu_eject_filament(uint8_t filament, bool recover) } } +static void load_more() +{ + for (uint8_t i = 0; i < MMU_IDLER_SENSOR_ATTEMPTS_NR; i++) + { + if (PIN_GET(IR_SENSOR_PIN) == 0) return; +#ifdef MMU_DEBUG + printf_P(PSTR("Additional load attempt nr. %d\n"), i); +#endif // MMU_DEBUG + mmu_command(MMU_CMD_C0); + manage_response(true, true, MMU_LOAD_MOVE); + } +} + void mmu_continue_loading() { + if (ir_sensor_detected) + { + load_more(); - if (ir_sensor_detected) { - for (uint8_t i = 0; i < MMU_IDLER_SENSOR_ATTEMPTS_NR; i++) { - if (PIN_GET(IR_SENSOR_PIN) == 0) return; -#ifdef MMU_DEBUG - printf_P(PSTR("Additional load attempt nr. %d\n"), i); -#endif // MMU_DEBUG - mmu_command(MMU_CMD_C0); - manage_response(true, true, MMU_LOAD_MOVE); - } if (PIN_GET(IR_SENSOR_PIN) != 0) { uint8_t mmu_load_fail = eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL); uint16_t mmu_load_fail_tot = eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT); if(mmu_load_fail < 255) eeprom_update_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL, mmu_load_fail + 1); if(mmu_load_fail_tot < 65535) eeprom_update_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT, mmu_load_fail_tot + 1); - char cmd[3]; - //pause print, show error message and then repeat last T-code - stop_and_save_print_to_ram(0, 0); - //lift z - current_position[Z_AXIS] += Z_PAUSE_LIFT; - if (current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder); - st_synchronize(); + mmu_command(MMU_CMD_T0 + tmp_extruder); + manage_response(true, true, MMU_TCODE_MOVE); + load_more(); - //Move XY to side - current_position[X_AXIS] = X_PAUSE_POS; - current_position[Y_AXIS] = Y_PAUSE_POS; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder); - st_synchronize(); + if (PIN_GET(IR_SENSOR_PIN) != 0) + { + //pause print, show error message and then repeat last T-code + stop_and_save_print_to_ram(0, 0); - mmu_command(MMU_CMD_U0); - manage_response(false, true, MMU_UNLOAD_MOVE); + //lift z + current_position[Z_AXIS] += Z_PAUSE_LIFT; + if (current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder); + st_synchronize(); - 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; + //Move XY to side + current_position[X_AXIS] = X_PAUSE_POS; + current_position[Y_AXIS] = Y_PAUSE_POS; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder); + st_synchronize(); + + mmu_command(MMU_CMD_U0); + manage_response(false, true, MMU_UNLOAD_MOVE); + + 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_ir_sensor_detected == false From 4c7639323194f33d606516cf38c3f7a90a41c927 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 12 Feb 2019 13:44:50 +0100 Subject: [PATCH 13/25] version change --- Firmware/Configuration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 2a33e9418..14104521e 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -8,7 +8,7 @@ // Firmware version #define FW_VERSION "3.5.3" -#define FW_COMMIT_NR 1990 +#define FW_COMMIT_NR 2007 // FW_VERSION_UNKNOWN means this is an unofficial build. // The firmware should only be checked into github with this symbol. #define FW_DEV_VERSION FW_VERSION_UNKNOWN From 3379fb4866d38996a74c8fd8a10c1e301b37287f Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 12 Feb 2019 21:43:26 +0100 Subject: [PATCH 14/25] Convert mmu_state to enum. --- Firmware/mmu.cpp | 85 +++++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 833d1fde2..f014613f7 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -30,11 +30,28 @@ #define MMU_RST_PIN 76 #endif //MMU_HWRESET +namespace +{ + enum class S + { + WaitStealthMode = -5, + GetFindaInit, + GetBuildNr, + GetVersion, + Init, + Disabled, + Idle, + GetFinda, + WaitCmd, //!< wait for command response + GetDrvError, //!< get power failures count + }; +} + bool mmu_enabled = false; bool mmu_ready = false; bool mmu_fil_loaded = false; //if true: blocks execution of duplicit T-codes -static int8_t mmu_state = 0; +static S mmu_state = S::Disabled; uint8_t mmu_cmd = 0; @@ -114,7 +131,7 @@ void mmu_init(void) uart2_init(); //init uart2 _delay_ms(10); //wait 10ms for sure mmu_reset(); //reset mmu (HW or SW), do not wait for response - mmu_state = -1; + mmu_state = S::Init; PIN_INP(IR_SENSOR_PIN); //input mode PIN_SET(IR_SENSOR_PIN); //pullup } @@ -155,9 +172,9 @@ void mmu_loop(void) // printf_P(PSTR("MMU loop, state=%d\n"), mmu_state); switch (mmu_state) { - case 0: + case S::Disabled: return; - case -1: + case S::Init: if (mmu_rx_start() > 0) { #ifdef MMU_DEBUG @@ -165,15 +182,15 @@ void mmu_loop(void) puts_P(PSTR("MMU <= 'S1'")); #endif //MMU_DEBUG mmu_puts_P(PSTR("S1\n")); //send 'read version' request - mmu_state = -2; + mmu_state = S::GetVersion; } else if (_millis() > 30000) //30sec after reset disable mmu { puts_P(PSTR("MMU not responding - DISABLED")); - mmu_state = 0; + mmu_state = S::Disabled; } return; - case -2: + case S::GetVersion: if (mmu_rx_ok() > 0) { fscanf_P(uart2io, PSTR("%u"), &mmu_version); //scan version from buffer @@ -182,10 +199,10 @@ void mmu_loop(void) puts_P(PSTR("MMU <= 'S2'")); #endif //MMU_DEBUG mmu_puts_P(PSTR("S2\n")); //send 'read buildnr' request - mmu_state = -3; + mmu_state = S::GetBuildNr; } return; - case -3: + case S::GetBuildNr: if (mmu_rx_ok() > 0) { fscanf_P(uart2io, PSTR("%u"), &mmu_buildnr); //scan buildnr from buffer @@ -202,7 +219,7 @@ void mmu_loop(void) puts_P(PSTR("MMU <= 'P0'")); #endif //MMU_DEBUG && MMU_FINDA_DEBUG mmu_puts_P(PSTR("P0\n")); //send 'read finda' request - mmu_state = -4; + mmu_state = S::GetFindaInit; } else { @@ -210,22 +227,22 @@ void mmu_loop(void) puts_P(PSTR("MMU <= 'M1'")); #endif //MMU_DEBUG mmu_puts_P(PSTR("M1\n")); //set mmu mode to stealth - mmu_state = -5; + mmu_state = S::WaitStealthMode; } } return; - case -5: + case S::WaitStealthMode: if (mmu_rx_ok() > 0) { #if defined MMU_DEBUG && defined MMU_FINDA_DEBUG puts_P(PSTR("MMU <= 'P0'")); #endif //MMU_DEBUG && MMU_FINDA_DEBUG mmu_puts_P(PSTR("P0\n")); //send 'read finda' request - mmu_state = -4; + mmu_state = S::GetFindaInit; } return; - case -4: + case S::GetFindaInit: if (mmu_rx_ok() > 0) { fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer @@ -234,10 +251,10 @@ void mmu_loop(void) #endif //MMU_DEBUG && MMU_FINDA_DEBUG puts_P(PSTR("MMU - ENABLED")); mmu_enabled = true; - mmu_state = 1; + mmu_state = S::Idle; } return; - case 1: + case S::Idle: if (mmu_cmd) //command request ? { if ((mmu_cmd >= MMU_CMD_T0) && (mmu_cmd <= MMU_CMD_T4)) @@ -247,7 +264,7 @@ void mmu_loop(void) printf_P(PSTR("MMU <= 'T%d'\n"), filament); #endif //MMU_DEBUG mmu_printf_P(PSTR("T%d\n"), filament); - mmu_state = 3; // wait for response + mmu_state = S::WaitCmd; // wait for response mmu_fil_loaded = true; mmu_idl_sens = 1; } @@ -258,7 +275,7 @@ void mmu_loop(void) printf_P(PSTR("MMU <= 'L%d'\n"), filament); #endif //MMU_DEBUG mmu_printf_P(PSTR("L%d\n"), filament); - mmu_state = 3; // wait for response + mmu_state = S::WaitCmd; // wait for response } else if (mmu_cmd == MMU_CMD_C0) { @@ -266,7 +283,7 @@ void mmu_loop(void) printf_P(PSTR("MMU <= 'C0'\n")); #endif //MMU_DEBUG mmu_puts_P(PSTR("C0\n")); //send 'continue loading' - mmu_state = 3; + mmu_state = S::WaitCmd; mmu_idl_sens = 1; } else if (mmu_cmd == MMU_CMD_U0) @@ -276,7 +293,7 @@ void mmu_loop(void) #endif //MMU_DEBUG mmu_puts_P(PSTR("U0\n")); //send 'unload current filament' mmu_fil_loaded = false; - mmu_state = 3; + mmu_state = S::WaitCmd; } else if ((mmu_cmd >= MMU_CMD_E0) && (mmu_cmd <= MMU_CMD_E4)) { @@ -286,7 +303,7 @@ void mmu_loop(void) #endif //MMU_DEBUG mmu_printf_P(PSTR("E%d\n"), filament); //send eject filament mmu_fil_loaded = false; - mmu_state = 3; // wait for response + mmu_state = S::WaitCmd; } else if (mmu_cmd == MMU_CMD_R0) { @@ -294,7 +311,7 @@ void mmu_loop(void) printf_P(PSTR("MMU <= 'R0'\n")); #endif //MMU_DEBUG mmu_puts_P(PSTR("R0\n")); //send recover after eject - mmu_state = 3; // wait for response + mmu_state = S::WaitCmd; } else if (mmu_cmd == MMU_CMD_S3) { @@ -302,7 +319,7 @@ void mmu_loop(void) printf_P(PSTR("MMU <= 'S3'\n")); #endif //MMU_DEBUG mmu_puts_P(PSTR("S3\n")); //send power failures request - mmu_state = 4; // power failures response + mmu_state = S::GetDrvError; } mmu_last_cmd = mmu_cmd; mmu_cmd = 0; @@ -316,10 +333,10 @@ void mmu_loop(void) puts_P(PSTR("MMU <= 'P0'")); #endif //MMU_DEBUG && MMU_FINDA_DEBUG mmu_puts_P(PSTR("P0\n")); //send 'read finda' request - mmu_state = 2; + mmu_state = S::GetFinda; } return; - case 2: //response to command P0 + case S::GetFinda: //response to command P0 if (mmu_rx_ok() > 0) { fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer @@ -340,16 +357,16 @@ void mmu_loop(void) enquecommand_front_P(PSTR("M600")); //save print and run M600 command } } - mmu_state = 1; + mmu_state = S::Idle; if (mmu_cmd == 0) mmu_ready = true; } else if ((mmu_last_request + MMU_P0_TIMEOUT) < _millis()) { //resend request after timeout (30s) - mmu_state = 1; + mmu_state = S::Idle; } return; - case 3: //response to mmu commands + case S::WaitCmd: //response to mmu commands if (mmu_idl_sens) { if (PIN_GET(IR_SENSOR_PIN) == 0 && mmu_loading_flag) @@ -372,7 +389,7 @@ void mmu_loop(void) mmu_attempt_nr = 0; mmu_last_cmd = 0; mmu_ready = true; - mmu_state = 1; + mmu_state = S::Idle; } else if ((mmu_last_request + MMU_CMD_TIMEOUT) < _millis()) { //resend request after timeout (5 min) @@ -390,10 +407,10 @@ void mmu_loop(void) mmu_attempt_nr = 0; } } - mmu_state = 1; + mmu_state = S::Idle; } return; - case 4: + case S::GetDrvError: if (mmu_rx_ok() > 0) { fscanf_P(uart2io, PSTR("%d"), &mmu_power_failures); //scan power failures @@ -402,11 +419,11 @@ void mmu_loop(void) #endif //MMU_DEBUG mmu_last_cmd = 0; mmu_ready = true; - mmu_state = 1; + mmu_state = S::Idle; } else if ((mmu_last_request + MMU_CMD_TIMEOUT) < _millis()) { //resend request after timeout (5 min) - mmu_state = 1; + mmu_state = S::Idle; } } } @@ -502,7 +519,7 @@ bool mmu_get_response(uint8_t move) while (!mmu_ready) { - if ((mmu_state != 3) && (mmu_last_cmd == 0)) + if ((mmu_state != S::WaitCmd) && (mmu_last_cmd == 0)) break; switch (move) { From e1216934ef3379a2f97e0044dffba2218b18051f Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 12 Feb 2019 21:53:11 +0100 Subject: [PATCH 15/25] Save flash by defining underlying type and omitting number value. --- Firmware/mmu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index f014613f7..b927afc50 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -32,9 +32,9 @@ namespace { - enum class S + enum class S : uint_least8_t { - WaitStealthMode = -5, + WaitStealthMode, GetFindaInit, GetBuildNr, GetVersion, From bb7eeef1f454753984ca2f85dab87da3b40c79d9 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 12 Feb 2019 23:24:23 +0100 Subject: [PATCH 16/25] Define debug printf and puts functions to make code more readable. --- Firmware/mmu.cpp | 106 ++++++++++++++++++----------------------------- 1 file changed, 40 insertions(+), 66 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index b927afc50..50a8689c0 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -78,6 +78,23 @@ uint8_t mmu_last_cmd = 0; uint16_t mmu_power_failures = 0; +#ifdef MMU_DEBUG +static const auto DEBUG_PUTS_P = puts_P; +static const auto DEBUG_PRINTF_P = printf_P; +#else //MMU_DEBUG +#define DEBUG_PUTS_P(str) +#define DEBUG_PRINTF_P( __fmt, ... ) +#endif //MMU_DEBUG + +#if defined(MMU_FINDA_DEBUG) && defined(MMU_DEBUG) +static const auto FDEBUG_PUTS_P = puts_P; +static const auto FDEBUG_PRINTF_P = printf_P; +#else +#define FDEBUG_PUTS_P(str) +#define FDEBUG_PRINTF_P( __fmt, ... ) +#endif //defined(MMU_FINDA_DEBUG) && defined(MMU_DEBUG) + + //clear rx buffer void mmu_clr_rx_buf(void) { @@ -136,7 +153,6 @@ void mmu_init(void) PIN_SET(IR_SENSOR_PIN); //pullup } - //if IR_SENSOR defined, always returns true //otherwise check for ir sensor and returns true if idler IR sensor was detected, otherwise returns false bool check_for_ir_sensor() @@ -177,10 +193,8 @@ void mmu_loop(void) case S::Init: if (mmu_rx_start() > 0) { -#ifdef MMU_DEBUG - puts_P(PSTR("MMU => 'start'")); - puts_P(PSTR("MMU <= 'S1'")); -#endif //MMU_DEBUG + DEBUG_PUTS_P(PSTR("MMU => 'start'")); + DEBUG_PUTS_P(PSTR("MMU <= 'S1'")); mmu_puts_P(PSTR("S1\n")); //send 'read version' request mmu_state = S::GetVersion; } @@ -194,10 +208,8 @@ void mmu_loop(void) if (mmu_rx_ok() > 0) { fscanf_P(uart2io, PSTR("%u"), &mmu_version); //scan version from buffer -#ifdef MMU_DEBUG - printf_P(PSTR("MMU => '%dok'\n"), mmu_version); - puts_P(PSTR("MMU <= 'S2'")); -#endif //MMU_DEBUG + DEBUG_PRINTF_P(PSTR("MMU => '%dok'\n"), mmu_version); + DEBUG_PUTS_P(PSTR("MMU <= 'S2'")); mmu_puts_P(PSTR("S2\n")); //send 'read buildnr' request mmu_state = S::GetBuildNr; } @@ -206,26 +218,20 @@ void mmu_loop(void) if (mmu_rx_ok() > 0) { fscanf_P(uart2io, PSTR("%u"), &mmu_buildnr); //scan buildnr from buffer -#ifdef MMU_DEBUG - printf_P(PSTR("MMU => '%dok'\n"), mmu_buildnr); -#endif //MMU_DEBUG + DEBUG_PRINTF_P(PSTR("MMU => '%dok'\n"), mmu_buildnr); bool version_valid = mmu_check_version(); if (!version_valid) mmu_show_warning(); else puts_P(PSTR("MMU version valid")); if ((PRINTER_TYPE == PRINTER_MK3) || (PRINTER_TYPE == PRINTER_MK3_SNMM)) { -#if defined MMU_DEBUG && defined MMU_FINDA_DEBUG - puts_P(PSTR("MMU <= 'P0'")); -#endif //MMU_DEBUG && MMU_FINDA_DEBUG + FDEBUG_PUTS_P(PSTR("MMU <= 'P0'")); mmu_puts_P(PSTR("P0\n")); //send 'read finda' request mmu_state = S::GetFindaInit; } else { -#ifdef MMU_DEBUG - puts_P(PSTR("MMU <= 'M1'")); -#endif //MMU_DEBUG + DEBUG_PUTS_P(PSTR("MMU <= 'M1'")); mmu_puts_P(PSTR("M1\n")); //set mmu mode to stealth mmu_state = S::WaitStealthMode; } @@ -235,9 +241,7 @@ void mmu_loop(void) case S::WaitStealthMode: if (mmu_rx_ok() > 0) { -#if defined MMU_DEBUG && defined MMU_FINDA_DEBUG - puts_P(PSTR("MMU <= 'P0'")); -#endif //MMU_DEBUG && MMU_FINDA_DEBUG + FDEBUG_PUTS_P(PSTR("MMU <= 'P0'")); mmu_puts_P(PSTR("P0\n")); //send 'read finda' request mmu_state = S::GetFindaInit; } @@ -246,9 +250,7 @@ void mmu_loop(void) if (mmu_rx_ok() > 0) { fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer -#if defined MMU_DEBUG && defined MMU_FINDA_DEBUG - printf_P(PSTR("MMU => '%dok'\n"), mmu_finda); -#endif //MMU_DEBUG && MMU_FINDA_DEBUG + FDEBUG_PRINTF_P(PSTR("MMU => '%dok'\n"), mmu_finda); puts_P(PSTR("MMU - ENABLED")); mmu_enabled = true; mmu_state = S::Idle; @@ -260,9 +262,7 @@ void mmu_loop(void) if ((mmu_cmd >= MMU_CMD_T0) && (mmu_cmd <= MMU_CMD_T4)) { filament = mmu_cmd - MMU_CMD_T0; -#ifdef MMU_DEBUG - printf_P(PSTR("MMU <= 'T%d'\n"), filament); -#endif //MMU_DEBUG + DEBUG_PRINTF_P(PSTR("MMU <= 'T%d'\n"), filament); mmu_printf_P(PSTR("T%d\n"), filament); mmu_state = S::WaitCmd; // wait for response mmu_fil_loaded = true; @@ -271,26 +271,20 @@ void mmu_loop(void) else if ((mmu_cmd >= MMU_CMD_L0) && (mmu_cmd <= MMU_CMD_L4)) { filament = mmu_cmd - MMU_CMD_L0; -#ifdef MMU_DEBUG - printf_P(PSTR("MMU <= 'L%d'\n"), filament); -#endif //MMU_DEBUG + DEBUG_PRINTF_P(PSTR("MMU <= 'L%d'\n"), filament); mmu_printf_P(PSTR("L%d\n"), filament); mmu_state = S::WaitCmd; // wait for response } else if (mmu_cmd == MMU_CMD_C0) { -#ifdef MMU_DEBUG - printf_P(PSTR("MMU <= 'C0'\n")); -#endif //MMU_DEBUG + DEBUG_PRINTF_P(PSTR("MMU <= 'C0'\n")); mmu_puts_P(PSTR("C0\n")); //send 'continue loading' mmu_state = S::WaitCmd; mmu_idl_sens = 1; } else if (mmu_cmd == MMU_CMD_U0) { -#ifdef MMU_DEBUG - printf_P(PSTR("MMU <= 'U0'\n")); -#endif //MMU_DEBUG + DEBUG_PRINTF_P(PSTR("MMU <= 'U0'\n")); mmu_puts_P(PSTR("U0\n")); //send 'unload current filament' mmu_fil_loaded = false; mmu_state = S::WaitCmd; @@ -298,26 +292,20 @@ void mmu_loop(void) else if ((mmu_cmd >= MMU_CMD_E0) && (mmu_cmd <= MMU_CMD_E4)) { int filament = mmu_cmd - MMU_CMD_E0; -#ifdef MMU_DEBUG - printf_P(PSTR("MMU <= 'E%d'\n"), filament); -#endif //MMU_DEBUG + DEBUG_PRINTF_P(PSTR("MMU <= 'E%d'\n"), filament); mmu_printf_P(PSTR("E%d\n"), filament); //send eject filament mmu_fil_loaded = false; mmu_state = S::WaitCmd; } else if (mmu_cmd == MMU_CMD_R0) { -#ifdef MMU_DEBUG - printf_P(PSTR("MMU <= 'R0'\n")); -#endif //MMU_DEBUG + DEBUG_PRINTF_P(PSTR("MMU <= 'R0'\n")); mmu_puts_P(PSTR("R0\n")); //send recover after eject mmu_state = S::WaitCmd; } else if (mmu_cmd == MMU_CMD_S3) { -#ifdef MMU_DEBUG - printf_P(PSTR("MMU <= 'S3'\n")); -#endif //MMU_DEBUG + DEBUG_PRINTF_P(PSTR("MMU <= 'S3'\n")); mmu_puts_P(PSTR("S3\n")); //send power failures request mmu_state = S::GetDrvError; } @@ -329,9 +317,7 @@ void mmu_loop(void) #ifndef IR_SENSOR if(check_for_ir_sensor()) ir_sensor_detected = true; #endif //IR_SENSOR not defined -#if defined MMU_DEBUG && defined MMU_FINDA_DEBUG - puts_P(PSTR("MMU <= 'P0'")); -#endif //MMU_DEBUG && MMU_FINDA_DEBUG + FDEBUG_PUTS_P(PSTR("MMU <= 'P0'")); mmu_puts_P(PSTR("P0\n")); //send 'read finda' request mmu_state = S::GetFinda; } @@ -340,9 +326,7 @@ void mmu_loop(void) if (mmu_rx_ok() > 0) { fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer -#if defined MMU_DEBUG && MMU_FINDA_DEBUG - printf_P(PSTR("MMU => '%dok'\n"), mmu_finda); -#endif //MMU_DEBUG && MMU_FINDA_DEBUG + FDEBUG_PRINTF_P(PSTR("MMU => '%dok'\n"), mmu_finda); //printf_P(PSTR("Eact: %d\n"), int(e_active())); if (!mmu_finda && CHECK_FSENSOR && fsensor_enabled) { fsensor_stop_and_save_print(); @@ -371,9 +355,7 @@ void mmu_loop(void) { if (PIN_GET(IR_SENSOR_PIN) == 0 && mmu_loading_flag) { -#ifdef MMU_DEBUG - printf_P(PSTR("MMU <= 'A'\n")); -#endif //MMU_DEBUG + DEBUG_PRINTF_P(PSTR("MMU <= 'A'\n")); mmu_puts_P(PSTR("A\n")); //send 'abort' request mmu_idl_sens = 0; //printf_P(PSTR("MMU IDLER_SENSOR = 0 - ABORT\n")); @@ -383,9 +365,7 @@ void mmu_loop(void) } if (mmu_rx_ok() > 0) { -#ifdef MMU_DEBUG - printf_P(PSTR("MMU => 'ok'\n")); -#endif //MMU_DEBUG + DEBUG_PRINTF_P(PSTR("MMU => 'ok'\n")); mmu_attempt_nr = 0; mmu_last_cmd = 0; mmu_ready = true; @@ -396,9 +376,7 @@ void mmu_loop(void) if (mmu_last_cmd) { if (mmu_attempt_nr++ < MMU_MAX_RESEND_ATTEMPTS) { -#ifdef MMU_DEBUG - printf_P(PSTR("MMU retry attempt nr. %d\n"), mmu_attempt_nr - 1); -#endif //MMU_DEBUG + DEBUG_PRINTF_P(PSTR("MMU retry attempt nr. %d\n"), mmu_attempt_nr - 1); mmu_cmd = mmu_last_cmd; } else { @@ -414,9 +392,7 @@ void mmu_loop(void) if (mmu_rx_ok() > 0) { fscanf_P(uart2io, PSTR("%d"), &mmu_power_failures); //scan power failures -#ifdef MMU_DEBUG - printf_P(PSTR("MMU => 'ok'\n")); -#endif //MMU_DEBUG + DEBUG_PRINTF_P(PSTR("MMU => 'ok'\n")); mmu_last_cmd = 0; mmu_ready = true; mmu_state = S::Idle; @@ -1384,9 +1360,7 @@ static void load_more() for (uint8_t i = 0; i < MMU_IDLER_SENSOR_ATTEMPTS_NR; i++) { if (PIN_GET(IR_SENSOR_PIN) == 0) return; -#ifdef MMU_DEBUG - printf_P(PSTR("Additional load attempt nr. %d\n"), i); -#endif // MMU_DEBUG + DEBUG_PRINTF_P(PSTR("Additional load attempt nr. %d\n"), i); mmu_command(MMU_CMD_C0); manage_response(true, true, MMU_LOAD_MOVE); } From 9e873ac0f7edb823f1664c4bfed6a2b473a00932 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 13 Feb 2019 01:51:39 +0100 Subject: [PATCH 17/25] Use enum for mmu_cmd instead of plain integer type. --- Firmware/Marlin_main.cpp | 6 ++-- Firmware/mmu.cpp | 66 ++++++++++++++++++++-------------------- Firmware/mmu.h | 45 ++++++++++++++------------- Firmware/ultralcd.cpp | 4 +-- 4 files changed, 62 insertions(+), 59 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 08df94088..ed3919a93 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3037,7 +3037,7 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_PLEASE_WAIT)); - mmu_command(MMU_CMD_R0); + mmu_command(MmuCmd::R0); manage_response(false, false); } } @@ -6933,7 +6933,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) return; //dont execute the same T-code twice in a row } st_synchronize(); - mmu_command(MMU_CMD_T0 + tmp_extruder); + mmu_command(static_cast(MmuCmd::T0 + tmp_extruder)); manage_response(true, true, MMU_TCODE_MOVE); } } @@ -6974,7 +6974,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) printf_P(PSTR("Duplicit T-code ignored.\n")); return; //dont execute the same T-code twice in a row } - mmu_command(MMU_CMD_T0 + tmp_extruder); + mmu_command(static_cast(MmuCmd::T0 + tmp_extruder)); manage_response(true, true, MMU_TCODE_MOVE); mmu_continue_loading(); diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 50a8689c0..19d6dfdb0 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -53,7 +53,7 @@ bool mmu_fil_loaded = false; //if true: blocks execution of duplicit T-codes static S mmu_state = S::Disabled; -uint8_t mmu_cmd = 0; +MmuCmd mmu_cmd = MmuCmd::None; //idler ir sensor uint8_t mmu_idl_sens = 0; @@ -74,7 +74,7 @@ int16_t mmu_buildnr = -1; uint32_t mmu_last_request = 0; uint32_t mmu_last_response = 0; -uint8_t mmu_last_cmd = 0; +MmuCmd mmu_last_cmd = MmuCmd::None; uint16_t mmu_power_failures = 0; @@ -259,58 +259,58 @@ void mmu_loop(void) case S::Idle: if (mmu_cmd) //command request ? { - if ((mmu_cmd >= MMU_CMD_T0) && (mmu_cmd <= MMU_CMD_T4)) + if ((mmu_cmd >= MmuCmd::T0) && (mmu_cmd <= MmuCmd::T4)) { - filament = mmu_cmd - MMU_CMD_T0; + filament = mmu_cmd - MmuCmd::T0; DEBUG_PRINTF_P(PSTR("MMU <= 'T%d'\n"), filament); mmu_printf_P(PSTR("T%d\n"), filament); mmu_state = S::WaitCmd; // wait for response mmu_fil_loaded = true; mmu_idl_sens = 1; } - else if ((mmu_cmd >= MMU_CMD_L0) && (mmu_cmd <= MMU_CMD_L4)) + else if ((mmu_cmd >= MmuCmd::L0) && (mmu_cmd <= MmuCmd::L4)) { - filament = mmu_cmd - MMU_CMD_L0; + filament = mmu_cmd - MmuCmd::L0; DEBUG_PRINTF_P(PSTR("MMU <= 'L%d'\n"), filament); mmu_printf_P(PSTR("L%d\n"), filament); mmu_state = S::WaitCmd; // wait for response } - else if (mmu_cmd == MMU_CMD_C0) + else if (mmu_cmd == MmuCmd::C0) { DEBUG_PRINTF_P(PSTR("MMU <= 'C0'\n")); mmu_puts_P(PSTR("C0\n")); //send 'continue loading' mmu_state = S::WaitCmd; mmu_idl_sens = 1; } - else if (mmu_cmd == MMU_CMD_U0) + else if (mmu_cmd == MmuCmd::U0) { DEBUG_PRINTF_P(PSTR("MMU <= 'U0'\n")); mmu_puts_P(PSTR("U0\n")); //send 'unload current filament' mmu_fil_loaded = false; mmu_state = S::WaitCmd; } - else if ((mmu_cmd >= MMU_CMD_E0) && (mmu_cmd <= MMU_CMD_E4)) + else if ((mmu_cmd >= MmuCmd::E0) && (mmu_cmd <= MmuCmd::E4)) { - int filament = mmu_cmd - MMU_CMD_E0; + int filament = mmu_cmd - MmuCmd::E0; DEBUG_PRINTF_P(PSTR("MMU <= 'E%d'\n"), filament); mmu_printf_P(PSTR("E%d\n"), filament); //send eject filament mmu_fil_loaded = false; mmu_state = S::WaitCmd; } - else if (mmu_cmd == MMU_CMD_R0) + else if (mmu_cmd == MmuCmd::R0) { DEBUG_PRINTF_P(PSTR("MMU <= 'R0'\n")); mmu_puts_P(PSTR("R0\n")); //send recover after eject mmu_state = S::WaitCmd; } - else if (mmu_cmd == MMU_CMD_S3) + else if (mmu_cmd == MmuCmd::S3) { DEBUG_PRINTF_P(PSTR("MMU <= 'S3'\n")); mmu_puts_P(PSTR("S3\n")); //send power failures request mmu_state = S::GetDrvError; } mmu_last_cmd = mmu_cmd; - mmu_cmd = 0; + mmu_cmd = MmuCmd::None; } else if ((mmu_last_response + 300) < _millis()) //request every 300ms { @@ -367,7 +367,7 @@ void mmu_loop(void) { DEBUG_PRINTF_P(PSTR("MMU => 'ok'\n")); mmu_attempt_nr = 0; - mmu_last_cmd = 0; + mmu_last_cmd = MmuCmd::None; mmu_ready = true; mmu_state = S::Idle; } @@ -380,8 +380,8 @@ void mmu_loop(void) mmu_cmd = mmu_last_cmd; } else { - mmu_cmd = 0; - mmu_last_cmd = 0; //check + mmu_cmd = MmuCmd::None; + mmu_last_cmd = MmuCmd::None; //check mmu_attempt_nr = 0; } } @@ -393,7 +393,7 @@ void mmu_loop(void) { fscanf_P(uart2io, PSTR("%d"), &mmu_power_failures); //scan power failures DEBUG_PRINTF_P(PSTR("MMU => 'ok'\n")); - mmu_last_cmd = 0; + mmu_last_cmd = MmuCmd::None; mmu_ready = true; mmu_state = S::Idle; } @@ -430,20 +430,20 @@ int8_t mmu_set_filament_type(uint8_t extruder, uint8_t filament) //! 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) +void mmu_command(MmuCmd cmd) { - if ((cmd >= MMU_CMD_T0) && (cmd <= MMU_CMD_T4)) + if ((cmd >= MmuCmd::T0) && (cmd <= MmuCmd::T4)) { //disable extruder motor #ifdef TMC2130 tmc2130_set_pwr(E_AXIS, 0); #endif //TMC2130 //printf_P(PSTR("E-axis disabled\n")); - ad_markLoaded(cmd - MMU_CMD_T0); + ad_markLoaded(cmd - MmuCmd::T0); } - if ((cmd >= MMU_CMD_L0) && (cmd <= MMU_CMD_L4)) + if ((cmd >= MmuCmd::L0) && (cmd <= MmuCmd::L4)) { - ad_markLoaded(cmd - MMU_CMD_L0); + ad_markLoaded(cmd - MmuCmd::L0); } mmu_cmd = cmd; @@ -787,7 +787,7 @@ void mmu_M600_load_filament(bool automatic) // printf_P(PSTR("T code: %d \n"), tmp_extruder); // mmu_printf_P(PSTR("T%d\n"), tmp_extruder); - mmu_command(MMU_CMD_T0 + tmp_extruder); + mmu_command(static_cast(MmuCmd::T0 + tmp_extruder)); manage_response(false, true, MMU_LOAD_MOVE); mmu_continue_loading(); @@ -878,8 +878,8 @@ void display_loading() void extr_adj(int extruder) //loading filament for SNMM { #ifndef SNMM - uint8_t cmd = MMU_CMD_L0 + extruder; - if (cmd > MMU_CMD_L4) + MmuCmd cmd = static_cast(MmuCmd::L0 + extruder); + if (cmd > MmuCmd::L4) { printf_P(PSTR("Filament out of range %d \n"),extruder); return; @@ -999,7 +999,7 @@ void extr_unload() mmu_filament_ramming(); - mmu_command(MMU_CMD_U0); + mmu_command(MmuCmd::U0); // get response manage_response(false, true, MMU_UNLOAD_MOVE); @@ -1296,7 +1296,7 @@ void lcd_mmu_load_to_nozzle(uint8_t filament_nr) lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT)); lcd_print(" "); lcd_print(tmp_extruder + 1); - mmu_command(MMU_CMD_T0 + tmp_extruder); + mmu_command(static_cast(MmuCmd::T0 + tmp_extruder)); manage_response(true, true, MMU_TCODE_MOVE); mmu_continue_loading(); mmu_extruder = tmp_extruder; //filament change is finished @@ -1333,12 +1333,12 @@ void mmu_eject_filament(uint8_t filament, bool recover) current_position[E_AXIS] -= 80; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder); st_synchronize(); - mmu_command(MMU_CMD_E0 + filament); + mmu_command(static_cast(MmuCmd::E0 + filament)); manage_response(false, false, MMU_UNLOAD_MOVE); if (recover) { lcd_show_fullscreen_message_and_wait_P(_i("Please remove filament and then press the knob.")); - mmu_command(MMU_CMD_R0); + mmu_command(MmuCmd::R0); manage_response(false, false); } @@ -1361,7 +1361,7 @@ static void load_more() { if (PIN_GET(IR_SENSOR_PIN) == 0) return; DEBUG_PRINTF_P(PSTR("Additional load attempt nr. %d\n"), i); - mmu_command(MMU_CMD_C0); + mmu_command(MmuCmd::C0); manage_response(true, true, MMU_LOAD_MOVE); } } @@ -1378,7 +1378,7 @@ void mmu_continue_loading() if(mmu_load_fail < 255) eeprom_update_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL, mmu_load_fail + 1); if(mmu_load_fail_tot < 65535) eeprom_update_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT, mmu_load_fail_tot + 1); - mmu_command(MMU_CMD_T0 + tmp_extruder); + mmu_command(static_cast(MmuCmd::T0 + tmp_extruder)); manage_response(true, true, MMU_TCODE_MOVE); load_more(); @@ -1399,7 +1399,7 @@ void mmu_continue_loading() plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder); st_synchronize(); - mmu_command(MMU_CMD_U0); + mmu_command(MmuCmd::U0); manage_response(false, true, MMU_UNLOAD_MOVE); setAllTargetHotends(0); @@ -1410,6 +1410,6 @@ void mmu_continue_loading() } } else { //mmu_ir_sensor_detected == false - mmu_command(MMU_CMD_C0); + mmu_command(MmuCmd::C0); } } diff --git a/Firmware/mmu.h b/Firmware/mmu.h index 473ee99d7..ff9cf0982 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -32,26 +32,29 @@ extern uint16_t mmu_power_failures; #define MMU_LOAD_FEEDRATE 19.02f //mm/s #define MMU_LOAD_TIME_MS 2000 //should be fine tuned to load time for shortest allowed PTFE tubing and maximum loading speed -#define MMU_CMD_NONE 0 -#define MMU_CMD_T0 0x10 -#define MMU_CMD_T1 0x11 -#define MMU_CMD_T2 0x12 -#define MMU_CMD_T3 0x13 -#define MMU_CMD_T4 0x14 -#define MMU_CMD_L0 0x20 -#define MMU_CMD_L1 0x21 -#define MMU_CMD_L2 0x22 -#define MMU_CMD_L3 0x23 -#define MMU_CMD_L4 0x24 -#define MMU_CMD_C0 0x30 -#define MMU_CMD_U0 0x40 -#define MMU_CMD_E0 0x50 -#define MMU_CMD_E1 0x51 -#define MMU_CMD_E2 0x52 -#define MMU_CMD_E3 0x53 -#define MMU_CMD_E4 0x54 -#define MMU_CMD_R0 0x60 -#define MMU_CMD_S3 0x73 +enum MmuCmd : uint_least8_t +{ + None, + T0, + T1, + T2, + T3, + T4, + L0, + L1, + L2, + L3, + L4, + C0, + U0, + E0, + E1, + E2, + E3, + E4, + R0, + S3, +}; extern int mmu_puts_P(const char* str); @@ -70,7 +73,7 @@ extern void mmu_reset(void); extern int8_t mmu_set_filament_type(uint8_t extruder, uint8_t filament); -extern void mmu_command(uint8_t cmd); +extern void mmu_command(MmuCmd cmd); extern bool mmu_get_response(uint8_t move = 0); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 9614c9a4d..f13c86697 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1986,7 +1986,7 @@ static void lcd_menu_fails_stats_mmu_total() // MMU load fails 000 // ////////////////////// - mmu_command(MMU_CMD_S3); + mmu_command(MmuCmd::S3); lcd_timeoutToStatus.stop(); //infinite timeout uint8_t fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL_TOT); uint16_t load_fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL_TOT); @@ -7208,7 +7208,7 @@ static bool selftest_irsensor() mmu_filament_ramming(); } progress = lcd_selftest_screen(testScreen::fsensor, progress, 1, true, 0); - mmu_command(MMU_CMD_U0); + mmu_command(MmuCmd::U0); manage_response(false, false); for(uint_least8_t i = 0; i < 200; ++i) From 8e23e7f322d5e9e6bd6ef260d8ff1d45be3fe53a Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 13 Feb 2019 16:37:54 +0100 Subject: [PATCH 18/25] Save some flash by using smaller type for filament. --- Firmware/mmu.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 19d6dfdb0..091384ecd 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -184,7 +184,6 @@ bool check_for_ir_sensor() void mmu_loop(void) { static uint8_t mmu_attempt_nr = 0; - int filament = 0; // printf_P(PSTR("MMU loop, state=%d\n"), mmu_state); switch (mmu_state) { @@ -261,7 +260,7 @@ void mmu_loop(void) { if ((mmu_cmd >= MmuCmd::T0) && (mmu_cmd <= MmuCmd::T4)) { - filament = mmu_cmd - MmuCmd::T0; + const uint8_t filament = mmu_cmd - MmuCmd::T0; DEBUG_PRINTF_P(PSTR("MMU <= 'T%d'\n"), filament); mmu_printf_P(PSTR("T%d\n"), filament); mmu_state = S::WaitCmd; // wait for response @@ -270,7 +269,7 @@ void mmu_loop(void) } else if ((mmu_cmd >= MmuCmd::L0) && (mmu_cmd <= MmuCmd::L4)) { - filament = mmu_cmd - MmuCmd::L0; + const uint8_t filament = mmu_cmd - MmuCmd::L0; DEBUG_PRINTF_P(PSTR("MMU <= 'L%d'\n"), filament); mmu_printf_P(PSTR("L%d\n"), filament); mmu_state = S::WaitCmd; // wait for response @@ -291,7 +290,7 @@ void mmu_loop(void) } else if ((mmu_cmd >= MmuCmd::E0) && (mmu_cmd <= MmuCmd::E4)) { - int filament = mmu_cmd - MmuCmd::E0; + const uint8_t filament = mmu_cmd - MmuCmd::E0; DEBUG_PRINTF_P(PSTR("MMU <= 'E%d'\n"), filament); mmu_printf_P(PSTR("E%d\n"), filament); //send eject filament mmu_fil_loaded = false; From daaec0ef04f62f8033127189568a5a825a846efd Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 13 Feb 2019 17:12:35 +0100 Subject: [PATCH 19/25] Convert MmuCmd to enum class. --- Firmware/Marlin_main.cpp | 4 ++-- Firmware/mmu.cpp | 20 ++++++++++---------- Firmware/mmu.h | 12 +++++++++++- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index ed3919a93..53668e8b2 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -6933,7 +6933,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) return; //dont execute the same T-code twice in a row } st_synchronize(); - mmu_command(static_cast(MmuCmd::T0 + tmp_extruder)); + mmu_command(MmuCmd::T0 + tmp_extruder); manage_response(true, true, MMU_TCODE_MOVE); } } @@ -6974,7 +6974,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) printf_P(PSTR("Duplicit T-code ignored.\n")); return; //dont execute the same T-code twice in a row } - mmu_command(static_cast(MmuCmd::T0 + tmp_extruder)); + mmu_command(MmuCmd::T0 + tmp_extruder); manage_response(true, true, MMU_TCODE_MOVE); mmu_continue_loading(); diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 091384ecd..039eebc9b 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -256,7 +256,7 @@ void mmu_loop(void) } return; case S::Idle: - if (mmu_cmd) //command request ? + if (mmu_cmd != MmuCmd::None) //command request ? { if ((mmu_cmd >= MmuCmd::T0) && (mmu_cmd <= MmuCmd::T4)) { @@ -341,7 +341,7 @@ void mmu_loop(void) } } mmu_state = S::Idle; - if (mmu_cmd == 0) + if (mmu_cmd == MmuCmd::None) mmu_ready = true; } else if ((mmu_last_request + MMU_P0_TIMEOUT) < _millis()) @@ -372,7 +372,7 @@ void mmu_loop(void) } else if ((mmu_last_request + MMU_CMD_TIMEOUT) < _millis()) { //resend request after timeout (5 min) - if (mmu_last_cmd) + if (mmu_last_cmd != MmuCmd::None) { if (mmu_attempt_nr++ < MMU_MAX_RESEND_ATTEMPTS) { DEBUG_PRINTF_P(PSTR("MMU retry attempt nr. %d\n"), mmu_attempt_nr - 1); @@ -487,14 +487,14 @@ bool mmu_get_response(uint8_t move) printf_P(PSTR("mmu_get_response - begin move:%d\n"), move); KEEPALIVE_STATE(IN_PROCESS); - while (mmu_cmd != 0) + while (mmu_cmd != MmuCmd::None) { delay_keep_alive(100); } while (!mmu_ready) { - if ((mmu_state != S::WaitCmd) && (mmu_last_cmd == 0)) + if ((mmu_state != S::WaitCmd) && (mmu_last_cmd == MmuCmd::None)) break; switch (move) { @@ -786,7 +786,7 @@ void mmu_M600_load_filament(bool automatic) // printf_P(PSTR("T code: %d \n"), tmp_extruder); // mmu_printf_P(PSTR("T%d\n"), tmp_extruder); - mmu_command(static_cast(MmuCmd::T0 + tmp_extruder)); + mmu_command(MmuCmd::T0 + tmp_extruder); manage_response(false, true, MMU_LOAD_MOVE); mmu_continue_loading(); @@ -877,7 +877,7 @@ void display_loading() void extr_adj(int extruder) //loading filament for SNMM { #ifndef SNMM - MmuCmd cmd = static_cast(MmuCmd::L0 + extruder); + MmuCmd cmd = MmuCmd::L0 + extruder; if (cmd > MmuCmd::L4) { printf_P(PSTR("Filament out of range %d \n"),extruder); @@ -1295,7 +1295,7 @@ void lcd_mmu_load_to_nozzle(uint8_t filament_nr) lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT)); lcd_print(" "); lcd_print(tmp_extruder + 1); - mmu_command(static_cast(MmuCmd::T0 + tmp_extruder)); + mmu_command(MmuCmd::T0 + tmp_extruder); manage_response(true, true, MMU_TCODE_MOVE); mmu_continue_loading(); mmu_extruder = tmp_extruder; //filament change is finished @@ -1332,7 +1332,7 @@ void mmu_eject_filament(uint8_t filament, bool recover) current_position[E_AXIS] -= 80; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder); st_synchronize(); - mmu_command(static_cast(MmuCmd::E0 + filament)); + mmu_command(MmuCmd::E0 + filament); manage_response(false, false, MMU_UNLOAD_MOVE); if (recover) { @@ -1377,7 +1377,7 @@ void mmu_continue_loading() if(mmu_load_fail < 255) eeprom_update_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL, mmu_load_fail + 1); if(mmu_load_fail_tot < 65535) eeprom_update_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT, mmu_load_fail_tot + 1); - mmu_command(static_cast(MmuCmd::T0 + tmp_extruder)); + mmu_command(MmuCmd::T0 + tmp_extruder); manage_response(true, true, MMU_TCODE_MOVE); load_more(); diff --git a/Firmware/mmu.h b/Firmware/mmu.h index ff9cf0982..80e12cab5 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -32,7 +32,7 @@ extern uint16_t mmu_power_failures; #define MMU_LOAD_FEEDRATE 19.02f //mm/s #define MMU_LOAD_TIME_MS 2000 //should be fine tuned to load time for shortest allowed PTFE tubing and maximum loading speed -enum MmuCmd : uint_least8_t +enum class MmuCmd : uint_least8_t { None, T0, @@ -56,6 +56,16 @@ enum MmuCmd : uint_least8_t S3, }; +inline MmuCmd operator+ (MmuCmd cmd, uint8_t filament) +{ + return static_cast(static_cast(cmd) + filament ); +} + +inline uint8_t operator- (MmuCmd cmda, MmuCmd cmdb) +{ + return (static_cast(cmda) - static_cast(cmdb)); +} + extern int mmu_puts_P(const char* str); extern int mmu_printf_P(const char* format, ...); From a4032e437e00b747fea300ec2ea271d0145504e3 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 13 Feb 2019 19:10:55 +0100 Subject: [PATCH 20/25] Add MMU wait command after MMU load failed. Resume print when MMU wait command returns OK. --- Firmware/mmu.cpp | 23 +++++++++++++++++++++++ Firmware/mmu.h | 1 + 2 files changed, 24 insertions(+) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 039eebc9b..3f59d5848 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -43,6 +43,7 @@ namespace Idle, GetFinda, WaitCmd, //!< wait for command response + Pause, GetDrvError, //!< get power failures count }; } @@ -308,6 +309,12 @@ void mmu_loop(void) mmu_puts_P(PSTR("S3\n")); //send power failures request mmu_state = S::GetDrvError; } + else if (mmu_cmd == MmuCmd::W0) + { + DEBUG_PRINTF_P(PSTR("MMU <= 'W0'\n")); + mmu_puts_P(PSTR("W0\n")); + mmu_state = S::Pause; + } mmu_last_cmd = mmu_cmd; mmu_cmd = MmuCmd::None; } @@ -387,6 +394,21 @@ void mmu_loop(void) mmu_state = S::Idle; } return; + case S::Pause: + if (mmu_rx_ok() > 0) + { + DEBUG_PRINTF_P(PSTR("MMU => 'ok', resume print\n")); + mmu_attempt_nr = 0; + mmu_last_cmd = MmuCmd::None; + mmu_ready = true; + mmu_state = S::Idle; + lcd_resume_print(); + } + if (mmu_cmd != MmuCmd::None) + { + mmu_state = S::Idle; + } + return; case S::GetDrvError: if (mmu_rx_ok() > 0) { @@ -1405,6 +1427,7 @@ void mmu_continue_loading() 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; + mmu_command(MmuCmd::W0); } } } diff --git a/Firmware/mmu.h b/Firmware/mmu.h index 80e12cab5..71930ae7c 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -54,6 +54,7 @@ enum class MmuCmd : uint_least8_t E4, R0, S3, + W0, }; inline MmuCmd operator+ (MmuCmd cmd, uint8_t filament) From a5437cb15b3033863df6016e2a2ec56dcd056b4b Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 13 Feb 2019 22:29:29 +0100 Subject: [PATCH 21/25] Resend MMU T commands only. This solves problem with unload repeated if unload takes too long, second ok reply then triggers Wait end and resumes print. --- Firmware/mmu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 3f59d5848..2d3f89903 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -379,7 +379,7 @@ void mmu_loop(void) } else if ((mmu_last_request + MMU_CMD_TIMEOUT) < _millis()) { //resend request after timeout (5 min) - if (mmu_last_cmd != MmuCmd::None) + if (mmu_last_cmd >= MmuCmd::T0 && mmu_last_cmd <= MmuCmd::T4) { if (mmu_attempt_nr++ < MMU_MAX_RESEND_ATTEMPTS) { DEBUG_PRINTF_P(PSTR("MMU retry attempt nr. %d\n"), mmu_attempt_nr - 1); From ef1f82627e022b6c9a66193bf1bd7ec0735228b0 Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Wed, 13 Feb 2019 23:53:00 +0100 Subject: [PATCH 22/25] preHeat @ filament load / unload / autoLoad / MMU MMU options added --- Firmware/Marlin_main.cpp | 5 +- Firmware/mmu.cpp | 8 ++- Firmware/ultralcd.cpp | 115 ++++++++++++++++++++++++++++++--------- Firmware/ultralcd.h | 5 +- 4 files changed, 102 insertions(+), 31 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 4853a4e99..e8cfd8fc1 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -7468,7 +7468,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s #ifdef FILAMENT_SENSOR if (mmu_enabled == false) { - if ((mcode_in_progress != 600) && (!bFilamentAutoloadFlag)) //M600 not in progress, preHeat @ autoLoad menu not active + if ((mcode_in_progress != 600) && (eFilamentAction != e_FILAMENT_ACTION_autoLoad)) //M600 not in progress, preHeat @ autoLoad menu not active { if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL) && !wizard_active) { @@ -7486,9 +7486,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } else { - bFilamentLoad=true; // i.e. filament loading mode + eFilamentAction=e_FILAMENT_ACTION_autoLoad; bFilamentFirstRun=false; - bFilamentAutoloadFlag=true; if(target_temperature[0]>=EXTRUDE_MINTEMP) { bFilamentPreheatState=true; diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 2321b8528..aa6d9d8e0 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -1057,7 +1057,13 @@ void extr_unload() } else { - show_preheat_nozzle_warning(); + eFilamentAction=e_FILAMENT_ACTION_mmuUnLoad; + bFilamentFirstRun=false; + if(target_temperature[0]>=EXTRUDE_MINTEMP) { + bFilamentPreheatState=true; + mFilamentItem(target_temperature[0]); + } + else menu_submenu(mFilamentMenu); } //lcd_return_to_status(); } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index f9e5d12c0..12e448eb9 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -141,6 +141,9 @@ static void lcd_menu_fails_stats_mmu_print(); static void lcd_menu_fails_stats_mmu_total(); static void lcd_menu_show_sensors_state(); +static void mmu_fil_eject_menu(); +static void mmu_load_to_nozzle_menu(); + #if defined(TMC2130) || defined(FILAMENT_SENSOR) static void lcd_menu_fails_stats(); #endif //TMC2130 or FILAMENT_SENSOR @@ -1781,7 +1784,7 @@ void lcd_return_to_status() lcd_refresh(); // to maybe revive the LCD if static electricity killed it. menu_goto(lcd_status_screen, 0, false, true); menu_depth = 0; - bFilamentAutoloadFlag=false; + eFilamentAction=e_FILAMENT_ACTION_none; // i.e. non-autoLoad } //! @brief Pause print, disable nozzle heater, move to park position @@ -2297,21 +2300,32 @@ void lcd_set_filament_oq_meass() } +eFILAMENT_ACTION eFilamentAction=e_FILAMENT_ACTION_none; // must be initialized as 'non-autoLoad' bool bFilamentFirstRun; -bool bFilamentLoad; bool bFilamentPreheatState; -bool bFilamentAutoloadFlag; static void mFilamentPrompt() { lcd_set_cursor(0,0); lcdui_print_temp(LCD_STR_THERMOMETER[0],(int)degHotend(0),(int)degTargetHotend(0)); lcd_set_cursor(0,2); -lcd_puts_P(_i("Press the knob")); +lcd_puts_P(_i("Press the knob")); ////MSG_ c=20 r=1 lcd_set_cursor(0,3); -if(bFilamentLoad) - lcd_puts_P(_i("to load filament")); -else lcd_puts_P(_i("to unload filament")); +switch(eFilamentAction) + { + case e_FILAMENT_ACTION_Load: + case e_FILAMENT_ACTION_autoLoad: + case e_FILAMENT_ACTION_mmuLoad: + lcd_puts_P(_i("to load filament")); ////MSG_ c=20 r=1 + break; + case e_FILAMENT_ACTION_unLoad: + case e_FILAMENT_ACTION_mmuUnLoad: + lcd_puts_P(_i("to unload filament")); ////MSG_ c=20 r=1 + break; + case e_FILAMENT_ACTION_mmuEject: + lcd_puts_P(_i("to eject filament")); ////MSG_ c=20 r=1 + break; + } if(lcd_clicked()) { menu_back(); @@ -2321,15 +2335,29 @@ if(lcd_clicked()) menu_back(); setTargetHotend0(0.0); } - if(bFilamentLoad) + switch(eFilamentAction) { - loading_flag = true; - enquecommand_P(PSTR("M701")); // load filament + case e_FILAMENT_ACTION_Load: + case e_FILAMENT_ACTION_autoLoad: + loading_flag = true; + enquecommand_P(PSTR("M701")); // load filament + break; + case e_FILAMENT_ACTION_unLoad: + enquecommand_P(PSTR("M702")); // unload filament + break; + case e_FILAMENT_ACTION_mmuLoad: + menu_submenu(mmu_load_to_nozzle_menu); + break; + case e_FILAMENT_ACTION_mmuUnLoad: + extr_unload(); + break; + case e_FILAMENT_ACTION_mmuEject: + menu_submenu(mmu_fil_eject_menu); + break; } - else enquecommand_P(PSTR("M702")); // unload filament + if(eFilamentAction==e_FILAMENT_ACTION_autoLoad) + eFilamentAction=e_FILAMENT_ACTION_none; // i.e. non-autoLoad } -if(bFilamentLoad) // i.e. not necessary for preHeat @ unload - bFilamentAutoloadFlag=false; } void mFilamentItem(uint16_t nTemp) @@ -2343,11 +2371,23 @@ lcd_timeoutToStatus.stop(); lcd_set_cursor(0,0); lcdui_print_temp(LCD_STR_THERMOMETER[0],(int)degHotend(0),(int)degTargetHotend(0)); lcd_set_cursor(0,1); -if(bFilamentLoad) - lcd_puts_P(_i("Preheating to load")); -else lcd_puts_P(_i("Preheating to unload")); +switch(eFilamentAction) + { + case e_FILAMENT_ACTION_Load: + case e_FILAMENT_ACTION_autoLoad: + case e_FILAMENT_ACTION_mmuLoad: + lcd_puts_P(_i("Preheating to load")); ////MSG_ c=20 r=1 + break; + case e_FILAMENT_ACTION_unLoad: + case e_FILAMENT_ACTION_mmuUnLoad: + lcd_puts_P(_i("Preheating to unload")); ////MSG_ c=20 r=1 + break; + case e_FILAMENT_ACTION_mmuEject: + lcd_puts_P(_i("Preheating to eject")); ////MSG_ c=20 r=1 + break; + } lcd_set_cursor(0,3); -lcd_puts_P(_i(">Cancel")); +lcd_puts_P(_i(">Cancel")); ////MSG_ c=20 r=1 if(lcd_clicked()) { if(!bFilamentPreheatState) @@ -2357,8 +2397,8 @@ if(lcd_clicked()) } else setTargetHotend0((float)nTargetOld); menu_back(); - if(bFilamentLoad) // i.e. not necessary for preHeat @ unload - bFilamentAutoloadFlag=false; + if(eFilamentAction==e_FILAMENT_ACTION_autoLoad) + eFilamentAction=e_FILAMENT_ACTION_none; // i.e. non-autoLoad } else if(!isHeatingHotend0()) { @@ -2407,8 +2447,8 @@ mFilamentItem(FLEX_PREHEAT_HOTEND_TEMP); void mFilamentBack() { menu_back(); -if(bFilamentLoad) // i.e. not necessary for preHeat @ unload - bFilamentAutoloadFlag=false; +if(eFilamentAction==e_FILAMENT_ACTION_autoLoad) + eFilamentAction=e_FILAMENT_ACTION_none; // i.e. non-autoLoad } void mFilamentMenu() @@ -2433,7 +2473,7 @@ if((degHotend0()>EXTRUDE_MINTEMP)&&bFilamentFirstRun) enquecommand_P(PSTR("M702")); // unload filament } else { - bFilamentLoad=false; // i.e. filament unloading mode + eFilamentAction=e_FILAMENT_ACTION_unLoad; bFilamentFirstRun=false; if(target_temperature[0]>=EXTRUDE_MINTEMP) { @@ -2666,7 +2706,7 @@ static void lcd_LoadFilament() } else { - bFilamentLoad=true; // i.e. filament loading mode + eFilamentAction=e_FILAMENT_ACTION_Load; bFilamentFirstRun=false; if(target_temperature[0]>=EXTRUDE_MINTEMP) { @@ -5578,6 +5618,8 @@ static void fil_load_menu() } static void mmu_load_to_nozzle_menu() +{ +if (degHotend0() > EXTRUDE_MINTEMP) { MENU_BEGIN(); MENU_ITEM_BACK_P(_T(MSG_MAIN)); @@ -5588,8 +5630,21 @@ static void mmu_load_to_nozzle_menu() MENU_ITEM_FUNCTION_P(_i("Load filament 5"), mmu_load_to_nozzle_4); MENU_END(); } +else { + eFilamentAction=e_FILAMENT_ACTION_mmuLoad; + bFilamentFirstRun=false; + if(target_temperature[0]>=EXTRUDE_MINTEMP) + { + bFilamentPreheatState=true; + mFilamentItem(target_temperature[0]); + } + else mFilamentMenu(); + } +} static void mmu_fil_eject_menu() +{ +if (degHotend0() > EXTRUDE_MINTEMP) { MENU_BEGIN(); MENU_ITEM_BACK_P(_T(MSG_MAIN)); @@ -5598,9 +5653,19 @@ static void mmu_fil_eject_menu() MENU_ITEM_FUNCTION_P(_i("Eject filament 3"), mmu_eject_fil_2); MENU_ITEM_FUNCTION_P(_i("Eject filament 4"), mmu_eject_fil_3); MENU_ITEM_FUNCTION_P(_i("Eject filament 5"), mmu_eject_fil_4); - MENU_END(); } +else { + eFilamentAction=e_FILAMENT_ACTION_mmuEject; + bFilamentFirstRun=false; + if(target_temperature[0]>=EXTRUDE_MINTEMP) + { + bFilamentPreheatState=true; + mFilamentItem(target_temperature[0]); + } + else mFilamentMenu(); + } +} #ifdef SNMM static void fil_unload_menu() @@ -6071,7 +6136,7 @@ static void lcd_main_menu() MENU_ITEM_SUBMENU_P(_T(MSG_LOAD_FILAMENT), fil_load_menu); MENU_ITEM_SUBMENU_P(_i("Load to nozzle"), mmu_load_to_nozzle_menu); MENU_ITEM_SUBMENU_P(_i("Eject filament"), mmu_fil_eject_menu); - MENU_ITEM_GCODE_P(_T(MSG_UNLOAD_FILAMENT), PSTR("M702 C")); + MENU_ITEM_FUNCTION_P(_T(MSG_UNLOAD_FILAMENT), extr_unload); } else { diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index c692de537..bf3e4697b 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -133,10 +133,11 @@ void extr_unload_used(); #endif //SNMM void extr_unload(); +typedef enum + {e_FILAMENT_ACTION_none,e_FILAMENT_ACTION_Load,e_FILAMENT_ACTION_autoLoad,e_FILAMENT_ACTION_unLoad,e_FILAMENT_ACTION_mmuLoad,e_FILAMENT_ACTION_mmuUnLoad,e_FILAMENT_ACTION_mmuEject} eFILAMENT_ACTION; // 'none' state is used as flag for (filament) autoLoad (i.e. opposite for 'autoLoad' state) +extern eFILAMENT_ACTION eFilamentAction; extern bool bFilamentFirstRun; -extern bool bFilamentLoad; extern bool bFilamentPreheatState; -extern bool bFilamentAutoloadFlag; void mFilamentItem(uint16_t nTemp); void mFilamentMenu(); void unload_filament(); From 0c1f9b5100b9daf6a57dae07e71cb54b7bf6f508 Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Fri, 15 Feb 2019 02:25:44 +0100 Subject: [PATCH 23/25] preHeat @ filament management target temperature keeping --- Firmware/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 2f0a1d8b0..5f63d4e5e 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2336,7 +2336,7 @@ if(lcd_clicked()) if(!bFilamentPreheatState) { menu_back(); - setTargetHotend0(0.0); +//-// setTargetHotend0(0.0); } switch(eFilamentAction) { From 0f791ce47f55f1b5e8fcdd3ca7bb0f011087adfd Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 15 Feb 2019 14:17:47 +0100 Subject: [PATCH 24/25] mmu needs attention: idler error fix --- Firmware/mmu.cpp | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 5d4b9eecd..cd38a81c8 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -22,7 +22,7 @@ #define MMU_TODELAY 100 #define MMU_TIMEOUT 10 -#define MMU_CMD_TIMEOUT 45000ul //5min timeout for mmu commands (except P0) +#define MMU_CMD_TIMEOUT 45000ul //45s timeout for mmu commands (except P0) #define MMU_P0_TIMEOUT 3000ul //timeout for P0 command: 3seconds #define MMU_MAX_RESEND_ATTEMPTS 2 @@ -41,7 +41,7 @@ uint8_t mmu_cmd = 0; //idler ir sensor uint8_t mmu_idl_sens = 0; bool ir_sensor_detected = false; -bool mmu_loading_flag = false; +bool mmu_loading_flag = false; //when set to true, we assume that mmu2 unload was finished and loading phase is now performed; printer can send 'A' to mmu2 to abort loading process uint8_t mmu_extruder = MMU_FILAMENT_UNKNOWN; @@ -258,7 +258,7 @@ void mmu_loop(void) printf_P(PSTR("MMU <= 'L%d'\n"), filament); #endif //MMU_DEBUG mmu_printf_P(PSTR("L%d\n"), filament); - mmu_state = 3; // wait for response + mmu_state = 3; // wait for response } else if (mmu_cmd == MMU_CMD_C0) { @@ -320,6 +320,20 @@ void mmu_loop(void) } return; case 2: //response to command P0 + if (mmu_idl_sens) + { + if (PIN_GET(IR_SENSOR_PIN) == 0 && mmu_loading_flag) + { +#ifdef MMU_DEBUG + 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")); + } if (mmu_rx_ok() > 0) { fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer @@ -489,11 +503,21 @@ bool can_extrude() return true; } +static void get_response_print_info(uint8_t move) { + printf_P(PSTR("mmu_get_response - begin move: "), move); + switch (move) { + case MMU_LOAD_MOVE: printf_P(PSTR("load\n")); break; + case MMU_UNLOAD_MOVE: printf_P(PSTR("unload\n")); break; + case MMU_TCODE_MOVE: printf_P(PSTR("T-code\n")); break; + case MMU_NO_MOVE: printf_P(PSTR("no move\n")); break; + default: printf_P(PSTR("error: unknown move\n")); break; + } +} + bool mmu_get_response(uint8_t move) { - mmu_loading_flag = false; - printf_P(PSTR("mmu_get_response - begin move:%d\n"), move); + get_response_print_info(move); KEEPALIVE_STATE(IN_PROCESS); while (mmu_cmd != 0) { @@ -547,7 +571,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); + get_response_print_info(move); } break; case MMU_NO_MOVE: @@ -586,7 +610,7 @@ void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move) float x_position_bckp = current_position[X_AXIS]; float y_position_bckp = current_position[Y_AXIS]; uint8_t screen = 0; //used for showing multiscreen messages - + mmu_loading_flag = false; while(!response) { response = mmu_get_response(move); //wait for "ok" from mmu @@ -661,6 +685,7 @@ void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move) } else if (mmu_print_saved) { printf_P(PSTR("MMU starts responding\n")); + mmu_loading_flag = false; if (turn_off_nozzle) { lcd_clear(); From 69ff37729ebc9d8f73bd4afe6e966de9ce8731d4 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 15 Feb 2019 14:19:30 +0100 Subject: [PATCH 25/25] whitespace --- Firmware/mmu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index cd38a81c8..e0f960189 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -320,7 +320,7 @@ void mmu_loop(void) } return; case 2: //response to command P0 - if (mmu_idl_sens) + if (mmu_idl_sens) { if (PIN_GET(IR_SENSOR_PIN) == 0 && mmu_loading_flag) {