What's new
VORON Design

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members!

Electronics compartment cooling fans.

FriedPCB

Active member
Does anyone know of way of turning on the the 60x20 cooling fans for the electronics compartment when the RPI temperature hits a certain temperature threshold?
The fans work well to cool the compartment and RPI while printing but I'm interested in knowing how to turn them on while the printer is idle. Thanks.
 
My solution probably isn't the most elegant, but it works.
Python:
[delayed_gcode skirt_fan_boot]
initial_duration: 1.0
gcode:
  {% if printer.print_stats.state|lower != "printing" %}
    SET_FAN_SPEED FAN=controller_fan SPEED=0.5
  {% else %}
    SET_FAN_SPEED FAN=controller_fan SPEED=0.75 #just so I can see if this is getting called
  {% endif %}
  UPDATE_DELAYED_GCODE ID=skirt_fan DURATION=5


# Pi temperature monitoring loop. Check temp every 5 minutes & turn on skirt fans if too hot. Turn off if cool.
[delayed_gcode skirt_fan]
gcode:
  {% if printer.print_stats.state|lower != "printing" %}
    {% if printer['temperature_sensor pi_4_mcu'].temperature >= 50 %}
      SET_FAN_SPEED FAN=controller_fan SPEED=1
    {% elif  printer['temperature_sensor pi_4_mcu'].temperature < 40 %}
      SET_FAN_SPEED FAN=controller_fan SPEED=0
    {% endif %}
  {% else %}
    SET_FAN_SPEED FAN=controller_fan SPEED=1
  {% endif %}
  UPDATE_DELAYED_GCODE ID=skirt_fan DURATION=300
 
My solution probably isn't the most elegant, but it works.
Python:
[delayed_gcode skirt_fan_boot]
initial_duration: 1.0
gcode:
  {% if printer.print_stats.state|lower != "printing" %}
    SET_FAN_SPEED FAN=controller_fan SPEED=0.5
  {% else %}
    SET_FAN_SPEED FAN=controller_fan SPEED=0.75 #just so I can see if this is getting called
  {% endif %}
  UPDATE_DELAYED_GCODE ID=skirt_fan DURATION=5


# Pi temperature monitoring loop. Check temp every 5 minutes & turn on skirt fans if too hot. Turn off if cool.
[delayed_gcode skirt_fan]
gcode:
  {% if printer.print_stats.state|lower != "printing" %}
    {% if printer['temperature_sensor pi_4_mcu'].temperature >= 50 %}
      SET_FAN_SPEED FAN=controller_fan SPEED=1
    {% elif  printer['temperature_sensor pi_4_mcu'].temperature < 40 %}
      SET_FAN_SPEED FAN=controller_fan SPEED=0
    {% endif %}
  {% else %}
    SET_FAN_SPEED FAN=controller_fan SPEED=1
  {% endif %}
  UPDATE_DELAYED_GCODE ID=skirt_fan DURATION=300
Thanks. Is this something you put in printer.cfg? How does it get invoked? Sorry if these are stupid questions, I'm still learning my way around Klipper. Thanks again.
 
Thanks. Is this something you put in printer.cfg? How does it get invoked? Sorry if these are stupid questions, I'm still learning my way around Klipper. Thanks again.
Could you pls share how exactly it is done? Learning to understand Klipper as well :)
 
Could you pls share how exactly it is done? Learning to understand Klipper as well :)
Well, I thought I understood what to do but it doesn't work. I 'm not sure what I'm doing wrong. I put the 2 macros into printer.cfg then saved and restarted the firmware. Nothing happens! I even tried to force the fans on by commenting out all the if statements in the skirt_fan macro - still nothing. I'm missing something and I haven't quite figured it out yet. I'll be sure to let know if I make any progress.
 
Ok. I got it working. I was missing some additional code plus I'm still learning Klipper syntax and how it all connects. This is what I got.

[temperature_sensor raspberry_pi]
sensor_type: temperature_host
min_temp:10
max_temp: 100

[duplicate_pin_override]
pins: PD12 # this is the pin number that controller_fan uses in my printer.cfg

[fan_generic cpu_fans]
pin: PD12

[delayed_gcode skirt_fan_boot]
initial_duration: 1.0
gcode:
{% if printer.print_stats.state|lower != "printing" %}
SET_FAN_SPEED FAN=cpu_fans SPEED=.5
{% else %}
SET_FAN_SPEED FAN=cpu_fans SPEED=0.75 #just so I can see if this is getting called
{% endif %}
UPDATE_DELAYED_GCODE ID=skirt_fan DURATION=5

# Pi temperature monitoring loop. Check temp every 5 minutes & turn on skirt fans if too hot. Turn off if cool.
[delayed_gcode skirt_fan]
gcode:
{% if printer.print_stats.state|lower != "printing" %}
{% if printer['temperature_sensor raspberry_pi'].temperature >= 50 %}
SET_FAN_SPEED FAN=cpu_fans SPEED=1
{% elif printer['temperature_sensor raspberry_pi'].temperature < 40 %}
SET_FAN_SPEED FAN=cpu_fans SPEED=0
{% endif %}
{% else %}
SET_FAN_SPEED FAN=cpu_fans SPEED=1
{% endif %}
UPDATE_DELAYED_GCODE ID=skirt_fan DURATION=300

You have to have the above defined in printer.cfg - [temperature_sensor raspberry_pi]. claudermilk calls it "pi_4_mcu". Use what ever name you defined it as - in my case raspberry_pi.
I could not get "controller_fan" to work although it was previously defined in my config file. I don't know why, I may still be missing something.
I had to create a [fan_generic] fan section. I called it cpu_fans to avoid any confusion with controller_fan. Lastly I had to add a [duplicate_pin_override] section for the controller fans otherwise Klipper didn't like having the pin# defined more than one section. I'm not sure if this a smart thing to do but it was the only way to get it to work. If I doing something wrong, let me know. I would still like to know why the controller_fan reference does not work.
 
I should have stipulated that. The fan has to be defined as fan_generic. I now recall I tried to make it work as a controller_fan and it wouldn't; I'd also like to know why. It's some quirk of how Klipper defines them, but I have no idea what it does different between generic and controller fans. I only have the generic pin definition in my config files.

@Yezariael yes, this goes into your printer.cfg file.
 
:) When you say generic pin, do you mean generic fan? Did you have to add a [duplicate_pin_override] section in your file? Without it, Klipper doesn't like the pin being defined in more than one section. If you didn't, how did you define the pin in [generic_fan]? Thanks.
 
I did not have to add a duplicate_pin_override. It sounds like you have that pin defined somewhere else. I just altered the default fan definition:
Python:
[fan_generic controller_fan]
#  Controller fan - FAN2
#  Generic so it can be controlled via delayed_gcode
pin: PD12
max_power: 1.0
kick_start_time: 0.5
 
I went the simple route - I used the controller_fan option. Whenever the controllers are alive and holding motors, the fans run. When the controller is timed out and the motors are inactive, the fans do not run. Shutdown speed is set to full in case there is a problem.

Code:
[controller_fan controller_fan]
pin: z:P2.4
shutdown_speed: 1.0
cycle_time: 0.04
kick_start_time: 0.5
fan_speed: 0.4
idle_speed: 0.4
 
I did not have to add a duplicate_pin_override. It sounds like you have that pin defined somewhere else. I just altered the default fan definition:
Python:
[fan_generic controller_fan]
#  Controller fan - FAN2
#  Generic so it can be controlled via delayed_gcode
pin: PD12
max_power: 1.0
kick_start_time: 0.5
I will check the printer.cfg file when I get a chance. If I recall I did have the pin previously defined but I'm not sure why :unsure:. Thanks for your help and input.
 
I went the simple route - I used the controller_fan option. Whenever the controllers are alive and holding motors, the fans run. When the controller is timed out and the motors are inactive, the fans do not run. Shutdown speed is set to full in case there is a problem.

Code:
[controller_fan controller_fan]
pin: z:P2.4
shutdown_speed: 1.0
cycle_time: 0.04
kick_start_time: 0.5
fan_speed: 0.4
idle_speed: 0.4
If I understand correctly, this won't provide any cooling to the rpi during periods of inactivity. Correct or am I missing something? I'm trying to run the fans even when everything is inactive to provide cooling to the rpi. Thanks.
 
Klipper has support for temperature_fan. This associates a specific fan with a temperature sensor and controls it similar to the way the hotend fan is controlled (either using a watermark or a pid controller). I'm using this to enable either side of my skirt fans based on the Raspberry Pi / Octopus temperature using the following:

Code:
[temperature_fan Pi]
pin: PD12
sensor_type: temperature_host
kick_start_time: 0.5
off_below: 0.1
max_power: 0.5
shutdown_speed: 0
min_speed: 0
min_temp: 0
max_temp: 85
target_temp: 55
control: pid
pid_kp: 1.0
pid_ki: 0.5
pid_kd: 2.0

[temperature_fan Octopus]
pin: PD13
sensor_type: temperature_mcu
kick_start_time: 0.5
off_below: 0.1
max_power: 0.5
min_speed: 0
shutdown_speed: 0
min_temp: 0
max_temp: 85
target_temp: 55
control: pid
pid_kp: 1.0
pid_ki: 0.5
pid_kd: 2.0

I didn't really tune the pid controller, but this appears to work good enough for me.
 
Last edited:
If I understand correctly, this won't provide any cooling to the rpi during periods of inactivity. Correct or am I missing something? I'm trying to run the fans even when everything is inactive to provide cooling to the rpi. Thanks.
Then don’t use my option. I find the Pi doesn’t generate enough heat when the printer is idle to need cooling, but that’s my opinion.
 
In my opinion, your bigger risk is that the pi doesn't heat enough to turn on the fans, and your step sticks then don't get cooled during a print. Which, unfortunately is a scenario that's far more likely to do actual damage
 
In my setup I have the printer override my auto cooling cycle & just turn the fans on full in print_start, then restart the cycle again in print_end. The Octopus sits at about 41-42C when idle. The Pi will climb to over 50C since it's never truly idle, so I set up that cycle.

In print_start near the beginning:
UPDATE_DELAYED_GCODE ID=skirt_fan DURATION=0
SET_FAN_SPEED FAN=controller_fan SPEED=1

In print_end near the end:
UPDATE_DELAYED_GCODE ID=skirt_fan DURATION=5
 
Top