いんくらyochさんの日記

興味あることの忘備録

RAMPS-FDv2をKlipper化

プリンタ3号機は1号機のOctopiと共用していたが、印刷中に1秒ほど停止する事象が発生するようになった。
停止するとその部分がブロブになって印刷品質が悪くなるため、Octopiのラズパイを3から4に交換することを考え4を買ったものの、1号機は3のままで動かし、よりパワーのある4はKlipperを入れて3号機を動かすことにした。
Klipperの導入はKIAUHを使ってFluiddと一緒にインストールした。
あと、RAMPS-FDv2のマザーであるAruduino DUEにファームをフラッシュするのだが、menuconfigを実行した際に選択するポートはプログラミングポートを使用の際はSerialで、ネイティブポートを使用の際はUSBを選択しなければならないらしく、ここで時間を要した。(フォーラムに記述があるだけ)

xChangeを使用したシングルノズルのマルチエクストルーダ構成のprinter.cfgは以下の内容で一応動いている。

# This file is an example config file for corexy (and also h-bot)
# style printers. One may copy and edit this file to configure a new
# corexy printer.

# DO NOT COPY THIS FILE WITHOUT CAREFULLY READING AND UPDATING IT
# FIRST. Incorrectly configured parameters may cause damage.

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

[board_pins arduino-due]
aliases:
    ar0=PA8,   ar1=PA9,   ar2=PB25,  ar3=PC28, 
    ar5=PC25,  ar6=PC24,  ar7=PC23,  ar8=PC22,  ar9=PC21,
    ar10=PA28, ar11=PD7,  ar12=PD8,  ar13=PB27, ar14=PD4,
    ar15=PD5,  ar18=PA11, ar19=PA10,
    ar20=PB12, ar21=PB13, ar22=PB26, ar24=PA15,
    ar26=PD1,  ar28=PD3,
    ar30=PD9,  ar32=PD10, ar34=PC2,  ar36=PC4,
    ar39=PC7,  ar38=PC6,  ar60=PA3,
    ar40=PC8,  ar41=PC9,  ar42=PA19, ar43=PA20, ar44=PC19,
    ar45=PC18, ar46=PC17, ar47=PC16, ar48=PC15, 
    ar50=PC13, ar51=PC12, ar52=PB21, ar53=PB14, ar54=PA16,
    ar55=PA24, ar56=PA23, ar57=PA22, ar58=PA6,  ar59=PA4,
    ar61=PA2,  ar62=PB17, ar63=PB18, ar64=PB19,
    ar65=PB20, ar66=PB15, ar67=PB16, ar68=PA1,  ar69=PA0,
    ar70=PA17, ar71=PA18, ar72=PC30, ar73=PA21, 
    ar77=PA28, ar78=PB23,
    analog0=PA16, analog1=PA24, analog2=PA23, analog3=PA22, analog4=PA6,
    analog5=PA4, analog6=PA3, analog7=PA2, analog8=PB17, analog9=PB18,
    analog10=PB19, analog11=PB20

[board_pins]
aliases:
    # Common EXP1 header found on many "all-in-one" ramps clones
    EXP1_1=PC5, EXP1_3=PA12, EXP1_5=PA14 , EXP1_7=PD2, EXP1_9=<GND>,
    EXP1_2=PC3, EXP1_4=PA13, EXP1_6=PD0  , EXP1_8=PD6, EXP1_10=<5V>,
    # EXP2 header
    EXP2_1=PA25, EXP2_3=PA7 , EXP2_5=PC1 , EXP2_7=PC14, EXP2_9=<GND>,
    EXP2_2=PA27, EXP2_4=PA29, EXP2_6=PA26, EXP2_10=<RST>

[stepper_x]
step_pin: ar63
dir_pin: ar62
enable_pin: !ar48
microsteps: 16
rotation_distance: 16
endstop_pin: ^!ar22
position_endstop: 0
position_max: 240

homing_speed: 50
homing_retract_dist: 2.0
homing_retract_speed: 10
homing_positive_dir: false

