area mesh

This commit is contained in:
Kyle Brown 2021-11-28 13:43:47 -08:00
parent e951be1a86
commit 5b151677d3
4 changed files with 172 additions and 67 deletions

View file

@ -21,7 +21,7 @@ gcode:
{% set travel_speed = printer["gcode_macro GlobalVariables"].travel_speed %}
{% set home_x = printer["gcode_macro GlobalVariables"].home_x %}
{% set probe_x_offset = printer["gcode_macro GlobalVariables"].probe_x_offset %}
{% set BED_TEMP = params.BED_TEMP|default(80)|float %}
{% set BED_TEMP = params.BED_TEMP|default(100)|float %}
# Start bed heating and wait
RESPOND PREFIX= MSG="Waiting for bed temperature..."
@ -83,3 +83,78 @@ gcode:
{% endfor %}
{% endif %}
{% endfor %}
# Home, get position, throw around toolhead, home again.
# If MCU stepper positions (first line in GET_POSITION) are greater than a full step different (your number of microsteps), then skipping occured.
# We only measure to a full step to accomodate for endstop variance.
# Example: TEST_SPEED SPEED=300 ACCEL=5000 ITERATIONS=10
[gcode_macro TEST_SPEED]
gcode:
# Speed
{% set speed = params.SPEED|default(printer.configfile.settings.printer.max_velocity)|int %}
# Iterations
{% set iterations = params.ITERATIONS|default(5)|int %}
# Acceleration
{% set accel = params.ACCEL|default(printer.configfile.settings.printer.max_accel)|int %}
# Bounding box (in case the machine min/maxes are not perfect)
{% set bound = params.BOUND|default(20)|int %}
# Set speed test bounds (machine minimum/maximum positions, inset by the bounding box)
{% set x_min = printer.toolhead.axis_minimum.x + bound %}
{% set x_max = printer.toolhead.axis_maximum.x - bound %}
{% set y_min = printer.toolhead.axis_minimum.y + bound %}
{% set y_max = printer.toolhead.axis_maximum.y - bound %}
# Save current gcode state (absolute/relative, etc)
SAVE_GCODE_STATE NAME=TEST_SPEED
# Absolute positioning
G90
# Set new limits
SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} ACCEL_TO_DECEL={accel / 2}
# Home and get position for comparison later:
G28
# QGL if not already QGLd (only if QGL section exists in config)
{% if printer.configfile.settings.quad_gantry_level %}
{% if printer.quad_gantry_level.applied == False %}
QUAD_GANTRY_LEVEL
G28 Z
{% endif %}
{% endif %}
G0 X{printer.toolhead.axis_maximum.x} Y{printer.toolhead.axis_maximum.y} F{30 * 60}
G4 P1000
GET_POSITION
# Go to starting position
G0 X{x_min} Y{y_min} Z{bound + 10} F{speed * 60}
{% for i in range(iterations) %}
# Diagonals
G0 X{x_min} Y{y_min} F{speed * 60}
G0 X{x_max} Y{y_max} F{speed * 60}
G0 X{x_min} Y{y_min} F{speed * 60}
G0 X{x_max} Y{y_min} F{speed * 60}
G0 X{x_min} Y{y_max} F{speed * 60}
G0 X{x_max} Y{y_min} F{speed * 60}
# Box
G0 X{x_min} Y{y_min} F{speed * 60}
G0 X{x_min} Y{y_max} F{speed * 60}
G0 X{x_max} Y{y_max} F{speed * 60}
G0 X{x_max} Y{y_min} F{speed * 60}
{% endfor %}
# Restore max speed/accel/accel_to_decel to their configured values
SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity} ACCEL={printer.configfile.settings.printer.max_accel} ACCEL_TO_DECEL={printer.configfile.settings.printer.max_accel_to_decel}
# Re-home XY and get position again for comparison:
G28 X Y
# Go to XY home positions (in case your homing override leaves it elsewhere)
G0 X{printer.toolhead.axis_maximum.x} Y{printer.toolhead.axis_maximum.y} F{30 * 60}
G4 P1000
GET_POSITION
# Restore previous gcode state (absolute/relative, etc)
RESTORE_GCODE_STATE NAME=TEST_SPEED

View file

@ -311,11 +311,78 @@ gcode:
[gcode_macro BED_MESH_CALIBRATE]
rename_existing: _BED_MESH_CALIBRATE
; gcode parameters
variable_parameter_AREA_START : 0,0
variable_parameter_AREA_END : 0,0
; the clearance between print area and probe area
variable_mesh_area_offset : 5.0
; number of sample per probe point
variable_probe_samples : 2
; minimum probe count
variable_min_probe_count : 3
gcode:
Attach_probe
_BED_MESH_CALIBRATE {% for p in params
%}{'%s=%s' % (p, params[p])}{%
endfor %}
{% if params.AREA_START and params.AREA_END %}
{% set bedMeshConfig = printer["configfile"].config["bed_mesh"] %}
{% set safe_min_x = bedMeshConfig.mesh_min.split(",")[0]|float %}
{% set safe_min_y = bedMeshConfig.mesh_min.split(",")[1]|float %}
{% set safe_max_x = bedMeshConfig.mesh_max.split(",")[0]|float %}
{% set safe_max_y = bedMeshConfig.mesh_max.split(",")[1]|float %}
{% set area_min_x = params.AREA_START.split(",")[0]|float %}
{% set area_min_y = params.AREA_START.split(",")[1]|float %}
{% set area_max_x = params.AREA_END.split(",")[0]|float %}
{% set area_max_y = params.AREA_END.split(",")[1]|float %}
{% set meshPointX = bedMeshConfig.probe_count.split(",")[0]|float %}
{% set meshPointY = bedMeshConfig.probe_count.split(",")[1]|float %}
{% if (area_min_x < area_max_x) and (area_min_y < area_max_y) %}
{% if area_min_x - mesh_area_offset >= safe_min_x %}
{% set area_min_x = area_min_x - mesh_area_offset %}
{% else %}
{% set area_min_x = safe_min_x %}
{% endif %}
{% if area_min_y - mesh_area_offset >= safe_min_y %}
{% set area_min_y = area_min_y - mesh_area_offset %}
{% else %}
{% set area_min_y = safe_min_y %}
{% endif %}
{% if area_max_x + mesh_area_offset <= safe_max_x %}
{% set area_max_x = area_max_x + mesh_area_offset %}
{% else %}
{% set area_max_x = safe_max_x %}
{% endif %}
{% if area_max_y + mesh_area_offset <= safe_max_y %}
{% set area_max_y = area_max_y + mesh_area_offset %}
{% else %}
{% set area_max_y = safe_max_y %}
{% endif %}
{% set meshPointX = (meshPointX * (area_max_x - area_min_x) / (safe_max_x - safe_min_x))|int %}
{% if meshPointX < min_probe_count %}
{% set meshPointX = min_probe_count %}
{% endif %}
{% set meshPointY = (meshPointY * (area_max_y -area_min_y ) / (safe_max_y - safe_min_y))|int %}
{% if meshPointY < min_probe_count %}
{% set meshPointY = min_probe_count %}
{% endif %}
_BED_MESH_CALIBRATE mesh_min={area_min_x},{area_min_y} mesh_max={area_max_x},{area_max_y} probe_count={meshPointX},{meshPointY} samples={probe_samples|int}
{% else %}
_BED_MESH_CALIBRATE
{% endif %}
{% else %}
_BED_MESH_CALIBRATE
{% endif %}
#_BED_MESH_CALIBRATE {% for p in params
# %}{'%s=%s' % (p, params[p])}{%
# endfor %}
[gcode_macro SCREWS_TILT_CALCULATE]
rename_existing: _SCREWS_TILT_CALCULATE

View file

@ -4,7 +4,8 @@ gcode:
{% set extruderTemp = params.EXTRUDER_TEMP|default(205)|int %}
{% set bedTemp = params.BED_TEMP|default(55)|int %}
{% set DWELL = params.DWELL|default(300000)|int %}
#SET_GCODE_OFFSET Z=0
{% set AREA_START= params.AREA_START|default(0)|int %}
{% set AREA_END = params.AREA_END|default(0)|int %}
LIGHT_DISPLAY
# Loading extruder and bed temperature
@ -16,13 +17,13 @@ gcode:
M190 S{bedTemp} # Wait for bed to come to temperature
RESPOND PREFIX= MSG="Waiting for thermal expansion..."
M117 Waiting for thermal expansion...
#HEATSOAK DWELL={DWELL} # Dwelling
HEATSOAK DWELL={DWELL} # Dwelling
# Homing and creating a mesh
RESPOND PREFIX= MSG="Creating a mesh..."
M117 Creating a mesh...
G28
BED_MESH_CALIBRATE
BED_MESH_CALIBRATE AREA_START={AREA_START} AREA_END={AREA_END}
M104 S{extruderTemp} # Set extruder to printing temperature
G90
M83

