Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [gcode_macro _CG28]
- gcode:
- {% if "xyz" not in printer.toolhead.homed_axes %}
- G28
- {% endif %}
- [pause_resume]
- [gcode_macro G29]
- gcode:
- BED_MESH_CLEAR
- BED_MESH_CALIBRATE ADAPTIVE=1
- #####################################################################
- # A better print_start macro for v2/trident
- #####################################################################
- ## *** THINGS TO UNCOMMENT: ***
- ## Bed mesh (2 lines at 2 locations)
- ## Nevermore (if you have one)
- ## Z_TILT_ADJUST (For Trident only)
- ## QUAD_GANTRY_LEVEL (For V2.4 only)
- ## Beacon Contact logic (if you have one. 4 lines at 4 locations)
- [gcode_macro PRINT_START]
- gcode:
- # This part fetches data from your slicer. Such as bed, extruder, and chamber temps and size of your printer.
- {% set target_extruder = params.EXTRUDER|int %}
- {% set target_bed = params.BED|int %}
- #{% set target_chamber = params.CHAMBER|default("45")|int %}
- {% set x_wait = printer.toolhead.axis_maximum.x|float / 2 %}
- {% set y_wait = printer.toolhead.axis_maximum.y|float / 2 %}
- ## Uncomment for Beacon Contact (1 of 4 for beacon contact)
- #SET_GCODE_OFFSET Z=0 # Set offset to 0
- # Home the printer, set absolute positioning and update the Stealthburner LEDs.
- #STATUS_HOMING # Set LEDs to homing-mode
- _CG28 # Full home (XYZ)
- G90 # Absolute position
- ## Uncomment for bed mesh (1 of 2 for bed mesh)
- BED_MESH_CLEAR # Clear old saved bed mesh (if any)
- # Check if the bed temp is higher than 90c - if so then trigger a heatsoak.
- #{% if params.BED|int > 90 %}
- #SET_DISPLAY_TEXT MSG="Bed: {target_bed}c" # Display info on display
- #STATUS_HEATING # Set LEDs to heating-mode
- #M106 S255 # Turn on the PT-fan
- ## Uncomment if you have a Nevermore.
- #SET_PIN PIN=nevermore VALUE=1 # Turn on the nevermore
- #G1 X{x_wait} Y{y_wait} Z15 F9000 # Go to center of the bed
- # M190 S{target_bed} # Set the target temp for the bed
- #SET_DISPLAY_TEXT MSG="Heatsoak: {target_chamber}c" # Display info on display
- #TEMPERATURE_WAIT SENSOR="temperature_sensor chamber" MINIMUM={target_chamber} # Waits for chamber temp
- # If the bed temp is not over 90c, then skip the heatsoak and just heat up to set temp with a 5 min soak
- # {% else %}
- SET_DISPLAY_TEXT MSG="Bed: {target_bed}c" # Display info on display
- #STATUS_HEATING # Set LEDs to heating-mode
- G1 X{x_wait} Y{y_wait} Z15 F9000 # Go to center of the bed
- M190 S{target_bed} # Set the target temp for the bed
- #SET_DISPLAY_TEXT MSG="Soak for 5 min" # Display info on display
- #G4 P300000 # Wait 5 min for the bedtemp to stabilize
- # {% endif %}
- # Heat hotend to 150c. This helps with getting a correct Z-home.
- SET_DISPLAY_TEXT MSG="Hotend: 150c" # Display info on display
- M109 S150 # Heat hotend to 150c
- ## Uncomment for Beacon contact (2 of 4 for beacon contact)
- #G28 Z METHOD=CONTACT CALIBRATE=1 # Calibrate z offset and beacon model
- ## Uncomment for Trident (Z_TILT_ADJUST)
- #SET_DISPLAY_TEXT MSG="Leveling" # Display info on display
- #STATUS_LEVELING # Set LEDs to leveling-mode
- #Z_TILT_ADJUST # Level the printer via Z_TILT_ADJUST
- #G28 Z # Home Z again after Z_TILT_ADJUST
- ## Uncomment for V2.4 (Quad gantry level AKA QGL)
- #SET_DISPLAY_TEXT MSG="Leveling" # Display info on display
- #STATUS_LEVELING # Set LEDs to leveling-mode
- #QUAD_GANTRY_LEVEL # Level the printer via QGL
- #G28 Z # Home Z again after QGL
- ## Uncomment for bed mesh (2 of 2 for bed mesh)
- SET_DISPLAY_TEXT MSG="Bed mesh" # Display info on display
- #STATUS_MESHING # Set LEDs to bed mesh-mode
- BED_MESH_CALIBRATE ADAPTIVE=1 # Start the bed mesh (add ADAPTIVE=1) for adaptive bed mesh
- ## Uncomment for Beacon Contact (3 of 4 for beacon contact)
- #G28 Z METHOD=CONTACT CALIBRATE=0 # Calibrate z offset only with hot nozzle
- # Heat up the hotend up to target via data from slicer
- SET_DISPLAY_TEXT MSG="Hotend: {target_extruder}c" # Display info on display
- # STATUS_HEATING # Set LEDs to heating-mode
- G1 X{x_wait} Y{y_wait} Z15 F9000 # Go to center of the bed
- M107 # Turn off partcooling fan
- M109 S{target_extruder} # Heat the hotend to set temp
- ## Uncomment for Beacon Contact (4 of 4 for beacon contact)
- #SET_GCODE_OFFSET Z=0.06 # Add a little offset for hotend thermal expansion
- # Get ready to print by doing a primeline and updating the LEDs
- SET_DISPLAY_TEXT MSG="Printer goes brr" # Display info on display
- #STATUS_PRINTING # Set LEDs to printing-mode
- #G0 X{x_wait - 50} Y4 F10000 # Go to starting point
- # G0 Z0.4 # Raise Z to 0.4
- # G91 # Incremental positioning
- # G1 X100 E20 F1000 # Primeline
- G90 # Absolute position
- VORON_PURGE
- [gcode_macro START_PRINT]
- gcode:
- PRINT_START { rawparams }
- [gcode_macro END_PRINT]
- gcode:
- #Get Boundaries
- {% set max_x = printer.configfile.config["stepper_x"]["position_max"]|float %}
- {% set max_y = printer.configfile.config["stepper_y"]["position_max"]|float %}
- {% set max_z = printer.configfile.config["stepper_z"]["position_max"]|float %}
- {% set min_x = printer.configfile.config["stepper_x"]["position_endstop"]|float %}
- #Check end position to determine safe directions to move
- {% if printer.toolhead.position.x < (max_x - 20) %}
- {% set x_safe = 20.0 %}
- {% else %}
- {% set x_safe = -20.0 %}
- {% endif %}
- {% if printer.toolhead.position.y < (max_y - 20) %}
- {% set y_safe = 20.0 %}
- {% else %}
- {% set y_safe = -20.0 %}
- {% endif %}
- {% if printer.toolhead.position.z < (max_z - 2) %}
- {% set z_safe = 2.0 %}
- {% else %}
- {% set z_safe = max_z - printer.toolhead.position.z %}
- {% endif %}
- #Commence END_PRINT
- # STATUS_COOLING
- M400 ; wait for buffer to clear
- G92 E0 ; zero the extruder
- G1 E-4.0 F3600 ; retract
- G91 ; relative positioning
- G0 Z{z_safe} F3600 ; move nozzle up
- M104 S0 ; turn off hotend
- M140 S0 ; turn off bed
- M106 S0 ; turn off fan
- M107 ; turn off part cooling fan
- G90 ; absolute positioning
- G1 X{min_x} Y{max_y} F2000 ; move nozzle and present
- # SET_DISPLAY_TEXT MSG="Scrubbing air..." # Displays info
- # SET_PIN PIN=nevermore VALUE=0 # Turns off the nevermore
- # UPDATE_DELAYED_GCODE ID=turn_off_nevermore DURATION=300
- SET_DISPLAY_TEXT MSG="Print finished!!" # Displays info
- # STATUS_PART_READY
- # UPDATE_DELAYED_GCODE ID=set_ready_status DURATION=60
- # 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
- [gcode_macro PRINT_END]
- gcode:
- END_PRINT { rawparams }
- [gcode_macro TEST_SPEED]
- # Home, get position, throw around toolhead, home again.
- # If MCU stepper positions (first line in GET_POSITION) are greater than a full step different (your number of microsteps), then skipping occured.
- # We only measure to a full step to accomodate for endstop variance.
- # Example: TEST_SPEED SPEED=300 ACCEL=5000 ITERATIONS=10
- description: Test for max speed and acceleration parameters for the printer. Procedure: Home -> ReadPositionFromMCU -> MovesToolhead@Vel&Accel -> Home -> ReadPositionfromMCU
- gcode:
- # Speed
- {% set speed = params.SPEED|default(printer.configfile.settings.printer.max_velocity)|int %}
- # Iterations
- {% set iterations = params.ITERATIONS|default(5)|int %}
- # Acceleration
- {% set accel = params.ACCEL|default(printer.configfile.settings.printer.max_accel)|int %}
- # Minimum Cruise Ratio
- {% set min_cruise_ratio = params.MIN_CRUISE_RATIO|default(0.5)|float %}
- # 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)
- {% set bound = params.BOUND|default(20)|int %}
- # Size for small pattern box
- {% set smallpatternsize = SMALLPATTERNSIZE|default(20)|int %}
- # Large pattern
- # Max positions, inset by BOUND
- {% set x_min = printer.toolhead.axis_minimum.x + bound %}
- {% set x_max = printer.toolhead.axis_maximum.x - bound %}
- {% set y_min = printer.toolhead.axis_minimum.y + bound %}
- {% set y_max = printer.toolhead.axis_maximum.y - bound %}
- # Small pattern at center
- # Find X/Y center point
- {% set x_center = (printer.toolhead.axis_minimum.x|float + printer.toolhead.axis_maximum.x|float ) / 2 %}
- {% set y_center = (printer.toolhead.axis_minimum.y|float + printer.toolhead.axis_maximum.y|float ) / 2 %}
- # Set small pattern box around center point
- {% set x_center_min = x_center - (smallpatternsize/2) %}
- {% set x_center_max = x_center + (smallpatternsize/2) %}
- {% set y_center_min = y_center - (smallpatternsize/2) %}
- {% set y_center_max = y_center + (smallpatternsize/2) %}
- # Save current gcode state (absolute/relative, etc)
- SAVE_GCODE_STATE NAME=TEST_SPEED
- # Output parameters to g-code terminal
- { action_respond_info("TEST_SPEED: starting %d iterations at speed %d, accel %d" % (iterations, speed, accel)) }
- # Home and get position for comparison later:
- M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66
- G28
- # QGL if not already QGLd (only if QGL section exists in config)
- {% if printer.configfile.settings.quad_gantry_level %}
- {% if printer.quad_gantry_level.applied == False %}
- QUAD_GANTRY_LEVEL
- G28 Z
- {% endif %}
- {% endif %}
- # 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)
- G90
- G1 X{printer.toolhead.axis_maximum.x-50} Y{printer.toolhead.axis_maximum.y-50} F{30*60}
- M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66
- G28 X Y
- G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{30*60}
- G4 P1000
- GET_POSITION
- # Go to starting position
- G0 X{x_min} Y{y_min} Z{bound + 10} F{speed*60}
- # Set new limits
- {% if printer.configfile.settings.printer.minimum_cruise_ratio is defined %}
- SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} MINIMUM_CRUISE_RATIO={min_cruise_ratio}
- {% else %}
- SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} ACCEL_TO_DECEL={accel / 2}
- {% endif %}
- {% for i in range(iterations) %}
- # Large pattern diagonals
- G0 X{x_min} Y{y_min} F{speed*60}
- G0 X{x_max} Y{y_max} F{speed*60}
- G0 X{x_min} Y{y_min} F{speed*60}
- G0 X{x_max} Y{y_min} F{speed*60}
- G0 X{x_min} Y{y_max} F{speed*60}
- G0 X{x_max} Y{y_min} F{speed*60}
- # Large pattern box
- G0 X{x_min} Y{y_min} F{speed*60}
- G0 X{x_min} Y{y_max} F{speed*60}
- G0 X{x_max} Y{y_max} F{speed*60}
- G0 X{x_max} Y{y_min} F{speed*60}
- # Small pattern diagonals
- G0 X{x_center_min} Y{y_center_min} F{speed*60}
- G0 X{x_center_max} Y{y_center_max} F{speed*60}
- G0 X{x_center_min} Y{y_center_min} F{speed*60}
- G0 X{x_center_max} Y{y_center_min} F{speed*60}
- G0 X{x_center_min} Y{y_center_max} F{speed*60}
- G0 X{x_center_max} Y{y_center_min} F{speed*60}
- # Small pattern box
- G0 X{x_center_min} Y{y_center_min} F{speed*60}
- G0 X{x_center_min} Y{y_center_max} F{speed*60}
- G0 X{x_center_max} Y{y_center_max} F{speed*60}
- G0 X{x_center_max} Y{y_center_min} F{speed*60}
- {% endfor %}
- # Restore max speed/accel/accel_to_decel to their configured values
- {% if printer.configfile.settings.printer.minimum_cruise_ratio is defined %}
- 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}
- {% else %}
- 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}
- {% endif %}
- # Re-home and get position again for comparison:
- M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66
- G28 # This is a full G28 to fix an issue with CoreXZ - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/12
- # Go to XY home positions (in case your homing override leaves it elsewhere)
- G90
- G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{30*60}
- G4 P1000
- GET_POSITION
- # Restore previous gcode state (absolute/relative, etc)
- RESTORE_GCODE_STATE NAME=TEST_SPEED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement