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.
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]
- 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
START_PROBE_AXIS
with variables. - The toolhead moves in 0.1mm increments until contact.
For Z Probing:
- Use the actual endmill for correct height offset.
Essential for CNC precision, these macros manage workspace coordinates and adjust movements accordingly.
To Do: Explore using Klipper's SET_GCODE_OFFSET.
Macro | Description |
---|---|
SAVE_OFFSETS | Saves current workspace offsets to the Raspberry Pi. |
LOAD_OFFSETS | Loads saved workspace offsets, reinstating workspace positions. |
CHECK_OFFSET_XYZ | Displays current workspace offsets with warnings if unset. |
SET_OFFSETS_FROM_TOOL | Sets tool's current position as workspace offsets. |
UPDATE_OFFSETS_XYZ | Manually set/update workspace offsets for X, Y, Z. |
ZERO_OFFSETS_XYZ | Resets workspace offsets to zero. |
WORKSPACE | Utility macro to report current workspace offsets. |
ADJUSTED_MOVE | Applies workspace offsets to movement commands with safety checks. |
Enhanced control and functionality for CNC operations through macro overrides and custom commands.
Macro | Description |
---|---|
FW_RESTART | Executes a firmware restart. |
EStop | Triggers an emergency stop (M112). |
PAUSE | Saves position, stops spindle, moves Z to max height. Needs update for state saving. |
RESUME | Restores spindle speed and position from saved state. |
CANCEL_PRINT | Raises Z, stops spindle, turns off motors. |
G28 | Custom homing sequence, homes Z first. |