-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathPA_Tuner.cfg
143 lines (133 loc) · 6.26 KB
/
PA_Tuner.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
[gcode_macro PA_TUNER]
description: Pressure Advance Tuning with pre-sliced tuning tower
gcode:
# Set your own default parameters here
{% set filament_d = params.FILAMENT_DIAMETER|default(1.75)|float %}
{% set e_width = params.EXTRUSION_WIDTH|default(0.4)|float %}
{% set tool = params.TOOLHEAD|default("") %}
{% set rect_side_len = params.SIDE_LENGTH|default(100.0)|float %}
{% set layer_h = params.LAYER_HEIGHT|default(0.3)|float %}
{% set fspeed = params.FAST_PRINT_SPEED|default(150.0)|float %}
{% set sspeed = params.SLOW_PRINT_SPEED|default(30.0)|float %}
{% set fan_speed = params.COOLING_FAN_SPEED|default(255.0)|float %}
{% set PA_low = params.PA_MIN|default(0.0)|float %}
{% set PA_high = params.PA_MAX|default(0.2)|float %}
{% set b_temp = params.BED_TEMP|default(110)|float %}
{% set p_temp = params.PRINTING_TEMP|default(250)|float %}
{% set off_x = params.X_OFFSET|default(0.0)|float %}
{% set off_y = params.Y_OFFSET|default(0.0)|float %}
{% set layer_num = params.LAYERS|default(60)|int %}
# End default parameters
# Computed parameters
{% set bed_x = printer.toolhead.axis_maximum.x|float %}
{% set bed_y = printer.toolhead.axis_maximum.y|float %}
{% set PA_const = (2 * ((PA_high - PA_low) / layer_num)) - PA_low %}
{% if PA_const < 0 %}
{% set PA_sign = " + " %}
{% else %}
{% set PA_sign = " - " %}
{% endif %}
RESPOND MSG="Bed X Length: {bed_x}"
{% set info_str = "Bed Y Length: " ~ bed_y %}
RESPOND MSG="{info_str}"
{% set info_str = "Bed X Offset: " ~ off_x %}
RESPOND MSG="{info_str}"
{% set info_str = "Bed Y Offset: " ~ off_y %}
RESPOND MSG="{info_str}"
{% set info_str = "Extrusion Width: " ~ e_width %}
RESPOND MSG="{info_str}"
{% set info_str = "Filament size: " ~ filament_d %}
RESPOND MSG="{info_str}"
{% set info_str = "Layer Height: " ~ layer_h %}
RESPOND MSG="{info_str}"
{% set info_str = "Bed Temperature: " ~ b_temp %}
RESPOND MSG="{info_str}"
{% set info_str = "Print Temperature: " ~ p_temp %}
RESPOND MSG="{info_str}"
{% set info_str = "Slow Printing Speed: " ~ sspeed %}
RESPOND MSG="{info_str}"
{% set info_str = "Fast Printing Speed: " ~ fspeed %}
RESPOND MSG="{info_str}"
{% set info_str = "Fan Speed: " ~ fan_speed %}
RESPOND MSG="{info_str}"
{% set info_str = "Length of Test Square: " ~ rect_side_len %}
RESPOND MSG="{info_str}"
{% set info_str = "Number of Layers: " ~ layer_num %}
RESPOND MSG="{info_str}"
{% set info_str = "Minimum Pressure Advance: " ~ PA_low %}
RESPOND MSG="{info_str}"
{% set info_str = "Maximum Pressure Advance: " ~ PA_high %}
RESPOND MSG="{info_str}"
{% set info_str = "Formula: Pressure Advance Value = Measured_Z_Height x " ~ (((PA_high - PA_low) / layer_num) / layer_h) ~ PA_sign ~ PA_const|abs %}
RESPOND MSG="{info_str}"
{% set g_cmd = tool %}
{ g_cmd }
# {% set g_cmd = startup_code %}
# { g_cmd }
START_PRINT BED_TEMPERATURE={b_temp} EXTRUDER_TEMPERATURE={p_temp} CHAMBER_TEMPERATURE=50
M220 S100
M221 S100
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=1 ACCEL=500
SET_PRESSURE_ADVANCE ADVANCE_LOOKAHEAD_TIME=0
G92 E0
M83
# Precompute absolute coordinates of all print moves and speeds
#
# fast
# V5 +-----+ V4
# | | slow
# slow| + V3
# | | fast
# V1 +-----+ V2
# fast
{% set x_center = bed_x|float / 2.0 %}
{% set y_center = bed_y|float / 2.0 %}
{% set half_width = rect_side_len|float / 2.0 %}
{% set x_left = x_center - half_width + off_x %}
{% set x_right = x_center + half_width + off_x %}
{% set y_front = y_center - half_width + off_y %}
{% set y_back = y_center + half_width + off_y %}
{% set current_z = layer_h %}
{% set move_feedrate = 300.0 * 60.0 %}
{% set fast_feedrate = fspeed|float * 60.0 %}
{% set slow_feedrate = sspeed|float * 60.0 %}
# move the printhead to the starting position and make ready
G0 X{x_left} Y{y_front} Z{current_z} F{move_feedrate}
{% set pressure_advance = 0.0 %}
SET_PRESSURE_ADVANCE ADVANCE={pressure_advance}
M106 S{fan_speed}
# Iterate through each layer
{% for i in range(layer_num) %}
{% set pressure_advance = i / layer_num * (PA_high - PA_low) + PA_low %}
SET_PRESSURE_ADVANCE ADVANCE={pressure_advance}
# Set correct Z height
{% set current_z = layer_h * i %}
G0 Z{current_z}
# V1 to V2, fast feedrate
PA_LINE FEEDRATE={fast_feedrate} XSTART={x_left} YSTART={y_front} XEND={x_right} YEND={y_front} FD={filament_d} EW={e_width} LH={layer_h}
# V2 to V3, fast feedrate
PA_LINE FEEDRATE={fast_feedrate} XSTART={x_right} YSTART={y_front} XEND={x_right} YEND={y_center} FD={filament_d} EW={e_width} LH={layer_h}
# V3 to V4, slow feedrate
PA_LINE FEEDRATE={slow_feedrate} XSTART={x_right} YSTART={y_center} XEND={x_right} YEND={y_back} FD={filament_d} EW={e_width} LH={layer_h}
# V4 to V5, fast feedrate
PA_LINE FEEDRATE={fast_feedrate} XSTART={x_right} YSTART={y_back} XEND={x_left} YEND={y_back} FD={filament_d} EW={e_width} LH={layer_h}
# V5 back to start, slow feedrate
PA_LINE FEEDRATE={slow_feedrate} XSTART={x_left} YSTART={y_back} XEND={x_left} YEND={y_front} FD={filament_d} EW={e_width} LH={layer_h}
{% endfor %}
END_PRINT
[gcode_macro PA_LINE]
gcode:
# All parameters mandatory (no defaults)
{% set print_feedrate = params.FEEDRATE|float %}
{% set xfrom = params.XSTART|float %}
{% set yfrom = params.YSTART|float %}
{% set xto = params.XEND|float %}
{% set yto = params.YEND|float %}
{% set f_size = params.FD|default(1.75)|float %}
{% set e_size = params.EW|default(0.4)|float %}
{% set l_size = params.LH|default(0.2)|float %}
{% set line_length = ((xto-xfrom)**2 + (yto-yfrom)**2)**0.5 %} # Pythagoras
{% set extrude_length = line_length / (f_size * f_size * 3.14159 * 0.25) %}
{% set e_num = extrude_length * e_size * l_size * 1.67 %}
G1 X{xto} Y{yto} E{e_num} F{print_feedrate}
{ g_cmd }