bassamanator

klipper

Dec 25th, 2021
1,487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 8.78 KB | None | 0 0
  1. #
  2. # Klipper configuration file for Anycubic i3 MEGA S
  3. #
  4. # This config file contains settings of all printer pins (steppers, sensors) for Anycubic i3 mega S in the factory configuration
  5. # Klipper firmware should be compiled for the atmega2560
  6. #
  7. # Config file includes
  8. #  - Original or 2208(2209) rotated by cabel drivers
  9. #  - Mesh bed leveling: BLtouch (3DTouch sensor from Triangelab)
  10. #  - Manual meshed bed leveling (commented out)
  11. #  - 'virtual_sdcard' for fast printing without gaps
  12. #  - Beeper through M300 gcode
  13. #  - Pause/Resume through M600 for filament change
  14. #
  15. # Home position is determined by 3DTouch. Z limit switches are not used.
  16. #
  17. # The latest version of the config reference is also available online at:
  18. # https://www.klipper3d.org/Config_Reference.html
  19.  
  20.  
  21. [stepper_x]
  22. step_pin = ar54
  23. dir_pin = ar55
  24. enable_pin = !ar38
  25. #step_distance = .0125
  26. rotation_distance = 40
  27. microsteps = 16
  28. full_steps_per_rotation = 200
  29. endstop_pin = ^!ar3
  30. position_min = -5
  31. position_endstop = -5
  32. position_max = 216
  33. homing_speed = 30
  34. homing_retract_dist = 5
  35. second_homing_speed = 10
  36.  
  37.  
  38. [stepper_y]
  39. step_pin = ar60
  40. dir_pin = !ar61
  41. enable_pin = !ar56
  42. #step_distance = .0125
  43. rotation_distance = 40
  44. microsteps = 16
  45. full_steps_per_rotation = 200
  46. endstop_pin = ^!ar42
  47. position_endstop = 0
  48. position_max = 217
  49. homing_speed = 50
  50. homing_retract_dist = 5
  51. second_homing_speed = 10
  52.  
  53.  
  54. [stepper_z]
  55. step_pin = ar46
  56. dir_pin = !ar48
  57. enable_pin = !ar62
  58. # step_distance = .0025
  59. rotation_distance = 2
  60. microsteps = 16
  61. full_steps_per_rotation = 200
  62. ## for 3dtouch. comment for mannual mesh bed leveling
  63. endstop_pin = probe:z_virtual_endstop
  64. ## uncomment below for manual mesh bed leveling and to enable Z limit switches
  65. endstop_pin = ^!ar18
  66. position_endstop = 0.0
  67. position_max = 160
  68. position_min = -0.09
  69. homing_speed = 10
  70. homing_retract_dist = 5
  71. second_homing_speed = 3
  72.  
  73.  
  74. [stepper_z1]
  75. step_pin = ar36
  76. dir_pin = !ar34
  77. ## uncomment below for manual mesh bed leveling and to enable Z limit switches
  78. endstop_pin = ^!ar43
  79. enable_pin = !ar30
  80. rotation_distance = 2
  81. microsteps = 16
  82. full_steps_per_rotation = 200
  83.  
  84.  
  85. [extruder]
  86. step_pin = ar26
  87. dir_pin = !ar28
  88. enable_pin = !ar24
  89. rotation_distance = 7.740
  90. microsteps = 16
  91. full_steps_per_rotation = 200
  92. nozzle_diameter = 0.400
  93. filament_diameter = 1.750
  94. heater_pin = ar10
  95. sensor_type = ATC Semitec 104GT-2
  96. sensor_pin = analog13
  97. min_temp = 0
  98. max_temp = 285
  99. max_extrude_only_distance = 150.0
  100. smooth_time = 1
  101. min_extrude_temp = 180
  102. pressure_advance = 0.1
  103. max_extrude_cross_section = 150
  104.  
  105.  
  106. [heater_fan extruder_fan]
  107. pin = ar44
  108.  
  109. [heater_bed]
  110. heater_pin = ar8
  111. sensor_type = EPCOS 100K B57560G104F
  112. sensor_pin = analog14
  113. min_temp = 0
  114. max_temp = 110
  115. smooth_time = 1
  116. control = pid
  117.  
  118.  
  119. [fan]
  120. pin = ar9
  121.  
  122. [mcu]
  123. serial = /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0
  124.  
  125. [printer]
  126. kinematics = cartesian
  127. max_velocity = 300
  128. max_accel = 1500
  129. max_accel_to_decel = 1500
  130. max_z_velocity = 7
  131. max_z_accel = 190
  132. square_corner_velocity = 5
  133.  
  134.  
  135. ## do your own measurement
  136. ## https://www.klipper3d.org/Resonance_Compensation.html
  137. #[input_shaper]
  138. #shaper_type_x = 3hump_ei
  139. #shaper_freq_x = 73.0
  140. #shaper_type_y = 3hump_ei
  141. #shaper_freq_y = 60.0
  142.  
  143.  
  144. [heater_fan stepstick_fan]
  145. pin = ar7
  146.  
  147. [bltouch]
  148. sensor_pin = ^ar2
  149. control_pin = ar11
  150. x_offset = 21.00
  151. y_offset = -17.00
  152. z_offset = 0.43
  153. # M851 X21.00 Y-17.00 Z-0.43
  154.  
  155. [safe_z_home]
  156. home_xy_position = 108,108.5
  157. speed = 100
  158. z_hop = 5
  159. z_hop_speed = 10
  160.  
  161.  
  162. ## bltouch mesh bed leveling
  163. [bed_mesh]
  164. speed = 200
  165. horizontal_move_z = 5
  166. mesh_min = 23,28
  167. mesh_max = 190,190
  168. probe_count = 4,4
  169. fade_start = 1.0
  170. fade_end = 10.0
  171. algorithm = bicubic
  172.  
  173. # Arduino aliases for atmega2560/1280 (Arduino mega) boards
  174. [board_pins arduino-mega]
  175. aliases:
  176.     ar0=PE0, ar1=PE1, ar2=PE4, ar3=PE5, ar4=PG5,
  177.     ar5=PE3, ar6=PH3, ar7=PH4, ar8=PH5, ar9=PH6,
  178.     ar10=PB4, ar11=PB5, ar12=PB6, ar13=PB7, ar14=PJ1,
  179.     ar15=PJ0, ar16=PH1, ar17=PH0, ar18=PD3, ar19=PD2,
  180.     ar20=PD1, ar21=PD0, ar22=PA0, ar23=PA1, ar24=PA2,
  181.     ar25=PA3, ar26=PA4, ar27=PA5, ar28=PA6, ar29=PA7,
  182.     ar30=PC7, ar31=PC6, ar32=PC5, ar33=PC4, ar34=PC3,
  183.     ar35=PC2, ar36=PC1, ar37=PC0, ar38=PD7, ar39=PG2,
  184.     ar40=PG1, ar41=PG0, ar42=PL7, ar43=PL6, ar44=PL5,
  185.     ar45=PL4, ar46=PL3, ar47=PL2, ar48=PL1, ar49=PL0,
  186.     ar50=PB3, ar51=PB2, ar52=PB1, ar53=PB0, ar54=PF0,
  187.     ar55=PF1, ar56=PF2, ar57=PF3, ar58=PF4, ar59=PF5,
  188.     ar60=PF6, ar61=PF7, ar62=PK0, ar63=PK1, ar64=PK2,
  189.     ar65=PK3, ar66=PK4, ar67=PK5, ar68=PK6, ar69=PK7,
  190.     analog0=PF0, analog1=PF1, analog2=PF2, analog3=PF3, analog4=PF4,
  191.     analog5=PF5, analog6=PF6, analog7=PF7, analog8=PK0, analog9=PK1,
  192.     analog10=PK2, analog11=PK3, analog12=PK4, analog13=PK5, analog14=PK6,
  193.     analog15=PK7,
  194.     # Marlin adds these additional aliases
  195.     ml70=PG4, ml71=PG3, ml72=PJ2, ml73=PJ3, ml74=PJ7,
  196.     ml75=PJ4, ml76=PJ5, ml77=PJ6, ml78=PE2, ml79=PE6,
  197.     ml80=PE7, ml81=PD4, ml82=PD5, ml83=PD6, ml84=PH2,
  198.     ml85=PH7
  199.  
  200. [force_move]
  201. enable_force_move: True
  202.  
  203. [virtual_sdcard]
  204. path: /home/pi/gcode_files/
  205.  
  206. [output_pin BEEPER_pin]
  207. pin: ar31
  208. pwm: True
  209. value: 0
  210. shutdown_value: 0
  211. cycle_time: 0.001
  212. scale: 1000
  213.  
  214. [gcode_macro M300]
  215. gcode:
  216.     # Use a default 1kHz tone if S is omitted.
  217.     {% set S = params.S|default(1000)|int %}
  218.     # Use a 10ms duration is P is omitted.
  219.     {% set P = params.P|default(100)|int %}
  220.     SET_PIN PIN=BEEPER_pin VALUE=0.5 CYCLE_TIME={ 1.0/S if S > 0 else 1 }
  221.     G4 P{P}
  222.     SET_PIN PIN=BEEPER_pin VALUE=0
  223.  
  224. [gcode_macro START_PRINT]
  225. gcode:
  226.     {% set BED_TEMP = params.BED_TEMP|default(60)|float %}
  227.     {% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(230)|float %}
  228.     # Start bed heating
  229.     M140 S{BED_TEMP}
  230.     # Use absolute coordinates
  231.     G90
  232.     # Reset the G-Code Z offset (adjust Z offset if needed)
  233.     #SET_GCODE_OFFSET Z=0.0
  234.     # Home the printer
  235.     G28
  236.     # Move the nozzle near the bed
  237.     G1 Z5 F3000
  238.     # Move the nozzle very close to the bed
  239.     G1 Z0.15 F300
  240.     # Wait for bed to reach temperature
  241.     M190 S{BED_TEMP}
  242.     # Set and wait for nozzle to reach temperature
  243.     M109 S{EXTRUDER_TEMP}
  244.  
  245. [gcode_macro END_PRINT]
  246. gcode:
  247.     # Turn off bed, extruder, and fan
  248.     M140 S0
  249.     M104 S0
  250.     M106 S0
  251.     # Move nozzle away from print while retracting
  252.     G91
  253.         G1 E-1 F300
  254.         G1 Z+0.5 E-0.5
  255.         G28 X0
  256.         G1 Y180 F2000
  257.         M300 S440 P200
  258.         M300 S660 P250
  259.         M300 S880 P300
  260.     G90
  261.     # Disable steppers
  262.     M84
  263.  
  264. [pause_resume]
  265.  
  266. [gcode_macro M600]
  267. gcode:
  268.     {% set X = params.X|default(50)|float %}
  269.     {% set Y = params.Y|default(0)|float %}
  270.     {% set Z = params.Z|default(10)|float %}
  271.     SAVE_GCODE_STATE NAME=M600_state
  272.     PAUSE
  273.     G91
  274.     G1 E-.8 F2700
  275.     G1 Z{Z}
  276.     G90
  277.     G1 X{X} Y{Y} F3000
  278.     G91
  279.     G1 E-50 F1000
  280.     RESTORE_GCODE_STATE NAME=M600_state
  281.  
  282. [display_status]
  283.  
  284. [gcode_macro PAUSE]
  285. description: Pause the actual running print
  286. rename_existing: PAUSE_BASE
  287. # change this if you need more or less extrusion
  288. variable_extrude: 1.0
  289. gcode:
  290.   ##### read E from pause macro #####
  291.   {% set E = printer["gcode_macro PAUSE"].extrude|float %}
  292.   ##### set park positon for x and y #####
  293.   # default is your max posion from your printer.cfg
  294.   {% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %}
  295.   {% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
  296.   ##### calculate save lift position #####
  297.   {% set max_z = printer.toolhead.axis_maximum.z|float %}
  298.   {% set act_z = printer.toolhead.position.z|float %}
  299.   {% if act_z < (max_z - 2.0) %}
  300.       {% set z_safe = 2.0 %}
  301.   {% else %}
  302.       {% set z_safe = max_z - act_z %}
  303.   {% endif %}
  304.   ##### end of definitions #####
  305.   PAUSE_BASE
  306.   G91
  307.   {% if printer.extruder.can_extrude|lower == 'true' %}
  308.     G1 E-{E} F2100
  309.   {% else %}
  310.     {action_respond_info("Extruder not hot enough")}
  311.   {% endif %}
  312.   {% if "xyz" in printer.toolhead.homed_axes %}
  313.     G1 Z{z_safe} F900
  314.     G90
  315.     G1 X{x_park} Y{y_park} F6000
  316.   {% else %}
  317.     {action_respond_info("Printer not homed")}
  318.   {% endif %}
  319.  
  320. [gcode_macro RESUME]
  321. description: Resume the actual running print
  322. rename_existing: RESUME_BASE
  323. gcode:
  324.   ##### read E from pause macro #####
  325.   {% set E = printer["gcode_macro PAUSE"].extrude|float %}
  326.   #### get VELOCITY parameter if specified ####
  327.   {% if 'VELOCITY' in params|upper %}
  328.     {% set get_params = ('VELOCITY=' + params.VELOCITY)  %}
  329.   {%else %}
  330.     {% set get_params = "" %}
  331.   {% endif %}
  332.   ##### end of definitions #####
  333.   {% if printer.extruder.can_extrude|lower == 'true' %}
  334.     G91
  335.     G1 E{E} F2100
  336.   {% else %}
  337.     {action_respond_info("Extruder not hot enough")}
  338.   {% endif %}  
  339.   RESUME_BASE {get_params}
  340.  
  341. [gcode_macro CANCEL_PRINT]
  342. description: Cancel the actual running print
  343. rename_existing: CANCEL_PRINT_BASE
  344. gcode:
  345.   TURN_OFF_HEATERS
  346.   CANCEL_PRINT_BASE
  347.  
Advertisement
Add Comment
Please, Sign In to add comment