diff --git a/config/printer.cfg b/config/printer.cfg index d5d32e2..bd46f0a 100644 --- a/config/printer.cfg +++ b/config/printer.cfg @@ -1,350 +1,83 @@ -## Sparkcube -## +# This file is an example config file. +# See https://github.com/Klipper3d/klipper/blob/master/docs/Config_Reference.md for a description of parameters. + +[mcu] +serial: /dev/ttymxc3 [printer] kinematics: cartesian max_velocity: 500 max_accel: 3000 -max_z_velocity: 8 -max_z_accel: 100 - -[input_shaper] -shaper_freq_x: 98.8 -shaper_freq_y: 72.2 -shaper_type: 2hump_ei - -[mcu] -serial: /dev/ttymxc3 -baud: 115200 -restart_method: command - -[pause_resume] -recover_velocity: 225 - -[respond] +max_z_velocity: 25 +max_z_accel: 30 [virtual_sdcard] path: /opt/gcode [display_status] -## Stepper -[stepper_x] -step_pin: PA7 -dir_pin: PC1 -enable_pin: !PD6 -rotation_distance: 40 -microsteps: 16 -endstop_pin: ^PD3 -position_min: -27 -position_endstop: -27 -position_max: 211 -homing_speed: 80 -homing_retract_dist: 5.0 -second_homing_speed: 25 -homing_positive_dir: false +[pause_resume] -[dual_carriage] -axis: x -step_pin: PC5 -dir_pin: !PD2 -enable_pin: !PD0 -rotation_distance: 40 -microsteps: 16 -endstop_pin: ^PC2 -position_min: 4 -position_endstop: 241.85 -position_max: 241.85 -homing_speed: 80 -homing_retract_dist: 5.0 -second_homing_speed: 25 -homing_positive_dir: true - -[stepper_y] -step_pin: PA12 -dir_pin: PA13 -enable_pin: !PB26 -rotation_distance: 40 -microsteps: 16 -endstop_pin: ^PC4 -position_min: -1 -position_endstop: 215 -position_max: 215 -homing_speed: 80 -homing_retract_dist: 5.0 -second_homing_speed: 25 -homing_positive_dir: true - -[stepper_y1] -step_pin: PA15 -dir_pin: !PA14 -enable_pin: !PD1 -rotation_distance: 40 -microsteps: 16 - -[stepper_z] -step_pin: PB25 -dir_pin: !PC28 -enable_pin: !PD5 -rotation_distance: 2 -microsteps: 16 -endstop_pin: ^PD10 -position_min: 0 -position_endstop: 0 -position_max: 205 -homing_speed: 8 -homing_retract_dist: 5.0 -second_homing_speed: 2 -homing_positive_dir: false - -## Extruder -[extruder] -step_pin: PA2 -dir_pin: PA3 -enable_pin: !PB17 -rotation_distance: 21.9392 -microsteps: 16 -nozzle_diameter: 0.400 -filament_diameter: 1.75 -max_extrude_only_distance: 700 -heater_pin: PB27 -sensor_type: ATC Semitec 104GT-2 -sensor_pin: PA16 -pullup_resistor: 4700 -smooth_time: 6.0 -control: pid -pid_Kp=26.868 -pid_Ki=1.410 -pid_Kd=127.958 -min_extrude_temp: 5 -min_temp: 5 -max_temp: 290 -max_extrude_only_accel: 10000 -max_extrude_only_velocity: 150 - -[extruder1] -step_pin: PB19 -dir_pin: !PB18 -enable_pin: !PB20 -rotation_distance: 21.9392 -microsteps: 16 -nozzle_diameter: 0.400 -filament_diameter: 1.75 -max_extrude_only_distance: 700 -heater_pin: PD8 -sensor_type: ATC Semitec 104GT-2 -sensor_pin: PA24 -pullup_resistor: 4700 -smooth_time: 6.0 -control: pid -pid_Kp: 15 -pid_Ki: 1 -pid_Kd: 25 -min_extrude_temp: 5 -min_temp: 5 -max_temp: 290 -max_extrude_only_accel: 10000 -max_extrude_only_velocity: 150 - -## TMC2130 Driver -[tmc2130 stepper_x] -cs_pin: PC16 -run_current: 0.4 -hold_current: 0.25 - -[tmc2130 dual_carriage] -cs_pin: PC9 -run_current: 0.4 -hold_current: 0.25 - -[tmc2130 stepper_y] -cs_pin: PC18 -run_current: 0.8 -hold_current: 0.4 - -[tmc2130 stepper_y1] -cs_pin: PC17 -run_current: 0.8 -hold_current: 0.4 - -[tmc2130 stepper_z] -cs_pin: PC19 -run_current: 0.6 -hold_current: 0.3 - -[tmc2130 extruder] -cs_pin: PA20 -run_current: 1.0 -hold_current: 0.6 - -[tmc2130 extruder1] -cs_pin: PA19 -run_current: 1.0 -hold_current: 0.6 - -## Heatbed -[heater_bed] -heater_pin: PC23 -sensor_type: EPCOS 100K B57560G104F -sensor_pin: PA6 -control: pid -pid_Kp: 66.069 -pid_Ki: 2.736 -pid_Kd: 398.889 -min_temp: 0 -max_temp: 120 - -## Fans -[heater_fan hotends] -pin: PC22 -max_power: 1.0 -heater: extruder,extruder1 -heater_temp: 50.0 -fan_speed: 0.75 - -[output_pin fan_extruder] -pin: PC21 -pwm: True -value: 0 -shutdown_value: 0 -scale: 255 - -[output_pin fan_extruder1] -pin: PD7 -pwm: True -value: 0 -shutdown_value: 0 -scale: 255 - -## Generic Macros -[gcode_macro LOAD_FILAMENT] +[gcode_macro PAUSE] +description: Pause the actual running print +rename_existing: PAUSE_BASE +# change this if you need more or less extrusion +variable_extrude: 1.0 gcode: + ##### read E from pause macro ##### + {% set E = printer["gcode_macro PAUSE"].extrude|float %} + ##### set park positon for x and y ##### + # default is your max posion from your printer.cfg + {% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %} + {% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %} + ##### calculate save lift position ##### + {% set max_z = printer.toolhead.axis_maximum.z|float %} + {% set act_z = printer.toolhead.position.z|float %} + {% if act_z < (max_z - 2.0) %} + {% set z_safe = 2.0 %} + {% else %} + {% set z_safe = max_z - act_z %} + {% endif %} + ##### end of definitions ##### + PAUSE_BASE G91 - G1 E600 F6000 - G90 - -[gcode_macro UNLOAD_FILAMENT] -gcode: - G91 - G1 E-650 F6000 - G90 - -[gcode_macro SWAP_FILAMENT] -gcode: - G28 - G1 Z50 F480 - G1 X110 Y110 F30000 - -[gcode_macro WAIT_FOR_HEATER] -gcode: - M109 S{printer.extruder.target} T0 - M109 S{printer.extruder1.target} T1 - M190 S{printer.heater_bed.target} - -## IDEX Macros -[gcode_macro ACTIVATE_TOOL] -gcode: - {% set tool_carriage = {'extruder': 0, 'extruder1': 1} %} - - ## Disable FAN, Activate carriage+extruder, Reactivate FAN - SET_TOOL_FAN SPEED=0 - ACTIVATE_EXTRUDER EXTRUDER={params.TOOL} - SET_DUAL_CARRIAGE CARRIAGE={tool_carriage[params.TOOL]} - SET_TOOL_FAN SPEED={printer["gcode_macro TOOL_FAN_STATE"].speed} - -[gcode_macro CHANGE_TOOL] -gcode: - {% set velocity = printer.configfile.config['printer']['max_velocity']|int*60 %} - {% set tool_config = { - 'extruder': { - 'park_pos': printer.configfile.config['stepper_x']['position_min'], - 'stepper': 'stepper_x', - 'offset': {'x': 0, 'y': 0, 'z': 0} - }, - 'extruder1': { - 'park_pos': printer.configfile.config['dual_carriage']['position_max'], - 'stepper': 'dual_carriage', - 'offset': {'x': 0, 'y': 0.52, 'z': -0.075} - } - } - %} - - ## Only Move if Printer is homed - {% if params.TOOL != printer.toolhead.extruder %} - {% if printer.toolhead.homed_axes == 'xyz' %} - ## Move current Tool to parking position, - SAVE_GCODE_STATE NAME=park - G90 - G1 X{tool_config[printer.toolhead.extruder]['park_pos']} F{velocity} - RESTORE_GCODE_STATE NAME=park - - ## Activate new Tool - ACTIVATE_TOOL TOOL={params.TOOL} - SET_GCODE_OFFSET X={tool_config[params.TOOL]['offset']['x']} Y={tool_config[params.TOOL]['offset']['y']} Z={tool_config[params.TOOL]['offset']['z']} - - ## Safely move new Tool to last known Location - {% if ( - printer.configfile.config[tool_config[params.TOOL]['stepper']]['position_min']|int <= printer.gcode_move.gcode_position.x and - printer.configfile.config[tool_config[params.TOOL]['stepper']]['position_max']|int >= printer.gcode_move.gcode_position.x and - printer.configfile.config['stepper_y']['position_min']|int <= printer.gcode_move.gcode_position.y and - printer.configfile.config['stepper_y']['position_max']|int >= printer.gcode_move.gcode_position.y and - printer.configfile.config['stepper_z']['position_min']|int <= printer.gcode_move.gcode_position.z and - printer.configfile.config['stepper_z']['position_max']|int >= printer.gcode_move.gcode_position.z) %} - SAVE_GCODE_STATE NAME=unpark - G90 - G1 X{printer.gcode_move.gcode_position.x} Y{printer.gcode_move.gcode_position.y} Z{printer.gcode_move.gcode_position.z} F{velocity} - RESTORE_GCODE_STATE NAME=unpark - {% endif %} - {% else %} - ## Activate new Tool - ACTIVATE_TOOL TOOL={params.TOOL} - {% endif %} + {% if printer.extruder.can_extrude|lower == 'true' %} + G1 E-{E} F2100 + {% else %} + {action_respond_info("Extruder not hot enough")} + {% endif %} + {% if "xyz" in printer.toolhead.homed_axes %} + G1 Z{z_safe} F900 + G90 + G1 X{x_park} Y{y_park} F6000 + {% else %} + {action_respond_info("Printer not homed")} {% endif %} -## Overrides for T0/T1 -[gcode_macro T0] +[gcode_macro RESUME] +description: Resume the actual running print +rename_existing: RESUME_BASE gcode: - CHANGE_TOOL TOOL=extruder - -[gcode_macro T1] -gcode: - CHANGE_TOOL TOOL=extruder1 - -## FAN Macros -### Save Fan State globally -[gcode_macro TOOL_FAN_STATE] -variable_speed: 0 -gcode: - -### Set the pin_value for the currently active extruder -### Update speed in TOOL_FAN_STATE -[gcode_macro SET_TOOL_FAN] -gcode: - SET_PIN PIN=fan_{printer.toolhead.extruder} VALUE={params.SPEED|int} - SET_GCODE_VARIABLE MACRO=TOOL_FAN_STATE VARIABLE=speed VALUE={params.SPEED|int} - -### Override Default M106 and M107 to use SET_TOOL_FAN -[gcode_macro M106] -gcode: - {% set fan_gcode_speed = 255 %} - {% if params.S is defined %} - {% set fan_gcode_speed = params.S|int %} + ##### read E from pause macro ##### + {% set E = printer["gcode_macro PAUSE"].extrude|float %} + #### get VELOCITY parameter if specified #### + {% if 'VELOCITY' in params|upper %} + {% set get_params = ('VELOCITY=' + params.VELOCITY) %} + {%else %} + {% set get_params = "" %} {% endif %} - {% if fan_gcode_speed < 0 %} - {% set fan_gcode_speed = 0 %} - {% endif %} - {% if fan_gcode_speed > 255 %} - {% set fan_gcode_speed = 255 %} - {% endif %} - SET_TOOL_FAN SPEED={fan_gcode_speed} + ##### end of definitions ##### + {% if printer.extruder.can_extrude|lower == 'true' %} + G91 + G1 E{E} F2100 + {% else %} + {action_respond_info("Extruder not hot enough")} + {% endif %} + RESUME_BASE {get_params} -[gcode_macro M107] -gcode: - SET_TOOL_FAN SPEED=0 - -## Required by Fluidd [gcode_macro CANCEL_PRINT] +description: Cancel the actual running print rename_existing: CANCEL_PRINT_BASE gcode: TURN_OFF_HEATERS - CANCEL_PRINT_BASE + CANCEL_PRINT_BASE \ No newline at end of file