Adding parameters to END_PRINT

Hi folks, just don´t want to change the END_PRINT macro or pull it out and add it to an own cfg. I really would like to move z to a defined hight like 200 before the motors are switched off. Further more, I would really like to ad a call for a special gcode at the end of the END_PRINT: This gcode will wait until the heaters are cooled down and then shut down Klipper and after some waiting time it calls my Tasmota to switch off. What should I do to get this working from your perspective?
11 Replies
blacksmithforlife
Look at the various built in variables and hooks you can override https://os.ratrig.com/docs/configuration/macros
Configuring RatOS Macros | RatOS
RatOS comes with a bunch of flexible predefined macro's that can be customized via variables and macro hooks.
Rigattoni
RigattoniOP3mo ago
So far okay, I got that. Nevertheless wouldn´t it be nice to have this as a variable in the printer.cfg, as it is for the printhead: variable_end_print_park_in: "back" like: variable_end_print_z_park_in: 200 Other than that... There is a macro hook called: _USER_END_FEATURE When is this hook called? Is it used at all? I know... If you have something printed which is higher than 200, you would run into an issue. So this needs to get calculated from the current hight. Okay, so let´s forget about the _USER_END_PRINT_AFTER_HEATERS_OFF hook. But I still would like to have at least the possibility to call some gcode after the print is ready and the END_PRINT is done. Couldn´t we get added the _USER_END_FEATURE at the end of the END_PRINT? As long it is empty nothing would happen, but the user would be able to add something instead of just manually run an additional gcode afterwards... @Helge Keck is this something one could think of?
Helge Keck
Helge Keck3mo ago
use _USER_END_PRINT_PARK macro to set your z height and for the rest jsut create another macro and put it after END_PRINT in your slicer and you are done
Rigattoni
RigattoniOP3mo ago
Okay, that´s the other way round... but that is some solution at least. Thanks guys... didn´t think about using the slicer for that.
miklschmidt
miklschmidt3mo ago
You can supply any parameter you want to END_PRINT, they will be passed down to the _USER hooks. For example
END_PRINT mycustomvariable="center"
END_PRINT mycustomvariable="center"
printer.cfg
[gcode_macro _USER_END_PRINT_PARK]
gcode:
M118 Park in {mycustomvariable}
[gcode_macro _USER_END_PRINT_PARK]
gcode:
M118 Park in {mycustomvariable}
Will print Park in center before END_PRINT calls _END_PRINT_PARK to park the print head. If you want to change the behavior of the endprint parking, i would override _END_PRINT_PARK specifically. If it's dependent on parameters, override _END_PRINT_PARK with a blank gcode parameter, and handle all the logic in _USER_END_PRINT_PARK.
Rigattoni
RigattoniOP3mo ago
I´m still waiting for my heater for the hotend so could not test yet. I just added this to my own_macros.cfg which is included in the printer.cfg: [gcode_macro _USER_END_PRINT_PARK] gcode: G1 z 300
miklschmidt
miklschmidt3mo ago
That'll do 👍
Rigattoni
RigattoniOP2mo ago
Well... so far so good, but I do have still an issue with the END_PRINT. If I call my script to shut down printer and stuff after the print is ready with this macro:
[gcode_macro POWER_OFF_PRINTER_NOW]
gcode:
{% if printer.extruder.temperature < 49 %}
RESPOND MSG="Printer switch-off..."
G4 P6000
host_shutdown # Calls safe shut down of Raspbi
tasmota_off # Calls Shell command to switch off Tasmota
{% else %}
RESPOND MSG="Waiting for cooling down to shut off."
TEMPERATURE_WAIT SENSOR=extruder MAXIMUM=49
G4 P6000
host_shutdown # Calls safe shut down of Raspbi
tasmota_off # Calls Shell command to switch off Tasmota
{% endif %}
[gcode_macro POWER_OFF_PRINTER_NOW]
gcode:
{% if printer.extruder.temperature < 49 %}
RESPOND MSG="Printer switch-off..."
G4 P6000
host_shutdown # Calls safe shut down of Raspbi
tasmota_off # Calls Shell command to switch off Tasmota
{% else %}
RESPOND MSG="Waiting for cooling down to shut off."
TEMPERATURE_WAIT SENSOR=extruder MAXIMUM=49
G4 P6000
host_shutdown # Calls safe shut down of Raspbi
tasmota_off # Calls Shell command to switch off Tasmota
{% endif %}
which is called in Orca after the END_PRINT as seen in my screenshot, the print does never reach 100%. It get stuck at 99% and the print is saved as error. Installed is v2.1.0-RC2-109-g975b128f Any idea how to wait for print finish (100%) to make sure all things are done?
Helge Keck
Helge Keck2mo ago
try it with a delayed gcode macro should do the trick
[delayed_gcode POWER_OFF_PRINTER_NOW]
gcode:
{% if printer.extruder.temperature < 49 %}
RESPOND MSG="Printer switch-off..."
G4 P6000
host_shutdown # Calls safe shut down of Raspbi
tasmota_off # Calls Shell command to switch off Tasmota
{% else %}
RESPOND MSG="Waiting for cooling down to shut off."
TEMPERATURE_WAIT SENSOR=extruder MAXIMUM=49
G4 P6000
host_shutdown # Calls safe shut down of Raspbi
tasmota_off # Calls Shell command to switch off Tasmota
{% endif %}
[delayed_gcode POWER_OFF_PRINTER_NOW]
gcode:
{% if printer.extruder.temperature < 49 %}
RESPOND MSG="Printer switch-off..."
G4 P6000
host_shutdown # Calls safe shut down of Raspbi
tasmota_off # Calls Shell command to switch off Tasmota
{% else %}
RESPOND MSG="Waiting for cooling down to shut off."
TEMPERATURE_WAIT SENSOR=extruder MAXIMUM=49
G4 P6000
host_shutdown # Calls safe shut down of Raspbi
tasmota_off # Calls Shell command to switch off Tasmota
{% endif %}
and after END_PRINT in the slicer you call it with
UPDATE_DELAYED_GCODE ID=POWER_OFF_PRINTER_NOW DURATION=1
UPDATE_DELAYED_GCODE ID=POWER_OFF_PRINTER_NOW DURATION=1
Rigattoni
RigattoniOP2mo ago
I´ll give it a try today. Thanks for the hint. OKay, I edited my macros now like this:
#############################################################################################################
### PRINTER AND TASMOTA SHUT DOWN
### this macro allows you to turn off the printer
#############################################################################################################

