From 3b6ad1b9f8acd441d873e047d32b748ee78193c9 Mon Sep 17 00:00:00 2001 From: Konstantin Koslowski Date: Fri, 10 Mar 2023 21:19:16 +0100 Subject: [PATCH] printer: add ebb36 with sensorless homing --- ebb36.cfg | 82 ++++++++++++++++++++++++++++++++++++++ fans.cfg | 34 ---------------- macros/_init.cfg | 1 + macros/sensorless.cfg | 76 +++++++++++++++++++++++++++++++++++ neopixel.cfg | 3 +- printer.cfg | 92 +++++++++++-------------------------------- 6 files changed, 183 insertions(+), 105 deletions(-) create mode 100644 ebb36.cfg create mode 100644 macros/sensorless.cfg diff --git a/ebb36.cfg b/ebb36.cfg new file mode 100644 index 0000000..e6373f9 --- /dev/null +++ b/ebb36.cfg @@ -0,0 +1,82 @@ +# This file contains common pin mappings for the BIGTREETECH EBBCan +# Canbus board. To use this config, the firmware should be compiled for the +# STM32G0B1 with "8 MHz crystal" and "USB (on PA11/PA12)" or "CAN bus (on PB0/PB1)". +# The "EBB Can" micro-controller will be used to control the components on the nozzle. + +# See docs/Config_Reference.md for a description of parameters. + +[mcu EBBCan] +# serial: /dev/serial/by-id/usb-Klipper_Klipper_firmware_12345-if00 +canbus_uuid: 8192d675a56e + +[adxl345] +cs_pin: EBBCan: PB12 +spi_software_sclk_pin: EBBCan: PB10 +spi_software_mosi_pin: EBBCan: PB11 +spi_software_miso_pin: EBBCan: PB2 +axes_map: x,y,z + +[extruder] +step_pin: EBBCan: PD0 +dir_pin: EBBCan: PD1 +enable_pin: !EBBCan: PD2 +## Update value below when you perform extruder calibration +## If you ask for 100mm of filament, but in reality it is 98mm: +## rotation_distance = * / 100 +## 22.6789511 is a good starting point +rotation_distance: 22.6789511 #Bondtech 5mm Drive Gears +## Update Gear Ratio depending on your Extruder Type +## - 50:17 for Afterburner/Clockwork +## - 50:10 for Stealthburner/Clockwork2 +## - 80:20 for M4, M3.1 +gear_ratio: 50:10 # SB BMG +microsteps: 32 +full_steps_per_rotation: 200 # 1.8 deg stepper: 200, 0.9 deg stepper: 400 +nozzle_diameter: 0.400 +filament_diameter: 1.750 +heater_pin: EBBCan: PB13 +sensor_type: ATC Semitec 104NT-4-R025H42G +sensor_pin: EBBCan: PA3 +max_power: 1.0 +min_extrude_temp: 180 +min_temp: 0 +max_temp: 280 # specified to 300 +## Try to keep pressure_advance below 1.0 +# pressure_advance: 0.05 +## Default is 0.040, leave stock +pressure_advance_smooth_time: 0.040 +# Maximum length (in mm of raw filament) that a retraction or +# extrude-only move may have, default: 50 +max_extrude_only_distance: 200 +# Maximum area (in mm^2) of an extrusion cross section (eg, +# extrusion width multiplied by layer height). This setting prevents +# excessive amounts of extrusion during relatively small XY moves. +# If a move requests an extrusion rate that would exceed this value +# it will cause an error to be returned. The default is: 4.0 * +# nozzle_diameter^2 +max_extrude_cross_section: 50.0 # default 4 * 0.4 = 0.64 +control: pid +pid_Kp: 21.527 +pid_Ki: 1.063 +pid_Kd: 108.982 + +[tmc2209 extruder] +uart_pin: EBBCan: PA15 +run_current: 0.650 +stealthchop_threshold: 999999 + +[fan] +pin: EBBCan: PA0 + +[heater_fan hotend_fan] +pin: EBBCan: PA1 +heater: extruder +heater_temp: 50.0 + +[filament_switch_sensor toolhead_sensor] +pause_on_runout: False +switch_pin: ^EBBCan: PB3 +# runout_gcode: +# M118 toolhead filament removed +# insert_gcode: +# M118 toolhead filament inserted diff --git a/fans.cfg b/fans.cfg index 9682105..d0cdec8 100644 --- a/fans.cfg +++ b/fans.cfg @@ -2,23 +2,6 @@ # Fan Control ##################################################################### -[fan] -pin: PA8 -kick_start_time: 0.5 -## Depending on your fan, you may need to increase this value -## if your fan will not start. Can change cycle_time (increase) -## if your fan is not able to slow down effectively -off_below: 0.10 - -[heater_fan hotend_fan] -pin: PE5 -max_power: 1.0 -kick_start_time: 0.5 -heater: extruder -heater_temp: 50.0 -## If you are experiencing back flow, you can reduce fan_speed -#fan_speed: 1.0 - # [fan_generic nevermore1] [heater_fan nevermore1] pin: PD12 @@ -51,20 +34,3 @@ heater: heater_bed heater_temp: 40.0 fan_speed: 0.40 -# ## exhaust automatic -# [heater_fan exhaust_fan] -# pin: PD14 -# max_power: 1.0 -# shutdown_speed: 0.0 -# kick_start_time: 0.5 -# heater: heater_bed -# heater_temp: 40 -# fan_speed: 0.6 - -# ## exhaust manual -# [fan_generic exhaust_fan] -# pin: PD14 -# max_power: 1.0 -# shutdown_speed: 0.0 -# kick_start_time: 0.5 - diff --git a/macros/_init.cfg b/macros/_init.cfg index 609e796..5549dce 100644 --- a/macros/_init.cfg +++ b/macros/_init.cfg @@ -5,4 +5,5 @@ [include debug.cfg] [include helpers.cfg] [include print.cfg] +[include sensorless.cfg] [include timelapse.cfg] diff --git a/macros/sensorless.cfg b/macros/sensorless.cfg new file mode 100644 index 0000000..5854a5d --- /dev/null +++ b/macros/sensorless.cfg @@ -0,0 +1,76 @@ +[gcode_macro _HOME_X] +gcode: + # Always use consistent run_current on A/B steppers during sensorless homing + {% set RUN_CURRENT_X = printer.configfile.settings['tmc5160 stepper_x'].run_current|float %} + {% set RUN_CURRENT_Y = printer.configfile.settings['tmc5160 stepper_y'].run_current|float %} + {% set HOME_CURRENT = 0.5 %} + SET_TMC_CURRENT STEPPER=stepper_x CURRENT={HOME_CURRENT} + SET_TMC_CURRENT STEPPER=stepper_y CURRENT={HOME_CURRENT} + + # Home + G28 X + # Move away + G91 + G1 X-10 F1200 + G90 + + # Wait just a moment + G4 P500 + # Set current during print + SET_TMC_CURRENT STEPPER=stepper_x CURRENT={RUN_CURRENT_X} + SET_TMC_CURRENT STEPPER=stepper_y CURRENT={RUN_CURRENT_Y} + +[gcode_macro _HOME_Y] +gcode: + # Set current for sensorless homing + {% set RUN_CURRENT_X = printer.configfile.settings['tmc5160 stepper_x'].run_current|float %} + {% set RUN_CURRENT_Y = printer.configfile.settings['tmc5160 stepper_y'].run_current|float %} + {% set HOME_CURRENT = 0.5 %} + SET_TMC_CURRENT STEPPER=stepper_x CURRENT={HOME_CURRENT} + SET_TMC_CURRENT STEPPER=stepper_y CURRENT={HOME_CURRENT} + + # Home + G28 Y + # Move away + G91 + G1 Y-10 F1200 + G90 + + # Wait just a moment + G4 P500 + # Set current during print + SET_TMC_CURRENT STEPPER=stepper_x CURRENT={RUN_CURRENT_X} + SET_TMC_CURRENT STEPPER=stepper_y CURRENT={RUN_CURRENT_Y} + +[homing_override] +axes: xyz +set_position_z: 0 +gcode: + {% set home_all = 'X' not in params and 'Y' not in params or 'Z' in params %} + + # set_position_z does home z + # but if x and y are not, guess that z is not really either z + {% if not "x" in printer.toolhead.homed_axes and not "y" in printer.toolhead.homed_axes %} + # move up 5 + G91 + G0 Z5 + G90 + {% else %} + # or to 5 + G0 Z5 + {% endif %} + + {% if home_all or 'X' in params %} + _HOME_X + {% endif %} + + {% if home_all or 'Y' in params %} + _HOME_Y + {% endif %} + + {% if home_all or 'Z' in params %} + G0 X150 Y150 F6000 + G28 Z + G1 Z10 + {% endif %} + diff --git a/neopixel.cfg b/neopixel.cfg index cc87245..29ba872 100644 --- a/neopixel.cfg +++ b/neopixel.cfg @@ -11,7 +11,8 @@ initial_BLUE: 0.4 [neopixel toolhead] # pin: PB6 # Octopus BL_Touch -pin: PB0 # Octopus LED +# pin: PB0 # Octopus LED +pin: EBBCan: PD3 chain_count: 3 color_order: GRBW initial_RED: 0.3 diff --git a/printer.cfg b/printer.cfg index 7c5fe39..b95b015 100644 --- a/printer.cfg +++ b/printer.cfg @@ -58,6 +58,7 @@ path: /home/pi/printer_data/gcodes # includes ##################################################################### +[include ebb36.cfg] [include macros/_init.cfg] [include neopixel.cfg] [include fans.cfg] @@ -77,14 +78,16 @@ step_pin: PF13 dir_pin: !PF12 enable_pin: !PF14 rotation_distance: 40 +homing_speed: 20 microsteps: 32 full_steps_per_rotation: 400 # 200: 1.8 deg stepper, 400: 0.9 deg stepper -endstop_pin: PG6 +# endstop_pin: PG6 # octopus +endstop_pin: tmc5160_stepper_x:virtual_endstop position_min: 0 position_endstop: 300 position_max: 300 -homing_speed: 30 # speed: mm/sec, feedrate: mm/min -homing_retract_dist: 5 +# homing_retract_dist: 5 +homing_retract_dist: 0 homing_positive_dir: true [tmc5160 stepper_x] @@ -96,6 +99,8 @@ interpolate: False run_current: 1.0 sense_resistor: 0.110 stealthchop_threshold: 0 +diag0_pin: ^!PG6 +driver_SGT: 1 # -64 most sensitive, 63 least sensitive ## Y Stepper on MOTOR1 (A Motor) [stepper_y] @@ -103,14 +108,16 @@ step_pin: PG0 dir_pin: !PG1 enable_pin: !PF15 rotation_distance: 40 +homing_speed: 20 microsteps: 32 full_steps_per_rotation: 400 # 200: 1.8 deg stepper, 400: 0.9 deg stepper -endstop_pin: PG9 +# endstop_pin: PG9 # octopus +endstop_pin: tmc5160_stepper_y:virtual_endstop position_min: 0 -position_endstop: 302.5 -position_max: 306 -homing_speed: 30 # Max 100 -homing_retract_dist: 5 +position_endstop: 303 +position_max: 303 +# homing_retract_dist: 5 +homing_retract_dist: 0 homing_positive_dir: true [tmc5160 stepper_y] @@ -122,6 +129,8 @@ interpolate: False run_current: 1.0 sense_resistor: 0.110 stealthchop_threshold: 0 +diag0_pin: ^!PG9 +driver_SGT: 1 # -64 most sensitive, 63 least sensitive ##################################################################### @@ -200,64 +209,6 @@ sense_resistor: 0.110 stealthchop_threshold: 0 -##################################################################### -# Extruder -##################################################################### - -# E0 on MOTOR6 -[extruder] -step_pin: PE2 -dir_pin: !PE3 -enable_pin: !PD4 -## Update value below when you perform extruder calibration -## If you ask for 100mm of filament, but in reality it is 98mm: -## rotation_distance = * / 100 -## 22.6789511 is a good starting point -rotation_distance: 22.6789511 #Bondtech 5mm Drive Gears -## Update Gear Ratio depending on your Extruder Type -## - 50:17 for Afterburner/Clockwork -## - 50:10 for Stealthburner/Clockwork2 -## - 80:20 for M4, M3.1 -gear_ratio: 50:10 # SB BMG -microsteps: 32 -full_steps_per_rotation: 200 # 1.8 deg stepper: 200, 0.9 deg stepper: 400 -nozzle_diameter: 0.400 -filament_diameter: 1.75 -heater_pin: PA2 -sensor_type: ATC Semitec 104NT-4-R025H42G -sensor_pin: PF4 -min_temp: 10 -max_temp: 280 # specified to 300 -max_power: 1.0 -min_extrude_temp: 170 -#control = pid -#pid_kp = 26.213 -#pid_ki = 1.304 -#pid_kd = 131.721 -## Try to keep pressure_advance below 1.0 -# pressure_advance: 0.05 -## Default is 0.040, leave stock -pressure_advance_smooth_time: 0.040 -# Maximum length (in mm of raw filament) that a retraction or -# extrude-only move may have, default: 50 -max_extrude_only_distance: 200 -# Maximum area (in mm^2) of an extrusion cross section (eg, -# extrusion width multiplied by layer height). This setting prevents -# excessive amounts of extrusion during relatively small XY moves. -# If a move requests an extrusion rate that would exceed this value -# it will cause an error to be returned. The default is: 4.0 * -# nozzle_diameter^2 -max_extrude_cross_section: 50.0 # default 4 * 0.4 = 0.64 - -## E0 on MOTOR6 -[tmc2209 extruder] -uart_pin: PE1 -interpolate: false -run_current: 0.5 -sense_resistor: 0.110 -stealthchop_threshold: 0 - - ##################################################################### # Bed Heater ##################################################################### @@ -309,9 +260,9 @@ max_temp: 100 [idle_timeout] timeout: 1800 -[safe_z_home] -home_xy_position: 150, 150 -z_hop: 10 +# [safe_z_home] +# home_xy_position: 150, 150 +# z_hop: 5 ##################################################################### @@ -320,7 +271,8 @@ z_hop: 10 [probe] ## Voron-Tap -pin: ^PG11 +# pin: ^PG11 +pin: EBBCan: PB9 x_offset: 0 y_offset: 0 #z_offset: 0