MACROS

Macros can offer convenience (when adding a one button calibration to the home screen) or can help get prints just the way you like them (filament change for example). Below is an ever-growing list of macros that I have used/created to make my printing experience better.

KEEP IN MIND macros need to be structured in a particular way. It' starts by naming the Macro. The name can be anything you want as long as there isn’t any spaces.

[gcode_macro ThisIsTheName]

Directly underneath the name there is a section for a description (if you want) and then the line ‘gcode:’

[gcode_macro ThisIsTheName]

description: this is a test macro

gcode:

G28

probe_calibrate

Beneath the gcode is the body of the macro where all the commands will be. The important aspect is, ALL THE GCODE NEEDS TO BE INDENTED! Formatting matters here, so all the gcode needs to be indented once(four spaces). If you are having issues with any of these macros it’s possible when you copy and paste them (or how this website formats them) the indentation will be misaligned. Double check that indentation if there is any issues.

Filament Change:

[gcode_macro M600]

gcode:

    {% set X = params.X|default(50)|float %}

{% set Y = params.Y|default(0)|float %}

    {% set Z = params.Z|default(10)|float %}

    SAVE_GCODE_STATE NAME=M600_state

    PAUSE

    G91

    G1 E-.8 F2700

    G1 Z{Z}

    G90

    G1 X{X} Y{Y} F3000

    G91

    G1 E-50 F1000

    SET_IDLE_TIMEOUT TIMEOUT=7200

    RESTORE_GCODE_STATE NAME=M600_state


There are several variables you can change to suit your tastes. By default, during the filament change, this macro retracts, moves the printhead 10mm up along the Z axis, then to the coordinates X50, Y0. It has a further retraction(50mm), then waits the length of the idle timeout, which by default is 7200seconds (120 minutes) all the while keeping the nozzle at temperature. If the print has not been restarted within the timeout period the nozzle will cool and the print will need to be started over.

Manual Bed Mesh (without BL Touch):

[bed_mesh]

#this video shows how to use a Manual Mesh https://youtu.be/yNoPNzFKXvU

speed: 80

horizontal_move_z: 1

mesh_min: 10, 10

mesh_max: 194, 203 #this may need to be calibrated for your individual printer

probe_count: 5,5 #this is the number of probing points on X then Y axis

mesh_pps: 2,2

fade_start: 1

fade_end: 10

fade_target: 0


To create a Bed Mesh without using a probe, first add this section to your printer.cfg. Then this command needs to be ran within the terminal line:

BED_MESH_CALIBRATE METHOD=MANUAL

This will move your nozzle around the bed while you attempt to get a uniformed gap between the nozzle and bed (using a post it note or similar). When finished you’ll be asked to save the mesh. To call upon the mesh you need to input this line within your start code:

BED_MESH_PROFILE LOAD=default

Bed Leveling (Manual):

[bed_screws]

screw1: 24, 38 #these are example coordinates

screw2: 194, 38 #find your own coordinates as described in this video https://youtu.be/yNoPNzFKXvU

screw3: 194, 204

screw4: 24, 204


To have Klipper help automate bed leveling, first add this section to your printer.cfg. Then this command needs to be ran within the terminal line:

BED_SCREWS_ADJUST

This will move your nozzle over each adjustment knob on the print bed. At each location you will bed level as normal (see calibrations page-attempt to get a uniformed gap between the nozzle and bed using a post it note or similar).

BL Touch (Auto bed leveling device):

[bltouch]

sensor_pin: ^PB1  #This is board specific

control_pin: PB0  #this is board specific 

x_offset: -31   #calibrate this yourself

y_offset: -40.4   #https://youtube.com/shorts/FKvPU2nwdts?feature=share

samples: 2

speed: 2

z_offset: 0.0 #this must be calibrated using probe_calibrate

[bed_mesh]

speed: 80

horizontal_move_z: 5

mesh_min: 10, 10 #finding the min and max limits for your bed mesh will

mesh_max: 194, 203  #will be featured in an upcoming video

probe_count: 5,5

mesh_pps: 2,2

fade_start: 1

fade_end: 10

fade_target: 0

[safe_z_home]

home_xy_position: 125,125  # Change coordinates to the center of your print bed

speed: 50

z_hop: 10        # Move up 10mm

z_hop_speed: 5


To create a bed mesh using an auto bed leveling device, first add all three of these sections to your printer.cfg Then you need to calibrate your z probe offset by inputting the following command in the terminal line:

PROBE_CALIBRATE

Then home the printer and calibrate a new mesh. Afterwards, Save and Restart, then add this to your start code after any calls to G28:

BED_MESH_PROFILE LOAD=default

START AND END MACRO:

[gcode_macro START_PRINT]

gcode:

G92 E0 # Reset Extruder

G90 # use Absolute Positioning

G28 # Home all axes

BED_MESH_PROFILE LOAD=default

G1 Z2.0 F3000 # Move Z Axis up little to prevent scratching of Heat Bed

G1 X0.1 Y20 Z0.3 F5000.0 # Move to start position

G1 X0.1 Y200.0 Z0.3 F1500.0 E15 # Draw the first line

G1 X0.4 Y200.0 Z0.3 F5000.0 # Move to side a little

G1 X0.4 Y20 Z0.3 F1500.0 E30 # Draw the second line

G92 E0 # Reset Extruder

G1 Z2.0 F3000 # Move Z Axis up little to prevent scratching of Heat Bed

G1 X5 Y20 Z0.3 F5000.0 # Move over to prevent blob squish

[gcode_macro END_PRINT]

gcode:

G91 ;Relative positioning

G1 E-2 F2700 ;Retract a bit

G1 E-2 Z0.2 F2400 ;Retract and raise Z

G1 X5 Y5 F3000 ;Wipe out

G1 Z10 ;Raise Z more

G90 ;Absolute positioning

G1 X0 Y230 ;Present print

M106 S0 ;Turn-off fan

M104 S0 ;Turn-off hotend

M140 S0 ;Turn-off bed

M84 X Y E ;Disable all steppers but Z


This is an extremely minimalist version of a Start and End macro that I use for the slicer Ultimaker Cura. start and end macros are written specific to the slicer you are using so make sure this is compatible with your current slicer. Keep in mind that slicer software gets updated all the time, new updates to a slicer can render previously usable macros unusable(by changing internal definitions for example), and if you run into any trouble with these macros now or in the future contact me.

PID Tune HOTEND and BED

[gcode_macro PIDtuneHOTEND]

gcode:

{% set TEMP = params.TEMP|default(200)|float %}

PID_CALIBRATE HEATER=extruder TARGET={TEMP}


[gcode_macro PIDtuneBED]

gcode:

{% set TEMP = params.TEMP|default(60)|float %}

PID_CALIBRATE HEATER=heater_bed TARGET={TEMP}


This Macro is simple convenience. Running a PID tune within Klipper only consists of a single line, except I always end up forgetting it. Instead of wasting a few minutes searching online (or looking back at my videos), I decided to dedicate a Macro to it. This creates a Macro button on your home screen that gives you the option to set the target temp and then Send the command. It’s simple, easy, and effective, as Macros aim to be.

Calibrate BL Touch Z Offset

[gcode_macro BeginTheProbe]

description: start process because I'm forgetful

gcode:

G28

probe_calibrate


Adding to the theme of convenience, this is another one line macro. Whenever I need to adjust the Z offset of my probe I always forget the command (is it probe_calibrate or calibrate_probe?). This let’s me click a button instead of having to tax my brain. As for the macro name feel free to change any and all of them. The name ‘BeginTheProbe’ just made me laugh, it can be named anything you want (as long as there aren’t any spaces within the name), so you can recall it’s function easily.