View file

@ -3,15 +3,16 @@
[include print_start.cfg]
[include print_end.cfg]
[include calibration_macros.cfg]
#[include klipper-mini12864.cfg]
[include klipper-mini12864.cfg]
[include dock_macros.cfg]
[pause_resume]
[respond]
[force_move]
enable_force_move: true
# Set to true to enable FORCE_MOVE and SET_KINEMATIC_POSITION
# extended G-Code commands. The default is false.
[stepper_x]
step_pin: PB13
dir_pin: PB12
@ -68,7 +69,7 @@ microsteps: 32
endstop_pin: ^PC2
position_endstop: -2.6
position_max: 250
homing_speed: 25
homing_speed: 40
position_min: -8.0
[tmc2209 stepper_z]
@ -95,7 +96,8 @@ fade_target: 0
pin: PC15
x_offset: 0.0
y_offset: 34.5
speed: 3
z_offset = 6.15
speed: 40
samples_result: median
samples_tolerance: 0.05
samples_tolerance_retries: 2
@ -119,10 +121,10 @@ sensor_type: ATC Semitec 104GT-2
#sensor_type: EPCOS 100K B57560G104F
#sensor_type: NTC 100K beta 3950
sensor_pin: PA0
#control = pid
#pid_kp = 18.973
#pid_ki = 0.771
#pid_kd = 116.683
control = pid
pid_kp = 27.402
pid_ki = 1.631
pid_kd = 115.090
min_temp: 0
max_temp: 300
@ -148,10 +150,10 @@ heater_pin: PC9
sensor_type: ATC Semitec 104GT-2
sensor_pin: PC3
pwm_cycle_time: 0.0166
#control = pid
#pid_kp = 60.695
#pid_ki = 1.073
#pid_kd = 858.069
control = pid
pid_kp = 59.514
pid_ki = 0.790
pid_kd = 1120.355
min_temp: 0
max_temp: 110
@ -185,8 +187,8 @@ kinematics: corexz
max_velocity: 500
max_accel: 10000
max_accel_to_decel: 10000
max_z_velocity: 50
max_z_accel: 7000
max_z_velocity: 70
max_z_accel: 10000
square_corner_velocity: 8.0
[static_digital_output usb_pullup_enable]
@ -208,11 +210,11 @@ screw4: 230,-21
screw4_name: front right screw
screw5: 230,84.5
screw5_name: center right screw
screw6: 230,190
screw6: 230,180
screw6_name: rear right screw
screw7: 125,190
screw7: 125,180
screw7_name: rear center screw
screw8: 20,190
screw8: 20,180
screw8_name: rear left screw
screw9: 20,84.5
screw9_name: center left screw
@ -223,53 +225,13 @@ screw_thread: CCW-M3
[virtual_sdcard]
path: /home/pi/sdcard
[pause_resume]
[respond]
[resonance_tester]
accel_chip: adxl345
probe_points:
125,119,20
[input_shaper]
shaper_type_x: zv
shaper_freq_x: 49.6
shaper_type_x = mzv
shaper_freq_x = 51.2
shaper_type_y: zv
shaper_freq_y: 42.0
#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [heater_bed]
#*# control = pid
#*# pid_kp = 59.514
#*# pid_ki = 0.790
#*# pid_kd = 1120.355
#*#
#*# [extruder]
#*# control = pid
#*# pid_kp = 27.402
#*# pid_ki = 1.631
#*# pid_kd = 115.090
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# 0.081250, 0.081250, -0.000000, -0.025000, -0.025000, -0.068750
#*# 0.112500, 0.081250, 0.018750, -0.012500, -0.031250, -0.056250
#*# 0.100000, 0.056250, 0.018750, 0.025000, -0.012500, -0.050000
#*# 0.068750, 0.050000, 0.006250, 0.012500, -0.025000, -0.056250
#*# 0.006250, 0.037500, 0.037500, 0.037500, 0.043750, -0.050000
#*# -0.143750, -0.068750, 0.006250, 0.056250, 0.012500, -0.018750
#*# tension = 0.2
#*# min_x = 25.0
#*# algo = bicubic
#*# y_count = 6
#*# mesh_y_pps = 2
#*# min_y = 35.0
#*# x_count = 6
#*# max_y = 220.0
#*# mesh_x_pps = 2
#*# max_x = 225.0
#*#
#*# [probe]
#*# z_offset = 6.206