Advertisement
cribbageSTARSHIP

client_macros.cfg_M8P_CB1_E3Max

May 4th, 2025
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.26 KB | None | 0 0
  1.  
  2. [gcode_macro _CG28]
  3. gcode:
  4. {% if "xyz" not in printer.toolhead.homed_axes %}
  5. G28
  6. {% endif %}
  7.  
  8. [pause_resume]
  9.  
  10. [gcode_macro G29]
  11. gcode:
  12. BED_MESH_CLEAR
  13. BED_MESH_CALIBRATE ADAPTIVE=1
  14.  
  15. #####################################################################
  16. # A better print_start macro for v2/trident
  17. #####################################################################
  18.  
  19. ## *** THINGS TO UNCOMMENT: ***
  20. ## Bed mesh (2 lines at 2 locations)
  21. ## Nevermore (if you have one)
  22. ## Z_TILT_ADJUST (For Trident only)
  23. ## QUAD_GANTRY_LEVEL (For V2.4 only)
  24. ## Beacon Contact logic (if you have one. 4 lines at 4 locations)
  25.  
  26. [gcode_macro PRINT_START]
  27. gcode:
  28. # This part fetches data from your slicer. Such as bed, extruder, and chamber temps and size of your printer.
  29. {% set target_extruder = params.EXTRUDER|int %}
  30. {% set target_bed = params.BED|int %}
  31. #{% set target_chamber = params.CHAMBER|default("45")|int %}
  32. {% set x_wait = printer.toolhead.axis_maximum.x|float / 2 %}
  33. {% set y_wait = printer.toolhead.axis_maximum.y|float / 2 %}
  34.  
  35. ## Uncomment for Beacon Contact (1 of 4 for beacon contact)
  36. #SET_GCODE_OFFSET Z=0 # Set offset to 0
  37.  
  38. # Home the printer, set absolute positioning and update the Stealthburner LEDs.
  39. #STATUS_HOMING # Set LEDs to homing-mode
  40. _CG28 # Full home (XYZ)
  41. G90 # Absolute position
  42.  
  43. ## Uncomment for bed mesh (1 of 2 for bed mesh)
  44. BED_MESH_CLEAR # Clear old saved bed mesh (if any)
  45.  
  46. # Check if the bed temp is higher than 90c - if so then trigger a heatsoak.
  47. #{% if params.BED|int > 90 %}
  48. #SET_DISPLAY_TEXT MSG="Bed: {target_bed}c" # Display info on display
  49. #STATUS_HEATING # Set LEDs to heating-mode
  50. #M106 S255 # Turn on the PT-fan
  51.  
  52. ## Uncomment if you have a Nevermore.
  53. #SET_PIN PIN=nevermore VALUE=1 # Turn on the nevermore
  54.  
  55. #G1 X{x_wait} Y{y_wait} Z15 F9000 # Go to center of the bed
  56. # M190 S{target_bed} # Set the target temp for the bed
  57. #SET_DISPLAY_TEXT MSG="Heatsoak: {target_chamber}c" # Display info on display
  58. #TEMPERATURE_WAIT SENSOR="temperature_sensor chamber" MINIMUM={target_chamber} # Waits for chamber temp
  59.  
  60. # If the bed temp is not over 90c, then skip the heatsoak and just heat up to set temp with a 5 min soak
  61. # {% else %}
  62. SET_DISPLAY_TEXT MSG="Bed: {target_bed}c" # Display info on display
  63. #STATUS_HEATING # Set LEDs to heating-mode
  64. G1 X{x_wait} Y{y_wait} Z15 F9000 # Go to center of the bed
  65. M190 S{target_bed} # Set the target temp for the bed
  66. #SET_DISPLAY_TEXT MSG="Soak for 5 min" # Display info on display
  67. #G4 P300000 # Wait 5 min for the bedtemp to stabilize
  68. # {% endif %}
  69.  
  70. # Heat hotend to 150c. This helps with getting a correct Z-home.
  71. SET_DISPLAY_TEXT MSG="Hotend: 150c" # Display info on display
  72. M109 S150 # Heat hotend to 150c
  73.  
  74. ## Uncomment for Beacon contact (2 of 4 for beacon contact)
  75. #G28 Z METHOD=CONTACT CALIBRATE=1 # Calibrate z offset and beacon model
  76.  
  77. ## Uncomment for Trident (Z_TILT_ADJUST)
  78. #SET_DISPLAY_TEXT MSG="Leveling" # Display info on display
  79. #STATUS_LEVELING # Set LEDs to leveling-mode
  80. #Z_TILT_ADJUST # Level the printer via Z_TILT_ADJUST
  81. #G28 Z # Home Z again after Z_TILT_ADJUST
  82.  
  83. ## Uncomment for V2.4 (Quad gantry level AKA QGL)
  84. #SET_DISPLAY_TEXT MSG="Leveling" # Display info on display
  85. #STATUS_LEVELING # Set LEDs to leveling-mode
  86. #QUAD_GANTRY_LEVEL # Level the printer via QGL
  87. #G28 Z # Home Z again after QGL
  88.  
  89. ## Uncomment for bed mesh (2 of 2 for bed mesh)
  90. SET_DISPLAY_TEXT MSG="Bed mesh" # Display info on display
  91. #STATUS_MESHING # Set LEDs to bed mesh-mode
  92. BED_MESH_CALIBRATE ADAPTIVE=1 # Start the bed mesh (add ADAPTIVE=1) for adaptive bed mesh
  93.  
  94. ## Uncomment for Beacon Contact (3 of 4 for beacon contact)
  95. #G28 Z METHOD=CONTACT CALIBRATE=0 # Calibrate z offset only with hot nozzle
  96.  
  97. # Heat up the hotend up to target via data from slicer
  98. SET_DISPLAY_TEXT MSG="Hotend: {target_extruder}c" # Display info on display
  99. # STATUS_HEATING # Set LEDs to heating-mode
  100. G1 X{x_wait} Y{y_wait} Z15 F9000 # Go to center of the bed
  101. M107 # Turn off partcooling fan
  102. M109 S{target_extruder} # Heat the hotend to set temp
  103.  
  104. ## Uncomment for Beacon Contact (4 of 4 for beacon contact)
  105. #SET_GCODE_OFFSET Z=0.06 # Add a little offset for hotend thermal expansion
  106.  
  107. # Get ready to print by doing a primeline and updating the LEDs
  108. SET_DISPLAY_TEXT MSG="Printer goes brr" # Display info on display
  109. #STATUS_PRINTING # Set LEDs to printing-mode
  110. #G0 X{x_wait - 50} Y4 F10000 # Go to starting point
  111. # G0 Z0.4 # Raise Z to 0.4
  112. # G91 # Incremental positioning
  113. # G1 X100 E20 F1000 # Primeline
  114. G90 # Absolute position
  115. VORON_PURGE
  116.  
  117. [gcode_macro START_PRINT]
  118. gcode:
  119. PRINT_START { rawparams }
  120.  
  121. [gcode_macro END_PRINT]
  122. gcode:
  123. #Get Boundaries
  124. {% set max_x = printer.configfile.config["stepper_x"]["position_max"]|float %}
  125. {% set max_y = printer.configfile.config["stepper_y"]["position_max"]|float %}
  126. {% set max_z = printer.configfile.config["stepper_z"]["position_max"]|float %}
  127. {% set min_x = printer.configfile.config["stepper_x"]["position_endstop"]|float %}
  128.  
  129. #Check end position to determine safe directions to move
  130. {% if printer.toolhead.position.x < (max_x - 20) %}
  131. {% set x_safe = 20.0 %}
  132. {% else %}
  133. {% set x_safe = -20.0 %}
  134. {% endif %}
  135.  
  136. {% if printer.toolhead.position.y < (max_y - 20) %}
  137. {% set y_safe = 20.0 %}
  138. {% else %}
  139. {% set y_safe = -20.0 %}
  140. {% endif %}
  141.  
  142. {% if printer.toolhead.position.z < (max_z - 2) %}
  143. {% set z_safe = 2.0 %}
  144. {% else %}
  145. {% set z_safe = max_z - printer.toolhead.position.z %}
  146. {% endif %}
  147. #Commence END_PRINT
  148. # STATUS_COOLING
  149. M400 ; wait for buffer to clear
  150. G92 E0 ; zero the extruder
  151. G1 E-4.0 F3600 ; retract
  152. G91 ; relative positioning
  153. G0 Z{z_safe} F3600 ; move nozzle up
  154. M104 S0 ; turn off hotend
  155. M140 S0 ; turn off bed
  156. M106 S0 ; turn off fan
  157. M107 ; turn off part cooling fan
  158. G90 ; absolute positioning
  159. G1 X{min_x} Y{max_y} F2000 ; move nozzle and present
  160. # SET_DISPLAY_TEXT MSG="Scrubbing air..." # Displays info
  161. # SET_PIN PIN=nevermore VALUE=0 # Turns off the nevermore
  162. # UPDATE_DELAYED_GCODE ID=turn_off_nevermore DURATION=300
  163. SET_DISPLAY_TEXT MSG="Print finished!!" # Displays info
  164. # STATUS_PART_READY
  165. # UPDATE_DELAYED_GCODE ID=set_ready_status DURATION=60
  166. # M84 # Disable motors ##CURRENTLY DISABLED THIS TO ALLOW THE IDLE TIMEOUT TIMER DISABLE THE MOTORS - PLEASE MAKE SURE YOUR HAVE AN IDLE TIMEOUT TIMER SET - FLUIDD OR MAINSAIL HAVE THESE BY DEFAULT
  167.  
  168. [gcode_macro PRINT_END]
  169. gcode:
  170. END_PRINT { rawparams }
  171.  
  172. [gcode_macro TEST_SPEED]
  173. # Home, get position, throw around toolhead, home again.
  174. # If MCU stepper positions (first line in GET_POSITION) are greater than a full step different (your number of microsteps), then skipping occured.
  175. # We only measure to a full step to accomodate for endstop variance.
  176. # Example: TEST_SPEED SPEED=300 ACCEL=5000 ITERATIONS=10
  177.  
  178. description: Test for max speed and acceleration parameters for the printer. Procedure: Home -> ReadPositionFromMCU -> MovesToolhead@Vel&Accel -> Home -> ReadPositionfromMCU
  179.  
  180. gcode:
  181. # Speed
  182. {% set speed = params.SPEED|default(printer.configfile.settings.printer.max_velocity)|int %}
  183. # Iterations
  184. {% set iterations = params.ITERATIONS|default(5)|int %}
  185. # Acceleration
  186. {% set accel = params.ACCEL|default(printer.configfile.settings.printer.max_accel)|int %}
  187. # Minimum Cruise Ratio
  188. {% set min_cruise_ratio = params.MIN_CRUISE_RATIO|default(0.5)|float %}
  189. # Bounding inset for large pattern (helps prevent slamming the toolhead into the sides after small skips, and helps to account for machines with imperfectly set dimensions)
  190. {% set bound = params.BOUND|default(20)|int %}
  191. # Size for small pattern box
  192. {% set smallpatternsize = SMALLPATTERNSIZE|default(20)|int %}
  193.  
  194. # Large pattern
  195. # Max positions, inset by BOUND
  196. {% set x_min = printer.toolhead.axis_minimum.x + bound %}
  197. {% set x_max = printer.toolhead.axis_maximum.x - bound %}
  198. {% set y_min = printer.toolhead.axis_minimum.y + bound %}
  199. {% set y_max = printer.toolhead.axis_maximum.y - bound %}
  200.  
  201. # Small pattern at center
  202. # Find X/Y center point
  203. {% set x_center = (printer.toolhead.axis_minimum.x|float + printer.toolhead.axis_maximum.x|float ) / 2 %}
  204. {% set y_center = (printer.toolhead.axis_minimum.y|float + printer.toolhead.axis_maximum.y|float ) / 2 %}
  205.  
  206. # Set small pattern box around center point
  207. {% set x_center_min = x_center - (smallpatternsize/2) %}
  208. {% set x_center_max = x_center + (smallpatternsize/2) %}
  209. {% set y_center_min = y_center - (smallpatternsize/2) %}
  210. {% set y_center_max = y_center + (smallpatternsize/2) %}
  211.  
  212. # Save current gcode state (absolute/relative, etc)
  213. SAVE_GCODE_STATE NAME=TEST_SPEED
  214.  
  215. # Output parameters to g-code terminal
  216. { action_respond_info("TEST_SPEED: starting %d iterations at speed %d, accel %d" % (iterations, speed, accel)) }
  217.  
  218. # Home and get position for comparison later:
  219. M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66
  220. G28
  221. # QGL if not already QGLd (only if QGL section exists in config)
  222. {% if printer.configfile.settings.quad_gantry_level %}
  223. {% if printer.quad_gantry_level.applied == False %}
  224. QUAD_GANTRY_LEVEL
  225. G28 Z
  226. {% endif %}
  227. {% endif %}
  228. # Move 50mm away from max position and home again (to help with hall effect endstop accuracy - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/24)
  229. G90
  230. G1 X{printer.toolhead.axis_maximum.x-50} Y{printer.toolhead.axis_maximum.y-50} F{30*60}
  231. M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66
  232. G28 X Y
  233. G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{30*60}
  234. G4 P1000
  235. GET_POSITION
  236.  
  237. # Go to starting position
  238. G0 X{x_min} Y{y_min} Z{bound + 10} F{speed*60}
  239.  
  240. # Set new limits
  241. {% if printer.configfile.settings.printer.minimum_cruise_ratio is defined %}
  242. SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} MINIMUM_CRUISE_RATIO={min_cruise_ratio}
  243. {% else %}
  244. SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} ACCEL_TO_DECEL={accel / 2}
  245. {% endif %}
  246.  
  247. {% for i in range(iterations) %}
  248. # Large pattern diagonals
  249. G0 X{x_min} Y{y_min} F{speed*60}
  250. G0 X{x_max} Y{y_max} F{speed*60}
  251. G0 X{x_min} Y{y_min} F{speed*60}
  252. G0 X{x_max} Y{y_min} F{speed*60}
  253. G0 X{x_min} Y{y_max} F{speed*60}
  254. G0 X{x_max} Y{y_min} F{speed*60}
  255.  
  256. # Large pattern box
  257. G0 X{x_min} Y{y_min} F{speed*60}
  258. G0 X{x_min} Y{y_max} F{speed*60}
  259. G0 X{x_max} Y{y_max} F{speed*60}
  260. G0 X{x_max} Y{y_min} F{speed*60}
  261.  
  262. # Small pattern diagonals
  263. G0 X{x_center_min} Y{y_center_min} F{speed*60}
  264. G0 X{x_center_max} Y{y_center_max} F{speed*60}
  265. G0 X{x_center_min} Y{y_center_min} F{speed*60}
  266. G0 X{x_center_max} Y{y_center_min} F{speed*60}
  267. G0 X{x_center_min} Y{y_center_max} F{speed*60}
  268. G0 X{x_center_max} Y{y_center_min} F{speed*60}
  269.  
  270. # Small pattern box
  271. G0 X{x_center_min} Y{y_center_min} F{speed*60}
  272. G0 X{x_center_min} Y{y_center_max} F{speed*60}
  273. G0 X{x_center_max} Y{y_center_max} F{speed*60}
  274. G0 X{x_center_max} Y{y_center_min} F{speed*60}
  275. {% endfor %}
  276.  
  277. # Restore max speed/accel/accel_to_decel to their configured values
  278. {% if printer.configfile.settings.printer.minimum_cruise_ratio is defined %}
  279. SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity} ACCEL={printer.configfile.settings.printer.max_accel} MINIMUM_CRUISE_RATIO={printer.configfile.settings.printer.minimum_cruise_ratio}
  280. {% else %}
  281. SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity} ACCEL={printer.configfile.settings.printer.max_accel} ACCEL_TO_DECEL={printer.configfile.settings.printer.max_accel_to_decel}
  282. {% endif %}
  283.  
  284. # Re-home and get position again for comparison:
  285. M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66
  286. G28 # This is a full G28 to fix an issue with CoreXZ - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/12
  287. # Go to XY home positions (in case your homing override leaves it elsewhere)
  288. G90
  289. G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{30*60}
  290. G4 P1000
  291. GET_POSITION
  292.  
  293. # Restore previous gcode state (absolute/relative, etc)
  294. RESTORE_GCODE_STATE NAME=TEST_SPEED
  295.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement