見出し画像

Klipper を Ender-3(SKR mini v1.2)+BLtouch に導入メモ

0.機器構成とか

Ender3
SKR mmini V1.2にメインボードは交換済
3D Touch -(BL TOUCHのクローン)
Raspberry 3B

1.ファームウェアのコンパイル

TeraTermなどでRasberryPiのMailsailに接続

cd ~/klipper/
make menuconfig
画像1
make clean
make

完了したら /home/pi/klipper/out/にある
Kilipper.bin を firmware.binにリネームし
SDカードに入れてEnder3に差し込んで再起動でファームをフラッシュ

WinSCPがあると便利

ここが大変参考になった

2.Printer.cfgの編集

Printer.cfgの例
(2022/10/15更新)

# This file contains common pin mappings for the BIGTREETECH SKR mini
# E3 v1.2. To use this config, the firmware should be compiled for the
# STM32F103 with a "28KiB bootloader" and USB communication. Also,
# select "Enable extra low-level configuration options" and configure
# "GPIO pins to set at micro-controller startup" to "!PC13".

# The "make flash" command does not work on the SKR mini E3. Instead,
# after running "make", copy the generated "out/klipper.bin" file to a
# file named "firmware.bin" on an SD card and then restart the SKR
# mini E3 with that SD card.

# See docs/Config_Reference.md for a description of parameters.

# Note: This board has a design flaw in its thermistor circuits that
# cause inaccurate temperatures (most noticeable at low temperatures).

[printer]
kinematics: cartesian
max_velocity: 150
max_accel: 3000
#max_accel_to_decel: 10000
max_z_velocity: 20
max_z_accel: 100
square_corner_velocity: 5.0


[input_shaper]
shaper_freq_x: 46.4
shaper_type_x: mzv
shaper_freq_y: 41.0
shaper_type_y: ei

[extruder]
step_pin: PB3
dir_pin: !PB4
enable_pin: !PD2
microsteps: 64  #16
full_steps_per_rotation: 400

# for MK8 Extruder
#rotation_distance: 33.500

# BMG Extruder
gear_ratio: 50:17
#rotation_distance: 22.172  #Increasing this value decreases the discharge volume.
rotation_distance: 22.172 #25.3
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PC8
sensor_type: NTC 100K MGB18-104F39050L32
sensor_pin: PA0
#control: pid
#pid_Kp: 21.527
#pid_Ki: 1.063
#pid_Kd: 108.982
min_temp: 0
max_temp: 300
pressure_advance: 0.01


#   Type of sensor - common thermistors are "EPCOS 100K B57560G104F",
#   "ATC Semitec 104GT-2"
#   "ATC Semitec 104NT-4-R025H42G"
#   "Generic3950"
#   "Honeywell 100K 135-104LAG-J01"
#   "NTC 100K MGB18-104F39050L32",
#   "SliceEngineering 450"
#   "TDK NTCG104LH104JT1". See the
#   "Temperature sensors" section for other sensors. This parameter
#   must be provided.



[bltouch]
sensor_pin = ^PC2
control_pin = PA1
x_offset = -40  
y_offset = -12
z_offset = 1.82 #1.95 #1.92 #1.52  ;1.44 ;1.14

[bed_mesh]
speed = 300
horizontal_move_z = 5
mesh_min = 10, 10
mesh_max = 190, 220
probe_count = 5, 5
mesh_pps = 2,2


[verify_heater heater_bed]
max_error: 200
#   The maximum "cumulative temperature error" before raising an
#   error. Smaller values result in stricter checking and larger
#   values allow for more time before an error is reported.
#   Specifically, the temperature is inspected once a second and if it
#   is close to the target temperature then an internal "error
#   counter" is reset; otherwise, if the temperature is below the
#   target range then the counter is increased by the amount the
#   reported temperature differs from that range. Should the counter
#   exceed this "max_error" then an error is raised. The default is
#   120.
#check_gain_time:
#   This controls heater verification during initial heating. Smaller
#   values result in stricter checking and larger values allow for
#   more time before an error is reported. Specifically, during
#   initial heating, as long as the heater increases in temperature
#   within this time frame (specified in seconds) then the internal
#   "error counter" is reset. The default is 20 seconds for extruders
#   and 60 seconds for heater_bed.
#hysteresis: 5
#   The maximum temperature difference (in Celsius) to a target
#   temperature that is considered in range of the target. This
#   controls the max_error range check. It is rare to customize this
#   value. The default is 5.
#heating_gain: 2
#   The minimum temperature (in Celsius) that the heater must increase
#   by during the check_gain_time check. It is rare to customize this
#   value. The default is 2.



[verify_heater extruder]
max_error: 240
#   The maximum "cumulative temperature error" before raising an
#   error. Smaller values result in stricter checking and larger
#   values allow for more time before an error is reported.
#   Specifically, the temperature is inspected once a second and if it
#   is close to the target temperature then an internal "error
#   counter" is reset; otherwise, if the temperature is below the
#   target range then the counter is increased by the amount the
#   reported temperature differs from that range. Should the counter
#   exceed this "max_error" then an error is raised. The default is
#   120.
#check_gain_time:
#   This controls heater verification during initial heating. Smaller
#   values result in stricter checking and larger values allow for
#   more time before an error is reported. Specifically, during
#   initial heating, as long as the heater increases in temperature
#   within this time frame (specified in seconds) then the internal
#   "error counter" is reset. The default is 20 seconds for extruders
#   and 60 seconds for heater_bed.
#hysteresis: 5
#   The maximum temperature difference (in Celsius) to a target
#   temperature that is considered in range of the target. This
#   controls the max_error range check. It is rare to customize this
#   value. The default is 5.
#heating_gain: 2
#   The minimum temperature (in Celsius) that the heater must increase
#   by during the check_gain_time check. It is rare to customize this
#   value. The default is 2.



[stepper_x]
step_pin: PB13
dir_pin: !PB12
enable_pin: !PB14
microsteps: 64 #16
rotation_distance: 40
endstop_pin: ^PC0
position_endstop: 0
position_max: 235
homing_speed: 50

[tmc2209 stepper_x]
uart_pin: PB15
run_current: 0.65

#run_current: 0.6 #0.580
##hold_current: 0.500
stealthchop_threshold: 0 #250

[stepper_y]
step_pin: PB10
dir_pin: !PB2
enable_pin: !PB11
microsteps: 64 #16
rotation_distance: 40
endstop_pin: ^PC1
position_endstop: 0
position_max: 235
homing_speed: 50

[tmc2209 stepper_y]
uart_pin: PC6
run_current: 0.65

#run_current: 0.6 #0.580
##hold_current: 0.500
stealthchop_threshold: 0 #250

[stepper_z]
step_pin: PB0
dir_pin: PC5
enable_pin: !PB1
microsteps: 64 #16
rotation_distance: 8
endstop_pin: probe:z_virtual_endstop  #defines the Z endstop as the BLtouch
#endstop_pin: ^PC2
#position_endstop: 0.0
position_max: 230
position_min: -3 # enable to use BLTouch
homing_speed: 10
homing_retract_dist: 5.0

[safe_z_home]
home_xy_position: 155,115
speed: 50
z_hop: 10
z_hop_speed: 15


[tmc2209 stepper_z]
uart_pin: PC10
run_current: 0.580
hold_current: 0.500
stealthchop_threshold: 0 #5


[tmc2209 extruder]
uart_pin: PC11
run_current: 0.650
hold_current: 0.500
stealthchop_threshold: 0 #5

[heater_bed]
heater_pin: PC9
sensor_type: ATC Semitec 104GT-2
sensor_pin: PC3
#control: pid
#pid_Kp: 54.027
#pid_Ki: 0.770
#pid_Kd: 948.182
min_temp: 0
max_temp: 120

[fan]
pin: PA8
kick_Start_time: 0.6

