Enhanced CNC Macros for Klipper Firmware
Drawing inspiration from Klippy-cnc (https://github.com/vladbabii/klippy-cnc/tree/master), this collection of CNC macros is specifically designed for 3-axis CNC machines like the 3018 / 3040 / 6040, but should work on any. It brings advanced capabilities in workspace management, custom movement commands, and specialized operations for CNC machining, elevating precision and functionality.
The macros make use of the built-in SET_GCODE_OFFSET command to set the workpiece offset.
- Workspace Management: Comprehensive set of macros for defining, adjusting, and recalling workspace coordinates.
- Custom Command Overrides: Customizes standard G-code commands to incorporate workspace offset.
- Specialized Operations: A range of specific macros tailored for tasks like slab flattening and probing.
- Enhanced Machine Control: Macros for controlling the spindle, emergency stops, and firmware restarts, augmenting safety and ease of use.
- workspaceMacro.cfg: Dedicated to workspace coordinate management.
- codeOverrides.cfg: Contains overrides for default macros and custom G-code/M-code commands.
- customOperations.cfg: Features macros for specific CNC tasks and operations.
- kcncCustomOperations.cfg: Features macros for specific CNC tasks and operations when running klipper-for-cnc fork
Combined, these files significantly improve control, accuracy, and safety in CNC machining using Klipper firmware.
- Download the
.cfg
files or clone the repo into~/printer_data/config
or your chosen directory. - add the [save_variables] section to your
printer.cfg
:
[save_variables]
filename:/home/pi/printer_data/config/savedVariables.cfg
- Include the
.cfg
files in yourprinter.cfg
:
[include CNC-Macros/codeOverrides.cfg]
[include CNC-Macros/workspaceMacro.cfg]
[include CNC-Macros/customOperations.cfg]
If you are using the klipper-for-cnc fork, also include this file
[include CNC-Macros/kcncCustomOperations.cfg]
- Note the kcncCustomOperations.cfg file overrides some macros in customOperations.cfg, this is by design.
- If using a tool setter switch add a
[gcode_macro USER_VARIABLES]
macro to printer.cfg
variable_tool_setter_xy: 1, 344.2
variable_tool_setter_z_offset: 2.359
variable_workpiece_probe_diameter: 4
variable_multi_diameter: 2.00
gcode:
- Read through the macros and comments in each of the cfg files so you know what's going on.
- Home the machine.
- Jog to the start position (e.g., stock Top, Front, Left as 0,0,0 in Fusion 360 CAM).
- Use
SET_OFFSET_FROM_TOOL
to set X, Y, Z offsets. - Optionally, use
SAVE_OFFSETS
to save offsets to a file. - Start the job.
- Profit.
Two methods for probing metal workpieces:
- Alligator Clips: Attach to the endmill and the metal piece.
- Z Puck Probe: Like this one from AliExpress.
With alligator clips, you can probe X, Y, and Z positions.
For X and Y Probing:
- Install a 4mm endmill or rod.
- Attach clips to endmill and workpiece.
- Position the tool close to the workpiece.
- Use
PROBE_AXIS
with variables. - The toolhead moves in 0.1mm increments until contact.
For Z Probing:
- Use the actual endmill for correct height offset.