Code Help - Update chamber temps after print start

Basic Information:

Printer Model: Voron 350
MCU / Printerboard: Manta M8p
Host / SBC: CM4
klippy.log

Fill out above information and in all cases attach your klippy.log file (use zip to compress it, if too big). Pasting your printer.cfg is not needed
Be sure to check our “Knowledge Base” Category first. Most relevant items, e.g. error messages, are covered there

Describe your issue:

Background: 350 Voron so a larger cavity and it takes a while to heatsoak. What I’ve been doing is to have the printer heat soak to 47C then start the print. But I want the chamber to go up to 55 C after the print starts. It can get there after the print is running, but there isn’t enough heat added to the chamber prior to print start (because the hotend isn’t running).

Getting to 47*C works fine, no issues there, but I’ve added some code to the end of the Print_Start macro that is supposed to update chamber temps to 55… but it’s not working.

I pass the material type to the printer from Cura and that works. I added in some debug calls to print out the status of the filament type and targets. So I know that the If/Then code works. But I ask the printer to update the chamber temp to 55 (for ABS) but that call isn’t working as the following console readout still says 47*C. I actually do it twice with the M141 macro call then the “manual” way just after. Neither works.

Question: Do I need to use a “Delayed_Gcode” macro to do this? Or does somebody else have an idea?

I can update the chamber temp normally from the dashboard once the print starts. but that’s manual not automatic.

The console status at print start (reverse chronological order):

01:52:28 PM : Chamber for ABS set at 47 / 55
01:52:23 PM : Print Start
01:50:38 PM : Hotend: 260c

(if it worked correctly, the 1st line should read: set at 55 / 55)

I can either edit the chamber temp from the console or type in:

SET_TEMPERATURE_FAN_TARGET temperature_fan=Chamber target=55

manually so that works, once the print has started.

End of the Print Start Macro:

SET_DISPLAY_TEXT MSG="Printer goes brr"          # Displays info
    RESPOND TYPE=echo MSG="Print Start"
    _status_printing                                 # Sets SB-leds to printing-mode
    _Party_Printing                                  # Party Lights
    G0 X{x_wait - 50} Y4 F10000                      # Moves to starting point
    G0 Z0.4                                          # Raises Z to 0.4
    G91                                              # Incremental positioning 
    G1 X100 E20 F1000                                # Purge line
    G90

   # Set material specific chamber and other settings

    {% if FILAMENT_TYPE == 'ABS' %}
        M141 S55
        SET_TEMPERATURE_FAN_TARGET temperature_fan=Chamber target=55
        RESPOND TYPE=echo MSG="Chamber for {FILAMENT_TYPE} set at {target_Chamber} / 55"
        #SET_PRESSURE_ADVANCE EXTRUDER=extruder ADVANCE=0.035
    {% elif FILAMENT_TYPE == 'Nylon' %}
        M141 S50
        SET_TEMPERATURE_FAN_TARGET temperature_fan=Chamber target=50
        RESPOND TYPE=echo MSG="Chamber for {FILAMENT_TYPE} set at {target_Chamber} / 50"
        #SET_PRESSURE_ADVANCE EXTRUDER=extruder ADVANCE=0.035
    {% elif FILAMENT_TYPE == 'PETG' %}
        SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=Chamber TARGET=40
        RESPOND TYPE=echo MSG="Chamber for {FILAMENT_TYPE} set at {target_Chamber} / 40"
        #SET_PRESSURE_ADVANCE EXTRUDER=extruder ADVANCE=0.035
    {% elif FILAMENT_TYPE == 'PLA' %}
        SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=Chamber TARGET=30
        RESPOND TYPE=echo MSG="Chamber for {FILAMENT_TYPE} set at {target_Chamber} / 30"
        #SET_PRESSURE_ADVANCE EXTRUDER=extruder ADVANCE=0.035        
    {% endif %}


klippy (3).zip (1.5 MB)

No, it shouldn’t. It should read “set at {target_Chamber} / 55”, because that’s what you’ve specified in your macro. target_Chamber is your initial target of 47, so the output you’ve provided is what is expected when everything is working correctly.

