-
-
Notifications
You must be signed in to change notification settings - Fork 252
Support beacon_klipper version >= 2.0.0, a.k.a Beacon Contact #637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c660870
ae1bab1
a3c5b27
9bae3f4
d1f698d
98ea159
c3e567c
e09bd85
f86bd2a
e83dabc
7ab1d65
b051cb7
28f17b6
5adc523
b6b2522
b54acdc
7aefef5
48c722f
5fe9bca
4a993aa
8e4eb2a
01d4a90
9d95044
a21e8c4
e27a344
70a1bba
438be2f
d43765b
2ade6d1
3e9e35a
0f64405
2ffcb63
619794b
94943a2
44e8dde
fb24ffc
d3171a0
677ebb6
03afdda
9006c0a
4ae2c94
6aba8ad
2236035
abe4209
55b34fa
f3b0501
5eb39bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# This probe type is for a Beacon probe used directly as a virtual Z endstop | ||
# rather than with an existing physical endstop. To use this configuration, | ||
# you will need to manually add the Beacon Klipper plugin! | ||
|
||
## Then, you should just add the following two lines to your overrides and everything should work! | ||
## The rest of the allowed config entries are available on this link: config/hardware/probes/inductive_virtual.cfg | ||
# [beacon] | ||
# serial: /dev/serial/by-id/usb-Beacon_Beacon_... | ||
|
||
|
||
[gcode_macro _USER_VARIABLES] | ||
# We can declare an "inductive_virtual" probe type as it's pretty close to the Beacon way of working and should just work! | ||
variable_probe_type_enabled: "beacon_contact" | ||
variable_startprint_actions: "extruder_preheating", "bed_soak", "chamber_soak", "tilt_calib", "bedmesh", "extruder_heating", "purge", "clean", "primeline" | ||
gcode: | ||
|
||
# Beacon probe definition also include the probe management macros directly from here | ||
[include ../../../macros/base/probing/beacon_probe.cfg] | ||
[include ../../../macros/base/probing/overrides/beacon_probe_overrides.cfg] | ||
[include ../../../macros/base/homing/beacon_homing_hooks.cfg] | ||
|
||
[stepper_z] | ||
endstop_pin: probe:z_virtual_endstop | ||
homing_retract_dist: 0 | ||
|
||
[beacon] | ||
home_xy_position: 117.5, 117.5 # update with your safe position | ||
home_z_hop: 5 | ||
home_z_hop_speed: 30 | ||
home_xy_move_speed: 300 | ||
home_y_before_x: false | ||
home_method: contact | ||
home_method_when_homed: proximity | ||
home_autocalibrate: unhomed | ||
home_gcode_pre_x: _HOME_PRE_AXIS AXIS=X | ||
home_gcode_post_x: _HOME_POST_AXIS AXIS=X | ||
home_gcode_pre_y: _HOME_PRE_AXIS AXIS=Y | ||
home_gcode_post_y: _HOME_POST_AXIS AXIS=Y | ||
home_gcode_pre_xy: _HOME_XY STAGE=pre | ||
home_gcode_post_xy: _HOME_XY STAGE=post | ||
contact_activate_gcode: _CONTACT_MACRO STAGE=activate | ||
contact_deactivate_gcode: _CONTACT_MACRO STAGE=deactivate | ||
|
||
[gcode_macro _beacon_contact_hardware_check] | ||
gcode: | ||
{% if 'mcu beacon' in printer %} | ||
{% set version = printer['mcu beacon'].mcu_version.split(' ')|last %} | ||
{% set major = version.split('.')|first|int %} | ||
{% if version < '2' %} | ||
{action_raise_error('Beacon firmware is too old. Found: %s, Expected: 2.0.0 or higher' % version)} | ||
{% endif %} | ||
{% else %} | ||
{action_raise_error('Beacon MCU was not found')} | ||
{% endif %} | ||
|
||
[delayed_gcode _do_beacon_contact_hardware_check] | ||
initial_duration: 5 | ||
gcode: | ||
_beacon_contact_hardware_check | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
[gcode_macro _HOME_PRE_AXIS] | ||
description: Perform actions prior to homing an axis | ||
gcode: | ||
{% set axis = params.AXIS %} | ||
{% set kinematics = printer['configfile'].config['printer']['kinematics'] %} | ||
{% set sensorless_homing_enabled = printer['gcode_macro _USER_VARIABLES'].sensorless_homing_enabled %} | ||
{% set sensorless_current_factor = printer['gcode_macro _USER_VARIABLES'].sensorless_current_factor / 100 %} | ||
{% set verbose = printer["gcode_macro _USER_VARIABLES"].verbose %} | ||
|
||
{% set x_driver = printer["gcode_macro _USER_VARIABLES"].x_driver %} | ||
{% set y_driver = printer["gcode_macro _USER_VARIABLES"].y_driver %} | ||
{% set z_driver = printer["gcode_macro _USER_VARIABLES"].z_driver %} | ||
{% set old_current_x = printer.configfile.config[x_driver ~ ' stepper_x'].run_current|float %} | ||
{% set old_current_y = printer.configfile.config[y_driver ~ ' stepper_y'].run_current|float %} | ||
{% set old_current_z = printer.configfile.config[z_driver ~ ' stepper_z'].run_current|float %} | ||
{% set new_current_x = sensorless_current_factor * old_current_x %} | ||
{% set new_current_y = sensorless_current_factor * old_current_y %} | ||
{% set new_current_z = sensorless_current_factor * old_current_z %} | ||
|
||
# reset parameters | ||
{% set X, Y = False, False %} | ||
|
||
# which axis has been requested for homing | ||
{% if axis == 'X' %} | ||
{% set X = True %} | ||
{% elif axis == 'Y' %} | ||
{% set Y = True %} | ||
{% endif %} | ||
|
||
|
||
{% if sensorless_homing_enabled %} | ||
{% if kinematics == 'corexy' %} | ||
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={new_current_x} | ||
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={new_current_y} | ||
M400 | ||
{% elif kinematics == 'corexz' %} | ||
{% if X %} | ||
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={old_current_x} | ||
SET_TMC_CURRENT STEPPER=stepper_z CURRENT={old_current_z} | ||
{% elif Y %} | ||
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={old_current_y} | ||
{% endif %} | ||
M400 | ||
{% elif kinematics == 'cartesian' %} | ||
{% if X %} | ||
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={new_current_x} | ||
{% elif Y %} | ||
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={new_current_y} | ||
{% endif %} | ||
M400 | ||
{% endif %} | ||
{% endif %} | ||
|
||
{% if verbose %} | ||
{ action_respond_info('Homing %s' % axis) } | ||
{% endif %} | ||
|
||
|
||
[gcode_macro _HOME_POST_AXIS] | ||
description: Perform actions after homing an axis | ||
gcode: | ||
{% set axis = params.AXIS %} | ||
{% set homing_travel_speed = printer['gcode_macro _USER_VARIABLES'].homing_travel_speed * 60 %} | ||
{% set kinematics = printer['configfile'].config['printer']['kinematics'] %} | ||
{% set sensorless_current_factor = printer['gcode_macro _USER_VARIABLES'].sensorless_current_factor / 100 %} | ||
{% set sensorless_homing_enabled = printer['gcode_macro _USER_VARIABLES'].sensorless_homing_enabled %} | ||
|
||
{% set x_homing_backoff, y_homing_backoff = printer['gcode_macro _USER_VARIABLES'].homing_backoff_distance_xy|map('float') %} | ||
|
||
{% set x_position_endstop = printer['configfile'].config['stepper_x']['position_endstop']|float %} | ||
{% set y_position_endstop = printer['configfile'].config['stepper_y']['position_endstop']|float %} | ||
|
||
{% set x_driver = printer["gcode_macro _USER_VARIABLES"].x_driver %} | ||
{% set y_driver = printer["gcode_macro _USER_VARIABLES"].y_driver %} | ||
{% set z_driver = printer["gcode_macro _USER_VARIABLES"].z_driver %} | ||
{% set old_current_x = printer.configfile.config[x_driver ~ ' stepper_x'].run_current|float %} | ||
{% set old_current_y = printer.configfile.config[y_driver ~ ' stepper_y'].run_current|float %} | ||
{% set old_current_z = printer.configfile.config[z_driver ~ ' stepper_z'].run_current|float %} | ||
|
||
# reset parameters | ||
{% set X, Y = False, False %} | ||
|
||
# Which axis has been requested for homing | ||
{% if axis == 'X' %} | ||
{% set X = True %} | ||
{% elif axis == 'Y' %} | ||
{% set Y = True %} | ||
{% endif %} | ||
|
||
# Ensure absolute mode is set | ||
{% if not printer['gcode_move'].absolute_coordinates %} | ||
G90 | ||
{% endif %} | ||
|
||
# Move away from the endstop a bit | ||
{% if X %} | ||
G1 X{x_position_endstop + x_homing_backoff} F{homing_travel_speed} | ||
{% elif Y %} | ||
G1 Y{y_position_endstop + y_homing_backoff} F{homing_travel_speed} | ||
{% endif %} | ||
|
||
{% if sensorless_homing_enabled %} | ||
{% if kinematics == "corexy" %} | ||
M400 | ||
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={old_current_x} | ||
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={old_current_y} | ||
{% elif kinematics == "corexz" %} | ||
{% if X %} | ||
M400 | ||
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={old_current_x} | ||
SET_TMC_CURRENT STEPPER=stepper_z CURRENT={old_current_z} | ||
{% elif Y %} | ||
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={old_current_y} | ||
{% endif %} | ||
{% elif kinematics == "cartesian" %} | ||
{% if X %} | ||
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={old_current_x} | ||
{% elif Y %} | ||
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={old_current_y} | ||
{% endif %} | ||
{% endif %} | ||
{% endif %} | ||
|
||
|
||
[gcode_macro _HOME_XY] | ||
description: Perform actions before or after homing x or y axis | ||
variable_saved_accel: 0 | ||
gcode: | ||
{% set stage = params.STAGE|lower %} | ||
|
||
{% set bed_mesh_enabled = printer["gcode_macro _USER_VARIABLES"].bed_mesh_enabled %} | ||
{% set homing_travel_accel = printer['gcode_macro _USER_VARIABLES'].homing_travel_accel %} | ||
{% set status_leds_enabled = printer["gcode_macro _USER_VARIABLES"].status_leds_enabled %} | ||
{% set probing_active = printer["gcode_macro ACTIVATE_PROBE"].is_active %} | ||
|
||
# reset parameters | ||
{% set pre, post = False, False %} | ||
|
||
# Which axis has been requested for homing | ||
{% if stage == 'pre' %} | ||
{% set pre = True %} | ||
{% elif stage == 'post' %} | ||
{% set post = True %} | ||
{% else %} | ||
{ action_raise_error('Unrecognized STAGE value, valid choices: pre, post') } | ||
{% endif %} | ||
|
||
{% if pre %} | ||
# Set the homing acceleration prior to any movement | ||
SET_GCODE_VARIABLE MACRO=_HOME_XY VARIABLE=saved_accel VALUE={printer.toolhead.max_accel} | ||
M204 S{homing_travel_accel} | ||
|
||
{% if bed_mesh_enabled %} | ||
BED_MESH_CLEAR | ||
{% endif %} | ||
|
||
G90 | ||
|
||
{% if status_leds_enabled %} | ||
STATUS_LEDS COLOR="homing" | ||
{% endif %} | ||
{% elif post %} | ||
# Reset acceleration values to what it was before | ||
{% set saved_accel = printer["gcode_macro _HOME_XY"].saved_accel %} | ||
SET_VELOCITY_LIMIT ACCEL={saved_accel} | ||
|
||
{% if status_leds_enabled %} | ||
STATUS_LEDS COLOR="ready" | ||
{% endif %} | ||
{% endif %} | ||
|
||
[gcode_macro _CONTACT_MACRO] | ||
description: Perform actions before or after contact activate/deactivate | ||
gcode: | ||
{% set stage = params.STAGE|lower %} | ||
|
||
{% set status_leds_enabled = printer["gcode_macro _USER_VARIABLES"].status_leds_enabled %} | ||
{% set probing_active = printer["gcode_macro ACTIVATE_PROBE"].is_active %} | ||
|
||
# reset parameters | ||
{% set activate, deactivate = False, False %} | ||
|
||
# Which axis has been requested for homing | ||
{% if stage == 'activate' %} | ||
{% set activate = True %} | ||
{% elif stage == 'deactivate' %} | ||
{% set deactivate = True %} | ||
{% else %} | ||
{ action_raise_error('Unrecognized STAGE value, valid choices: activate, deactivate') } | ||
{% endif %} | ||
|
||
{% if not probing_active %} | ||
{% if activate %} | ||
{% if status_leds_enabled %} | ||
STATUS_LEDS COLOR="homing" | ||
{% endif %} | ||
{% elif deactivate %} | ||
{% if status_leds_enabled %} | ||
STATUS_LEDS COLOR="ready" | ||
{% endif %} | ||
{% endif %} | ||
{% endif %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# This file is used as an interface to activate/deactivate every probe type | ||
# depending of the needs: | ||
# - Beacon: need to be at a correct nozzle temperature to avoid burning the PEI when used | ||
|
||
[gcode_macro ACTIVATE_PROBE] | ||
description: Put the machine in a state being able to probe | ||
variable_temperature: 0 | ||
variable_is_active: False | ||
gcode: | ||
{% set beacon_max_probing_temp = printer["gcode_macro _USER_VARIABLES"].beacon_max_probing_temp|float %} | ||
|
||
SET_GCODE_VARIABLE MACRO=ACTIVATE_PROBE VARIABLE=is_active VALUE=True | ||
|
||
# Check the temperature and lower it if needed | ||
SAVE_GCODE_STATE NAME=BEFORE_BEACON_ACTION | ||
|
||
{% set ACTUAL_TEMP = printer.extruder.temperature %} | ||
{% set TARGET_TEMP = printer.extruder.target %} | ||
|
||
SET_GCODE_VARIABLE MACRO=ACTIVATE_PROBE VARIABLE=temperature VALUE={TARGET_TEMP} | ||
|
||
{% if TARGET_TEMP > beacon_max_probing_temp %} | ||
{ action_respond_info('Extruder temperature target of %.1fC is too high for Beacon probing, lowering to %.1fC' % (TARGET_TEMP, beacon_max_probing_temp)) } | ||
M106 S255 ; 100% the part cooling fan to help the extruder cooling | ||
M109 S{beacon_max_probing_temp} | ||
M106 S0 ; Stop the part cooling fan | ||
{% else %} | ||
# Temperature target is already low enough, but nozzle may still be too hot | ||
{% if ACTUAL_TEMP > beacon_max_probing_temp + 3 %} | ||
M106 S255 ; 100% the part cooling fan to help the extruder cooling | ||
TEMPERATURE_WAIT SENSOR=extruder MAXIMUM={beacon_max_probing_temp} | ||
M106 S0 ; Stop the part cooling fan | ||
{% endif %} | ||
{% endif %} | ||
|
||
G28 Z METHOD=CONTACT CALIBRATE=1 | ||
|
||
|
||
[gcode_macro DEACTIVATE_PROBE] | ||
description: Revert the machine to a normal state after probing | ||
gcode: | ||
{% set beacon_deactivation_zhop = printer["gcode_macro _USER_VARIABLES"].beacon_deactivation_zhop %} | ||
{% set Sz = printer["gcode_macro _USER_VARIABLES"].z_drop_speed * 60 %} | ||
|
||
G28 Z METHOD=CONTACT CALIBRATE=1 | ||
|
||
# Check and restore the nozzle temperature if needed | ||
# Small Z hop to avoid restoring the temperature directly on the PEI | ||
{% set z_safe = printer.toolhead.position.z + beacon_deactivation_zhop %} | ||
{% if z_safe > printer.toolhead.axis_maximum.z %} | ||
{% set z_safe = printer.toolhead.axis_maximum.z %} | ||
{% endif %} | ||
G90 | ||
G1 Z{z_safe} F{Sz} | ||
|
||
# Then restoring the temperature | ||
{% set old_target_temperature = printer["gcode_macro ACTIVATE_PROBE"].temperature %} | ||
M109 S{old_target_temperature} | ||
|
||
RESTORE_GCODE_STATE NAME=BEFORE_BEACON_ACTION | ||
|
||
SET_GCODE_VARIABLE MACRO=ACTIVATE_PROBE VARIABLE=is_active VALUE=False | ||
Comment on lines
+1
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this duplication of ACTIVATE/DEACTIVATE_PROBE doesn't make sense and could be avoided. In fact, these original macros were designed to be generic and accept any type of probe. If I understand correctly, you made this duplication choice because you added See my next comments. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
# - Dockable probe: need to be attached/docked when used | ||
# - ... can be improved depending of new probes needs ... | ||
|
||
[include ../homing/homing_override.cfg] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this line into each probe type that require it. |
||
|
||
[gcode_macro ACTIVATE_PROBE] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And add the beacon specificity in these macros. |
||
description: Put the machine in a state being able to probe | ||
variable_temperature: 0 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to move this check in the startup.cfg file? There's already a few things that are checked at Klippain startup and this could be added in the _INIT_CHECKPROBECONF macro that is done exactly for this purpose.
https://github.com/Frix-x/klippain/blob/main/macros/miscs/startup.cfg