Skip to content

Instantly share code, notes, and snippets.

@punkisdead
Forked from besser/cura_klipper_end.gcode
Last active March 13, 2023 15:09
Show Gist options
  • Save punkisdead/023d66bfc60246e6d7f6bcf599d94081 to your computer and use it in GitHub Desktop.
Save punkisdead/023d66bfc60246e6d7f6bcf599d94081 to your computer and use it in GitHub Desktop.
Klipper configuration file and Cura Start/End gcode
SET_GCODE_VARIABLE MACRO=END_PRINT VARIABLE=machine_depth VALUE={machine_depth}
END_PRINT
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=bed_temp VALUE={material_bed_temperature_layer_0}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=extruder_temp VALUE={material_print_temperature_layer_0}
START_PRINT
# This file contains common pin mappings for the BIGTREETECH SKR mini
# E3. To use this config, the firmware should be compiled for the
# STM32F103 with a "28KiB bootloader". Also, select "Enable extra
# low-level configuration options" and configure "GPIO pins to set at
# micro-controller startup" to "!PC13".
# The "make flash" command does not work on the SKR mini E3. Instead,
# after running "make", copy the generated "out/klipper.bin" file to a
# file named "firmware.bin" on an SD card and then restart the SKR
# mini E3 with that SD card.
# See the example.cfg file for a description of available parameters.
[stepper_x]
step_pin: PB13
dir_pin: !PB12
enable_pin: !PB14
step_distance: .0125
endstop_pin: ^PC0
position_endstop: 0
position_max: 235
homing_speed: 50
[tmc2209 stepper_x]
uart_pin: PC11
tx_pin: PC10
uart_address: 0
microsteps: 16
run_current: 0.580
hold_current: 0.500
stealthchop_threshold: 250
[stepper_y]
step_pin: PB10
dir_pin: !PB2
enable_pin: !PB11
step_distance: .0125
endstop_pin: ^PC1
position_endstop: 0
position_max: 235
homing_speed: 50
[tmc2209 stepper_y]
uart_pin: PC11
tx_pin: PC10
uart_address: 1
microsteps: 16
run_current: 0.580
hold_current: 0.500
stealthchop_threshold: 250
[stepper_z]
step_pin: PB0
dir_pin: PC5
enable_pin: !PB1
step_distance: .0025
endstop_pin: ^PC2
position_endstop: 0.0
position_max: 250
[tmc2209 stepper_z]
uart_pin: PC11
tx_pin: PC10
uart_address: 2
microsteps: 16
run_current: 0.580
hold_current: 0.500
stealthchop_threshold: 5
[extruder]
step_pin: PB3
dir_pin: !PB4
enable_pin: !PD2
#step_distance: 0.010526
step_distance: 0.002439
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PC8
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PA0
#control: pid
#pid_Kp: 21.527
#pid_Ki: 1.063
#pid_Kd: 108.982
min_temp: 0
max_temp: 275
[tmc2209 extruder]
uart_pin: PC11
tx_pin: PC10
uart_address: 3
microsteps: 16
run_current: 0.650
hold_current: 0.500
stealthchop_threshold: 5
[heater_bed]
heater_pin: PC9
sensor_type: ATC Semitec 104GT-2
sensor_pin: PC3
#control: pid
#pid_Kp: 54.027
#pid_Ki: 0.770
#pid_Kd: 948.182
min_temp: 0
max_temp: 125
[fan]
pin: PA8
[mcu]
serial: /dev/ttyAMA0
baud: 250000
[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 5
max_z_accel: 100
[static_digital_output usb_pullup_enable]
pins: !PC13
[board_pins]
aliases:
# EXP1 header
EXP1_1=PB5, EXP1_3=PA9, EXP1_5=PA10, EXP1_7=PB8, EXP1_9=<GND>,
EXP1_2=PB6, EXP1_4=<RST>, EXP1_6=PB9, EXP1_8=PB7, EXP1_10=<5V>
# See the sample-lcd.cfg file for definitions of common LCD displays.
######################################################################
# 128x64 Full Graphic Creality CR10 / ENDER 3 stockdisplay
######################################################################
[display]
lcd_type: st7920
cs_pin: EXP1_7
sclk_pin: EXP1_6
sid_pin: EXP1_8
encoder_pins: ^EXP1_5, ^EXP1_3
click_pin: ^!EXP1_2
[output_pin beeper]
pin: EXP1_1
######################################################################
# MACROS
######################################################################
# ----------------------------- Beeper -------------------------------
# M300 : Play tone. Beeper support, as commonly found on usual LCD
# displays (i.e. RepRapDiscount 2004 Smart Controller, RepRapDiscount
# 12864 Full Graphic). This defines a custom I/O pin and a custom
# GCODE macro. Usage:
# M300 [P<ms>] [S<Hz>]
# P is the tone duration, S the tone frequency.
# The frequency won't be pitch perfect.
[gcode_macro M300]
# Use a default 1kHz tone if S is omitted.
default_parameter_S: 1
# Use a 10ms duration is P is omitted.
default_parameter_P: 100
gcode:
SET_PIN PIN=beeper VALUE={S}
G4 P{P}
SET_PIN PIN=beeper VALUE=0
# --------------------------------------------------------------------
# ------------------------- Filament Change --------------------------
# M600: Filament Change. This macro will pause the printer, move the
# tool to the change position, and retract the filament 50mm. Adjust
# the retraction settings for your own extruder. After filament has
# been changed, the print can be resumed from its previous position
# with the "RESUME" gcode.
[pause_resume]
[gcode_macro M600]
default_parameter_X: 50
default_parameter_Y: 0
default_parameter_Z: 10
gcode:
SAVE_GCODE_STATE NAME=M600_state
PAUSE
G91
G1 E-.8 F2700
G1 Z{Z}
G90
G1 X{X} Y{Y} F3000
G91
G1 E-50 F1000
RESTORE_GCODE_STATE NAME=M600_state
# --------------------------------------------------------------------
# --------------------------- Start Print ----------------------------
[gcode_macro START_PRINT]
variable_bed_temp: 60
variable_extruder_temp: 185
gcode:
# Start bed heating
M140 S{bed_temp}
# Use absolute coordinates
G90
# Reset the G-Code Z offset (adjust Z offset if needed)
SET_GCODE_OFFSET Z=0.0
# Home the printer
G28
# Move the nozzle near the bed
G1 Z5 F3000
# Move the nozzle very close to the bed
G1 Z0.15 F300
# Wait for bed to reach temperature
M190 S{bed_temp}
# Set and wait for nozzle to reach temperature
M109 S{extruder_temp}
# Reset Extruder
G92 E0
# Move Z Axis up
G1 Z2.0 F3000
# Move to start position
G1 X2.1 Y20 Z0.28 F5000.0
# Draw the first line
G1 X2.1 Y200.0 Z0.28 F1500.0 E15
# Move to side a little
G1 X2.4 Y200.0 Z0.28 F5000.0
# Draw the second line
G1 X2.4 Y20 Z0.28 F1500.0 E30
# Reset Extruder
G92 E0
# Move Z Axis up
G1 Z2.0 F3000
# Print message on LCD
M117 By your command!
# --------------------------------------------------------------------
# ---------------------------- End Print -----------------------------
[gcode_macro END_PRINT]
variable_machine_depth: 235
gcode:
# Turn off bed, extruder, and fan
M140 S0
M104 S0
M106 S0
# Relative positionning
G91
# Retract and raise Z
G1 Z0.2 E-2 F2400
# Wipe out
G1 X5 Y5 F3000
# Raise Z more
G1 Z10
# Absolute positionning
G90
# Present print
G1 X0 Y{machine_depth}
# Disable steppers
M84
# Print message on LCD
M117 That's All Folks
# --------------------------------------------------------------------
#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [extruder]
#*# control = pid
#*# pid_kp = 27.446
#*# pid_ki = 1.663
#*# pid_kd = 113.214
#*#
#*# [heater_bed]
#*# control = pid
#*# pid_kp = 61.301
#*# pid_ki = 1.362
#*# pid_kd = 689.640
[gcode_macro M600]
description: Starts process of Filament Change
gcode:
{% if printer.extruder.temperature < 180 %}
{action_respond_info("Extruder temperature too low")}
{% else %}
PAUSE_MACRO
_DISABLE_FS
UNLOAD_FILAMENT
{% endif %}
[gcode_macro PAUSE_MACRO]
description: Pauses Print
gcode:
PAUSE
SET_IDLE_TIMEOUT TIMEOUT={ 30 * 60 }
[gcode_macro FC_RESUME]
description: Resume print after Filament Change
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
SET_IDLE_TIMEOUT TIMEOUT={ 10 * 60 }
G1 E-{ E }
# Reset extruder position
G92 E0
RESUME
[gcode_macro UNLOAD_FILAMENT]
description: Unloads Filament from extruder
gcode:
{% if printer.extruder.temperature < 180 %}
{action_respond_info("Extruder temperature too low")}
{% else %}
SAVE_GCODE_STATE NAME=UNLOAD_state
{% set Z = params.Z|default(50)|int %}
{% set axis_max = printer.toolhead.axis_maximum %}
{% set pos = printer.toolhead.position %}
{% set z_diff = axis_max.z - pos.z %}
{% set z_safe_lift = [ Z, z_diff ] | min%}
G91 # relative positioning
G0 Z{ z_safe_lift }
# Reset extruder position
G92 E0
G1 E5.0 F300 # extrude a little
G1 E-50 F{ 10 * 60 } # perform the unload
G1 E-50 F{ 5 * 60 } # finish the unload
RESTORE_GCODE_STATE NAME=UNLOAD_state
{% endif %}
[gcode_macro PURGE]
description: Extrudes filament, used to clean out previous filament
gcode:
{% if printer.extruder.temperature < 180 %}
{action_respond_info("Extruder temperature too low")}
{% else %}
{% set PURGE_AMOUNT = params.PURGE_AMOUNT|default(40)|float %}
SAVE_GCODE_STATE NAME=PURGE_state
G91 # relative coords
G1 E{PURGE_AMOUNT} F{ 5 * 60 } # purge
RESTORE_GCODE_STATE NAME=PURGE_state
{% endif %}
[gcode_macro LOAD_FILAMENT]
description: Loads filament into the extruder
gcode:
{% if printer.extruder.temperature < 180 %}
{action_respond_info("Extruder temperature too low")}
{% else %}
SAVE_GCODE_STATE NAME=LOAD_state
G91 # Relative coords
G1 E50 F{ 5 * 60 } # extrude
G4 P{ 0.9 * 1000 } # dwell (ms)
G1 E25.0 F{ 5 * 60 } # extrude a little more
_ENABLE_FS
RESTORE_GCODE_STATE NAME=LOAD_state
{% endif %}
[gcode_macro _DISABLE_FS]
description: placeholder, disables filament sensor that might trigger an M600 in the middle of a load/unload/M600...
gcode:
SET_FILAMENT_SENSOR SENSOR=RunoutSensor ENABLE=0
[gcode_macro _ENABLE_FS]
description: placeholder, enables filament sensor
gcode:
SET_FILAMENT_SENSOR SENSOR=RunoutSensor ENABLE=1
[gcode_macro HEAT]
description: Heats up the extruder to get ready for Filament Change
gcode:
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(200)|float %}
{% set Z = params.Z|default(50)|float %}
{% set X = params.X|default(110)|float %}
{% set Y = params.Y|default(110)|float %}
SET_HEATER_TEMPERATURE HEATER=extruder TARGET={EXTRUDER_TEMP}
HOME_CHECK
G1 Z{Z} F500
G1 X{X} Y{Y} F6000
[gcode_macro COOL]
description: Turns off all heaters
gcode:
TURN_OFF_HEATERS
[gcode_macro PREHEAT_PLA]
description: Preheats extruder and bed for PLA printing, extruder set to 150 to prevent filament leaking while homing etc
gcode:
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(150)|float %}
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
SET_HEATER_TEMPERATURE HEATER=extruder TARGET={EXTRUDER_TEMP}
SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={BED_TEMP}
[gcode_macro BED_TRAMMING_1]
description: Heats bed and starts process to level the bed with the screws
gcode:
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={BED_TEMP}
HOME_CHECK
M190 S{BED_TEMP}
SCREWS_TILT_CALCULATE
[gcode_macro BED_TRAMMING_2]
description: Continues the bed screw leveling process
gcode:
SCREWS_TILT_CALCULATE
[gcode_macro BED_MESH]
description: Heats bed, makes a mesh and saves it
gcode:
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={BED_TEMP}
HOME_CHECK
M190 S{BED_TEMP}
BED_MESH_CLEAR
BED_MESH_CALIBRATE
TURN_OFF_HEATERS
SAVE_CONFIG
[gcode_macro DISABLE_STEPPERS]
description: Disables the printers stepper motors
gcode:
M84 X Y E
[gcode_macro PID_EXTRUDER]
description: PID Tune for the Extruder
gcode:
{% set TARGET_TEMP = params.TARGET_TEMP|default(200)|float %}
PID_CALIBRATE HEATER=extruder TARGET={TARGET_TEMP}
TURN_OFF_HEATERS
SAVE_CONFIG
[gcode_macro PID_BED]
description: PID Tune for the Bed
gcode:
{% set TARGET_TEMP = params.TARGET_TEMP|default(60)|float %}
PID_CALIBRATE HEATER=heater_bed TARGET={TARGET_TEMP}
TURN_OFF_HEATERS
SAVE_CONFIG
[gcode_macro NOZZLE_MID]
description: Moves nozzle to the center of the bed
gcode:
{% set Z = params.Z|default(10)|float %}
HOME_CHECK
G1 Z{Z} F500
G1 X110 Y110 F6000
[gcode_macro home_check]
description: Checks if the printer is homed, it not it homes the printer
gcode:
{% if printer.toolhead.homed_axes != "xyz" %}
G28
{% endif %}
[gcode_macro SHOW_PRINT]
description: Moves the extruder out of the way and bed forward
gcode:
HOME_CHECK
{% set Z = params.Z|default(50)|int %}
{% set axis_max = printer.toolhead.axis_maximum %}
{% set pos = printer.toolhead.position %}
{% set z_diff = axis_max.z - pos.z %}
{% set z_safe_lift = [ Z, z_diff ] | min%}
G1 Z{ z_safe_lift }
G1 X10 Y220 F4000
[gcode_macro ZOffset_Setup]
description: Starts Z-Offset Calibration, under 30 degrees Celsius
gcode:
{% if printer.heater_bed.temperature > 30 %}
{action_respond_info("Bed temperature too high")}
{% elif printer.extruder.temperature > 30 %}
{action_respond_info("Extruder temperature too High")}
{% else %}
G28
PROBE_CALIBRATE
{% endif %}
[gcode_macro Z_Down_01]
description: Moves Z down by 0.1
gcode:
TESTZ Z=-.1
[gcode_macro Z_Up_01]
description: Moves Z up by 0.1
gcode:
TESTZ Z=+.1
[gcode_macro Z_Low_Half]
description: Sets Z between current value and previous lower value
gcode:
TESTZ Z=-
[gcode_macro Z_High_Half]
description: Sets Z between current value and previous higher value
gcode:
TESTZ Z=+
[gcode_macro Accept_Save]
description: Accepts the Z-Offset and saves the config
gcode:
ACCEPT
SAVE_CONFIG
[gcode_macro Abort_Setup]
description: Aborts the Z-Offset calibration
gcode:
ABORT
[screws_tilt_adjust]
horizontal_move_z: 5
screw1: 50,220
screw1_name: Back left
screw2: 228,220
screw2_name: Back Right
screw3: 50,74
screw3_name: Front Left
screw4: 228,74
screw4_name: Front Right
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment