Merge branch 'personal'

This commit is contained in:
Bassam Husain
2023-02-02 19:12:49 -05:00
8 changed files with 2420 additions and 882 deletions

View File

@@ -0,0 +1,107 @@
###############################################################################
# Source https://github.com/strayr/strayr-k-macros/blob/e0807570a66d28735cf05143b105ab4ea6d9798f/mechanical_level_tmc2209.cfg
#
# Mechanical Gantry Calibration
#
# Requires TMC2209 drivers with UART control, some tuning and perhaps
# some printed endstops.
#
# Based on on (depricated) M915 and now alternate G34 from Marlin
# I beleive Prusa use this, certainly there's older videos advising to just
# ram the gantry at full current into the the z-max stops.
#
# It moves the gantry to the top of the travel, drops the current and then
# does a force move to force the steppers to stall against the physical end
# stops, transfering the level of the frame to the gantry.
#
# This is the only way to programatically level a multi-stepper single-driver
# gantry. It may also help with a dual-driver gantry on a bed-slinger design
# or where the plane of the bed is less trustworthy than the frame.
#
# It's particularly risky doing Z_TILT_ADJUST and SCREWS_TILT_CALCULATE
# without a mechanical reference as if one side of the gantry or bed is prone
# to droop, over time both bed and gantry will skew excessively but still read
# as level, so this can help transfer "level" from the frame to the gantry and
# then to the bed.
#
# I don't recommend doing this in a START_PRINT, I call this if a
# SCREWS_TILT_CALCULATE shows some drift, althoughon an Ender 3 type printer
# it's prudent to check the v-slot rollers for correct adjustment if drift is
# observed.
#
# It's probably best to run this and then do SCREWS_TILT_CALCULATE
# until the bed is really level. IF you have dual Z steppers you can then
# use Z_TILT_ADJUST for subsequent leveling of the gantry but make sure you
# use the same points for gantry level as you use in SCREWS_TILT_CALCULATE
#
# It may damage your printer if you do this at too high a current, or don't
# have proper endstops.
#
# HERE BE DRAGONS!
# YOU WERE WARNED!
#
# Here's a video of this in action
# https://www.youtube.com/watch?v=aVdIeIIpUAk
# and the endstops for 2020 v-slot
# https://www.thingiverse.com/thing:4848479
[gcode_macro MECHANICAL_GANTRY_CALIBRATION]
gcode:
### SET THIS DEFAULT CARFULLY - start really low
{% set my_current = params.CURRENT|default(0.12)|float %} ; adjust crash current on the fly :D
###
{% set oldcurrent = printer.configfile.settings["tmc2209 stepper_z"].run_current %} ; TODO: Find runtime current settings
{% set oldhold = printer.configfile.settings["tmc2209 stepper_z"].hold_current %}
{% set x_max = printer.toolhead.axis_maximum.x %}
{% set y_max = printer.toolhead.axis_maximum.y %}
{% set z_max = printer.toolhead.axis_maximum.z %}
{% set fast_move_z = printer.configfile.settings["printer"].max_z_velocity %}
{% set fast_move = printer.configfile.settings["printer"].max_velocity %}
M117 {printer.homed_axes}
{% if printer.homed_axes != 'xyz' %}
G28 #Home All Axes
{% endif %}
G90 ; absolute
G0 X{x_max / 2} Y{y_max / 2} F{fast_move * 30 } ;put toolhead in the center of the gantry
G0 Z{z_max -1} F{fast_move_z * 60 } ; go to the Z-max at speed max z speed
SET_TMC_CURRENT STEPPER=stepper_z CURRENT={my_current} ; drop current on Z stepper
{% if printer.configfile.settings["stepper_z1"] %} ; test for dual Z
SET_TMC_CURRENT STEPPER=stepper_z1 CURRENT={my_current} ; drop current
{% endif %}
G4 P200 ; Probably not necessary, it is here just for sure
SET_KINEMATIC_POSITION Z={z_max - 12} ; Trick printer into beleiving the gantry is 12mm lower than it is
G1 Z{z_max -2} F{6 * 60} ; try to move 10mm up
G4 P200 ; wait
G1 Z{z_max -6} F{6 * 60} ; move 4mm down
G4 P200 ; same as the first one
SET_TMC_CURRENT STEPPER=stepper_z CURRENT={oldcurrent} HOLDCURRENT={oldhold}
{% if printer.configfile.settings["stepper_z1"] %} ; test for dual Z
SET_TMC_CURRENT STEPPER=stepper_z1 CURRENT={oldcurrent} HOLDCURRENT={oldhold} ; reset current
{% endif %}
G1 Z{z_max -30} F{6 * 60} ; move to 30mm below z-max to allow homing movement
G4 P200 ; same as the first one
G28 Z ; we MUST home again as the ganty is really in the wrong place.
[gcode_macro G34]
gcode:
MECHANICAL_GANTRY_CALIBRATION
[menu __main __setup __calib __mech_gantry_calibrate]
type: command
enable: {not printer.idle_timeout.state == "Printing"}
name: G34 Gantry Level
gcode:
G34
[force_move]
enable_force_move: true ; enable FORCE_MOVE and SET_KINEMATIC_POSITION

54
cfgs/PARKING.cfg Normal file
View File

@@ -0,0 +1,54 @@
# Park front center
[gcode_macro PARKFRONT]
gcode:
{% if "xyz" not in printer.toolhead.homed_axes %}
G28 ; home if not already homed
{% endif %}
SAVE_GCODE_STATE NAME=PARKFRONT
G90 ; absolute positioning
G0 X{printer.toolhead.axis_maximum.x/2} Y{printer.toolhead.axis_minimum.y+5} Z{printer.toolhead.axis_maximum.z/2} F6000
RESTORE_GCODE_STATE NAME=PARKFRONT
# Park front center, but low down.
[gcode_macro PARKFRONTLOW]
gcode:
{% if "xyz" not in printer.toolhead.homed_axes %}
G28 ; home if not already homed
{% endif %}
SAVE_GCODE_STATE NAME=PARKFRONT
G90 ; absolute positioning
G0 X{printer.toolhead.axis_maximum.x/2} Y{printer.toolhead.axis_minimum.y+5} Z20 F6000
RESTORE_GCODE_STATE NAME=PARKFRONT
# Park top rear left
[gcode_macro PARKREAR]
gcode:
{% if "xyz" not in printer.toolhead.homed_axes %}
G28 ; home if not already homed
{% endif %}
SAVE_GCODE_STATE NAME=PARKREAR
G90 ; absolute positioning
G0 X{printer.toolhead.axis_minimum.x+10} Y{printer.toolhead.axis_maximum.y-10} Z{printer.toolhead.axis_maximum.z-50} F6000
RESTORE_GCODE_STATE NAME=PARKREAR
# Park at center of build volume
[gcode_macro PARKCENTER]
gcode:
{% if "xyz" not in printer.toolhead.homed_axes %}
G28 ; home if not already homed
{% endif %}
SAVE_GCODE_STATE NAME=PARKCENTER
G90 ; absolute positioning
G0 X{printer.toolhead.axis_maximum.x/2} Y{printer.toolhead.axis_maximum.y/2} Z{printer.toolhead.axis_maximum.z/2} F6000
RESTORE_GCODE_STATE NAME=PARKCENTER
# Park 15mm above center of bed
[gcode_macro PARKBED]
gcode:
{% if "xyz" not in printer.toolhead.homed_axes %}
G28 ; home if not already homed
{% endif %}
SAVE_GCODE_STATE NAME=PARKBED
G90 ; absolute positioning
G0 X{printer.toolhead.axis_maximum.x/2} Y{printer.toolhead.axis_maximum.y/2} Z15 F6000
RESTORE_GCODE_STATE NAME=PARKBED

12
cfgs/adxl-direct.cfg Normal file
View File

@@ -0,0 +1,12 @@
# Documentation https://www.klipper3d.org/Measuring_Resonances.html?h=adxl#configure-adxl345-with-rpi
# Documentation https://www.klipper3d.org/RPi_microcontroller.html
[mcu rpi]
serial: /tmp/klipper_host_mcu
[adxl345]
cs_pin: rpi:None
[resonance_tester]
accel_chip: adxl345
probe_points: 111.5, 111.5, 20

22
cfgs/adxl-rp2040.cfg Normal file
View File

@@ -0,0 +1,22 @@
#####################################################################
# ADXL345 related Settings
# https://www.klipper3d.org/Measuring_Resonances.html#adxl345
#####################################################################
[mcu rp2040]
baud: 115200 # 250000
restart_method: command
# Obtain definition by "ls -l /dev/serial/by-id/"
serial: /dev/serial/by-id/usb-Klipper_rp2040_E66138935F154C28-if00
[adxl345]
spi_software_miso_pin: rp2040:gpio8
cs_pin: rp2040:gpio9
# spi_bus: spi0b
spi_software_sclk_pin: rp2040:gpio10
spi_software_mosi_pin: rp2040:gpio11
axes_map: x,y,z
[resonance_tester]
accel_chip: adxl345
probe_points: 111.5, 111.5, 20

54
cfgs/beeper.cfg Normal file
View File

@@ -0,0 +1,54 @@
[output_pin beeper]
pin: PC6
value: 0
shutdown_value: 0
pwm: True
cycle_time: 0.0005 ; Default beeper tone in kHz. 1 / 0.0005 = 2000Hz (2kHz)
[gcode_macro M300]
gcode:
{% set S = params.S|default(1000)|int %}
{% set P = params.P|default(100)|int %}
SET_PIN PIN=beeper VALUE=0.5 CYCLE_TIME={ 1.0/S if S > 0 else 1 }
G4 P{P}
SET_PIN PIN=beeper VALUE=0
[gcode_macro BEEP]
description: "BEEP I=3 DUR=200 FREQ=2000: Beep 3 times, for 200ms each, at 2kHz frequency."
gcode:
# Parameters
{% set i = params.I|default(1)|int %} ; Iterations (number of times to beep).
{% set dur = params.DUR|default(100)|int %} ; Duration/wait of each beep in ms. Default 100ms.
{% set freq = params.FREQ|default(2000)|int %} ; Frequency in Hz. Default 2kHz.
{% for iteration in range(i|int) %}
SET_PIN PIN=beeper VALUE=0.8 CYCLE_TIME={ 1.0/freq if freq > 0 else 1 }
G4 P{dur}
SET_PIN PIN=beeper VALUE=0
G4 P{dur}
{% endfor %}
[gcode_macro SONG_SINGLE_BEEP]
gcode:
M300 S830.61 P137
[gcode_macro TOGGLE_BEEPER]
description: Toggle the printer beeper on and off.
gcode:
{% set beeper_state = printer.save_variables.variables.beeper_state|lower %}
{% if printer['gcode_macro _USER_VARIABLE'].debug == 1 %}
{action_respond_info('==== TOGGLE_BEEPER ====')}
{action_respond_info("beeper_state: %s" % (beeper_state))}
{action_respond_info('===============')}
{% endif %}
{% if beeper_state == "off" %}
{action_respond_info('beeper is off, turning it on')}
SAVE_VARIABLE VARIABLE=beeper_state VALUE='"on"'
{% else %}
{action_respond_info('beeper is on= turning it off')}
SAVE_VARIABLE VARIABLE=beeper_state VALUE='"off"'
{% endif %}
SONG_SINGLE_BEEP

183
cfgs/macros.cfg Normal file
View File

