Anet A8 & AM8 Klipper Example Config for SKR v1.3

Klipper is a 3d-Printer firmware. It combines the power of a general purpose computer with one or more micro-controllers. Details can be found from https://www.klipper3d.org/

This configuration is mainly for AM8 (Anet A8 metal frame upgrade) but it should work with Anet A8 on SKR v1.3 mainboard.

Note: Depending on your bed position you should specify position_endstop:  value for both X and Y.

# This file contains common pin mappings for the BIGTREETECH SKR V1.3
# board. To use this config, the firmware should be compiled for the
# LPC1768.

#############################################################################
###########           CONFIGURATION STARTS HERE                   ###########
#############################################################################

[mcu]
serial: /dev/serial/by-id/usb-Klipper_lpc1768_1E70000F801C3DAF883E975CC22000F5-if00

[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 1000
max_z_velocity: 20
max_z_accel: 100

#####################################################################
#  X/Y/Z Stepper Settings
#####################################################################

[stepper_x]
step_pin: P2.2
dir_pin: !P2.6
enable_pin: !P2.1
step_distance: .009981
endstop_pin: !P1.29  # P1.28 for X-max
position_endstop: -10
position_min: -14
position_max: 220
homing_speed: 50
second_homing_speed: 25
homing_retract_dist: 5

[stepper_y]
step_pin: P0.19
dir_pin: !P0.20
enable_pin: !P2.8
step_distance: .00995
endstop_pin: !P1.27  # P1.26 for Y-max
position_min: -26
position_endstop: -24
position_max: 220
homing_speed: 50
second_homing_speed: 25
homing_retract_dist: 5

[stepper_z]
step_pin: P0.22
dir_pin: !P2.11
enable_pin: !P0.21
step_distance: .002470
endstop_pin: !P1.25  # P1.24 for Z-max
position_endstop: 0
position_max: 200
position_min: -5
homing_speed: 10.0
second_homing_speed: 3
homing_retract_dist: 3.0

#####################################################################
#  Extruder Settings
#####################################################################

[extruder]
step_pin: P2.13
dir_pin: !P0.11
enable_pin: !P2.12
heater_pin: P2.7
sensor_pin: P0.25
smooth_time: 3.0
step_distance: 0.001733
nozzle_diameter: 0.4
filament_diameter: 1.75
max_extrude_cross_section: 50.0
max_extrude_only_distance: 780
#sensor_type: EPCOS 100K B57560G104F
sensor_type: ATC Semitec 104GT-2
#control: watermark
#pid_Kp: 27.666
#pid_Ki: 1.724
#pid_Kd: 111
min_temp: 15
max_temp: 260
max_power: 1.0
######### Try to keep pressure_advance below 1.0
######### PA can be disabled by declaring a 0.0 value
pressure_advance: 0.0
# time seconds to look ahead for PA moves default is 0.010 or 10ms
pressure_advance_lookahead_time: 0.030

[verify_heater extruder]
max_error: 600
check_gain_time: 40
hysteresis: 15
heating_gain: 2

#####################################################################
#  Bed Heater
#####################################################################

[heater_bed]
heater_pin: P2.5
sensor_type: ATC Semitec 104GT-2
sensor_pin: P0.23
min_temp: 0
max_temp: 110
smooth_time: 3.0
control: pid
pid_Kp=75.945
pid_Ki=1.285
pid_Kd=1122.092

[verify_heater heater_bed]
max_error: 120
check_gain_time: 60
hysteresis: 5
heating_gain: 2

#####################################################################
#  Fan Control
#####################################################################

[fan]
pin: P2.3

[heater_fan my_nozzle_fan]
pin: P2.4
heater: extruder
heater_temp: 60.0
fan_speed: 1.0

#####################################################################
#  Homing and Adjustment Routines
#####################################################################

[bed_mesh]
mesh_min: 50,20
mesh_max: 220,185
probe_count: 4,4
horizontal_move_z: 12

#####################################################################
# Other Settings
#####################################################################

[idle_timeout]
gcode:
   TURN_OFF_HEATERS
   M84             ; disable steppers
timeout: 1800      ;30 min

[skew_correction]

# Pause/Resume Functionality
[pause_resume]
recover_velocity: 100

# This adds the 'respond' G-Code that you can use to send commands back to OctoPrint
[respond]
default_type: echo

#[force_move]
#enable_force_move: true

# add virtual sd card
[virtual_sdcard]
path: ~/.octoprint/uploads/

#[include /home/pi/custommenu.cfg]

#####################################################################
#  Display Routines
#  RepRapDiscount 128x64 Full Graphic Smart Controller
#####################################################################

[display]
lcd_type: st7920
cs_pin: P1.19
sclk_pin: P1.20
sid_pin: P1.18
encoder_pins: ^P3.26, ^P3.25
click_pin: ^!P0.28
#kill_pin: ^!<RST>

[output_pin beeper]
pin: P1.30

#####################################################################
### 	MACROS
#####################################################################

[gcode_macro G32]
gcode:
   {% if printer.toolhead.status == "Ready" %}
      M141 S55      ; set chamber for 55C max
    {% if "z" not in printer.toolhead.homed_axes %} ; G28 Home if needed
      M117 Homing...      
      G28
    {% endif %}
      M117 Nozzle Cleaning...
      NOZZLE_CLEAN     ; Clean Nozzle
      M117 Homing...
      G28 Z0
      G0 X150 Y150 Z10 F6000
   {% else %}
      { printer.gcode.action_respond_info("G32 is disabled while printing!") }
   {% endif %}

[gcode_macro PRINT_START]
gcode:
  PRINT_START_1            ;print start macro 1
  M140 S{BED_TEMP}         ;set bed temperature and wait
  M109 S{EXTRUDER_TEMP}    ;set hotend temperature and wait
  M190 S{BED_TEMP}         ;set bed temperature and do not wait
  #G32
  #M117 Bed meshing...
  BED_MESH_CLEAR
  #bed_mesh_calibrate
  #BED_MESH_PROFILE LOAD=am8
  M117 Ready
default_parameter_EXTRUDER_TEMP: 205
default_parameter_BED_TEMP: 60

[gcode_macro PRINT_START_1]
gcode:                                    
    M104 S0    ;cancel set temp
    M107       ;turn cooling fans off
    G21        ;set units to mm
    G90        ;use absolute coordinates
    M83        ;use relative extrusion
    G92 E0.0   ;reset e count
    M220 S100  ;reset speed multiplier
    G28
    G0 X110 Y110 Z10 F6000

[gcode_macro PRINT_END]
#   Use PRINT_END for the slicer ending script - PLEASE CUSTOMISE THE SCRIPT FOR YOUR SLICER OF CHOICE
gcode:
   M400                           ; wait for buffer to clear
   G92 E0                         ; zero the extruder
   G1 E-4.0 F3600                 ; retract filament
   G91                            ; relative positioning
   G0 Z20 F3000                   ; move nozzle up 25mm
   TURN_OFF_HEATERS
   M107                           ; turn off fan
   G90                            ; absolute positioning
   G0 X110 Y200 F3600             ; park nozzle at rear
   M117 Finished!                 ; display message

[gcode_macro NOZZLE_CLEAN]
#   Use for scrubbing the nozzle to keep it clean and ensure accurate z height 
default_parameter_I: 5
gcode:
    G0 Z10 F3000                            ;lift z 10mm
    {% if "z" not in printer.toolhead.homed_axes %} ; G28 Home if needed
      M117 Homing...      
      G28
    {% endif %}
    SAVE_GCODE_STATE NAME=cleaning          ;save pre-run g-code state (relative/absolute, etc)
    G91                                     ;relative positioning
    G90                                     ;absolute positioning
    G0 X60 Y300 F3000                       ;move to nozzle scrubber
    G0 Z9 F5000                             ;lower z to brush height
    G91                                       ;relative positioning
    M117 Cleaning... 
    # loop scrub move back/forth I amount of times
    {% for wipe in range(1,I|int,1) %}
        {% for distance in [50,-50] %}
            G0 X{distance} F10000
        {% endfor %}
    {% endfor %}
    G0 Z10 F3000                            ;lift z 10mm
    RESTORE_GCODE_STATE NAME=cleaning         ;restore previous g-code state (relative/absolute, etc)
    M117 Ready...

#   Prime the nozzle 
[gcode_macro PRIME_LINE]
gcode: 
    SAVE_GCODE_STATE NAME=BEFORE_PRIME
    M117 Prime Line
    M83
    {% if "z" not in printer.toolhead.homed_axes %}
        G28                             ;Only G28 Home if needed
    {% endif %}
    G92 E0                              ;Reset Extruder
    G1 Z5.0 F3000                       ;Move Z Axis up
    G1 X5 Y30 Z0.24 F5000.0             ;Move to start position (5,30,.24)
    G1 X5 Y230.0 Z0.24 F1500.0 E20      ;Draw the first 200mm line
    G1 X5.5 Y230.0 Z0.24 F5000.0        ;Move to side a little
    G1 X5.5 Y30 Z0.24 F1500.0 E20       ;Draw the second line
    G92 E0                              ;Reset Extruder
    G1 Z5.0 F3000                       ;Move Z Axis up
    RESTORE_GCODE_STATE NAME=BEFORE_PRIME   

[gcode_macro OFFSET]
default_parameter_D: 0.025
gcode:
  set_gcode_offset z_adjust={D}
  NULL_MOVE

[gcode_macro BABY_UP]
gcode:
  OFFSET D=0.025

[gcode_macro BABY_DOWN]
gcode:
  OFFSET D=-0.025

[gcode_macro NULL_MOVE]
gcode:
  G91
  G1 Z0 Y0 X0
  G90

[gcode_macro LOAD_FILAMENT]
#   Extrusion lengths must be adjusted for your particular configuration before use
gcode:
   {% if printer.toolhead.status == "Ready" %}
      M83                            ; set extruder to relative
      G1 E400 F1800                  ; quickly load filament to down bowden
      G1 E40 F300                    ; slower extrusion for hotend path
      G1 E30 F150                    ; prime nozzle with filament
      M82                            ; set extruder to absolute
   {% else %}
      { printer.gcode.action_respond_info("Filament loading disabled while printing!") }
   {% endif %}

[gcode_macro UNLOAD_FILAMENT]
#   Extrusion lengths must be adjusted for your particular configuration before use
gcode:
   {% if printer.toolhead.status == "Ready" %}
      M83                            ; set extruder to relative
      G1 E10 F300                    ; extrude a little to soften tip
      G1 E-650 F1800                 ; retract filament completely
      M82                            ; set extruder to absolute
   {% else %}
      { printer.gcode.action_respond_info("Filament unloading disabled while printing!") }
   {% endif %}   

[gcode_macro M600]
default_parameter_X: 110
default_parameter_Y: 0
default_parameter_Z: 20
gcode:
    SAVE_GCODE_STATE NAME=STATE
    PAUSE
    G91
    G1 Z{Z} F900
    G90
    G1 X{X} Y{Y} F18000
    RESTORE_GCODE_STATE NAME=STATE

[gcode_macro ADVANCED_RESUME]
default_parameter_E: 2.5
default_parameter_Z: -20
gcode:
    SAVE_GCODE_STATE NAME=STATE
    G91
    G1 Z{Z} E{E} F900
    RESTORE_GCODE_STATE NAME=STATE
    RESUME

[gcode_macro ABS60]
gcode:
	M140 S60  ;set bed temperature and do not wait
	M109 S235 ;set print head temperature and wait

[gcode_macro ABS80]
gcode:
	M140 S80  ;set bed temperature and do not wait
	M109 S235 ;set print head temperature and wait

[gcode_macro ABS100]
gcode:
	M140 S100  ;set bed temperature and do not wait
	M109 S235 ;set print head temperature and wait

[gcode_macro PLA60]
gcode:
	M140 S60  ;set bed temperature and do not wait
	M109 S205 ;set print head temperature and wait

#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [extruder]
#*# control = pid
#*# pid_kp = 15.943
#*# pid_ki = 0.590
#*# pid_kd = 107.612