Advertisement
Guest User

Untitled

a guest
Sep 30th, 2022
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.98 KB | None | 0 0
  1. ################################
  2. # BED MESH
  3. ################################
  4. [gcode_macro BED_MESH_CALIBRATE]
  5. rename_existing: BED_MESH_CALIBRATE_BASE
  6. ; gcode parameters
  7. variable_parameter_AREA_START : 0,0
  8. variable_parameter_AREA_END : 0,0
  9. ; the clearance between print area and probe area
  10. variable_mesh_area_offset : 5.0
  11. ; number of sample per probe point
  12. variable_probe_samples : 2
  13. ; minimum probe count
  14. variable_min_probe_count : 3
  15. ; scale up the probe count, should be 1.0 ~ < variable_max_probe_count/variable_min_probe_count
  16. variable_probe_count_scale_factor : 1.0
  17. ; enable preference index
  18. variable_enable_reference_index : False
  19. gcode:
  20. {% if params.AREA_START and params.AREA_END %}
  21. {% set bedMeshConfig = printer["configfile"].config["bed_mesh"] %}
  22. {% set safe_min_x = bedMeshConfig.mesh_min.split(",")[0]|float %}
  23. {% set safe_min_y = bedMeshConfig.mesh_min.split(",")[1]|float %}
  24. {% set safe_max_x = bedMeshConfig.mesh_max.split(",")[0]|float %}
  25. {% set safe_max_y = bedMeshConfig.mesh_max.split(",")[1]|float %}
  26.  
  27. {% set area_min_x = params.AREA_START.split(",")[0]|float %}
  28. {% set area_min_y = params.AREA_START.split(",")[1]|float %}
  29. {% set area_max_x = params.AREA_END.split(",")[0]|float %}
  30. {% set area_max_y = params.AREA_END.split(",")[1]|float %}
  31.  
  32. {% if bedMeshConfig.probe_count.split(",")|length == 2 %}
  33. {% set meshPointX = bedMeshConfig.probe_count.split(",")[0]|int %}
  34. {% set meshPointY = bedMeshConfig.probe_count.split(",")[1]|int %}
  35. {% else %}
  36. {% set meshPointX = bedMeshConfig.probe_count.split(",")[0]|int %}
  37. {% set meshPointY = bedMeshConfig.probe_count.split(",")[0]|int %}
  38. {% endif %}
  39.  
  40. {% set meshMaxPointX = meshPointX %}
  41. {% set meshMaxPointY = meshPointY %}
  42.  
  43.  
  44. {% if (area_min_x < area_max_x) and (area_min_y < area_max_y) %}
  45. {% if area_min_x - mesh_area_offset >= safe_min_x %}
  46. {% set area_min_x = area_min_x - mesh_area_offset %}
  47. {% else %}
  48. {% set area_min_x = safe_min_x %}
  49. {% endif %}
  50.  
  51. {% if area_min_y - mesh_area_offset >= safe_min_y %}
  52. {% set area_min_y = area_min_y - mesh_area_offset %}
  53. {% else %}
  54. {% set area_min_y = safe_min_y %}
  55. {% endif %}
  56.  
  57. {% if area_max_x + mesh_area_offset <= safe_max_x %}
  58. {% set area_max_x = area_max_x + mesh_area_offset %}
  59. {% else %}
  60. {% set area_max_x = safe_max_x %}
  61. {% endif %}
  62.  
  63. {% if area_max_y + mesh_area_offset <= safe_max_y %}
  64. {% set area_max_y = area_max_y + mesh_area_offset %}
  65. {% else %}
  66. {% set area_max_y = safe_max_y %}
  67. {% endif %}
  68.  
  69. {% set meshPointX = (meshPointX * (area_max_x - area_min_x) / (safe_max_x - safe_min_x) * probe_count_scale_factor)|round(0)|int %}
  70. {% if meshPointX < min_probe_count %}
  71. {% set meshPointX = min_probe_count %}
  72. {% endif %}
  73. {% if meshPointX > meshMaxPointX %}
  74. {% set meshPointX = meshMaxPointX %}
  75. {% endif %}
  76.  
  77. {% set meshPointY = (meshPointY * (area_max_y -area_min_y ) / (safe_max_y - safe_min_y) * probe_count_scale_factor )|round(0)|int %}
  78. {% if meshPointY < min_probe_count %}
  79. {% set meshPointY = min_probe_count %}
  80. {% endif %}
  81. {% if meshPointY > meshMaxPointY %}
  82. {% set meshPointY = meshMaxPointY %}
  83. {% endif %}
  84.  
  85. {% set algorithm = "lagrange" %}
  86. {% if "algorithm" in bedMeshConfig and meshPointX >=4 and meshPointY >=4 %}
  87. {% set algorithm = bedMeshConfig.algorithm %}
  88. {% endif %}
  89.  
  90. {% if enable_reference_index %}
  91. {% set referenceIndex = (meshPointX * meshPointY / 2 - 1 )|round(0)|int %}
  92. BED_MESH_CALIBRATE_BASE mesh_min={area_min_x},{area_min_y} mesh_max={area_max_x},{area_max_y} probe_count={meshPointX},{meshPointY} samples={probe_samples|int} algorithm={algorithm} relative_reference_index={referenceIndex}
  93. {% else %}
  94. BED_MESH_CALIBRATE_BASE mesh_min={area_min_x},{area_min_y} mesh_max={area_max_x},{area_max_y} probe_count={meshPointX},{meshPointY} samples={probe_samples|int} algorithm={algorithm}
  95. {% endif %}
  96. {% else %}
  97. BED_MESH_CALIBRATE_BASE
  98. {% endif %}
  99. {% else %}
  100. BED_MESH_CALIBRATE_BASE
  101. {% endif %}
  102.  
  103.  
  104. ################################
  105. # BED MESH
  106. ################################
  107. #[gcode_macro BED_MESH_CALIBRATE]
  108. #description: custom overwrite of the base BED_MESH_CALIBRATE function
  109. #rename_existing: BED_MESH_CALIBRATE_BASE
  110. #gcode:
  111. # BED_MESH_CLEAR
  112. # G28
  113. # BED_MESH_CALIBRATE_BASE {rawparams}
  114.  
  115. ################################
  116. # START PRINT
  117. ################################
  118. [gcode_macro START_PRINT]
  119. # Use PRINT_START for the slicer starting script - PLEASE CUSTOMISE THE SCRIPT
  120. # gcode parameters for area bed mesh
  121. variable_parameter_AREA_START : 0,0
  122. variable_parameter_AREA_END : 0,0
  123.  
  124. gcode:
  125. {% set th = printer.toolhead %}
  126. # Get temps from slicer
  127. {% set BED_TEMP = params.BED_TEMP|default(51)|float %}
  128. {% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(191)|float %}
  129. {% set CHAMBER_TEMP = params.CHAMBER|default(45)|float %}
  130. {% set FILAMENT_TYPE = params.FILAMENT|default(PLA)|string %}
  131. # Get Boundaries
  132. {% set max_x = printer.configfile.config["stepper_x"]["position_max"]|float %}
  133. {% set max_y = printer.configfile.config["stepper_y"]["position_max"]|float %}
  134. {% set max_z = printer.configfile.config["stepper_z"]["position_max"]|float %}
  135. # Homing sequence
  136. G28
  137. SCREWS_TILT_CALCULATE MAX_DEVIATION=0.06 ; need to enable screw tile in printer.cfg
  138. M104 S170 ; set nozzle temp without waiting
  139. M190 S{BED_TEMP} ; wait for bed to reach temp
  140. # BED_MESH_CALIBRATE ; This is the default bed mesh method
  141. {% if params.AREA_START and params.AREA_END %} ; source: https://gist.github.com/ChipCE/95fdbd3c2f3a064397f9610f915f7d02
  142. BED_MESH_CALIBRATE AREA_START={params.AREA_START} AREA_END={params.AREA_END}
  143. {% else %}
  144. BED_MESH_CALIBRATE
  145. {% endif %}
  146. # BED_MESH_PROFILE LOAD=default
  147. # M140 S{BED_TEMP} ; heat bed to reach temp without waiting
  148. PROBE_IN
  149. G0 X46 Y0 F3000 ; park nozzle at front
  150. M109 S{EXTRUDER_TEMP} ; wait for nozzle to reach temperature
  151.  
  152. # nozzle_clean
  153. M82 ; set extruder to absolute
  154. G92 E0 ; zero the extruder
  155. G90 ; absolute positioning
  156. G1 E5.0 F3000 ; reset filament in extruder
  157. G1 X46 Y0 Z1 F4000 ; Go to start pos for purge line
  158. G1 Z0.4 F600 ; Lower to purge height
  159. G91 ; relative positioning
  160. G1 X5 E40 F40 ; Extrude blob of filament on the bed
  161. M106 P0 ; Enable Cooling Fan
  162. G1 X20 Z5 F100 ; Slow drag away from the blob with fans helping cool and break strings. Also raise z so the blob clears the fan duct
  163. G1 X5 Z-5.1 F1000 ; Now that the blob has cleared the duct we go back down for a short 0.3mm height extrusion
  164. G1 X5 E2 F180 ; Slow 5mm extrude move to help with stringing
  165. G1 X30 E-1 F5000 ; Fast move and retract to break strings and reduce ooze
  166. G1 Z2 F100 ; Lift
  167. M106 P0 S0 ; Disable Cooling Fan
  168. G92 E0 ; zero the extruder
  169. G90 ; absolute positioning
  170.  
  171. SKEW_PROFILE LOAD=my_skew_profile
  172.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement