Skip to content

Useful code snippets

Sven edited this page Aug 11, 2019 · 5 revisions

Useful code snippets

Check linuxcnc for further GCode information.
Here are some useful gcodes for use inside scripts or custom buttons:

Move in absolute machine coordinates (homing with end-switches is needed)

G90 G0			(absolute distance mode, rapid move)
G53 Z-50		(move in machine coordinates to save height)
G53 X-150 Y-50		(move in machine coordinates to stationary switch/tool length sensor)

Probing (assume units = mm, tool stays above tool length sensor)

G38.3 Z-30 F100		(probe towards tool length sensor, maximum 30 mm downwards, speed 100 mm/min, stop on contact)
G43.1 Z#PRBZ		(Offset Tool with result from probing)
G91 G0 Z5		(move relative 5 mm upwards, to get free from sensor)
G90			(switch back to absolute distance mode)