@@ -0,0 +1,183 @@
[pause_resume]
[display_status]
[gcode_macro _globals]
variable_pre_purge_prime_length: 1.4
gcode:
SET_GCODE_VARIABLE MACRO=_globals VARIABLE=pre_purge_prime_length VALUE={ variable_pre_purge_prime_length }
[gcode_macro CHECK_PRE_PURGE_PRIME_LENGTH]
gcode:
{% set PRE_PURGE_PRIME_LENGTH=printer["gcode_macro _globals"].pre_purge_prime_length %}
{% if not PRE_PURGE_PRIME_LENGTH %}
{action_raise_error('Pre purge prime length not found')}
{% endif %}
[gcode_macro PURGE_LINE]
# https://github.com/JoeCat1207/V0.1-Purge-line-SuperSlicer/blob/main/Purgeline.txt
# https://github.com/VoronDesign/Voron-Switchwire/blob/200cdae033c59ef81f67c4235469da7ca66d53a1/Firmware/skr_mini_e3_v2_config.cfg
gcode:
{% set PRE_PURGE_PRIME_LENGTH=printer["gcode_macro _globals"].pre_purge_prime_length %}
CHECK_PRE_PURGE_PRIME_LENGTH
G0 Y0 X0 F4000 ; go to tongue of print bed
G1 Z0.4 F500.0 ; move bed to nozzle
G92 E0.0 ; reset extruder
G1 E{PRE_PURGE_PRIME_LENGTH} F500 ; pre-purge prime LENGTH SHOULD MATCH YOUR PRINT_END RETRACT
G1 Y140 E35.0 F1200.0 ; intro line 1
G92 E0.0 ; reset extruder
G1 Z3.0 ; move nozzle to prevent scratch
[gcode_macro CANCEL_PRINT]
rename_existing: BASE_CANCEL_PRINT
gcode:
SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout} ; set timeout back to configured value
CLEAR_PAUSE
SDCARD_RESET_FILE
PRINT_END
BASE_CANCEL_PRINT
[gcode_macro PRINT_START]
# Use PRINT_START for the slicer starting script - please customize for your slicer of choice
#gcode:
# G28 ; home all axes
# G1 Z20 F3000 ; move nozzle away from bed
gcode:
# Parameters
{% set bedtemp = params.BED|int %}
{% set hotendtemp = params.HOTEND|int %}
{% set chambertemp = params.CHAMBER|default(0)|int %}
G28 X Y
# <insert your routines here>
M140 S{bedtemp} ; set & don't wait for bed temp
M104 S{hotendtemp} ; set & don't wait for hotend temp
M190 S{bedtemp} ; set & wait for bed temp
# TEMPERATURE_WAIT SENSOR="temperature_sensor chamber" MINIMUM={chambertemp} ; wait for chamber temp
# <insert your routines here>
M109 S{hotendtemp} ; set & wait for hotend temp
# <insert your routines here>
G28 Z ; final z homing
BED_MESH_PROFILE LOAD=default
G1 Z20 F3000 ; move nozzle away from bed
[gcode_macro PRINT_END]
# Use PRINT_END for the slicer ending script - please customize for your slicer of choice
gcode:
BEEP I=2 DUR=30 FREQ=8500
{% set PRE_PURGE_PRIME_LENGTH=printer["gcode_macro _globals"].pre_purge_prime_length|default(1.40)|float %}
M400 ; wait for buffer to clear
G92 E0 ; zero the extruder
G1 E-{PRE_PURGE_PRIME_LENGTH} F400 ; retract filament
G91 ; relative positioning
# Get Boundaries
{% set max_x = printer.configfile.config["stepper_x"]["position_max"]|float %}
{% set max_y = printer.configfile.config["stepper_y"]["position_max"]|float %}
{% set max_z = printer.configfile.config["stepper_z"]["position_max"]|float %}
# Check end position to determine safe direction to move
{% if printer.toolhead.position.x < (max_x - 20) %}
{% set x_safe = 20.0 %}
{% else %}
{% set x_safe = -20.0 %}
{% endif %}
{% if printer.toolhead.position.y < (max_y - 20) %}
{% set y_safe = 20.0 %}
{% else %}
{% set y_safe = -20.0 %}
{% endif %}
{% if printer.toolhead.position.z < (max_z - 2) %}
{% set z_safe = 2.0 %}
{% else %}
{% set z_safe = max_z - printer.toolhead.position.z %}
{% endif %}
G0 Z{z_safe} F2000 ; move nozzle up
G0 X{x_safe} Y{y_safe} F7200 ; move nozzle to remove stringing
TURN_OFF_HEATERS
M107 ; turn off fan
G90 ; absolute positioning
G0 X60 Y{max_y} F3600 ; park nozzle at rear
[gcode_macro LOAD_FILAMENT]
gcode:
M83 ; set extruder to relative
G1 E30 F300 ; load
G1 E15 F150 ; prime nozzle with filament
M82 ; set extruder to absolute
[gcode_macro UNLOAD_FILAMENT]
gcode:
M83 ; set extruder to relative
G1 E10 F300 ; extrude a little to soften tip
G1 E-40 F1800 ; retract some, but not too much or it will jam
M82 ; set extruder to absolute
[gcode_macro M600]
gcode:
#LCDRGB R=0 G=1 B=0 ; Turn LCD green
PAUSE ; Pause
[gcode_macro PAUSE]
rename_existing: BASE_PAUSE
gcode:
# Parameters
{% set z = params.Z|default(10)|int %} ; z hop amount
{% if printer['pause_resume'].is_paused|int == 0 %}
SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=zhop VALUE={z} ; set z hop variable for reference in resume macro
SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=etemp VALUE={printer['extruder'].target} ; set hotend temp variable for reference in resume macro
# SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0 ; disable filament sensor
SAVE_GCODE_STATE NAME=PAUSE ; save current print position for resume
BASE_PAUSE ; pause print
{% if (printer.gcode_move.position.z + z) < printer.toolhead.axis_maximum.z %} ; check that zhop doesn't exceed z max
G91 ; relative positioning
G1 Z{z} F900 ; raise Z up by z hop amount
{% else %}
{ action_respond_info("Pause zhop exceeds maximum Z height.") } ; if z max is exceeded, show message and set zhop value for resume to 0
SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=zhop VALUE=0
{% endif %}
G90 ; absolute positioning
G1 X{printer.toolhead.axis_maximum.x/2} Y{printer.toolhead.axis_minimum.y+5} F6000 ; park toolhead at front center
SAVE_GCODE_STATE NAME=PAUSEPARK ; save parked position in case toolhead is moved during the pause (otherwise the return zhop can error)
M104 S0 ; turn off hotend
SET_IDLE_TIMEOUT TIMEOUT=43200 ; set timeout to 12 hours
{% endif %}
[gcode_macro RESUME]
rename_existing: BASE_RESUME
variable_zhop: 0
variable_etemp: 0
gcode:
# Parameters
{% set e = params.E|default(2.5)|int %} ; hotend prime amount (in mm)
{% if printer['pause_resume'].is_paused|int == 1 %}
# SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=1 ; enable filament sensor
#INITIAL_RGB ; reset LCD color
SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout} ; set timeout back to configured value
{% if etemp > 0 %}
M109 S{etemp|int} ; wait for hotend to heat back up
{% endif %}
RESTORE_GCODE_STATE NAME=PAUSEPARK MOVE=1 MOVE_SPEED=100 ; go back to parked position in case toolhead was moved during pause (otherwise the return zhop can error)
G91 ; relative positioning
M83 ; relative extruder positioning
{% if printer[printer.toolhead.extruder].temperature >= printer.configfile.settings.extruder.min_extrude_temp %}
G1 Z{zhop * -1} E{e} F900 ; prime nozzle by E, lower Z back down
{% else %}
G1 Z{zhop * -1} F900 ; lower Z back down without priming (just in case we are testing the macro with cold hotend)
{% endif %}
RESTORE_GCODE_STATE NAME=PAUSE MOVE=1 MOVE_SPEED=60 ; restore position
BASE_RESUME ; resume print
{% endif %}
[gcode_macro _CG28]
# Conditional homing
gcode:
{% if "xyz" not in printer.toolhead.homed_axes %}
G28
{% endif %}