Temperature_fan for chamber and set from Superslicer

Hi, I have a temperature_fan that I’m hopefully trying to have set from superslicer’s chamber temperature setting being passed in. The idea is that once the chamber gets up to temp the fan will use PID to control it so that it stays around the target. (I don’t have a heater for the chamber, so it works using bed heat)

[temperature_fan exhaust_fan]
#  Exhaust fan - FAN3
pin: PD13
shutdown_speed: 0.0
kick_start_time: 5.0
sensor_type: NTC 100K MGB18-104F39050L32
sensor_pin: PF6
gcode_id: C
control: watermark
min_temp: 0
max_temp: 100

What I can’t figure out is how to get it to set a target temperature based on a value from super slicer. I’m passing M141 S[chamber_temperature] in my start gcode from superslicer but it doesn’t seem to set target_temp. What am I doing wrong?

You need to create an M141 macro that uses SET_TEMPERATURE_FAN_TARGET to control the target temp.

https://www.klipper3d.org/G-Codes.html#set_temperature_fan_target

Ok, thanks!

Could you provide me a little more detail? How does one get the value from the gcode that comes in on M141? Does that automatically then execute on m141 in gcode? I see that there is param. notation but I don’t know what the param would be for the above M141 S[temp] command?

Instead of using M141, create a macro called SET_CHAMBER_TEMP (or whatever you like).

In your start gcode, call it using SET_CHAMBER_TEMP CTEMP=[chamber_temperature]

Then, start your macro like this:

gcode:
    {% set myTemp = params.CTEMP|default(50)|int %}
1 Like

So then I get an unknown gcode m141. It would be preferable to be able to get the value of the m141 that is passed in and call the macro m141. I can’t find anything on how to get that?

The only I can think of that might work is to use “rawparams” and parse the value yourself, but I’ve never tried it so I don’t know for sure. See Commands templates - Klipper documentation for some info on using rawparams

[gcode_macro M141]

gcode:
    SET_TEMPERATURE_FAN_TARGET TEMPERATUE_FAN=exhaust_fan TARGET={params.S}

Will not work?

Yes! That works!

Mainsail has a bug on it though because it will prompt for a value of S but it passes = S instead of just S so it doesn’t work in the UI but it does work in GCode.

Thanks!

Nice solution! I just learned something new, thank you!