-
Notifications
You must be signed in to change notification settings - Fork 0
/
FLOW_CAL.cfg
131 lines (122 loc) · 7.03 KB
/
FLOW_CAL.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
[gcode_macro _FLOW_CAL_CUSTOM_EXAMPLE]
# An example of customising flow calculator using presets and start and end macros.
# Create a few with presets if you like.
gcode:
PRINT_START BED=110 HOTEND=245
FLOW_CAL BED_TEMPERATURE=110 TEMP_START=260
PRINT_END
[gcode_macro FLOW_CAL]
# Klipper extruder flow calculator.
# Usage example: FLOW_CAL BED_TEMPERATURE=110 FLOW_START=2 TEMP_START=260
# Or you can execute with no parameters, which will use values from printer.cfg and saved_variables.cfg.
# Weight the blobs and input them into Stefan's Excel sheet
# Based on CNCKitchen's ExtrusionSystemBenchmark by Stefan Hermann https://github.com/CNCKitchen/ExtrusionSystemBenchmark
description: Flow calculator
gcode:
# saved_variables.cfg
{% set svv = printer.save_variables.variables %}
# macro parameters
{% set BED_MARGIN = params.BED_MARGIN|default(svv.fc_bed_margin)|int %}
{% set TRAVEL_SPEED = params.TRAVEL_SPEED|default(svv.fc_travel_speed)|int %}
{% set DWELL_TIME = params.DWELL_TIME|default(svv.fc_dwell_time)|int %}
{% set BED_TEMPERATURE = params.BED_TEMPERATURE|default(svv.fc_bed_temperature)|int %}
{% set FAN_SPEED = params.FAN_SPEED|default(svv.fc_fan_speed)|int %}
{% set PRIME_LENGTH = params.PRIME_LENGTH|default(svv.fc_prime_length)|int %}
{% set PRIME_AMOUNT = params.PRIME_AMOUNT|default(svv.fc_prime_amount)|int %}
{% set PRIME_SPEED = params.PRIME_SPEED|default(svv.fc_prime_speed)|int %}
{% set WIPE_LENGTH = params.WIPE_LENGTH|default(svv.fc_wipe_length)|int %}
{% set RETRACTION_DISTANCE = params.RETRACTION_DISTANCE|default(svv.fc_retraction_distance)|float %}
{% set RETRACTION_SPEED = params.RETRACTION_SPEED|default(svv.fc_retraction_speed)|int %}
{% set BLOB_HEIGHT = params.BLOB_HEIGHT|default(svv.fc_blob_height)|float %}
{% set EXTRUSION_AMOUNT = params.EXTRUSION_AMOUNT|default(svv.fc_extrusion_amount)|int %}
{% set BLOB_Z_LIFT = params.BLOB_Z_LIFT|default(svv.fc_blob_z_lift)|float %}
{% set DIRECTION = params.DIRECTION|default(svv.fc_direction)|int %}
{% set TEMP_SPACING = params.TEMP_SPACING|default(svv.fc_temp_spacing)|int %}
{% set FLOW_SPACING = params.FLOW_SPACING|default(svv.fc_flow_spacing)|int %}
{% set FLOW_START = params.FLOW_START|default(svv.fc_flow_start)|int %}
{% set FLOW_OFFSET = params.FLOW_OFFSET|default(svv.fc_flow_offset)|int %}
{% set FLOW_STEPS = params.FLOW_STEPS|default(svv.fc_flow_steps)|int %}
{% set TEMP_START = params.TEMP_START|default(svv.fc_temp_start)|int %}
{% set TEMP_OFFSET = params.TEMP_OFFSET|default(svv.fc_temp_offset)|int %}
{% set TEMP_STEPS = params.TEMP_STEPS|default(svv.fc_temp_steps)|int %}
# load variables
{% set FILAMENT_DIAMETER = printer.configfile.config["extruder"]["filament_diameter"]|float %}
# calculated variables
{% set ATAN1 = 0.7853981633974483 %}
{% set BED_WIDTH = printer['configfile'].config["stepper_x"]["position_max"]|float %}
{% set BED_LENGTH = printer['configfile'].config["stepper_y"]["position_max"]|float %}
{% set BED_LENGTH_SAVE = BED_LENGTH %}
{% set FLOW_END = FLOW_START + (FLOW_STEPS - 1) * FLOW_OFFSET %}
{% if TEMP_STEPS == 1 %} ; Fill mode
{% set TEMP_STEPS = (FLOW_STEPS / ((BED_LENGTH - 2 * BED_MARGIN) / FLOW_SPACING)|round(0, 'floor'))|round(0, 'ceil')|int %}
{% set FLOW_STEPS = ((BED_LENGTH - 2 * BED_MARGIN) / FLOW_SPACING)|round(0, 'floor')|int %}
{% set TEMP_OFFSET = 0 %}
{% else %}
# Otherwise check to make sure we are not going to move outside printer bounds
{% if (BED_MARGIN + (FLOW_STEPS - 1) * FLOW_SPACING) > BED_LENGTH %}
{ action_raise_error("Flow steps and flow spacing exceed bed length") }
{% endif %}
{% endif %}
{% if DIRECTION == 1 %}
{% set BED_LENGTH = 0 %}
{% set BED_MARGIN = BED_MARGIN * -1 %}
{% set FLOW_SPACING = FLOW_SPACING * -1 %}
{% endif %}
M104 S{TEMP_START} ; Set Nozzle Temperature
M140 S{BED_TEMPERATURE} ; Set Bed Temperature
G90
{% if printer.toolhead.homed_axes != "xyz" %} ; Conditional home
G28
{% endif %}
M190 S{BED_TEMPERATURE} ; Set bed temperature and wait
M106 S{(FAN_SPEED * 255 / 100)|round|int} ; Set fan speed
G0 Z10 ; Lift nozzle
G21 ; unit in mm
G92 E0 ; reset extruder
M83 ; set extruder to relative mode
{% for i in range(1, TEMP_STEPS + 1) %}
{% if TEMP_OFFSET == 0 and i > 1 %}
{% set FLOW_START = FLOW_START + FLOW_STEPS * FLOW_OFFSET %}
{% endif %}
G4 S0 ; Dwell
M109 S{TEMP_START + (i - 1) * TEMP_OFFSET} ; Nozzle temperature and wait
{% for j in range(1, FLOW_STEPS + 1) if not (TEMP_OFFSET == 0 and TEMP_STEPS == i and FLOW_START + (j - 2) * FLOW_OFFSET >= FLOW_END) %}
{% set EXTRUSION_SPEED = (BLOB_HEIGHT / (EXTRUSION_AMOUNT / ((FLOW_START + (j - 1) * FLOW_OFFSET) / (ATAN1 * FILAMENT_DIAMETER * FILAMENT_DIAMETER) * 60)))|round(2) %}
_FLOW_CAL_BLOB BLOB_HEIGHT={BLOB_HEIGHT} BLOB_Z_LIFT={BLOB_Z_LIFT} DWELL_TIME={DWELL_TIME} EXTRUSION_AMOUNT={EXTRUSION_AMOUNT} EXTRUSION_SPEED={EXTRUSION_SPEED} FLOW={FLOW_START + (j - 1) * FLOW_OFFSET} PRIME_AMOUNT={PRIME_AMOUNT} PRIME_LENGTH={PRIME_LENGTH} PRIME_SPEED={PRIME_SPEED * 60} RETRACTION_DISTANCE={RETRACTION_DISTANCE} RETRACTION_SPEED={RETRACTION_SPEED * 60} TEMPERATURE={TEMP_START + (i - 1) * TEMP_OFFSET} TRAVEL_SPEED={TRAVEL_SPEED * 60} WIPE_LENGTH={WIPE_LENGTH} X={BED_MARGIN|abs + (i - 1) * (PRIME_LENGTH + WIPE_LENGTH + TEMP_SPACING)} Y={(BED_LENGTH - BED_MARGIN) - (j - 1) * FLOW_SPACING}
{% endfor %}
{% endfor %}
G0 X{BED_WIDTH - BED_MARGIN|abs} Y{BED_LENGTH_SAVE - BED_MARGIN|abs} ; Move to Corner
SET_DISPLAY_TEXT ; Clear
[gcode_macro _FLOW_CAL_BLOB]
gcode:
{% set BLOB_HEIGHT = params.BLOB_HEIGHT|float %}
{% set BLOB_Z_LIFT = params.BLOB_Z_LIFT|float %}
{% set DWELL_TIME = params.DWELL_TIME|int %}
{% set EXTRUSION_AMOUNT = params.EXTRUSION_AMOUNT|int %}
{% set EXTRUSION_SPEED = params.EXTRUSION_SPEED|int %}
{% set FLOW = params.FLOW|int %}
{% set PRIME_AMOUNT = params.PRIME_AMOUNT|int %}
{% set PRIME_LENGTH = params.PRIME_LENGTH|int %}
{% set PRIME_SPEED = params.PRIME_SPEED|int %}
{% set RETRACTION_DISTANCE = params.RETRACTION_DISTANCE|float %}
{% set RETRACTION_SPEED = params.RETRACTION_SPEED|int %}
{% set TEMPERATURE = params.TEMPERATURE|int %}
{% set TRAVEL_SPEED = params.TRAVEL_SPEED|int %}
{% set WIPE_LENGTH = params.WIPE_LENGTH|int %}
{% set X = params.X|int %}
{% set Y = params.Y|int %}
{ action_respond_info("blob: %dC - %dmm3/s" % (TEMPERATURE, FLOW)) }
M117 {TEMPERATURE}C // {FLOW}mm3/s
G0 X{X} Y{Y} Z{0.5 + BLOB_HEIGHT + BLOB_Z_LIFT} F{TRAVEL_SPEED}
G0 Z0.3 ; Drop down
G1 X{X + PRIME_LENGTH} E{PRIME_AMOUNT} F{PRIME_SPEED} ; Prime
G1 E{0 - RETRACTION_DISTANCE} F{RETRACTION_SPEED} ; Retract
G0 X{X + PRIME_LENGTH + WIPE_LENGTH} F{TRAVEL_SPEED} ; Wipe
G0 Z0.5 ; Lift
G1 E{RETRACTION_DISTANCE} F{RETRACTION_SPEED} ; Undo Retract
G1 Z{0.5 + BLOB_HEIGHT} E{EXTRUSION_AMOUNT} F{EXTRUSION_SPEED} ; Extrude
G1 E{0 - RETRACTION_DISTANCE} F{RETRACTION_SPEED} ; Retract
G0 Z{0.5 + BLOB_HEIGHT + BLOB_Z_LIFT} ; Lift
G0 X{X} Y{Y} F{TRAVEL_SPEED}
G4 P{DWELL_TIME * 1000} ; Stabalize and give a chance to catch mistakes
G92 E0 ; Reset Extruder