Coder Social home page Coder Social logo

cnc-macros's Introduction

CNC-Macros

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 Macros

Features

  • 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.

File Structure

  • 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.

Usage

  1. Download the .cfg files or clone the repo into ~/printer_data/config or your chosen directory.
  2. add the [save_variables] section to your printer.cfg:
[save_variables]
filename:/home/pi/printer_data/config/savedVariables.cfg
  1. Include the .cfg files in your printer.cfg:
[include CNC-Macros/codeOverrides.cfg]
[include CNC-Macros/workspaceMacro.cfg]
[include CNC-Macros/customOperations.cfg]

Processes

Simple Job Setup

  1. Home the machine.
  2. Jog to the start position (e.g., stock Top, Front, Left as 0,0,0 in Fusion 360 CAM).
  3. Use SET_OFFSET_FROM_TOOL to set X, Y, Z offsets.
  4. Optionally, use SAVE_OFFSETS to save offsets to a file.
  5. Start the job.
  6. Profit.

Probing

Two methods for probing metal workpieces:

  1. Alligator Clips: Attach to the endmill and the metal piece.
  2. Z Puck Probe: Like this one from AliExpress.

With alligator clips, you can probe X, Y, and Z positions.

For X and Y Probing:

  1. Install a 4mm endmill or rod.
  2. Attach clips to endmill and workpiece.
  3. Position the tool close to the workpiece.
  4. Use START_PROBE_AXIS with variables.
  5. The toolhead moves in 0.1mm increments until contact.

For Z Probing:

  • Use the actual endmill for correct height offset.

G-Code Macros

Workspace Macros

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.

Built-In Overrides

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.

cnc-macros's People

Contributors

noobydp avatar renoschubert avatar

Stargazers

 avatar Royal 58 avatar  avatar kejoy avatar  avatar Swap avatar  avatar

Watchers

 avatar  avatar  avatar

cnc-macros's Issues

Can't "jog" after setting Workspace Origin

First off, thank you for your work on this, it's tremendous and usable as is! There were a few things I had to tweak I'm happy to share as well in a pull request once I understand everything and get some use with it.

One noticeable issue I have is trying to job the toolhead around after setting workspace. If I use the jogging controls in Mainsail, it will take the number that displays in Mainsail and seemingly add it to the workspace offset as a relative move (which sends things crashing).

I was able to write a macro to wiggle around this for the few movements I need (for instance, moving Z to a safe distance after setting workspace home so I can turn the router on) but do you see any way of changing that behavior or am I using something incorrectly?

Cheers!
Rob

discord username is xberty if you want to chat about this project

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.