# Q1_Pro
# V4.4.14 2024-3-14 
# modify: heater_generic hot -> chamber
#         out_put_pin fan0 -> fan_generic cooling_fan
#         out_put_pin fan2 -> fan_generic auxiliary_cooling_fan
#         out_put_pin fan3 -> fan_generic chamber_circulation_fan
#         heater_fan hot -> heater_fan chamber
#         verify_heater hot -> verify_heater chamber
# V4.4.17 2024-3-29
# modify: delete comments
#         add time_update macro
#         [bed_mesh] 6,6 ->8,8
#V4.4.19  2024-4-16
# modify: add [chamber_fan chamber_fan] 
[include timelapse.cfg]
[include Adaptive_Mesh.cfg]
[include gcode_macro.cfg]
[include plr.cfg]
[include time_update.cfg]

[mcu]
serial: /dev/ttyS2
restart_method: command

[mcu U_1]
serial: /dev/ttyS0
restart_method: command

[respond]
default_type: echo

[save_variables] 
filename =/home/mks/klipper_config/saved_variables.cfg

[resonance_tester]
accel_per_hz: 150
max_smoothing:0.5

[duplicate_pin_override]
pins:
     gpio21 ,U_1:PC3

[bed_screws]
screw1:10,10
screw1_name: Front left
screw2: 230,10
screw2_name: Front right
screw3: 125,240
screw3_name: Last right

[screws_tilt_adjust] 
screw1:-5,5.6
screw1_name: Front left
screw2: 216,5.6
screw2_name: Front right
screw3: 103,235.6
screw3_name: Last right
screw_thread: CW-M4

[force_move]
enable_force_move : false

[hall_filament_width_sensor]
adc1: gpio27
adc2: gpio28
cal_dia1: 1.50
cal_dia2: 2.0
raw_dia1: 14397
raw_dia2: 15058
default_nominal_filament_diameter: 1.75
max_difference: 0
measurement_delay: 50
enable: false
measurement_interval: 10
logging: False
min_diameter: 0.3
use_current_dia_while_delay: False
pause_on_runout:True
runout_gcode:
            pause
            RESET_FILAMENT_WIDTH_SENSOR
            M118 Filament run out
event_delay: 3.0
pause_delay: 0.5

[extruder]
step_pin:gpio5
dir_pin:gpio4
enable_pin:!gpio10
rotation_distance: 53.7  #22.6789511	#Bondtech 5mm Drive Gears
gear_ratio: 1517:170
microsteps: 16
full_steps_per_rotation: 200	#200 for 1.8 degree, 400 for 0.9 degree
nozzle_diameter: 0.400
filament_diameter: 1.75
min_temp: 0
max_temp: 360
min_extrude_temp: 175
smooth_time: 0.000001
heater_pin:gpio24
sensor_type:MAX6675
sensor_pin:gpio17
spi_speed: 100000
spi_software_sclk_pin:gpio18
spi_software_mosi_pin:gpio19
spi_software_miso_pin:gpio16
max_power: 1

control : pid  
pid_Kp=33.555
pid_Ki=4.76
pid_Kd=59.141

pressure_advance: 0.032
pressure_advance_smooth_time: 0.03
max_extrude_cross_section:500
instantaneous_corner_velocity: 10.000
max_extrude_only_distance: 1000.0
max_extrude_only_velocity:5000
max_extrude_only_accel:2000
step_pulse_duration:0.000002

[tmc2209 extruder]
uart_pin:gpio6
interpolate: True
run_current: 0.714
stealthchop_threshold: 0

[adxl345]
cs_pin:gpio13
spi_software_sclk_pin:gpio14
spi_software_mosi_pin:gpio15
spi_software_miso_pin:gpio12
axes_map: -x, z, -y

[printer]
kinematics:corexy
max_velocity: 600
max_accel: 20000
max_accel_to_decel: 10000
max_z_velocity: 10
max_z_accel: 500
square_corner_velocity: 8

[stepper_x]
step_pin:U_1:PB4
dir_pin:!U_1:PB3
enable_pin:!U_1:PB5
microsteps:16
rotation_distance: 39.88
full_steps_per_rotation:200  #set to 400 for 0.9 degree stepper
endstop_pin:tmc2240_stepper_x:virtual_endstop
position_min: -5.5  
position_endstop: -5.5
position_max:245
homing_speed:50
homing_retract_dist:0
homing_positive_dir:False
step_pulse_duration:0.0000001

[stepper_y]
step_pin:U_1:PC14
dir_pin:!U_1:PC13
enable_pin:!U_1:PC15
microsteps: 16
rotation_distance: 39.88
full_steps_per_rotation:200  #set to 400 for 0.9 degree stepper
endstop_pin:tmc2240_stepper_y:virtual_endstop
position_min: -4.5  
position_endstop: -4.5
position_max: 258
homing_speed:50
homing_retract_dist:0
homing_positive_dir:False
step_pulse_duration:0.0000001

[stepper_z]
step_pin:U_1:PC10
dir_pin:U_1:PA15
enable_pin:!U_1:PC11
microsteps: 128
rotation_distance: 4
full_steps_per_rotation: 200
endstop_pin:probe:z_virtual_endstop #U_1:PC3 for Z-max
endstop_pin_reverse:tmc2209_stepper_z:virtual_endstop
position_endstop:-0.2
position_endstop_reverse:248
position_max:248
position_min: -4
homing_speed: 8
homing_speed_reverse: 8
second_homing_speed: 10
homing_retract_dist: 5.0
homing_positive_dir:false
homing_positive_dir_reverse:true
step_pulse_duration:0.0000001

[stepper_z1]
step_pin:U_1:PB1
dir_pin:U_1:PB6
enable_pin:!U_1:PB0
microsteps: 128
rotation_distance: 4
full_steps_per_rotation: 200
step_pulse_duration:0.0000001
endstop_pin_reverse:tmc2209_stepper_z1:virtual_endstop

[z_tilt]
z_positions:
    -59,125
    307.5,125

points:
    0,125
    215,125

speed: 150
horizontal_move_z: 5
retries: 2
retry_tolerance: 0.05

[tmc2240 stepper_y]
cs_pin:U_1:PB9
spi_software_sclk_pin:U_1:PA5
spi_software_mosi_pin:U_1:PA7
spi_software_miso_pin:U_1:PA6
spi_speed:200000
run_current: 1.07
#hold_current: 0.5
interpolate:true
stealthchop_threshold:0
diag0_pin:!U_1:PC0
driver_SGT:1

[tmc2240 stepper_x]
cs_pin:U_1:PD2
spi_software_sclk_pin:U_1:PA5
spi_software_mosi_pin:U_1:PA7
spi_software_miso_pin:U_1:PA6
spi_speed:200000
run_current: 1.07
#hold_current: 0.5
interpolate:true
stealthchop_threshold:0
diag0_pin:!U_1:PB8
driver_SGT:1

[tmc2209 stepper_z]
uart_pin:U_1: PC5
run_current: 0.6
#hold_current: 0.17
interpolate: True
stealthchop_threshold: 9999999999
diag_pin:^U_1:PC12
driver_SGTHRS:140

[tmc2209 stepper_z1]
uart_pin:U_1: PB7
run_current: 0.6
#hold_current: 0.17
interpolate: True
stealthchop_threshold: 9999999999
diag_pin:^U_1:PA13
driver_SGTHRS:140

[heater_bed]
heater_pin: U_1:PB10
sensor_type:NTC 100K MGB18-104F39050L32
sensor_pin:U_1: PA0
max_power: 1.0
control = pid
pid_Kp=63.418 
pid_Ki=1.342 
pid_Kd=749.125
min_temp: -60
max_temp: 125

[heater_generic chamber]
heater_pin:U_1:PC8
max_power:1.0
sensor_type:NTC 100K MGB18-104F39050L32
sensor_pin:U_1:PA1

control = pid#watermark
pid_Kp=63.418 
pid_Ki=1.342 
pid_Kd=749.125

min_temp:-100
max_temp:65

[verify_heater chamber]
max_error: 300
check_gain_time:480
hysteresis: 5
heating_gain: 1

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

[verify_heater heater_bed]
max_error: 200
check_gain_time:60
hysteresis: 5
heating_gain: 1

[fan_generic auxiliary_cooling_fan]
pin: U_1:PA8
shutdown_speed: 0.0
cycle_time: 0.0100
hardware_pwm: false
kick_start_time: 0.100
off_below: 0.0

[fan_generic chamber_circulation_fan]
pin:U_1:PC9
shutdown_speed: 0.0
cycle_time: 0.100
hardware_pwm: false
kick_start_time: 0.100
off_below: 0.0

[chamber_fan chamber_fan]
pin:U_1:PA4
max_power: 1.0
shutdown_speed: 0
kick_start_time: 0.5
heater:chamber
fan_speed: 1.0
off_below: 0
idle_timeout:60
idle_speed:1.0

[heater_fan hotend_fan]
pin:gpio25
max_power: 1.0
shutdown_speed:1.0
kick_start_time: 0.5
heater: extruder
heater_temp: 50.0
fan_speed: 1.0
off_below: 0

[heater_fan hotend_fan2]
pin:gpio11
max_power: 1.0
shutdown_speed:1.0
kick_start_time: 0.5
heater: extruder
heater_temp: 50.0
fan_speed: 1.0
off_below: 0

[controller_fan board_fan]
pin:U_1:PC4
max_power:1.0
shutdown_speed:1.0
cycle_time:0.01
fan_speed: 0.6
stepper:stepper_z,stepper_z1

[fan_generic cooling_fan]
pin:gpio2
max_power: 1.0
shutdown_speed: 0
cycle_time: 0.0100
hardware_pwm: false
kick_start_time: 0.100
off_below: 0.0

[output_pin caselight]
pin: U_1:PC7
pwm: false
shutdown_value:1
value:1

[output_pin beeper]
pin:U_1: PA2
pwm: false
shutdown_value:0
value:0

[output_pin ctlyd]
pin:U_1: PA14
pwm: false
shutdown_value:0
value:0

[smart_effector]
pin:U_1:PC1
recovery_time:0
x_offset: 17.6
y_offset: 4.4
z_offset: 0.000001
speed:10
probe_accel:50
samples: 2
samples_result: average
sample_retract_dist: 3.0
samples_tolerance: 0.05
samples_tolerance_retries:5

[qdprobe]
pin:!gpio21
z_offset:0.000001

[bed_mesh]
speed:150 
horizontal_move_z:7
mesh_min:20,15      
mesh_max:230,230    
probe_count:8,8     
algorithm:bicubic
bicubic_tension:0.2
mesh_pps: 2, 2
vibrate_gcode:
    G90
    m204 S5000
    SET_Z_VELOCITY_LIMIT VALUE=15
    SET_PIN PIN=ctlyd VALUE=1
    G4 P500    
    G91 
    G1 Z1 F900
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1  Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1  Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1  Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1  Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1  Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1  Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1  Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G1 Z1 
    G1 Z-1
    G90
    SET_PIN PIN=ctlyd VALUE=0
    SET_Z_VELOCITY_LIMIT VALUE=10
    G4 P500

[filament_switch_sensor fila]
pause_on_runout: True
runout_gcode:
            PAUSE
event_delay: 3.0
pause_delay: 0.5
switch_pin:U_1:PC3

[resonance_tester]
accel_chip:adxl345
probe_points:
   120, 120, 10

[gcode_macro_break]
# Used for cancel print in a macro

[idle_timeout]
timeout: 43200

[pause_resume]

[display_status]

[virtual_sdcard]
path: ~/gcode_files

#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [input_shaper]
#*# shaper_type_x = ei
#*# shaper_freq_x = 81.6
#*# shaper_type_y = ei
#*# shaper_freq_y = 39.8
#*#
#*# [adxl345]
#*# probe_pin = gpio9
#*# int_pin = int1
#*# tap_thresh = 3500
#*# tap_dur = 0.01
#*# speed = 20
#*# z_offset = -0.1
#*# samples = 3
#*# sample_retract_dist = 10.0
#*# samples_result = median
#*# samples_tolerance = 0.05
#*# samples_tolerance_retries = 3
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# 	  0,0,0,0,0,0
#*# 	  0,0,0,0,0,0
#*# 	  0,0,0,0,0,0
#*# 	  0,0,0,0,0,0
#*# 	  0,0,0,0,0,0
#*# 	  0,0,0,0,0,0
#*# tension = 0.2
#*# min_x = 20.0
#*# algo = lagrange
#*# y_count = 6
#*# mesh_y_pps = 2
#*# min_y = 10.0
#*# x_count = 6
#*# max_y = 230.0
#*# mesh_x_pps = 2
#*# max_x = 230.0
#*#
#*# [bed_mesh kamp]
#*# version = 1
#*# points =
#*# 	0, 0, 0
#*# 	0, 0, 0
#*# 	0, 0, 0
#*# tension = 0.2
#*# min_x = 86.05
#*# algo = lagrange
#*# y_count = 3
#*# mesh_y_pps = 2
#*# min_y = 86.05
#*# x_count = 3
#*# max_y = 158.95
#*# mesh_x_pps = 2
#*# max_x = 158.93
