Skip to content
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

Factor most of the magic-numbers out of PRIME_LINE #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 39 additions & 10 deletions macros.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -148,24 +148,53 @@ description: Prints a primeline, used internally, if configured, as part of the
gcode:
SAVE_GCODE_STATE NAME=prime_line_state
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set prime_x0 = params.X0|default(5)|float %}
{% set prime_y0 = params.Y0|default(5)|float %}
{% set prime_len = params.LENGTH|default(70)|float %}
{% set prime_wipe_len = params.WIPE_LENGTH|default(20)|float %}
{% set prime_axis = params.AXIS|default("Y") %}
{% if prime_axis not in "XY" %}
{% set prime_axis = "Y" %}
{% endif %}
{% if params.AXIS_INVERT %}
{% set prime_len = -prime_len %}
{% set prime_wipe_len = -prime_wipe_len %}
{% endif %}
# for some reason, the nozzle consistently goes cold if the entire line is
# ordered in a single G1, but holds true if the line is broken up into
# pieces; it's almost like the PID loop only runs between G1s
{% set prime_segments = params.SEGMENTS|default(8)|int %}
{% set filament_cross_section_area = 2.405281875 %} # approximately pi*1.75*1.75/4
{% set nozzle_diameter = params.NOZZLE_DIAMETER|default(0.4)|float %}
{% set prime_layer_height = nozzle_diameter * 5 / 8 %}
# nozzles of varying bores seem to have flats of constant wall-thickness;
# so if we used a percentage of nozzle-bore, then we'd be more likely to
# extrude past the flats, the bigger the nozzle we were being asked about.
# so it's unfortunate that SuperSlicer's width settings can't do
# what we're about to do here:
Comment on lines +170 to +174
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the perennial problem of link rot, I don't know how to cram a photograph like this into a comment in the code.

Thus, I'll just put here an example that clearly shows the nozzle-flats at various bores of one popular line of nozzles, the Bondtech CHT in nickel-coated brass.

image

{% set prime_line_width = nozzle_diameter + 1.6 %}
{% set prime_extrudate_area = prime_layer_height * prime_line_width %}
{% set prime_e_per_x = prime_extrudate_area/filament_cross_section_area %}
# Absolute positioning
G90
# Absolute extrusion
M82
G90
# Relative extrusion
M83
M117 Priming nozzle with prime line..
RESPOND MSG="Priming nozzle with prime line.."
# Lift 5 mm
G1 Z5 F3000
# Move to prime area
G1 X{printer.toolhead.axis_minimum.x + 5} Y{printer.toolhead.axis_minimum.y + 10} F{speed}
G1 X{printer.toolhead.axis_minimum.x + prime_x0} Y{printer.toolhead.axis_minimum.y + prime_y0} F{speed}
# Get ready to prime
G1 Z0.3 F3000
# Reset extrusion distance
G92 E0
# Prime nozzle
G1 Y{printer.toolhead.axis_minimum.y + 80} E16 F1200
G1 Z{prime_layer_height} F3000
# Relative positioning
G91
# Prime nozzle
{% for i in range(prime_segments) %}
G1 {prime_axis}{prime_len/prime_segments} E{prime_e_per_x * prime_len/prime_segments} F1200
{% endfor %}
# Wipe
G1 Y{printer.toolhead.axis_minimum.y + 100} F{speed}
G1 {prime_axis}{prime_wipe_len} F{speed}
RESTORE_GCODE_STATE NAME=prime_line_state

[gcode_macro PRIME_BLOB]
Expand Down