KTC icon indicating copy to clipboard operation
KTC copied to clipboard

Printer start commandsq

Open midicdj1000 opened this issue 1 year ago • 8 comments

Hi, I am working on a ratrig style toolchanger and having some issues with setting up the filament standby and active temps. Is there a guide or examples to some start_print macro or g code for the slicer to set this up?

I am setting up the temperatures like normal, but then when it does a tool change all tools are set to 0. SET_TOOL_TEMPERATURE TOOL=1 CHNG_STATE=1

midicdj1000 avatar Sep 15 '24 18:09 midicdj1000

Hi!

I will have to refine this and include it inside the readme but for now here is an example start G-code using the supplied macros for PrusaSlicer:

KTCC_INIT_PRINT_STATS

; Heat the bed first
M140 S[first_layer_bed_temperature]
; Wait for bed to reach temperature with 1 degrees tolerance
M116 H0 W1

G28

G0 Z3 F5000	; Ensure nozzle is at 3mm over the bed
T[initial_extruder]	; Mount extruder first used (even if only one extruder used). Waits for temperature inside the script.

;G0 Z3 F5000	; Ensure nozzle is at 3mm over the bed
G0 X{first_layer_print_max[0]} Y{first_layer_print_min[1]} Z3 F30000

And an end G-Code:

; Custom gcode to run at end of print
M104 S0 		; turn off temperature
G10 P0 S0 R0 A0	; turn off extruder 0
G10 P1 S0 R0 A0	; turn off extruder 1
G10 P2 S0 R0 A0	; turn off extruder 2
G10 P3 S0 R0 A0	; turn off extruder 3
G10 P4 S0 R0 A0	; turn off extruder 4
G10 P5 S0 R0 A0	; turn off extruder 5
G10 P6 S0 R0 A0	; turn off extruder 6
G10 P7 S0 R0 A0	; turn off extruder 7
G10 P8 S0 R0 A0	; turn off extruder 8
G10 P9 S0 R0 A0	; turn off extruder 9
G10 P10 S0 R0 A0	; turn off extruder 10
G10 P11 S0 R0 A0	; turn off extruder 11
M140 S0 		; turn off bed
T_1		; dropoff current tool
G91 		; relative moves
G0 Z20  		; move bed down another 30mm
G90 		; absolute moves
G0 X1 Y1 F30000	; Move toolhead out of the way
SAVE_POSITION
KTCC_DUMP_PRINT_STATS

Regards, Andrei

TypQxQ avatar Sep 15 '24 19:09 TypQxQ

HI, Many thanks for your help, I have my 4 tool changer working quite well in Prusaslicer, but having some trouble with the new Orca slicer toolchanger in the new 2.2 beta.

Can I ask when a tool is changed is there something that sets the hotend to 0 ? the way the Orca toolchanger works is by setting it's own temperature settings and not using M568. So it sets a standby temp and then when the tool is changed something is setting it to 0 as the tool it dropped off. I set my macro to not have any commands to change the hotend temp thinking this would fix it, but it didn't.

example code from orca M104 S160 T0 T1 M109 S220 T1 but as soon as T0 drops off the tool the temp is set to 0

midicdj1000 avatar Oct 22 '24 17:10 midicdj1000

Sounds like you have a low heater_standby_to_powerdown_delay so that it shuts down the tool. Default should be 600 if I'm not misstaken. That is 10 minutes. Check it with KTC_TOOL_SET_TEMPERATURE [TOOL= | T=] This is so the cases where a tool is used on lower levels of a long print. No need to have it in standby for hours when not being used. Check the KTC log if it puts the tool in off or does anything else strange.

TypQxQ avatar Oct 22 '24 18:10 TypQxQ

Also check what standby temp you have.

TypQxQ avatar Oct 22 '24 18:10 TypQxQ

My example to test this is not actually in any slicer and I just set the T0 to 215 and as soon as I drop off the tool it's set to 0 even though I removed the commands in dropoff and pickup to change temps, so something else is setting T0 = 0 that I can't see.

How can I make it so only Orca slicer can change the tool temps.

midicdj1000 avatar Oct 22 '24 19:10 midicdj1000

The temperatures are changed dynamically in the background. If you don't want to change the temperature, then you have to setup the heater_active_to_standby_delay. See the last two settings here: https://github.com/TypQxQ/KTC/blob/main/doc/configuration.md#----inheritable-options

TypQxQ avatar Oct 22 '24 23:10 TypQxQ

TLDR: KTC_T0->KTC_T1, No standby timeout. KTC_T0->KTC_DESELSCT_ALL->KTC_T1, Now standby timeout is working.

Not sure if it belogs to this issue or should I open another issue instead, I'll post it here for now: I set up tool pre-heating in my slicer so it will put the gcode that heats up the next tool roughly 30s before tool changing. However in case that the time between tool changes are less than 30s, the slicer won't put that gcode in due to lack of time. which caused the tool to be cooled to standby temperature once docked, and won't be ready when next toolchange comes. After reviewing the avaliable commands and configurations of KTC, there seems to be 2 options for a standby timeout, which I'll use to delay the cooldown to standby by 30 seconds, therefore avoid any cooldown for tool changes less than 30s all together.

The first option is to set the temperature with KTC_TOOL_SET_TEMPERATURE [TOOL= | [STDB_TIMEOUT=], which I set STDB_TIMEOUT=30 in my PRINT_START macro along with temperatures for that tool. However it doesn't seem to be working during printing: the tool still cools down for frequent tool changes. Then I restarted klipper via FIRMWARE_RESTART and entered following gcode into console: KTC_TOOL_SET_TEMPERATURE T=0 ACTV_TMP=100 STDB_TMP=50 CHNG_STATE=2 STDB_TIMEOUT=30 ;The tool 0 heated to 100C as expected, note that STDB_TIMEOUT is set to 30s. KTC_T0; tool 0 picked up, maintaining 100c, as expected. KTC_T1; tool 0 dropped and tool 1 picked up, however now the tool 0 is targeted at 50c, with no standby delay at all.

KTC_T0; tool 0 picked up, and heated to 100c again. KTC_DESELSCT_ALL; tool 0 dropped, while still maintaining 100c. After standby delay of 30s, it goes back to 50c, this is expected behavior

KTC_T0; tool 0 picked up, and heated to 100c again. KTC_DESELSCT_ALL; tool 0 dropped, while still maintaining 100c. However within 30s: KTC_T1; tool 1 picked up within 30s of KTC_DESELSCT_ALL, this time the tool 0 is still targeting at 100c. After a total delay of 30s since the last KTC_DESELSCT_ALL, the tool0 is cooled to 50c

I also tried to set up heater_active_to_standby_delay for ktc, toolchanger and all the tools, which resulted in the similar behavior. It seems that the STDB_TIMEOUT or heater_active_to_standby_delay is only honored when using KTC_DESELSCT_ALL between KTC_T0 and KTC_T1, and won't take effect when switching directly using KTC_T0 and KTC_T1. Is it a expected behavior? here is my toolchange gcode for ktc, which is mostly copied from configuration example:

tool_select_gcode:
  {% if "xyz" not in printer.toolhead.homed_axes %}
    G28
  {% endif %}
  # myself will be replaced with the tool that is selected
  # This code will be inherited by Jubillee and on untill overriden by tool 2, 3 or 4.
  KTC_TOOL_SET_TEMPERATURE TOOL={myself.name} CHNG_STATE=2   # Put tool heater in Active mode so heating while moving
  SAVE_GCODE_STATE NAME=TOOL_PICKUP                          # Save GCODE state. Will be restored at the end of pickup code
  {% set ACCEL_BEFORE_TOOLCHANGE = printer.configfile.settings['printer'].max_accel|float %} #save accel
  SET_VELOCITY_LIMIT ACCEL=6000
  SET_FAN_SPEED FAN=EMAG SPEED=1.0 #TURN ON ELECTROMAGNET
  SET_GCODE_OFFSET X=0 Y=0
  #####LOWER Z####
  G91                                    # relative positions
  #G0 Z2         # lower bulidplate by 2
  G90                                    # Absolute positions
  ##############  Move in to parking spot  ##############
  G0 X{myself.params_tool_picking_x[0]} Y{myself.params_park[1]}  F50000    # Fast move X to the empty safe point
  G0 X{myself.params_tool_picking_x[1]} F50000               # Fast move X to the empty pickup point
  G0 X{myself.params_park[0]} F15000                          # Slow Move to the parking position for tool.
  SET_GCODE_OFFSET Z={myself.offset[2]} MOVE=1
  ##############  Atach Tool  ##############
  # PAUSE for EM to be attached
  G4 P300
  KTC_TEMPERATURE_WAIT_WITH_TOLERANCE TOOL={myself.name} TOLERANCE=5
  ##############  Tool Z Offset  ##############
  #TODO
  #SET_GCODE_OFFSET Z={myself.offset[2]} MOVE=1              Set and move the Z offset. Avoid crashing into bed when moving out later.
  ##############  Move out  ##############
  G0 X{myself.params_tool_picking_x[2]}  F50000    # Fast move X to the loaded safe spot
  
  ##############  Finnish up  ##############
  G91                                    # relative positions
  G0 Z-2         # lower bulidplate by 2
  G90                                    # Absolute positions
  M400                                                       # Wait for current moves to finish.
  RESTORE_GCODE_STATE NAME=TOOL_PICKUP MOVE=0                # Restore GCODE state. Was saved at thebegining of SUB_TOOL_PICKUP_START. Move fast to last location.
  SET_VELOCITY_LIMIT ACCEL={ACCEL_BEFORE_TOOLCHANGE}         # Restore accel
  KTC_SET_STATE TOOL={myself.name} STATE=SELECTED            # set tool state to selected
  ACTIVATE_EXTRUDER EXTRUDER={myself.heater_names[0]}                # Activate the extruder
                                                             
  ######## Set the toolhead offsets. Needs to be after any RESTORE_GCODE_STATE!##########
  SET_GCODE_OFFSET X={myself.offset[0]*-1} Y={myself.offset[1]*-1} Z={myself.offset[2]} MOVE=0 # apparently xy should be in reverse to fit most of the calibration toturial

  
tool_deselect_gcode:
  # myself will be replaced with the tool that is deselected
  # This code will be inherited by Jubillee and on untill overriden by ERCF.

  SET_GCODE_OFFSET X=0 Y=0 MOVE=0                                   # Set XY offset to 0 so we park the tool right.
  SAVE_GCODE_STATE NAME=TOOL_DROPOFF                         # Save GCode state.
  {% set ACCEL_BEFORE_TOOLCHANGE = printer.configfile.settings['printer'].max_accel|float %} #save accel
  SET_VELOCITY_LIMIT ACCEL=6000
                                                     
  #####LOWER Z####
  G91                                    # relative positions
  G0 Z2                                  # lower bulidplate by 2
  G90                                    # Absolute positions
  ##############  Move in to parking spot  ##############
  G0 X{myself.params_tool_picking_x[2]} Y{myself.params_park[1]}  F50000    # Fast move X to the loaded safe spot
  G0 X{myself.params_tool_picking_x[3]} F50000               # Fast move X to loaded rod contact spot
  G0 X{myself.params_park[0]} F15000                                 # Slow Move to the dropoff position for tool.
  #SET_GCODE_OFFSET Z=0 MOVE=1
  ##############  Detach Tool  ##############
  SET_FAN_SPEED FAN=EMAG SPEED=0.0                     # Detach tool
  G4 P10
  ##############  Move out  ##############
  G0 X{myself.params_tool_picking_x[0]}  F50000    # Fast move X to the empty safe point
  ##############  Finnish up  ##############
  M400                                                       # Wait for current moves to finish.
  RESTORE_GCODE_STATE NAME=TOOL_DROPOFF MOVE=0               # Restore Gcode state
  SET_VELOCITY_LIMIT ACCEL={ACCEL_BEFORE_TOOLCHANGE}         # Restore accel
  #SET_GCODE_OFFSET Z=0 MOVE=0                                      # Set Z offset to 0 after tool is parked.
  KTC_SET_STATE TOOL={myself.name} STATE=READY

FredWang1999 avatar Nov 20 '24 16:11 FredWang1999

This is not the expected behaviour. Sorry for late response. Please attach your tool and toolchanger configuration.

TypQxQ avatar Dec 14 '24 21:12 TypQxQ