[tmc2208 stepper_x]
uart_pin: ar19
tx_pin: ar18
interpolate: True
run_current: 1.000
sense_resistor: 0.110
stealthchop_threshold: 0

[stepper_y]
step_pin: ar65
dir_pin: ar64
enable_pin: !ar46
microsteps: 16
rotation_distance: 16
endstop_pin: ^!ar24
position_endstop: 0
position_max: 194

homing_speed: 50
homing_retract_dist: 2.0
homing_retract_speed: 10
homing_positive_dir: false

[tmc2208 stepper_y]
uart_pin: ar15
tx_pin: ar14
interpolate: True
run_current: 1.000
sense_resistor: 0.110
stealthchop_threshold: 0

[stepper_z]
step_pin: ar67
dir_pin: ar66
enable_pin: !ar44
microsteps: 16
rotation_distance: 8
endstop_pin: ^ar34
position_endstop: 309
position_max: 309

homing_speed: 25
homing_retract_dist: 1.0
homing_retract_speed: 5
homing_positive_dir: true

[stepper_z1]
step_pin: ar32
dir_pin: ar47
enable_pin: !ar45
microsteps: 16
rotation_distance: 8
endstop_pin: ^ar38

[homing_override]
gcode:
  G28 Z
  G28 X0 Y0
axes: Z

[input_shaper]
shaper_freq_x: 138.4
shaper_freq_y: 92.3

[extruder]
step_pin: ar36
dir_pin: ar28
enable_pin: !ar42
microsteps: 16
rotation_distance: 5.586 #4.637
max_extrude_only_velocity: 10
max_extrude_only_accel: 3000
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: ar9
sensor_type: EPCOS 100K B57560G104F
sensor_pin: analog1
pullup_resistor: 4700
#inline_resistor: 4700
#control: pid
#pid_Kp: 22.2
#pid_Ki: 1.08
#pid_Kd: 114
min_temp: 0
max_temp: 275

# Script to change back to the main extruder
[gcode_macro T0]
gcode:
    SYNC_EXTRUDER_MOTION EXTRUDER=my_extra_stepper MOTION_QUEUE= # Remove other extruders from motion queue
    SYNC_EXTRUDER_MOTION EXTRUDER=extruder MOTION_QUEUE=extruder # Add e1 to the motion queue
    SET_GCODE_OFFSET Z_ADJUST=4.9
    SET_PRESSURE_ADVANCE EXTRUDER=extruder ADVANCE=0.17

# Secondary extruder
[extruder_stepper my_extra_stepper]
extruder: 
step_pin: ar43
dir_pin: ar41
enable_pin: !ar39
microsteps: 16
rotation_distance: 8.83

# Script to activate second extruder
[gcode_macro T1]
gcode:
    SYNC_EXTRUDER_MOTION EXTRUDER=extruder MOTION_QUEUE= # Remove other extruders from motion queue
    SYNC_EXTRUDER_MOTION EXTRUDER=my_extra_stepper MOTION_QUEUE=extruder # Add e1 to the motion queue
    SET_GCODE_OFFSET Z_ADJUST=3.1
    SET_PRESSURE_ADVANCE EXTRUDER=my_extra_stepper ADVANCE=0.02

[gcode_macro T2]
gcode:
    SYNC_EXTRUDER_MOTION EXTRUDER=extruder MOTION_QUEUE= # Remove other extruders from motion queue
    SYNC_EXTRUDER_MOTION EXTRUDER=my_extra_stepper MOTION_QUEUE=extruder # Add e1 to the motion queue
    SET_GCODE_OFFSET Z_ADJUST=3.1

[bltouch]
sensor_pin: ^ar26
control_pin: ar7
x_offset: 0
y_offset: 28
z_offset: 4.05

[bed_mesh]
speed: 120
horizontal_move_z: 7
mesh_min: 10, 28
mesh_max: 230, 175
probe_count: 5, 3
mesh_pps: 2, 3
algorithm: bicubic
bicubic_tension: 0.2
fade_start: 1
fade_end: 10
fade_target: 0

