How to Machine an Internal Keyway on a CNC Lathe?

Machining an internal keyway (slot for a key) directly on a CNC lathe is a massive time saver. It eliminates the need to transfer the workpiece to a slotting machine, while maintaining perfect coaxiality.

Process Kinematics on a Lathe

Slotting on a CNC lathe is most commonly performed with a locked spindle (C-axis or M19 code). The cutting (working) movement is executed by the Z-axis, while the X-axis is responsible for the radial feed of subsequent material layers and the tool retract distance before the return stroke. Unfortunately, manufacturers do not implement appropriate functions for this in their software. Fortunately, every lathe supports low-level control via G-codes. With a basic knowledge of this language, you can quickly write a program to control the tool movement accordingly. Here is an example:

As you can see, the code is very simple, yet long. It can be simplified with a loop, allowing the machine to increase the depth automatically:

In this program, a simple WHILE loop forces the execution of 4 lines of G-code until variable #102 equals variable #103. The program can be further expanded by adding an extra loop for subsequent teeth, etc. However, I recommend a tool that you simply install on your PC to quickly generate safe machine code by entering the required keyway parameters.



Regardless of how you control the machine, there are certain factors to keep in mind:

  • Each lathe has a different rigidity and maximum axis thrust.
  • Slotting can induce vibrations and faster axis wear.
  • Excessively fast and short movements can cause the Z-axis to operate for too long under ultimate load caused by speed changes (axis acceleration and deceleration), which can lead to servo overheating.

However, responsible slotting does not harm the machine, and the benefits are truly immense:

  • Turning and keyway/spline machining in a single setup.
  • When positioning with the C-axis, the division between keyways is highly precise.
  • Tool retraction is always full – in many traditional slotting machines, tool retraction is symbolic, causing the tool to slightly rub during the return stroke anyway.
  • Time savings.
Scroll to Top