[delayed_gcode POWER_OFF_PRINTER]
initial_duration: 0.
gcode:
{% if printer.extruder.temperature < 45 %}
UPDATE_DELAYED_GCODE ID=DELAYED_POWER_OFF_PRINTER DURATION=10
RESPOND MSG="Printer switch-off..."
G4 P6000
host_shutdown # Calls safe shut down of Raspbi
tasmota_off # Calls Shell command to switch off Tasmota
{% else %}
RESPOND MSG="Waiting for cooling down to shut off."
TEMPERATURE_WAIT SENSOR=extruder MAXIMUM=45
G4 P6000
host_shutdown # Calls safe shut down of Raspbi
tasmota_off # Calls Shell command to switch off Tasmota
{% endif %}

[gcode_macro STOP_POWER_OFF]
gcode:
UPDATE_DELAYED_GCODE ID=DELAYED_POWER_OFF_PRINTER DURATION=0

[gcode_shell_command host_shutdown]
command: poweroff
timeout: 3.
verbose: False

[gcode_macro HOST_SHUTDOWN]
gcode:
RUN_SHELL_COMMAND CMD=host_shutdown

#shell command to shutdown the tasmota
[gcode_shell_command tasmota_off]
command: curl "http://192.168.***.**/cm?user=some_user&password=some_passwordcmnd=Backlog%3BDelay%20300%3BPower%20OFF"
timeout: 2.
verbose: False

[gcode_macro TASMOTA_OFF]
gcode:
RUN_SHELL_COMMAND CMD=tasmota_off
#############################################################################################################
### PRINTER AND TASMOTA SHUT DOWN
### this macro allows you to turn off the printer
#############################################################################################################

[delayed_gcode POWER_OFF_PRINTER]
initial_duration: 0.
gcode:
{% if printer.extruder.temperature < 45 %}
UPDATE_DELAYED_GCODE ID=DELAYED_POWER_OFF_PRINTER DURATION=10
RESPOND MSG="Printer switch-off..."
G4 P6000
host_shutdown # Calls safe shut down of Raspbi
tasmota_off # Calls Shell command to switch off Tasmota
{% else %}
RESPOND MSG="Waiting for cooling down to shut off."
TEMPERATURE_WAIT SENSOR=extruder MAXIMUM=45
G4 P6000
host_shutdown # Calls safe shut down of Raspbi
tasmota_off # Calls Shell command to switch off Tasmota
{% endif %}

[gcode_macro STOP_POWER_OFF]
gcode:
UPDATE_DELAYED_GCODE ID=DELAYED_POWER_OFF_PRINTER DURATION=0

[gcode_shell_command host_shutdown]
command: poweroff
timeout: 3.
verbose: False

[gcode_macro HOST_SHUTDOWN]
gcode:
RUN_SHELL_COMMAND CMD=host_shutdown

#shell command to shutdown the tasmota
[gcode_shell_command tasmota_off]
command: curl "http://192.168.***.**/cm?user=some_user&password=some_passwordcmnd=Backlog%3BDelay%20300%3BPower%20OFF"
timeout: 2.
verbose: False

[gcode_macro TASMOTA_OFF]
gcode:
RUN_SHELL_COMMAND CMD=tasmota_off
Update: That did the trick, thanks mate. I just had to add "CHAMBER_HEATER_OFF" after "gcode:" because the chamber heater kept heating for any reason. After that I had no issues.
Want results from more Discord servers?
Add your server