Yes, you can create a macro to do it. Here is a potential procedure, and probably not the only, or best way to do it.
This is mostly from memory so it will need tweaking.
Also be sure to update to the latest stable firmware version first, if possible. In the gcode examples below, i'm assuming at least RRF v3.0
-
Mount a switch somewhere on the build plate where every tool can reach.
-
Define an additional Z-endstop in the console. Add this line to the beginning of your macro, later on, as well.
(e.g.M574 Z0 P"pin_name" S1
)
- Before proceeding, you need to measure the height at which your z-offset probing switch actuates (e.g. "z_switch_actuation_height")
- Pickup any tool with a syringe tip and clear the existing Z-offset
- move the tip above the switch
Tx ; Pick up a tool with syringe tip
G10 Px Z0 ; clear z-offset for active tool
G1 Xx Yx ; move syringe tip over z-offset switch
-
manually jog the bed upward until the switch actuates (use M119 in the console to determine the endstop state and note at which height it changes. Always use M114 in the console to check axes positions, the positions in the DWC dashboard are rounded numbers)
-
write down the current z-position (for instance 40mm)
-
move off the switch and manually jog the buildplate up to the syringe tip (use a sheet of paper, if needed, to feel when the tip is close to touching the build plate).
-
write down the current z-position (for instance, 25mm)
-
Initiate a global variable for the actuation height. This will always be the same unless you change something about your z-switch mount.
global z_switch_actuation_height = 40 - 25 ; minus the thickness of the sheet of paper, too , if needed
- Put this global variable at the end of your config.g
The Automatic offset macro:
- Write some gcode to pick up a tool (with newly installed syringe tip), move the syringe tip over the switch and probe the switch
Tx ; pick up a tool
G1 Z10 ; Move the bed down (probably taken care of by your tpostx.g macros already, just need to more the bed to a safe position to prevent crashes)
G10 Px Z0 ; clear the previous Z-offset for the active tool
G1 Xx Yx ; move over the switch
G91 ; set to relative positioning
G1 Z-10 H4 ; Syringe tip probes the switch and stops when the switch actuates (that's what the H4 does)
G90 ; set to absolute positioning
Query the object model for the current position of the Z-axis and initiate a variable. An if statement checks if the variable already exists, and will overwrite it if so, or initiate it if not. This is useful if you are running the macro multiple times; otherwise RRF will give you an error that a variable already exists.
if exists (var.current_z_pos)
set var.current_z_pos = move.axes[2].machinePosition
else
var current_z_pos = move.axes[2].machinePosition
- Take the measured z-position and subtract your pre-determined z-switch 'actuation height'
var Tx_z_offset = var.current_z_pos - global.z_switch_actuation_height
- The difference calculated in step 4 should be your new z-offset for the active tool. Add this to the active tool's G10 command, ENSURE IS IT NEGATIVE, and save with M500 to the config-override.g
G10 Px Z{var.Tx_z_offset} ; set new z-offset
M500 ; save the offset (will appear in config-override.g)
T-x ; return the tool to the dock