G Code for Turning Straight: Syntax and Example
To turn a straight line on a CNC lathe, use
G01 for linear interpolation combined with coordinate values for the tool path. The command moves the tool in a straight line at a controlled feed rate, essential for straight turning operations.Syntax
The basic syntax for straight turning uses the G01 command, which tells the machine to move the tool in a straight line at a set feed rate.
G01: Linear interpolation (straight line move)X: Target position along the X-axis (diameter or radius)Z: Target position along the Z-axis (lengthwise along the part)F: Feed rate (how fast the tool moves)
Example: G01 X20 Z-50 F0.2 moves the tool straight to X=20 and Z=-50 at feed 0.2.
gcode
G01 X20 Z-50 F0.2
Example
This example shows a simple straight turning move from the current position to X=30 and Z=-100 at a feed rate of 0.15 mm/rev.
gcode
N10 G90 G95 G54 N20 T0101 M06 N30 S1200 M03 N40 G00 X50 Z5 N50 G01 X30 Z-100 F0.15 N60 G00 X100 Z100 N70 M05 N80 M30
Output
Tool moves rapidly to X50 Z5, then cuts straight to X30 Z-100 at feed 0.15, then retracts.
Common Pitfalls
Common mistakes when programming straight turning include:
- Forgetting to set the feed rate with
F, causing the machine to use rapid moves which can damage the tool or part. - Using
G00(rapid move) instead ofG01for cutting moves. - Not specifying both
XandZcoordinates, leading to unintended tool paths.
Correct usage ensures smooth, controlled straight cuts.
gcode
Wrong: G00 X20 Z-50 (rapid move, no cutting) Right: G01 X20 Z-50 F0.2 (controlled straight cut)
Quick Reference
| Command | Description |
|---|---|
| G00 | Rapid positioning (non-cutting move) |
| G01 | Linear interpolation (straight cutting move) |
| X | Target position on X-axis (diameter/radius) |
| Z | Target position on Z-axis (lengthwise) |
| F | Feed rate (speed of cutting) |
Key Takeaways
Use G01 with X, Z, and F to program straight turning moves.
Always set a proper feed rate with F to avoid rapid moves during cutting.
Avoid using G00 for cutting; it is for rapid, non-cutting moves only.
Specify both X and Z coordinates to control the tool path precisely.
Check your program for correct command sequence to prevent tool or part damage.