mirror of
https://github.com/Klipper3d/klipper.git
synced 2026-02-08 09:10:56 -07:00
Merge 84fc18e466 into 6d7d3403e4
This commit is contained in:
commit
b71c32f1ff
2 changed files with 10 additions and 1 deletions
|
|
@ -3349,6 +3349,9 @@ information.
|
|||
# The minimum fan speed (expressed as a value from 0.0 to 1.0) that
|
||||
# the fan will be set to for PID temperature fans.
|
||||
# The default is 0.3.
|
||||
#invert_control: False
|
||||
# The control output is inverted. Useful for bed fans that
|
||||
# are supposed to increase temperature instead of decreasing it.
|
||||
#gcode_id:
|
||||
# If set, the temperature will be reported in M105 queries using the
|
||||
# given id. The default is to not report the temperature via M105.
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ class TemperatureFan:
|
|||
algos = {'watermark': ControlBangBang, 'pid': ControlPID}
|
||||
algo = config.getchoice('control', algos)
|
||||
self.control = algo(self, config)
|
||||
self.invert_control = config.getboolean('invert_control', False)
|
||||
self.next_speed_time = 0.
|
||||
self.last_speed_value = 0.
|
||||
gcode = self.printer.lookup_object('gcode')
|
||||
|
|
@ -70,6 +71,8 @@ class TemperatureFan:
|
|||
return self.min_speed
|
||||
def get_max_speed(self):
|
||||
return self.max_speed
|
||||
def get_invert_control(self):
|
||||
return self.invert_control
|
||||
def get_status(self, eventtime):
|
||||
status = self.fan.get_status(eventtime)
|
||||
status["temperature"] = round(self.last_temp, 2)
|
||||
|
|
@ -127,7 +130,7 @@ class ControlBangBang:
|
|||
elif (not self.heating
|
||||
and temp <= target_temp-self.max_delta):
|
||||
self.heating = True
|
||||
if self.heating:
|
||||
if self.heating != self.temperature_fan.get_invert_control():
|
||||
self.temperature_fan.set_tf_speed(read_time, 0.)
|
||||
else:
|
||||
self.temperature_fan.set_tf_speed(
|
||||
|
|
@ -170,6 +173,9 @@ class ControlPID:
|
|||
temp_integ = max(0., min(self.temp_integ_max, temp_integ))
|
||||
# Calculate output
|
||||
co = self.Kp*temp_err + self.Ki*temp_integ - self.Kd*temp_deriv
|
||||
# Handle inverted control
|
||||
if self.temperature_fan.get_invert_control():
|
||||
co = self.temperature_fan.get_max_speed() - co
|
||||
bounded_co = max(0., min(self.temperature_fan.get_max_speed(), co))
|
||||
self.temperature_fan.set_tf_speed(
|
||||
read_time, max(self.temperature_fan.get_min_speed(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue