# VORON2 250mm config

# This is a base printer.cfg file for the VORON2 printer and matches the manual/build guide exactly
# for controllers used (dual RAMPS) and pin layout for all connected components.
# Created by "Boff" with help from the VORON community.

# For other build sizes, controllers, or non-standard pin connections, please see
# https://github.com/VoronDesign/Voron-2/tree/master/firmware/klipper/configurations
# for other example Klipper configs created by the VORON community.

# This file is only an example - be sure to review and update it
# according to the specifics of your printer. See the example.cfg and
# example-extras.cfg files for a description of available Klipper parameters.

# AND PLEASE READ THROUGH THE KLIPPER DOCUMENTATION FIRST!
# https://github.com/KevinOConnor/klipper/tree/master/docs

#Pinouts for RAMPS 1.4
# X_STEP_PIN         ar54
# X_DIR_PIN          ar55
# X_ENABLE_PIN       ar38
# X_MIN_PIN          ar3
# X_MAX_PIN          ar2
# Y_STEP_PIN         ar60
# Y_DIR_PIN          ar61
# Y_ENABLE_PIN       ar56
# Y_MIN_PIN          ar14
# Y_MAX_PIN          ar15
# Z_STEP_PIN         ar46
# Z_DIR_PIN          ar48
# Z_ENABLE_PIN       ar62
# Z_MIN_PIN          ar18
# Z_MAX_PIN          ar19
# E0_STEP_PIN        ar26
# E0_DIR_PIN         ar28
# E0_ENABLE_PIN      ar24
# E1_STEP_PIN        ar36
# E1_DIR_PIN         ar34
# E1_ENABLE_PIN      ar30
# D10                ar10
# D9                 ar9
# D8                 ar8
# TEMP_0_PIN         analog13
# TEMP_1_PIN         analog14
# TEMP_2_PIN         analog15
# SERVO 1 (TOP)      D11
# SERVO 2            D6
# SERVO 3            D5
# SERVO 4            D4

# use the following modifiers before the pin definition (ex: ^!ar99)
# !                  invert the logic
# ^                  activate 5v pullup (does not apply to all pins)
# mcu_name:          use pins on additional MCU (ex: z:ar10)

# *** THINGS TO CHANGE/CHECK: ***
# Arduino paths                         [mcu] section
# Thermistor types                      [extruder] and [heater_bed] sections - See 'sensor types' list at end of file
# Microswitch (z endstop) location      [homing_override] section
# Microswitch (z endstop) offset for Z0 [stepper_z] section
# Inductive Probe Type (NC/NO)          [probe] section
# Probe points                          [quad_gantry_level] section
# Min & Max gantry corner positions     [quad_gantry_level] section
# PID tune                              [extruder] and [heater_bed] sections
# Fine tune E steps                     [extruder] section

[mcu]
# Mcu for X/Y/E steppers
serial: /dev/serial/by-id/**INSERT_YOUR_ARDUINO_DEFINITION_HERE**
# Obtain definition by "ls -l /dev/serial/by-id/"
# Some Arduinos clones (CH340) may require using "ls -l /dev/serial/by-path/"
pin_map: arduino
restart_method: arduino

[mcu z]
# Mcu for Z steppers
serial: /dev/serial/by-id/**INSERT_YOUR_ARDUINO_DEFINITION_HERE**
# Obtain definition by "ls -l /dev/serial/by-id/"
# Some Arduinos clones (CH340) may require using "ls -l /dev/serial/by-path/"
pin_map: arduino
restart_method: arduino

[printer]
kinematics: corexy
# Velocities and accels may be increased for better performance
# but should be tested and increased incrementally
max_velocity: 250
max_accel: 2500
max_z_velocity: 35
max_z_accel: 350
square_corner_velocity: 5.0
#   The maximum velocity (in mm/s) that the toolhead may travel a 90
#   degree corner at. The default is 5mm/s.
#   For more information, refer to Klipper docs.

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

[stepper_x]
# B Stepper
step_pin: ar54
dir_pin: !ar55
enable_pin: !ar38
#   X on mcu_xye
step_distance: 0.0125
#   80 steps per mm - 1.8 deg - 1/16 microstepping
endstop_pin: ^ar2
#   X_MAX on mcu_xye
position_min: 0
position_endstop: 253
position_max: 253
homing_speed: 100
second_homing_speed: 25
homing_retract_dist: 5
homing_positive_dir: true

[stepper_y]
# A Stepper
step_pin: ar60
dir_pin: !ar61
enable_pin: !ar56
#   Y on mcu_xye
step_distance: 0.0125
#   80 steps per mm - 1.8 deg - 1/16 microstepping
endstop_pin: ^ar15
#   Y_MAX on mcu_xye
position_min: 0
position_endstop: 253
position_max: 253
homing_speed: 100
second_homing_speed: 25
homing_retract_dist: 5
homing_positive_dir: true

[stepper_z]
# Z0 Stepper - Front Left
step_pin: z:ar54
dir_pin: z:ar55
enable_pin: !z:ar38
#   X on mcu_z
step_distance: 0.00250
#   400 steps per mm - 1.8 deg - 1/16 microstepping
endstop_pin: ^!z:ar18
#   Z_MIN on mcu_z
position_endstop: 0
#   Z-position of nozzle (in mm) to z-endstop trigger point relative to print surface (Z0)
#   (+) value = endstop above Z0, (-) value = endstop below
position_max: 240
position_min: -5
#   Set to -5 to allow room for squaring gantry with quad_gantry_level
homing_speed: 15.0
second_homing_speed: 1.5
homing_retract_dist: 3.0
homing_positive_dir: false

[stepper_z1]
# Z1 Stepper - Rear Left
step_pin: z:ar60
dir_pin: !z:ar61
enable_pin: !z:ar56
#   Y on mcu_z
step_distance: 0.00250
#   400 steps per mm - 1.8 deg - 1/16 microstepping

[stepper_z2]
# Z2 Stepper - Rear Right
step_pin: z:ar46
dir_pin: z:ar48
enable_pin: !z:ar62
#   Z on mcu_z
step_distance: 0.00250
#   400 steps per mm - 1.8 deg - 1/16 microstepping

[stepper_z3]
# Z3 Stepper - Front Right
step_pin: z:ar26
dir_pin: !z:ar28
enable_pin: !z:ar24
#   E0 on mcu_z
step_distance: 0.00250
#   400 steps per mm - 1.8 deg - 1/16 microstepping

[extruder]
step_pin: ar26
dir_pin: ar28
enable_pin: !ar24
#   E0 on mcu_xye
step_distance: 0.00180180
#   555 steps per mm - 1.8 deg - 1/16 microstepping (Mobius3)
#   This must be calibrated to your specific machine for best results
nozzle_diameter: 0.400
filament_diameter: 1.750
max_extrude_only_distance: 780
#   This is set high to allow the load/unload filament macros to run
#   Adjust to match your approximate filament path length
#max_extrude_cross_section:
#   Maximum area (in mm^2) of an extrusion cross section (eg.
#   extrusion width multiplied by layer height). This setting prevents
#   excessive amounts of extrusion during relatively small XY moves.
#   If a move requests an extrusion rate that would exceed this value
#   it will cause an error to be returned. The default is: 4.0 *
#   nozzle_diameter^2
#max_extrude_only_velocity:
#max_extrude_only_accel:
#   Maximum velocity (in mm/s) and acceleration (in mm/s^2) of the
#   extruder motor for retractions and extrude-only moves. These
#   settings do not place any limit on normal printing moves. If not
#   specified then they are calculated to match the limit an XY
#   printing move with a cross section of 4.0*nozzle_diameter^2 would
#   have.
heater_pin: ar10
#   D10 on mcu_xye
max_power: 1.0
sensor_type: ATC Semitec 104GT-2
# use "ATC Semitec 104GT-2" for Trianglelab 104GT-2 and 104NT-4-R025H42G sensors
# Other sensor types
#   "EPCOS 100K B57560G104F"
#   "ATC Semitec 104GT-2"
#   "NTC 100K beta 3950"
#   "Honeywell 100K 135-104LAG-J01"
#   "NTC 100K MGB18-104F39050L32" (Keenovo Heater Pad)
#   "AD595"
#   "PT100 INA826"

sensor_pin: analog13
#   T0 on mcu_xye
smooth_time: 3.0
control: pid
pid_Kp: 16.430
pid_Ki: 0.755
pid_Kd: 89.337
min_extrude_temp: 170
min_temp: 0
max_temp: 270
# pressure_advance: 0
#   The amount of raw filament to push into the extruder during
#   extruder acceleration. An equal amount of filament is retracted
#   during deceleration. It is measured in millimeters per
#   millimeter/second. The default is 0, which disables pressure
#   advance.
# pressure_advance_smooth_time: 0.040
#   A time range (in seconds) to use when calculating the average
#   extruder velocity for pressure advance. A larger value results in
#   smoother extruder movements. This parameter may not exceed 200ms.
#   This setting only applies if pressure_advance is non-zero. The
#   default is 0.040 (40 milliseconds).

[probe]
# Inductive Probe
# Z height probe. One may define this section to enable Z height
# probing hardware. When this section is enabled, PROBE and
# QUERY_PROBE extended g-code commands become available. The probe
# section also creates a virtual "probe:z_virtual_endstop" pin. One
# may set the stepper_z endstop_pin to this virtual pin on cartesian
# style printers that use the probe in place of a z endstop.
pin: ^!z:ar19
#   Z_MAX input on mcu_z
#   use '^!z:ar19' for "Normally Open" probes like the PL-08N, PL-05N, TL-Q5MC1
#   use '^z:ar19' for "Normally Closed" probes like the PL-08N2, PL-05N2, TL-Q5MC2
x_offset: 0.0
y_offset: 25.0
#   Offset (in mm) for inductive probe Y direction from nozzle
z_offset: 0.0
#   Offset (in mm) for inductive probe in Z height
speed: 2.0
#   Speed (in mm/s) of the Z axis when probing. The default is 5mm/s.
samples: 4
#   Number of times to probe a point
sample_retract_dist: 3.0
#   How far to retract (in mm) from the probe point for multi-probe samples
samples_result: average
#   The calculation method when sampling more than once - either
#   "median" or "average". The default is average.
#samples_tolerance: 0.100
#   The maximum Z distance (in mm) that a sample may differ from other
#   samples. If this tolerance is exceeded then either an error is
#   reported or the attempt is restarted (see
#   samples_tolerance_retries). The default is 0.100mm.
#samples_tolerance_retries: 0
#   The number of times to retry if a sample is found that exceeds
#   samples_tolerance. On a retry, all current samples are discarded
#   and the probe attempt is restarted. If a valid set of samples are
#   not obtained in the given number of retries then an error is
#   reported. The default is zero which causes an error to be reported
#   on the first sample that exceeds samples_tolerance.

[fan]
# Print cooling fan
pin: ar9
#   D9 on mcu_xye
max_power: 1.0
#   The maximum power (expressed as a value from 0.0 to 1.0) that the
#   pin may be set to. The value 1.0 allows the pin to be set fully
#   enabled for extended periods, while a value of 0.5 would allow the
#   pin to be enabled for no more than half the time. This setting may
#   be used to limit the total power output (over extended periods) to
#   the fan. If this value is less than 1.0 then fan speed requests
#   will be scaled between zero and max_power (for example, if
#   max_power is .9 and a fan speed of 80% is requested then the fan
#   power will be set to 72%). The default is 1.0.
shutdown_speed: 0
#   The desired fan speed (expressed as a value from 0.0 to 1.0) if
#   the micro-controller software enters an error state. The default
#   is 0.
cycle_time: 0.010
#   The amount of time (in seconds) for each PWM power cycle to the
#   fan. It is recommended this be 10 milliseconds or greater when
#   using software based PWM. The default is 0.010 seconds.
hardware_pwm: false
#   Enable this to use hardware PWM instead of software PWM. The
#   default is False.
kick_start_time: 0.500
#   Time (in seconds) to run the fan at full speed when first enabling
#   it (helps get the fan spinning). The default is 0.100 seconds.
#   See the "fan" section in example.cfg for a description of the
#   above parameters.

[heater_fan hotend_fan]
# Hotend fan
#   See the "heater_fan" section in example-extras.cfg for a complete
#   description of this sections parameters.
pin: z:ar9
#   D9 on mcu_z
max_power: 1.0
shutdown_speed: 1.0
cycle_time: 0.010
hardware_pwm: false
kick_start_time: 0.500
heater: extruder
heater_temp: 75.0
#   A temperature (in Celsius) that the heater must drop below before
#   the fan is disabled. The default is 50 Celsius.
fan_speed: 1.0
#   The fan speed (expressed as a value from 0.0 to 1.0) that the fan
#   will be set to when its associated heater is enabled. The default
#   is 1.0

[controller_fan controller_fan]
# Controller fan
#   See the "controller_fan" section in example-extras.cfg for a complete
#   description of this sections parameters.
pin: z:ar10
#   D10 on mcu_z
max_power: 1.0
shutdown_speed: 0
cycle_time: 0.010
hardware_pwm: false
kick_start_time: 0.500
idle_timeout: 30
#   The ammount of time (in seconds) after a stepper driver or heater
#   was active and the fan should be kept running. The default
#   is 30 seconds.
idle_speed: 0.4
#   The fan speed (expressed as a value from 0.0 to 1.0) that the fan
#   will be set to when a heater or stepper driver was active and before
#   the idle_timeout is reached. This must be greater or equal
#   max_power. The default is max_power
heater: extruder,heater_bed
#   Name of the config section defining the heater that this fan is
#   associated with. If a comma separated list of heater names is
#   provided here, then the fan will be enabled when any of the given
#   heaters are enabled. The default is "extruder".

# [temperature_fan chamber]
# # Chamber temp and Exhaust fan
# #   See the "temperature_fan" section in example-extras.cfg for a complete
# #   description of this sections parameters.
# pin: z:ar8
# #   D8 on mcu_z
# max_power: 1.0
# shutdown_speed: 0
# cycle_time: 0.010
# hardware_pwm: false
# kick_start_time: 0.500
# sensor_type: ATC Semitec 104GT-2
# sensor_pin: analog15
# min_temp: 0
# max_temp: 100
# #   The maximum range of valid temperatures (in Celsius) that the
# #   sensor must remain within. This controls a safety feature
# #   implemented in the micro-controller code - should the measured
# #   temperature ever fall outside this range then the micro-controller
# #   will go into a shutdown state. Set this range just wide enough so
# #   that reasonable temperatures do not result in an error. These
# #   parameters must be provided.
# target_temp: 50
# #   A temperature (in Celsius) that will be the target temperature.
# #   The default is 40 degrees.
# max_speed: 1.0
# #   The fan speed (expressed as a value from 0.0 to 1.0) that the fan
# #   will be set to when the sensor temperature exceeds the set value.
# #   The default is 1.0.
# min_speed: 0
# #   The minimum fan speed (expressed as a value from 0.0 to 1.0) that
# #   the fan will be set to for PID temperature fans.
# #   The default is 0.3.
# control: pid
# pid_Kp: 40
# pid_Ki: 0.2
# pid_Kd: 0.1
# pid_deriv_time: 2.0
# #pid_integral_max:
# #   The maximum "windup" the integral term may accumulate. The default
# #   is to use the same value as max_power.
# gcode_id: C
# #   If set, the temperature will be reported in M105 queries using the
# #   given id. The default is to not report the temperature via M105.

[heater_bed]
heater_pin: z:ar11
#   D11 (servo) on mcu_z
sensor_type: NTC 100K MGB18-104F39050L32
#   NTC 100K MGB18-104F39050L32 is for Keenovo thermistors
sensor_pin: z:analog15
#   T2 on mcu_z
smooth_time: 3.0
max_power: 0.75
control: pid
pid_Kp: 47.690
pid_Ki: 1.556
pid_Kd: 365.338
min_temp: 0
max_temp: 110

[verify_heater heater_bed]
max_error: 120
#   The maximum "cumulative temperature error" before raising an
#   error. Smaller values result in stricter checking and larger
#   values allow for more time before an error is reported.
#   Specifically, the temperature is inspected once a second and if it
#   is close to the target temperature then an internal "error
#   counter" is reset; otherwise, if the temperature is below the
#   target range then the counter is increased by the amount the
#   reported temperature differs from that range. Should the counter
#   exceed this "max_error" then an error is raised. The default is
#   120.
check_gain_time: 60
#   This controls heater verification during initial heating.  Smaller
#   values result in stricter checking and larger values allow for
#   more time before an error is reported. Specifically, during
#   initial heating, as long as the heater increases in temperature
#   within this time frame (specified in seconds) then the internal
#   "error counter" is reset. The default is 20 seconds for extruders
#   and 60 seconds for heater_bed.
hysteresis: 5
#   The maximum temperature difference (in Celsius) to a target
#   temperature that is considered in range of the target. This
#   controls the max_error range check. It is rare to customize this
#   value. The default is 5.
heating_gain: 2
#   The minimum temperature (in Celsius) that the heater must increase
#   by during the check_gain_time check. It is rare to customize this
#   value. The default is 2.

[verify_heater extruder]
max_error: 120
check_gain_time: 20
hysteresis: 5
heating_gain: 2

[homing_override]
axes: z
set_position_z: 0
gcode:
   G90
   G0 Z5 F600
   G28 X Y
   G0 X179 Y250 F3600
#   XY Location of the Z Min Switch. Update to your machines XY location.
   G28 Z
   G0 Z10 F1800
   G0 X125 Y125 Z20 F3600

[quad_gantry_level]
#   Use QUAD_GANTRY_LEVEL to level a gantry.
gantry_corners:
   -58,-7
   308,318
#   Min & Max gantry corners - measure from nozzle at MIN (0,0) and MAX (250,250) to respective belt positions
points:
   60,60
   60,200
   195,200
   195,60
#   Probe points
speed: 200
#   The speed (in mm/s) of non-probing moves during the calibration.
#   The default is 50.
horizontal_move_z: 5
#   The height (in mm) that the head should be commanded to move to
#   just prior to starting a probe operation. The default is 5
retries: 5
#   number of times to retry if the stepper movements aren't within tolerance
retry_tolerance: 0.0075
#   if retries are enabled then retry if any z_stepper movement was greater
#   than the retry_tolerance

# [display]
# # RepRapDiscount 128x64 Full Graphic Smart Controller
# lcd_type: st7920
# cs_pin: z:ar16
# sclk_pin: z:ar23
# sid_pin: z:ar17
# #   LCD connector on mcu_z
# menu_timeout: 40
# #   Timeout for menu. Being inactive this amount of seconds will exit the menu
# #   Default is 0 seconds (disabled)
# encoder_pins: ^z:ar33, ^z:ar31
# click_pin: ^!z:ar35
# kill_pin: ^!z:ar41


###   Macros   ###


[gcode_macro G32]
gcode:
   {% if printer.toolhead.status == "Ready" %}
      G28
      QUAD_GANTRY_LEVEL
      G28 Z0
      G0 X125 Y125 Z20 F6000
   {% else %}
      { printer.gcode.action_respond_info("G32 is disabled while printing!") }
   {% endif %}

[gcode_macro PRINT_START]
#   Use PRINT_START for the slicer starting script - PLEASE CUSTOMISE THE SCRIPT FOR YOUR SLICER OF CHOICE
gcode:
   M117 Homing...                 ; display message
   G28                            ; home all axes
   G1 Z20 F3000                   ; move nozzle away from bed
   M117 Preheat (Print)           ; display message

[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 Z1.00 X20.0 Y20.0 F20000    ; move nozzle to remove stringing
   TURN_OFF_HEATERS
   M107                           ; turn off fan
   G1 Z5 F3000                    ; move nozzle up 5mm
   G90                            ; absolute positioning
   G0  X125 Y250 F3600            ; park nozzle at rear
   M117 Finished!                 ; display message

[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-780 F1800                 ; retract filament completely
      M82                            ; set extruder to absolute
   {% else %}
      { printer.gcode.action_respond_info("Filament unloading disabled while printing!") }
   {% endif %}


[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 E750 F1800                  ; quickly load filament to down bowden
      G1 E30 F300                    ; slower extrusion for hotend path
      G1 E15 F150                    ; prime nozzle with filament
      M82                            ; set extruder to absolute
   {% else %}
      { printer.gcode.action_respond_info("Filament loading disabled while printing!") }
   {% endif %}

