CNC command support

I just submitted a pull request to support work offsets and planning on adding the following cnc commands (a minimal set based on what fusion 360 produces). Feedback if these are sufficient or if there are others that should also be included based on cnc g-code producers.

Where possible, g-codes consistent across most command sets are used to invoke functionality. For other situations, functionality uses Klipper’s preference for human readable “extended G-Code command” language and additional macro mappings are provided to support the different command sets. All status commands will follow Klipper’s extended command language.

| function                   | command | GRBL v1.1 | marlin | linuxcnc | Haas CNC | Smoothie | Mach3 |
| -------------------------- | ------- | --------- | ------ | -------- | -------- | -------- | ----- |
| probe target               | G38.2-5 | x         | x      | x        | G36      | x        | G31   |
| spindle forward            | M3      | x         | x      | x        | x        | x        | x     |
| spindle reverse            | M4      | x         | x      | x        | x        |          | x     |
| spindle stop               | M5      | x         | x      | x        | x        | x        | x     |
| make tool change           | M6      | x         |        | x        | x        |          | x     |
| mist coolant on            | M7      | x         | x      | x        | x        | x        | x     |
| flood coolant on           | M8      | x         | x      | x        | x        | x        | x     |
| coolant off                | M9      | x         | x      | x        | x        | x        | x     |
| prepare tool change        | T       | x         | x      | x        | x        | x        | x     |
2 Likes

Ever thought about writing/using macros for them?

There is an extensive Klipper CNC Macro set here: GitHub - enarges/klippy-cnc: KCNC - Klipper CNC Macro Package

I’m not into CNC so I cannot comment qualified but in my opinion:

  • Macros should not be used for complex operations
  • Macros require many workarounds to implement more complex logics
  • Macros are hard to debug
  • They make the configs virtually unreadable
  • Are simply copied all across the configs without the user understanding them and probably also do not need them

I’ve seen so many beginner configs where not even the endstops were working but contained around 1000 lines of macros → Everything that is not a macro is my friend

Having said this, I think Klipper overall would profit from a serious CNC implementation, so :+1:

2 Likes

Never the less, a z axis with two endstops is required to use klipper for a cnc milling solution. this requrement was often discussed and also often declined from Kevin. I try to implement estlcam features in klipper step by step and found a solution for this but a still open point is the “press button → move stepper” usecase or using a handwheel, If you are interested in I provide my hacks here. GitHub - linux-paul/klipper: MPCNC Klipper modification