[heater_bed]
heater_pin: ar8
sensor_type: EPCOS 100K B57560G104F
sensor_pin: analog0
pullup_resistor: 4700
#inline_resistor: 4700
#control: watermark
min_temp: 0
max_temp: 120

[fan]
pin: ar12
max_power: 1.0
shutdown_speed: 0
cycle_time: 0.010
kick_start_time: 0.100
off_below: 0.0

[heater_fan my_nozzle_fan]
pin: ar11
max_power: 1.0
shutdown_speed: 0
heater: extruder
heater_temp: 100.0
fan_speed: 0.9

[controller_fan my_controller_fan]
pin:ar2
max_power:1.0
shutdown_speed:0.0
fan_speed: 0.8

[mcu]
serial: /dev/serial/by-id/usb-Arduino__www.arduino.cc__Arduino_Due_Prog._Port_14238313834351A02120-if00
baud: 115200

[printer]
kinematics: corexy
max_velocity: 300
max_accel: 9000
max_z_velocity: 41
max_z_accel: 100

######################################################################
# MKS Mini 12864 LCD
######################################################################
[display]
lcd_type: uc1701
cs_pin: EXP1_6
a0_pin: EXP1_7
contrast: 40
encoder_pins: ^EXP2_5, ^EXP2_3
click_pin: ^!EXP1_2
## Some micro-controller boards may require an spi bus to be specified:
#spi_bus: spi
## Alternatively, some micro-controller boards may work with software spi:
spi_software_miso_pin: EXP2_1
spi_software_mosi_pin: EXP2_6
spi_software_sclk_pin: EXP2_2

[output_pin beeper]
pin: EXP1_1

[force_move]
enable_force_move: true

[virtual_sdcard]
path: /home/pi/printer_data/gcodes

[display_status]

[pause_resume]

[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
# change this if you need more or less extrusion
variable_extrude: 1.0
gcode:
  ##### read E from pause macro #####
  {% set E = printer["gcode_macro PAUSE"].extrude|float %}
  ##### set park positon for x and y #####
  # default is your max posion from your printer.cfg
  {% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %}
  {% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
  ##### calculate save lift position #####
  {% set max_z = printer.toolhead.axis_maximum.z|float %}
  {% set act_z = printer.toolhead.position.z|float %}
  {% if act_z < (max_z - 2.0) %}
      {% set z_safe = 2.0 %}
  {% 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} F900
    G90
    G1 X{x_park} Y{y_park} F6000
  {% else %}
    {action_respond_info("Printer not homed")}
  {% endif %} 

[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
gcode:
  ##### read E from pause macro #####
  {% set E = printer["gcode_macro PAUSE"].extrude|float %}
  #### get VELOCITY parameter if specified ####
  {% if 'VELOCITY' in params|upper %}
    {% set get_params = ('VELOCITY=' + params.VELOCITY)  %}
  {%else %}
    {% set get_params = "" %}
  {% endif %}
  ##### end of definitions #####
  {% if printer.extruder.can_extrude|lower == 'true' %}
    G91
    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

#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [extruder]
#*# control = pid
#*# pid_kp = 23.500
#*# pid_ki = 1.205
#*# pid_kd = 114.562
#*#
#*# [heater_bed]
#*# control = pid
#*# pid_kp = 48.861
#*# pid_ki = 2.378
#*# pid_kd = 251.021
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# 	  0.082500, 0.042500, -0.010000, 0.020000, 0.070000
#*# 	  0.045000, 0.042500, 0.012500, 0.037500, -0.000000
#*# 	  0.030000, 0.057500, 0.022500, 0.045000, 0.022500
#*# x_count = 5
#*# y_count = 3
#*# mesh_x_pps = 2
#*# mesh_y_pps = 3
#*# algo = bicubic
#*# tension = 0.2
#*# min_x = 10.0
#*# max_x = 230.0
#*# min_y = 28.0
#*# max_y = 175.0