diff --git a/.gitignore b/.gitignore index bc56f34..f85d726 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ * !.gitignore !printer.cfg -!btt-ebb36.cfg !macros.cfg +!flexplate.cfg diff --git a/flexplate.cfg b/flexplate.cfg new file mode 100644 index 0000000..44ab9f8 --- /dev/null +++ b/flexplate.cfg @@ -0,0 +1,211 @@ +##################################################################### +# Preperation +##################################################################### +# copy this file in the same directory as your printer.cfg +# add +# [include flexplate.cfg] +# to your printer.cfg +# +# add +# _SET_PLATE_OFFSET +# to your print start gcode to apply the offset before you print the first line of filament +# +# A [save_variables] block is needed since a printer save variable needs to be used to have it available after power up. +# You can skip this if you already have an [save_variables] config block +# e.g: +# [save_variables] +# filename: /home/pi/klipper_config/.variables.stb +# I like to hide that file as there is nothing in that should be modified by the user. +# Do a klipper restart after adding the stuff above +# +# After klipper is back you need define your first plate e.g. +# ADD_NEW_PLATE NAME=Texture OFFSET=-0.010 +# +##################################################################### +# Macro for the print_start gcode section of your slicer +# or your print start macro +##################################################################### +# _SET_PLATE_OFFSET [MOVE=0|1] : Set the z offset +# Set the offset of the active flexplate as an Z_ADJUST offset. MOVE=0 (default) +# will add the offset with the next z move, MOVE=1 imitate change the z offset. +# +# !!! Caution: Insure that SET_GCODE_OFFSET Z=0 is set once at every +# print start. Please read also the desribtion of the gcode SET_GCODE_OFFSET +# at https://www.klipper3d.org/G-Codes.html#extended-g-code-commands !!! +# +##################################################################### +# Console ussage +##################################################################### +# LIST_PLATES: List all plates +# Use the index shown there for all other macros +# +# SET_PLATE INDEX=: Set the active flexplate +# The flexplate stored at index will be activated. +# +# ADD_PLATE [NAME=] [OFFSET=]: Add a new flexplate to the list +# If NAME or OFFSET is not defined than the defaults 'New' and 0.000 will be used. +# !!! Caution do not use special characters like äüö or anything else in the name !!! +# +# REMOVE_PLATE INDEX=: Remove a flexplate of the list +# Remove plate with INDEX from the list. Note the last or active plate can not be removed. +# +# CHANGE_PLATE_VALUE [INDEX=] [NAME=] [OFFSET=]: Change name or/and offset of an flexplate +# If INDEX is not defined the name and/or offset value of the active plate will be changed. +# !!! Caution do not use special characters like äüö or anything else in the name !!! +# +##################################################################### +# LCD menu usage +##################################################################### +# Change the active flexplate and the offset of that flexplate. +# +##################################################################### +# Get offset_z and name for own usage +##################################################################### +# {% set offset = printer.save_variables.variables.plates.array[printer.save_variables.variables.plates.index].offset %} +# {% set name = printer.save_variables.variables.plates.array[printer.save_variables.variables.plates.index].name %} +# +##################################################################### +[gcode_macro _SET_PLATE_OFFSET] +description: Helper: Apply the z-offset of the active flexplate +gcode: + {% if not printer.save_variables.variables.plates %} + {action_respond_info("FLEXPLATE: No Plate Array defined. ABORDED")} + {% else %} + {% set plates = printer.save_variables.variables.plates %} + SET_GCODE_OFFSET Z_ADJUST={plates.array[plates.index].offset} MOVE={params.MOVE|default(0)} + {% endif %} + +[gcode_macro LIST_PLATES] +description: List all flexplates +gcode: + {% if not printer.save_variables.variables.plates %} + {action_respond_info("FLEXPLATE: No Plate Array defined. ABORDED")} + {% else %} + {% set plates = printer.save_variables.variables.plates %} + {% set out = ["FLEXPLATE: Defined Plates"] %} + {% for elem in range(plates.array|length) %} + {% set _dummy = out.append("INDEX: %d -> %s -> offset: %.3fmm" % + (elem, plates.array[elem].name, plates.array[elem].offset)) %} + {% endfor %} + {% set _dummy = out.append("\n Active Plate: %s" % plates.array[plates.index].name) %} + {action_respond_info(out|join("\n"))} + {% endif %} + +[gcode_macro SET_PLATE] +description: Set an flexplate +gcode: + {% if not printer.save_variables.variables.plates %} + {action_respond_info("FLEXPLATE: No Plate Array defined. ABORDED")} + {% else %} + {% set plates = printer.save_variables.variables.plates %} + {% if 'INDEX' not in params|upper %} + {action_respond_info("FLEXPLATE: No INDEX defined, use SET_PLATE INDEX=index. ABORDED")} + {% elif params.INDEX|int < 0 or params.INDEX|int >= plates.array|length %} + {action_respond_info("FLEXPLATE: Index out of range [0..%d]. ABORDED" % (plates.array|length-1))} + {% else %} + {% set _dummy = plates.update({'index' : params.INDEX|int}) %} + SAVE_VARIABLE VARIABLE=plates VALUE="{plates}" + M117 Plate: {plates.array[plates.index].name} + {action_respond_info("FLEXPLATE: Set plate: %s with offset: %.3fmm" % ( + plates.array[plates.index].name,plates.array[plates.index].offset))} + {% endif %} + {% endif %} + +[gcode_macro ADD_PLATE] +description: Add a flexplate to the list +gcode: + {% set name = params.NAME|default('New')|string %} + {% set offset = params.OFFSET|default(0.0)|float|round(3) %} + {% if not printer.save_variables.variables.plates %} + {action_respond_info("FLEXPLATE: Initialize Plate Array + Add plate: %s with offset: %.3fmm at INDEX: 0" % (name,offset))} + {% set plates = {'array': [{'name': name, 'offset': offset}], 'index' : 0} %} + {% else %} + {% set plates = printer.save_variables.variables.plates %} + {action_respond_info("FLEXPLATE: Add plate: %s with offset: %.3fmm at INDEX: %d" % (name,offset,plates.array|length))} + {% set _dummy = plates.array.append({'name': name, 'offset': offset}) %} + {% endif %} + SAVE_VARIABLE VARIABLE=plates VALUE="{plates}" + +[gcode_macro REMOVE_PLATE] +description: Remove a flexplate from the list +gcode: + {% if not printer.save_variables.variables.plates %} + {action_respond_info("FLEXPLATE: No Plate Array defined. ABORDED")} + {% else %} + {% set plates = printer.save_variables.variables.plates %} + {% if 'INDEX' not in params|upper %} + {action_respond_info("FLEXPLATE: No INDEX defined, use REMOVE_PLATE INDEX=index. ABORDED")} + {% elif plates.array|length == 1 or params.INDEX|int == plates.index %} + {action_respond_info("FLEXPLATE: Last or active plate can not be removed. ABORDED")} + {% elif params.INDEX|int < 0 or params.INDEX|int >= plates.array|length %} + {action_respond_info("FLEXPLATE: Index out of range [0..%d]. ABORDED" % (plates.array|length-1))} + {% else %} + {action_respond_info("FLEXPLATE: Remove plate with INDEX %d from list " % params.INDEX|int)} + {% set _dummy = plates.array.pop(params.INDEX|int) %} + SAVE_VARIABLE VARIABLE=plates VALUE="{plates}" + {% endif %} + {% endif %} + +[gcode_macro CHANGE_PLATE_VALUE] +description: Change name or offset of an flexplate in the list +gcode: + {% if not printer.save_variables.variables.plates %} + {action_respond_info("FLEXPLATE: No Plate Array defined. ABORDED")} + {% else %} + {% set plates = printer.save_variables.variables.plates %} + {% set index = params.INDEX|default(plates.index)|int %} + {% if index < 0 or index >= plates.array|length %} + {action_respond_info("FLEXPLATE: Index out of range [0..%d]. ABORDED" % (plates.array|length-1))} + {% else %} + {% set change_txt = [] %} + {% if 'NAME' in params|upper %} + {% set _dummy = change_txt.append("name to %s" % params.NAME|string) %} + {% set _dummy = plates.array[index].update({'name': params.NAME|string}) %} + {% endif %} + {% if 'OFFSET' in params|upper %} + {% set _dummy = change_txt.append("offset to %.3fmm" % params.OFFSET|float|round(3)) %} + {% set _dummy = plates.array[index].update({'offset': params.OFFSET|float|round(3)}) %} + {% endif %} + {% if change_txt|length > 0 %} + {action_respond_info("FLEXPLATE: Changed %s at plate with INDEX %d" % (change_txt|join(" and "),index))} + SAVE_VARIABLE VARIABLE=plates VALUE="{plates}" + {% else %} + {action_respond_info("FLEXPLATE: Nothing changed at plate with INDEX %d" % index)} + {% endif %} + {% endif %} + {% endif %} + +# Display Menu +# !!! Caution: I use my own menu root __voron_main !!! +# If you use a stock menu un comment this here +#[menu __main __flexplate] +#type: list +#name: Flexplate: {printer.save_variables.variables.plates.array[printer.save_variables.variables.plates.index].name} +#enable: {'plates' in printer.save_variables.variables} +#index: 1 + +#[menu __main __flexplate __set] +#type: input +#name: Set: {printer.save_variables.variables.plates.array[menu.input|int].name} +#enable: {printer.print_stats.state != "printing" and printer.print_stats.state != "paused"} +#input: {printer.save_variables.variables.plates.index} +#input_min: 0 +#input_max: {printer.save_variables.variables.plates.array|length - 1} +#gcode: +# {%- if menu.event == 'long_click' -%} +# SET_PLATE INDEX={menu.input|int} +# {%- endif -%} + +#[menu __main __flexplate __offset] +#type: input +#name: Offset:{'%01.3f' % menu.input} +#enable: {printer.print_stats.state != "printing" and printer.print_stats.state != "paused"} +#input: {printer.save_variables.variables.plates.array[printer.save_variables.variables.plates.index].offset} +#input_min: -1.0 +#input_max: 1.0 +#input_step: 0.001 +#gcode: +# {%- if menu.event == 'long_click' -%} +# CHANGE_PLATE_VALUE OFFSET={menu.input|float} +# {%- endif -%} \ No newline at end of file diff --git a/macros.cfg b/macros.cfg index b8a4faa..ad9d6ca 100644 --- a/macros.cfg +++ b/macros.cfg @@ -16,6 +16,10 @@ gcode: {% set target_bed = params.BED|int %} {% set target_extruder = params.EXTRUDER|int %} + # Apply our z-offset + SET_GCODE_OFFSET Z=0 + _SET_PLATE_OFFSET + # Homes the printer, sets absolute positioning, update the Stealthburner leds and clear old bed mesh. STATUS_PRINTING # Sets SB-leds to printing-mode SET_NOZZLE_LEDS_OFF # Disable SB nozzle leds diff --git a/printer.cfg b/printer.cfg index ac8abdb..d1014e7 100644 --- a/printer.cfg +++ b/printer.cfg @@ -21,6 +21,7 @@ [include stealthburner_leds.cfg] [include OrbiterSensor.cfg] # Plugins +[include flexplate.cfg] [include KAMP_Settings.cfg] ######################################## @@ -54,6 +55,9 @@ retract_length: 0.5 retract_speed: 35 unretract_speed: 35 +[save_variables] +filename: /home/biqu/printer_data/config/variables.stb + [virtual_sdcard] path: /home/biqu/printer_data/gcodes on_error_gcode: CANCEL_PRINT @@ -85,8 +89,8 @@ sensor_pin: ^EBBCan:PB8 control_pin: EBBCan:PB9 x_offset: 0 y_offset: 22.5 -z_offset: 2.005 -speed: 20 +z_offset: 2.04 +speed: 3 samples: 3 sample_retract_dist: 5.0 samples_result: median @@ -112,6 +116,31 @@ pid_Kd: 1029.416 min_temp: 0 max_temp: 130 +[extruder] +step_pin: EBBCan: PD0 +dir_pin: EBBCan: PD1 +enable_pin: !EBBCan: PD2 +microsteps: 16 +full_steps_per_rotation: 200 +rotation_distance: 4.729266 +nozzle_diameter: 0.400 +filament_diameter: 1.750 +max_extrude_cross_section: 5 +max_extrude_only_distance: 500 +max_extrude_only_velocity: 120 +pressure_advance: 0.025 #to be calibrated +pressure_advance_smooth_time: 0.03 #to be calibrated +heater_pin: EBBCan: PB13 +sensor_type: DREMC NTC100K B3950 +sensor_pin: EBBCan: PA3 +control: pid +pid_Kp: 25.194 +pid_Ki: 1.312 +pid_Kd: 120.930 +min_extrude_temp: 180 +min_temp: 0 +max_temp: 300 + ######################################## # Stepper Configuration ######################################## @@ -147,7 +176,7 @@ enable_pin: !PD3 microsteps: 16 rotation_distance: 8 endstop_pin: probe:z_virtual_endstop -position_min: -1 +position_min: 0 position_max: 260 [stepper_z1] @@ -157,53 +186,28 @@ enable_pin: !PB4 microsteps: 16 rotation_distance: 8 -[extruder] -step_pin: EBBCan: PD0 -dir_pin: EBBCan: PD1 -enable_pin: !EBBCan: PD2 -microsteps: 16 -full_steps_per_rotation: 200 -rotation_distance: 4.729266 -nozzle_diameter: 0.400 -filament_diameter: 1.750 -max_extrude_cross_section: 5 -max_extrude_only_distance: 500 -max_extrude_only_velocity: 120 -pressure_advance: 0.025 #to be calibrated -pressure_advance_smooth_time: 0.03 #to be calibrated -heater_pin: EBBCan: PB13 -sensor_type: DREMC NTC100K B3950 -sensor_pin: EBBCan: PA3 -control: pid -pid_Kp: 25.60 -pid_Ki: 1.369 -pid_Kd: 116.510 -min_extrude_temp: 180 -min_temp: 0 -max_temp: 300 - ######################################## # TMC2209 Configuration ######################################## [tmc2209 stepper_x] uart_pin: PB8 -run_current: 0.580 +run_current: 0.594 interpolate: True [tmc2209 stepper_y] uart_pin: PC9 -run_current: 0.580 +run_current: 0.594 interpolate: True [tmc2209 stepper_z] uart_pin: PD0 -run_current: 0.580 +run_current: 0.594 interpolate: True [tmc2209 stepper_z1] uart_pin: PB5 -run_current: 0.580 +run_current: 0.594 interpolate: True [tmc2209 extruder] @@ -293,4 +297,4 @@ shaper_freq_y: 56.4 shaper_type_x: ei shaper_type_y: ei damping_ratio_x: 0.040 -damping_ratio_y: 0.039 +damping_ratio_y: 0.039 \ No newline at end of file