diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 2951dc7161..f340844ddd 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -9689,6 +9689,7 @@ inline void gcode_M400() { stepper.synchronize(); } inline void gcode_M404() { if (parser.seen('W')) { filament_width_nominal = parser.value_linear_units(); + planner.volumetric_area_nominal = CIRCLE_AREA(filament_width_nominal * 0.5); } else { SERIAL_PROTOCOLPGM("Filament dia (nominal mm):"); diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index e507708615..daaafa90c7 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -95,6 +95,7 @@ int16_t Planner::flow_percentage[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(100); // Extru float Planner::e_factor[EXTRUDERS], // The flow percentage and volumetric multiplier combine to scale E movement Planner::filament_size[EXTRUDERS], // diameter of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder + Planner::volumetric_area_nominal = CIRCLE_AREA((DEFAULT_NOMINAL_FILAMENT_DIA) * 0.5), // Nominal cross-sectional area Planner::volumetric_multiplier[EXTRUDERS]; // Reciprocal of cross-sectional area of filament (in mm^2). Pre-calculated to reduce computation in the planner uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N], diff --git a/Marlin/planner.h b/Marlin/planner.h index 17421b5bc5..fb593f6185 100644 --- a/Marlin/planner.h +++ b/Marlin/planner.h @@ -144,6 +144,7 @@ class Planner { static float e_factor[EXTRUDERS], // The flow percentage and volumetric multiplier combine to scale E movement filament_size[EXTRUDERS], // diameter of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder + volumetric_area_nominal, // Nominal cross-sectional area volumetric_multiplier[EXTRUDERS]; // Reciprocal of cross-sectional area of filament (in mm^2). Pre-calculated to reduce computation in the planner // May be auto-adjusted by a filament width sensor diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 1ab024d868..d6e8d80e10 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -814,8 +814,9 @@ void Temperature::manage_heater() { // Get the delayed info and add 100 to reconstitute to a percent of // the nominal filament diameter then square it to get an area - const float vmroot = measurement_delay[meas_shift_index] * 0.01 + 1.0; - planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vmroot <= 0.1 ? 0.01 : sq(vmroot); + float vmroot = measurement_delay[meas_shift_index] * 0.01 + 1.0; + NOLESS(vmroot, 0.1); + planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = 1.0 / CIRCLE_AREA(vmroot / 2); planner.refresh_e_factor(FILAMENT_SENSOR_EXTRUDER_NUM); } #endif // FILAMENT_WIDTH_SENSOR diff --git a/Marlin/ultralcd_impl_DOGM.h b/Marlin/ultralcd_impl_DOGM.h index d05fe9c68f..57cf12deee 100644 --- a/Marlin/ultralcd_impl_DOGM.h +++ b/Marlin/ultralcd_impl_DOGM.h @@ -651,12 +651,9 @@ static void lcd_implementation_status_screen() { #if ENABLED(FILAMENT_LCD_DISPLAY) strcpy(wstring, ftostr12ns(filament_width_meas)); if (parser.volumetric_enabled) - strcpy(mstring, itostr3(100.0 * filament_width_meas / filament_width_nominal)); + strcpy(mstring, itostr3(100.0 * planner.volumetric_area_nominal / planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM])); else strcpy_P(mstring, PSTR("---")); - // Alternatively, show the ratio between cross-sectional areas: - //strcpy(mstring, itostr3(100.0 / CIRCLE_AREA(filament_width_nominal * 0.5) - // / planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM])); #endif } diff --git a/Marlin/ultralcd_impl_HD44780.h b/Marlin/ultralcd_impl_HD44780.h index a4c6b18fbb..760443edf3 100644 --- a/Marlin/ultralcd_impl_HD44780.h +++ b/Marlin/ultralcd_impl_HD44780.h @@ -858,7 +858,7 @@ static void lcd_implementation_status_screen() { lcd.print(ftostr12ns(filament_width_meas)); lcd_printPGM(PSTR(" V")); if (parser.volumetric_enabled) { - lcd.print(itostr3(100.0 * filament_width_meas / filament_width_nominal)); + lcd.print(itostr3(100.0 * planner.volumetric_area_nominal / planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM])); lcd.write('%'); } else