Use a servo controlled valve as the part cooling fan?

Greetings! I have an air pump that I use for remote hotend and part cooling on my high temp printer. Currently, the pump output is regulated by the part fan output.

I was wanting to use a servo controlled valve so that I can use an air tank. When the part cooling fan is at 0%, then the valve would be closed with the servo angle 0. When the fan is at 50% the servo angle would be 90, and with the fan at 100% the servo angle would be 180. This is just an example for reference.

Is this something that can be done in Klipper with the servo or PWM controls?

Try

Additional servos, LEDs, buttons, and other pins

https://www.klipper3d.org/Config_Reference.html

Btw, have you posted anywehere how you’re cooling the hot-end? I think compressed air is the way to go, but have not tried yet.

1 Like

Basically quite easy:

[servo myServo]
pin: myPin
initial_angle: 0
maximum_servo_angle = 90
minimum_pulse_width = 0.001
maximum_pulse_width = 0.002

Then control it with:

SET_SERVO SERVO=myServo ANGLE=90
1 Like

Thanks for the help. I am new to Klipper, coming from Marlin.

I understand for the most part what you described. How would I control the servo in Klipper as the part cooling fan?

Thanks! I dont have anything posted. I am just using a diaphragm pump (Berg style) mounted to the outside frame, with some silicone tubing going to a custom V6 hotend fan shroud I designed.

You could build a “delayed gcode macro” that referenced the fan speed (0-255) and convert it to the stepper angle (0-180), then modify the stepper angle automatically.

1 Like

Klipper reports the fan speed between 0.0 and 1.0.

Once you setup your servo like @Sineos posted, then you can use a combination of gcode_macro and delayed_gcode to automate the fan speed to servo angle with something like this:

[delayed_gcode set_stepper_angle_timer]
initial_duration: 1
gcode:
    # Delayed gcode will poll every second and update the servo angle
    SET_STEPPER_ANGLE
    UPDATE_DELAYED_GCODE ID=set_stepper_angle_timer DURATION=1

[gcode_macro SET_STEPPER_ANGLE]
gcode:
    # Set the servo angle based on the part cooling fan speed
    # Fan = 0.0, servo angle = 0
    # Fan = 0.5, servo angle = 90
    # Fan = 1.0, servo angle = 180
    SET_SERVO SERVO=myServo ANGLE={% printer.fan.speed * 180 %}

I might not have the Jinja2 syntax correct {% printer.fan.speed * 180 %}, and if you are not using the standard part cooling fan, that will need to be adjusted as well.

Hope this helps.

1 Like

Nice ideas @jjarosz
Another approach could be to define a custom M106 macro (no idea if this would work) or a completely new command and post-process your GCODE file to use the new command instead of the regular M106.

Quite specific requirement, so probably a lot tinkering.

@jjarosz Thanks for the help! I will try to get it working based on your suggestion. I am new to Klipper and havent tried any of the custom macro stuff yet so this should be a fun rabbit hole. Thanks again.

Hi, I am trying to understand the configuration syntax and whether it provides a way to tell Klipper that I am using a [fan] that is controlled like a [servo] rather than by PWM.

For example something like:

[servo myservo]
…

[fan myservo]
…

Hey AMV101!
How did this work? I had the same idea and just came across this in my search for answers. I have everything in place, just trying to get the config to work.

Yes I think it worked from my tests, but I moved on from that idea and cant remember if I had to change anything.

Hello everyone,
I’d like to revive this conversation as I am trying this avenue myself. Thanks to the previous posters who have helped.
I am having trouble with jjarosz answer as Klipper will not recognize the name seen at the bottom, printer.fan.speed
I tried removing printer and also putting fan in brackets to no avail. How do I reference the fan speed into the macro controlling the servo?
I have attached my printer.cfg file below
printer.cfg (3.6 KB)