But these lines are before the console call:

M141 S55
SET_TEMPERATURE_FAN_TARGET temperature_fan=Chamber target=55

Then it’s:

RESPOND TYPE=echo MSG="Chamber for {FILAMENT_TYPE} set at {target_Chamber} / 55"

Either one of those two lines should have updated the chamber temp target to 55, but they don’t.

Those lines are irrelevant to the output. target_Chamber is a variable that you created and set to 47, so it has the value 47, which your output reflects.

I do not have a line in the print_start macro to set that variable. I have an earlier call from the Cura file that sets it at 47.

But I’m trying to change that variable AFTER the print starts with the last If/else/then set in the original post.

I can manually try to change the 47 to 55 once the print starts either through the console or through the GUI. So that works.

I’m just trying to do that automatically based on the material type (hence the if/else/then statement).

So how do I automate that change? (vs just telling me I’m doing it wrong).

=====

M141 macro:

###################################
## 	Chamber Temp Control
##  https://github.com/zellneralex/klipper_config/blob/master/fan.cfg
##  https://github.com/claudermilk/TridentBackup/blob/master/fans.cfg
###################################

[gcode_macro M141]
description: Set temperature of Chamber fan
gcode: SET_TEMPERATURE_FAN_TARGET temperature_fan=Chamber target={params.S|default(0)}

Yes, you do.

{% set target_Chamber = params.CHAMBER|default("40")|int %}

This is the only time this variable is set, so this is the value it’s expected to have every time you reference it (params.CHAMBER, which in the case of this print is 47).

No, you aren’t. You’re trying to change the fan’s target temperature. You have provided no evidence that your attempt to change the target temperature is failing, so my assumption is that it is successful.

I did not, at any point, tell you that you were doing it wrong. I explained that you were misinterpreting the output. As far as I know you are doing it correctly, you just believe you’re doing it wrong because your expectations for what will be output are incorrect.

I’ll ask again - how do I automate this change in code?

What I want the printer to do is:

  1. Heat chamber to 47.
  2. Start the print.
  3. Then automatically raise chamber temp to 55 (based on material)

I do not have a line in the print_start macro to set that variable. I have an earlier call from the Cura file that sets it at 47.

This line:

{% set target_Chamber = params.CHAMBER|default(“40”)|int %}

Sets it to a default of 40… BUT Cura changes it to 47 - as I explained in my original post. It is not setting the chamber to 40 - because I have the code change it to 47 based on a pull from Cura. Cura sets CHAMBER to 47 for ABS.

So no, I do not have a variable call in the print start to set that to 47 - because Cura sets that to 47.

I can raise the temperature manually to 55 (material dependent) but I want that to be done automatically. That is the intent of the code block I posted originally. I want to change that variable FROM 47 to 55 (based on material).

I’ll say it again - you’ve already automated that change in code.

No, Cura does not change it, because Cura does not have the ability to change variables. This line sets it to 47, and that’s the only place this variable is set so that’s the only value it has.

No, you don’t. You want to change the fan’s target temperature, which you’ve already done. You can, if you want, do that by first changing this variable and then using this variable when you change the target temperature, but it’s not necessary.

The usual workflow would be:

  1. Have a START_PRINT macro that processes the starting gcode from the slicer, e.g. with {% set target_Chamber = params.CHAMBER|default("40")|int %}
  2. Have the slicer’s starting gcode set your chamber temperature according to the material needs, e.g. Cura Material Plugin and a call similar to START_PRINT CHAMBER={build_volume_temperature} ...
  3. Heat up chamber, nozzle and bed. Length of heat soaking or waiting for minimum temperatures etc can be controlled from the START_PRINT macro
  4. Start printing

Apparently I’m not explaining what I’d like to happen simply enough.

  1. Cura tells printer chamber temp based on material (47c for ABS) via gcode

  2. Klipper has printer heat up to desired temp for a heat soak (47c)

  3. Start print

  4. Automatically update chamber temp to a higher temp (55c)

    • Because chamber won’t get to 55 without the hotend also on - (will burn filament if I turn on hotend). Heated bed doesn’t put out enough watts to get there. So 47*C for ABS heatsoak. But prints work better with a hotter chamber, so desire for 55c chamber.

Everything works properly - EXCEPT - chamber isn’t changing temperature to the higher chamber temp after print starts. This is what I’m trying to do with the last if/else/then statement posted above.

So, how can I ask the printer to update chamber temp targets after heatsoak has completed?

What evidence do you have that this is not happening? Everything that you’ve showed indicates that it is.

Either I do not understand your intention or it makes no sense.

If you wish to have a chamber temperature of whatever degrees centigrade, then you should tell the slicer to aim for this temperature.
If your hardware does not support this temperature, what is Klipper supposed to do?

If you want to heat-soak at a lower temperature, then you can do something like:

set target_Chamber = params.CHAMBER|default("40")|int %}
set target_Chamber_Soak = params.CHAMBER_SOAK|default("40")|int %}
...
...
M191 S{target_Chamber_Soak}

and then call your start macro with something like

START_PRINT CHAMBER_SOAK=47 ...

of course this is assuming that Cura later adds a M191 S{build_volume_temperature} to the gcode.

Dunno if I can get more clear than this as to what I want it to do.

I want to do it this way because the chamber won’t heat soak to 55. 47 takes about 30 minutes. It won’t get to 55 without the hotend on. But if I use the hotend, it will burn the filament.

Once the print starts it will get to 55 with the hotend on after about 10-15 minutes of printing.

But after the print starts, I want to allow the chamber to get up to 55 without changing it manually, because doing that requires that I pay attention to it.

I can either change it via the GUI or by console entry command. But I want it to raise the chamber temp to 55 automatically.

I’ll emphasis again - everything works properly (95% of the code comes from the “better start gcode” macros combined with some of the Ellis stuff).

I’m just trying to automate allowing the chamber temp to go from 47 to 55 after the print starts.

In short words: If the chamber can’t reach 55C by it’s own, it is not suitable for 55°C.

You should install a more powerful chamber heater.

I don’t know how much more clearly I can say this: there’s nothing wrong with the code you showed us and the output that you showed is consistent with that code working correctly. If the value ends up something other than what you expect it’s due to something outside of what you showed us (e.g. a hard-coded change to the fan settings in the G-code file itself after START_PRINT is called.)

Still not sure how much sense this makes, but would the following satisfy your requirement?

[gcode_macro M141]
description: Set temperature of Chamber fan
gcode: SET_TEMPERATURE_FAN_TARGET temperature_fan=Chamber target={params.S|default(0)}

[gcode_macro START_PRINT]
gcode:
    # ... whatever you need
    {% set TARGET_CHAMBER = params.CHAMBER|default(0)|float %}

    # Check if a chamber temperature over 47°C is requested
    # by the slicer. If so, only pre-heat up to 47°C
    {% if TARGET_CHAMBER > 47.0 %}
        M141 S47
    {% else %}
        M141 S{TARGET_CHAMBER}
    {% endif %}

    # ... whatever you need
  1. In the slicer you set a {build_volume_temperature} to the max you want to reach, e.g. 55 °C
  2. The macro would be called from the slicer via START_PRINT CHAMBER={build_volume_temperature} ...
  3. START_PRINT macro checks if a temp bigger than 47 °C has been requested. If so, it will only go up to 47°C, else it will use the requested temperature
  4. After the START_PRINT has finished and the “real” gcode starts, Cura issues another M141 S55 and goes up to 55 °C

Ah, yes, that might work. I’ll give that a go and see what happens. I had been approaching it “the other way” and it didn’t work.

What’s killing me is if I put this into the start_print code (after the heatsoak code):

SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=Chamber_Fan TARGET=55

or simply:

M141 S55

It won’t update the chamber temp, but if I enter those after the print has started into the console it will update it as expected.

So yes, that would make sense that the print gcode is overriding those changes in print_start.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.