見出し画像

Klipper をAnycubic MEGA Proに導入メモ

0.機器構成とか

Anycubic MEGA Pro
モータードライバは標準でXYはTMC2208だが、ZとEもTMC2208に換装済
3D Touch -(BL TOUCHのクローン)を使用
Raspberry 3B (Mainsail導入済)
レーザーは使う気無し
MailsailOSで運用
ラズパイへの導入は他を見て

1.ファームウェアのコンパイルとフラッシュ

TeraTermなどでRasberryPiのMailsailに接続

cd ~/klipper/
make menuconfig

画像1

make

完了したら PCとプリンタをUSBで接続し/home/pi/klipper/out/にある
klipper.elf.hexを PurusaSlicer や Repetier-Hostを使ってフラッシュ

WinSCPがあると便利

2.Printer.cfgの編集

Printer.cfgの例 ここから持ってきた物をベースに編集

注)このプリンタはZが2軸なのでBLTouchをプローブをZのリミットスイッチとして使うことが出来ない。だから原点はZ軸のマイクロスイッチになる。という事はプローブを0として調整ではない。
Z_Offsetの値は、マイクロスイッチとノズルの差になるのか??
それともあくまでプローブとの差であって、[Stepper_Z]のposition_endstop: の値で調整するのか?
その辺がいまいち腹落ちできていない。したがって設定値は参考にしない方がいい。誰か教えて下さい。

※TMC2208を使っているのでTMC2209関連はすべてコメントアウト
※モータを逆回転させるためには #dir_pin: !ar55の様に「!」を付けると
 逆回転になる


# With Anycubic MEGA Pro, Z and E are also converted to TMC2208 and optimized 
#for machines that have been converted to direct drives.

# the firmware should be compiled for the AVR atmega2560.


[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 1400
max_accel_to_decel: 700

max_z_velocity: 20
max_z_accel: 60
square_corner_velocity: 5.0


[input_shaper]
shaper_freq_x: 42.9
shaper_freq_y: 38.46
shaper_type: mzv


[bltouch]
sensor_pin: ^ar2
control_pin: ar11
x_offset: -30.1
y_offset: -37.6
z_offset: 1.5

[bed_mesh]
speed: 150
horizontal_move_z: 8
mesh_min: 10,10
mesh_max: 178,165
probe_count: 4,4

[extruder]
step_pin: ar26
dir_pin: ar28
enable_pin: !ar24

full_steps_per_rotation: 200
microsteps: 16

# BMG Extruder 
gear_ratio: 50:17
#rotation_distance: 22.172 #Increasing this value decreases the discharge volume.
rotation_distance: 23.157


nozzle_diameter: 0.400
filament_diameter: 1.750
max_extrude_only_velocity: 50
max_extrude_only_accel: 3000
max_extrude_only_distance: 120.0
heater_pin: ar10
sensor_type: ATC Semitec 104GT-2
sensor_pin: analog13

min_temp: 0
max_temp: 250
pressure_advance: 0.04 # eSun + BMG


[stepper_z]
step_pin: ar46
#dir_pin: ar48  #逆回転
dir_pin: !ar48
enable_pin: !ar62
microsteps: 16
rotation_distance: 8
endstop_pin: ^!ar18
#endstop_pin: probe:z_virtual_endstop #defines the Z endstop as the BLtouch
position_endstop: 1.21 ;0.12  ;0.17   ;The smaller this number, the larger the clearance between the bed and the nozzle.
position_min: -3   
position_max: 150
homing_speed: 10.0
homing_retract_dist: 8.0

[heater_fan extruder_fan]
pin: ar44

[heater_bed]
heater_pin: ar8
sensor_type: EPCOS 100K B57560G104F
sensor_pin: analog14
#control: pid
#pid_Kp=76.304
#pid_Ki=1.657
#pid_Kd=878.444
min_temp: 0
max_temp: 110


[verify_heater heater_bed]
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.

[verify_heater extruder]
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.


[stepper_x]
step_pin:ar54
dir_pin: ar55
enable_pin: !ar38
microsteps: 16
rotation_distance: 40
endstop_pin: ^!ar3
position_min: 0
position_endstop: 0
position_max: 210
homing_speed: 80.0

[stepper_y]
step_pin: ar60
dir_pin: !ar61
enable_pin: !ar56
microsteps: 16
rotation_distance: 40
endstop_pin: ^!ar42
position_endstop: 0
position_max: 210
homing_speed: 80.0

#[safe_z_home]  
#home_xy_position: 100,100
#speed: 50
#z_hop: 10
#z_hop_speed: 15


[stepper_z1]
step_pin: ar36
dir_pin: !ar34
enable_pin: !ar30
microsteps: 16
rotation_distance: 8
endstop_pin: ^!ar43

[fan]
pin: ar9

[mcu]
serial: /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0
#pin_map: arduino

# Arduino aliases for atmega2560/1280 (Arduino mega) boards
[board_pins arduino-mega]
aliases:
   ar0=PE0, ar1=PE1, ar2=PE4, ar3=PE5, ar4=PG5,
   ar5=PE3, ar6=PH3, ar7=PH4, ar8=PH5, ar9=PH6,
   ar10=PB4, ar11=PB5, ar12=PB6, ar13=PB7, ar14=PJ1,
   ar15=PJ0, ar16=PH1, ar17=PH0, ar18=PD3, ar19=PD2,
   ar20=PD1, ar21=PD0, ar22=PA0, ar23=PA1, ar24=PA2,
   ar25=PA3, ar26=PA4, ar27=PA5, ar28=PA6, ar29=PA7,
   ar30=PC7, ar31=PC6, ar32=PC5, ar33=PC4, ar34=PC3,
   ar35=PC2, ar36=PC1, ar37=PC0, ar38=PD7, ar39=PG2,
   ar40=PG1, ar41=PG0, ar42=PL7, ar43=PL6, ar44=PL5,
   ar45=PL4, ar46=PL3, ar47=PL2, ar48=PL1, ar49=PL0,
   ar50=PB3, ar51=PB2, ar52=PB1, ar53=PB0, ar54=PF0,
   ar55=PF1, ar56=PF2, ar57=PF3, ar58=PF4, ar59=PF5,
   ar60=PF6, ar61=PF7, ar62=PK0, ar63=PK1, ar64=PK2,
   ar65=PK3, ar66=PK4, ar67=PK5, ar68=PK6, ar69=PK7,
   analog0=PF0, analog1=PF1, analog2=PF2, analog3=PF3, analog4=PF4,
   analog5=PF5, analog6=PF6, analog7=PF7, analog8=PK0, analog9=PK1,
   analog10=PK2, analog11=PK3, analog12=PK4, analog13=PK5, analog14=PK6,
   analog15=PK7,
   # Marlin adds these additional aliases
   ml70=PG4, ml71=PG3, ml72=PJ2, ml73=PJ3, ml74=PJ7,
   ml75=PJ4, ml76=PJ5, ml77=PJ6, ml78=PE2, ml79=PE6,
   ml80=PE7, ml81=PD4, ml82=PD5, ml83=PD6, ml84=PH2,
   ml85=PH7

[heater_fan stepstick_fan]
pin: ar7

[endstop_phase]


[gcode_arcs]
resolution: 0.1

[display_status]

[pause_resume]
recover_velocity: 60.
#   When capture/restore is enabled, the speed at which to return to
#   the captured position (in mm/s).  Default is 50.0 mm/s.

# Filament Switch Sensor.  Support for filament insert and runout detection
# using a switch sensor, such as an endstop switch.

[filament_switch_sensor filament_sensor]
pause_on_runout: false #True
#   When set to True, a PAUSE will execute immediately after a runout
#   is detected. Note that if pause_on_runout is False and the
#   runout_gcode is omitted then runout detection is disabled. Default
#   is True.
runout_gcode:
#    M118 Filament Runout Detected
#   A list of G-Code commands to execute after a filament runout is
#   detected. See docs/Command_Templates.md for G-Code format. If
#   pause_on_runout is set to True this G-Code will run after the
#   PAUSE is complete. The default is not to run any G-Code commands.
insert_gcode:
#    M118 Filament Load Detected
#   A list of G-Code commands to execute after a filament insert is
#   detected. See docs/Command_Templates.md for G-Code format. The
#   default is not to run any G-Code commands, which disables insert
#   detection.
#event_delay: 3.0
#   The minimum amount of time in seconds to delay between events.
#   Events triggered during this time period will be silently
#   ignored. The default is 3 seconds.
#pause_delay: 0.5
#   The amount of time to delay, in seconds, between the pause command
#   dispatch and execution of the runout_gcode.  It may be useful to
#   increase this delay if Octoprint exhibits strange pause behavior.
#   Default is 0.5 seconds.
switch_pin: ^!ar19
#   The pin on which the switch is connected. This parameter must be
#   provided.

# BLTouch probe. One may define this section (instead of a probe
# section) to enable a BLTouch probe. A virtual
# "probe:z_virtual_endstop" pin is also created (see the "probe"
# section above for the details).


[respond]

[virtual_sdcard]
path: ~/gcode_files


[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 AUTO_LEVELING]
gcode:
   M140 S90
   M104 S240 T0
   M109 S240 T0
   M190 S90
   
   G28
   BED_MESH_CLEAR
   BED_MESH_CALIBRATE    
   #BED_MESH_PROFILE LOAD=default

   SAVE_CONFIG
   G28
   
[gcode_macro MOTOR_OFF]
gcode:
   M18   

[gcode_macro G29]
gcode:
   G28
   BED_MESH_CALIBRATE
   SAVE_CONFIG
   

######################################################################
# Beeper
######################################################################

# GCODE macro.  Usage:
#   M300 [S<Hz>]  [P<ms>] 
#   S the tone frequency, P is the tone duration
# 
#   for Exsample 
#   M300 S440 P1000  :440Hz 1000ms

[output_pin BEEPER_Pin]
pin: ar31
pwm: TRUE ; A piezo beeper needs a PWM signal, a DC buzzer doesn't.
value: 0 ; Silent at power on, set to 1 if active low.
shutdown_value: 0 ; Disable at emergency shutdown
cycle_time: 0.001 ; PWM frequency : 0.001 = 1ms will give a base tone of 1kHz
scale: 1

[gcode_macro M300]
gcode:
   {% set S = params.S|default(1000)|int %} ; S sets the tone frequency
   {% set P = params.P|default(1000)|int %} ; P sets the tone duration

   {% set L = 0.5 %} ; L varies the PWM on time, close to 0 or 1 the tone gets a bit quieter. 0.5 is a symmetric waveform

   {% if S <= 0 %} ; dont divide through zero
       {% set F = 1 %}
       {% set L = 0 %}
   {% elif S >= 10000 %} ;max frequency set to 10kHz
       {% set F = 0 %}
   {% else %}
       {% set F = 1/S %} ;convert frequency to seconds 
   {% endif %}

       SET_PIN PIN=BEEPER_Pin VALUE={L} CYCLE_TIME={F} ;Play tone
       G4 P{P} ;tone duration
       SET_PIN PIN=BEEPER_Pin VALUE=0


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

[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


#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# 	-0.487500, -0.395000, -0.380000, -0.445000
#*# 	-0.477500, -0.377500, -0.365000, -0.445000
#*# 	-0.452500, -0.355000, -0.342500, -0.420000
#*# 	-0.417500, -0.337500, -0.342500, -0.435000
#*# tension = 0.2
#*# min_x = 10.0
#*# algo = lagrange
#*# y_count = 4
#*# mesh_y_pps = 2
#*# min_y = 10.0
#*# x_count = 4
#*# max_y = 164.97
#*# mesh_x_pps = 2
#*# max_x = 178.0
#*#
#*# [heater_bed]
#*# control = pid
#*# pid_kp = 74.254
#*# pid_ki = 2.012
#*# pid_kd = 684.991
#*#
#*# [extruder]
#*# control = pid
#*# pid_kp = 22.800
#*# pid_ki = 0.859
#*# pid_kd = 151.338

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