[mcu]
serial: /dev/serial/by-id/usb-Klipper_stm32f103xe_33FFDA054242363222770157-if00

[mcu rpi]
serial: /tmp/klipper_host_mcu

[adxl345]
cs_pin: rpi:None

[resonance_tester]
accel_chip: adxl345
probe_points:
    110,110,20

[virtual_sdcard]
#path:~/gcode_files
path:/home/pi/gcode_files


[temperature_sensor raspberry_pi]
sensor_type : temperature_host
min_temp:5
max_temp:110



[neopixel neo]
pin: PC7
chain_count: 15
initial_RED: 0.9
initial_GREEN: 0.9
initial_BLUE: 0.9
color_order: GRB #RGB


[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
gcode:
    ##### set defaults #####
    {% set x = params.X|default(230) %}       #edit to your park position
    {% set y = params.Y|default(230) %}       #edit to your park position
    {% set z = params.Z|default(10)|float %}  #edit to your park position
    {% set e = params.E|default(1) %}         #edit to your retract length
    ##### calculate save lift position #####
    {% set max_z = printer.toolhead.axis_maximum.z|float %}
    {% set act_z = printer.toolhead.position.z|float %}
    {% set lift_z = z|abs %}
    {% if act_z < (max_z - lift_z) %}
        {% set z_safe = lift_z %}
    {% else %}
        {% set z_safe = max_z - act_z %}
    {% endif %}
    ##### end of definitions #####
    PAUSE_BASE
    G91
    {% if printer.extruder.can_extrude|lower == 'true' %}
      G1 E-{e} F2100
    {% else %}
      {action_respond_info("Extruder not hot enough")}
    {% endif %}
    {% if "xyz" in printer.toolhead.homed_axes %}    
      G1 Z{z_safe}
      G90
      G1 X{x} Y{y} F6000
    {% else %}
      {action_respond_info("Printer not homed")}
    {% endif %}

[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
gcode:
    ##### set defaults #####
    {% set e = params.E|default(1) %}  #edit to your retract length
    #### get VELOCITY parameter if specified ####
    {% if 'VELOCITY' in params|upper %}
      {% set get_params = ('VELOCITY=' + params.VELOCITY)  %}
    {%else %}
      {% set get_params = "" %}
    {% endif %}
    ##### end of definitions #####
    G91
    {% if printer.extruder.can_extrude|lower == 'true' %}
      G1 E{e} F2100
    {% else %}
      {action_respond_info("Extruder not hot enough")}
    {% endif %}  
    RESUME_BASE {get_params}

[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
    TURN_OFF_HEATERS
    CANCEL_PRINT_BASE


#[gcode_macro M900]
#default_parameter_K: 0
#gcode:
#    SET_PRESSURE_ADVANCE ADVANCE={K}


[gcode_macro AUTO_LEVELING]
gcode:
    M140 S95
    M104 S240 T0
    M109 S240 T0
    M190 S95
      
    G28
    BED_MESH_CALIBRATE
    SAVE_CONFIG
    G28
    
[gcode_macro MOTOR_OFF]
gcode:
    M18    

[static_digital_output usb_pullup_enable]
pins: !PC13

[pause_resume]
recover_velocity: 50

[gcode_arcs]
resolution: 0.1

[display_status]


[board_pins]
aliases:
    # EXP1 header
    EXP1_1=PB5, EXP1_3=PA9,   EXP1_5=PA10, EXP1_7=PB8, EXP1_9=<GND>,
    EXP1_2=PB6, EXP1_4=<RST>, EXP1_6=PB9,  EXP1_8=PB7, EXP1_10=<5V>

[display]
lcd_type: st7920
cs_pin: EXP1_7
sclk_pin: EXP1_6
sid_pin: EXP1_8
encoder_pins: ^EXP1_5, ^EXP1_3
click_pin: ^!EXP1_2
 
[output_pin beeper]
pin: EXP1_1

[gcode_macro POWER_OFF_PRINTER]
gcode:
  {action_call_remote_method("set_device_power",
                                device="Ende3Power",
                                state="off")}





[gcode_macro PA_CAL]

# https://note.com/eitoku_note/n/n78f0d240940a#33b2b8db-c7b4-419a-a459-8c5e06125f04
# Pressure Advance Simple Test macro, using .4mm nozzle.
# Usage: PA_CAL BED=100 EXTRUDER=240 PA_START=0.03 PA_STEP=0.002
# Or with no parameters as: PA_CAL, this would execute as
# PA_CAL BED=100 EXTRUDER=250 PA_START=0.0 PA_STEP=0.005
# First prints a line with current set PA, then prints 20 line segments
# starting with PA_START, increasing each line by PA_STEP.
# Based http://realdeuce.github.io/Voron/PA/pressure_advance.html
description: Tune Pressure Advance

gcode:
    #   Get Boundaries
    
    {% if printer.idle_timeout.state == "Printing" or printer.pause_resume.is_paused %}
        {action_respond_info("Cannot do that while printing")}
	
    {% else %}
        {% set BED = params.BED|default(100)|float %}
        {% set EXTRUDER = params.EXTRUDER|default(250)|float %}
        {% set PA_START = params.PA_START|default(0.0)|float %}
        {% set PA_STEP = params.PA_STEP|default(0.005)|float %}
        {% set NZL = printer.configfile.config["extruder"]["nozzle_diameter"]|float %}
        {% set E20 = (0.1147475 * NZL) * 20|float %}
        {% set E40 = (0.1147475 * NZL) * 40|float %}
        {% set X_MID = printer.configfile.config["stepper_x"]["position_max"]|float / 2.0 %}
        {% set Y_MID = printer.configfile.config["stepper_y"]["position_max"]|float / 2.0 %}
        {% set h = NZL * 0.625|float %}    ; layer height
        {% set EANC = (0.415751687 * NZL * h) * 105|float %}
        {% set accel = printer.toolhead.max_accel|float %}
        {% set deaccel = printer.toolhead.max_accel_to_decel|float %}
        {action_respond_info("PA_CAL Nozzle:%.1f  layer height:%.2f  accel:%d  deaccel:%d" % (NZL, h, accel, deaccel)) }   

        #PRINT_START BED_TEMP={BED} EXTRUDER_TEMP={EXTRUDER}
        M140 S{BED}
        M104 S{EXTRUDER} T0
        M109 S{EXTRUDER} T0
        M190 S{BED}

        G28

        G21 ; Millimeter units
        G90 ; Absolute XYZ
        M83 ; Relative E
        SET_VELOCITY_LIMIT ACCEL={accel} ACCEL_TO_DECEL={deaccel}
        G92 E0
        M106 S0 

        ;print anchor frame
        G1 Z{h} F300 
        G1 X{X_MID-40} Y{Y_MID-55-2} F9000      ;move_to_start
        G1 X{X_MID-40} Y{Y_MID-40+5*19+2} E{EANC} F1500  ;print_line
        G1 X{X_MID-40+0.48} Y{Y_MID-40+5*19+2} F9000  ;move_to_start
        G1 X{X_MID-40+0.48} Y{Y_MID-55-2} E{EANC} F1500  ;print_line
        G1 E-0.75 F1800                        ; retract
        G1 X{X_MID+40} Y{Y_MID-55-2} F9000     ; move_to_start
        G1 E0.75 F1800                         ; un-retract
        G1 X{X_MID+40} Y{Y_MID-40+5*19+2} E{EANC} F1500 ;print_line
        G1 X{X_MID+40-0.48} Y{Y_MID-40+5*19+2} F9000    ; move_to_start
        G1 X{X_MID+40-0.48} Y{Y_MID-55-2} E{EANC} F1500  ;print_line
        G1 E-0.75 F1800                        ; retract
        G1 Z1 F300
		
        G1 X{(X_MID-40)} Y{(Y_MID-55)} F30000          ; move to start position
        G1 Z{h} F300                                   ; move to layer height
        G1 E0.75 F1800                                 ; un-retract
        G1 X{(X_MID-20)} Y{(Y_MID-55)} E{E20} F300     ; print line part one
        G1 X{(X_MID+20)} Y{(Y_MID-55)} E{E40} F9000    ; print line part two
        G1 X{(X_MID+40)} Y{(Y_MID-55)} E{E20} F300     ; print line part three
        G1 E-0.75 F1800                                ; retract
        G1 Z1 F300                                     ; Move above layer height  
		
        {% for i in range(0, 20) %}
            SET_PRESSURE_ADVANCE ADVANCE={PA_START + (i * PA_STEP)} ; set Pressure Advance
            M117 Testing Pressure Advance at: {PA_START + (i * PA_STEP)}
            G1 X{(X_MID-40)} Y{(Y_MID-40)+(5*i)} F30000           ; move to start position
            G1 Z{h} F300                                          ; move to layer height
            G1 E0.75 F1800                                        ; un-retract
            G1 X{(X_MID-20)} Y{(Y_MID-40)+(5*i)} E{E20} F300      ; print line part one
            G1 X{(X_MID+20)} Y{(Y_MID-40)+(5*i)} E{E40} F9000     ; print line part two
            G1 X{(X_MID+40)} Y{(Y_MID-40)+(5*i)} E{E20} F300      ; print line part three
            G1 E-0.75 F1800                                       ; retract
            G1 Z1 F300                                            ; Move above layer height  
        {% endfor %}
	
	    M117 Find best line and multiply it by ({PA_START} + (line * {PA_STEP}) ) to find your PA setting.
 

    #---------------------------------------------------
      M104 S0 ; turn off extruder
      M140 S0 ; turn off bed
      G91 ; use relative coordinates
      G1 Z5 F5000 ; lift nozzle by 0.6mm
      G90 ; use absolute coordinates
      G28 X0 ; home X axis
      G1 Y180 ; move Y axis to end position

      M84 ; disable motors

      {% endif %}

#[delayed_gcode delayed_printer_off]
#initial_duration: 0.
#gcode:
#  {% if printer.idle_timeout.state == "Idle" %}
#    POWER_OFF_PRINTER
#  {% endif %}

#[idle_timeout]
#gcode:
#  M84
#  TURN_OFF_HEATERS
#  UPDATE_DELAYED_GCODE ID=delayed_printer_off DURATION=540

# See the sample-lcd.cfg file for definitions of common LCD displays.

#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# 	  -0.070000, -0.035000, -0.040000, -0.042500, 0.015000
#*# 	  -0.040000, 0.020000, 0.070000, 0.075000, 0.077500
#*# 	  -0.060000, -0.017500, 0.002500, 0.042500, 0.092500
#*# 	  -0.120000, -0.042500, 0.060000, 0.032500, 0.062500
#*# 	  -0.197500, -0.155000, -0.130000, -0.097500, -0.027500
#*# tension = 0.2
#*# min_x = 10.0
#*# algo = lagrange
#*# y_count = 5
#*# mesh_y_pps = 2
#*# min_y = 10.0
#*# x_count = 5
#*# max_y = 220.0
#*# mesh_x_pps = 2
#*# max_x = 190.0
#*#
#*# [extruder]
#*# control = pid
#*# pid_kp = 28.151
#*# pid_ki = 1.604
#*# pid_kd = 123.512
#*#
#*# [heater_bed]
#*# control = pid
#*# pid_kp = 76.223
#*# pid_ki = 2.126
#*# pid_kd = 683.151


[mcu]の値は

ls /dev/serial/by-id/*

で取得した値に変える。

pi@mainsailos:~/klipper $ ls /dev/serial/by-id/*
/dev/serial/by-id/usb-Klipper_stm32f103xe_33FFDA054242363222770157-if00

こんな感じで返ってきた値を使う。


もし気に入って頂けたのであればサポートお願いします。 今後の励みになります!