From b931a58338cadd9ea205fc057b2126d0191470a5 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Thu, 2 Jan 2025 20:32:54 +0100 Subject: [PATCH 1/2] updated docs to reflect actual mpc behaviour docs and code had a discrepancy which is now fixed also removed some redundant code --- docs/MPC.md | 10 +++++---- klippy/extras/control_mpc.py | 39 +++++++++++++++++------------------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/docs/MPC.md b/docs/MPC.md index 3c17f6f05..7ccca4fff 100644 --- a/docs/MPC.md +++ b/docs/MPC.md @@ -24,7 +24,7 @@ To use MPC as the temperature controller for the extruder use the following basi [extruder] control: mpc heater_power: 50 -cooling_fan: fan +cooling_fan: filament_diameter: 1.75 filament_density: 1.20 filament_heat_capacity: 1.8 @@ -42,9 +42,11 @@ filament_heat_capacity: 1.8 heater. Setting heater_power to the power output at the expected printing temperature is recommended. -- `cooling_fan: fan` - _Default Value: fan_ - This is the fan that is cooling extruded filament and the hotend. +- `cooling_fan:` + _Default Value: Nothing_ + This is the fan that is cooling extruded filament and the hotend. + Default is no fan so there will be no fan transfer tests conducted if no + `cooling_fan` is specified Specifying "fan" will automatically use the part cooling fan. - `filament_diameter: 1.75` diff --git a/klippy/extras/control_mpc.py b/klippy/extras/control_mpc.py index 1f7c5673e..d9155f11a 100644 --- a/klippy/extras/control_mpc.py +++ b/klippy/extras/control_mpc.py @@ -417,7 +417,6 @@ def run(self, gcmd): ambient_max_measure_time, ambient_measure_sample_time, fan_breakpoints, - new_control, first_res, ) second_res = self.process_second_pass( @@ -588,7 +587,6 @@ def transfer_test( ambient_max_measure_time, ambient_measure_sample_time, fan_breakpoints, - control, first_pass_results, ): target_temp = round(first_pass_results["post_block_temp"]) @@ -609,27 +607,26 @@ def transfer_test( ) gcmd.respond_info(f"Average stable power: {power_base} W") else: - if fan is not None: - for idx in range(0, fan_breakpoints): - speed = idx / (fan_breakpoints - 1) - curtime = self.heater.reactor.monotonic() - print_time = fan.get_mcu().estimated_print_time(curtime) - fan.set_speed(print_time + PIN_MIN_TIME, speed) - gcmd.respond_info("Waiting for temperature to stabilize") - self.wait_stable(3) - gcmd.respond_info( - f"Temperature stable, measuring power usage with {speed*100.:.0f}% fan speed" - ) - power = self.measure_power( - ambient_max_measure_time, ambient_measure_sample_time - ) - gcmd.respond_info( - f"{speed*100.:.0f}% fan average power: {power:.2f} W" - ) - fan_powers.append((speed, power)) + for idx in range(0, fan_breakpoints): + speed = idx / (fan_breakpoints - 1) curtime = self.heater.reactor.monotonic() print_time = fan.get_mcu().estimated_print_time(curtime) - fan.set_speed(print_time + PIN_MIN_TIME, 0.0) + fan.set_speed(print_time + PIN_MIN_TIME, speed) + gcmd.respond_info("Waiting for temperature to stabilize") + self.wait_stable(3) + gcmd.respond_info( + f"Temperature stable, measuring power usage with {speed*100.:.0f}% fan speed" + ) + power = self.measure_power( + ambient_max_measure_time, ambient_measure_sample_time + ) + gcmd.respond_info( + f"{speed*100.:.0f}% fan average power: {power:.2f} W" + ) + fan_powers.append((speed, power)) + curtime = self.heater.reactor.monotonic() + print_time = fan.get_mcu().estimated_print_time(curtime) + fan.set_speed(print_time + PIN_MIN_TIME, 0.0) power_base = fan_powers[0][1] return { From a1f3faa7b0e84c4692016f4503c957ce476ac56d Mon Sep 17 00:00:00 2001 From: Zeanon Date: Thu, 2 Jan 2025 20:51:34 +0100 Subject: [PATCH 2/2] Update MPC.md --- docs/MPC.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/MPC.md b/docs/MPC.md index 7ccca4fff..dd64f4609 100644 --- a/docs/MPC.md +++ b/docs/MPC.md @@ -44,9 +44,8 @@ filament_heat_capacity: 1.8 - `cooling_fan:` _Default Value: Nothing_ - This is the fan that is cooling extruded filament and the hotend. - Default is no fan so there will be no fan transfer tests conducted if no - `cooling_fan` is specified + The fan that is cooling extruded filament and the hotend. Default is no fan so + there will be no fan taken into account for controlling the heater. Specifying "fan" will automatically use the part cooling fan. - `filament_diameter: 1.75`