CNC Lathe G-code Generator: Create Turning Programs Without CAM
· ~14 min read
In short: a CNC lathe G-code generator turns the sizes of a typical operation (diameters, lengths, depth of cut, feeds, RPM) into a ready program, with no CAM and no model. Turn G-code is a desktop generator for Windows and Linux: 12 turning cycles, a 2D toolpath preview before the file is written, plain ISO G-code without canned cycles. Made for LinuxCNC; also fits grblHAL, PathPilot and Fanuc System B/C; not for Fanuc System A, Haas, GSK or KND.
Try it now: the OD turning cycle runs right in your browser in the online CNC lathe G-code generator - free, no sign-up, same code as the program.
You need to turn a shaft down, cut a thread or part off a piece. Writing the G-code by hand takes a while, and firing up a CAM system for a job like that is overkill. That is what a CNC lathe G-code generator is for: you enter the sizes and cutting data, and it works out the passes and writes the program. This page shows how that works in Turn G-code, which operations it covers, how it fits a LinuxCNC lathe, and where its limits are.
Contents
- What a lathe G-code generator is
- How Turn G-code works
- Which turning operations it can program
- Turn G-code and LinuxCNC
- Which CNC controls it works with
- G-code generator or CAM?
- Online G-code generators or a desktop program?
- Example: turning Ø12 down to Ø10
- Checking the toolpath before you cut
- Who Turn G-code is for
- FAQ
What a lathe G-code generator is
There are three ways to get a program for a CNC lathe:
- By hand. Full control, but you work out and type every pass, approach and retract yourself. Five roughing passes means dozens of lines, and one typo in an X value means a scrapped part or a broken insert.
- In CAM. You need a part model, stock and tool setup, and a post processor for your control. See the overview of CAM software for CNC lathes.
- With a parametric generator. Pick the operation and fill in the fields: diameters, length, depth of cut, finishing allowance, feeds, spindle speed. The generator calculates the toolpath by fixed rules and writes the G-code.
A generator does not machine from a 3D model or look for an optimal strategy the way CAM does. It does one thing: turns the dimensions of a typical operation into a correct program. Industrial controls call the same idea conversational programming - more on that in Conversational programming for CNC lathes.
How Turn G-code works
Turn G-code is a standalone program for Linux and Windows. Every job follows the same steps:
- Pick the operation. Each of the 12 cycles has its own form: turning, threading, grooving and so on.
- Enter the parameters. Dimensions from the drawing or the stock: diameters, lengths, thread pitch. Cutting data: depth per pass, finishing allowance, feeds, spindle speed.
- Check it. Next to the fields is a 2D simulator, so the tool path is visible right in the form, before any file is generated.
- Generate. You get a plain-text G-code file (
.ngc,.ncor.tap): roughing passes down to the allowance, the finishing pass, approaches and retracts, all worked out. - Run it. LinuxCNC opens the file like any other program: preview, a dry run if you want one, then the cut.
The output format is set once to suit your control and your habits: a G7/G8 switch (X as diameter or radius) for all cycles at once, threading moves as G33 or G32 with the pitch word I, K or F, your own coolant M-codes, and the tool number, comments and M30 at the end can each be switched on or off. The interface is in English or Russian, and works in millimeters or inches.
Which turning operations it can program
Turn G-code has 12 cycles, each with its own page showing the parameters, a screenshot of the form and a sample program:
- OD turning - roughing passes plus a finishing pass with allowance.
- Facing - face to length in one or more passes.
- Threading - external and internal, right- and left-hand, multi-start, with adjustable run-in and run-out.
- Taper threading - the same options, with the thread cut along a taper.
- Taper - external and internal, from start and end diameters.
- Sphere - convex and concave, such as a pulley groove.
- Grooving - set width and depth, accounting for the tool width, external or internal.
- Drilling - on the spindle axis, including peck drilling to clear chips.
- Boring - internal diameters with roughing and finishing passes.
- Cutoff - accounts for the parting tool width.
- Chamfer and radius - external and internal, front and back edges, all four combinations.
- Archimedean spiral - a spiral groove or thread on the face.
One cycle produces one program. Turn G-code cannot chain several operations into one process plan, and it has no free-form contour made of arcs.
Turn G-code and LinuxCNC
Turn G-code was built for LinuxCNC lathes and tested on the author’s machine - most cycles with real cuts in metal, not just air runs. Each cycle page says which.
What that means in practice:
- No changes to your LinuxCNC config. Turn G-code does not plug into the LinuxCNC GUI and needs no ini or HAL edits. Install it with a normal installer on the machine PC (Linux) or an office PC (Windows) and move the finished file across.
- G7 and G8. LinuxCNC supports both X modes, and Turn G-code outputs whichever one you pick. The difference is explained in G7 and G8 in LinuxCNC.
- Threads pass by pass. A thread is not one G76 line: every pass is written out with G33 (or G32). That is what makes multi-start threads, run-in and run-out, and full-length tapered threads possible. Details in Threading in LinuxCNC: G33 and G76.
- Compared with the free tools. LinuxCNC has free lathe options of its own - Lathe Macros, LatheEasyStep, NativeCAM. An honest comparison: Turn G-code vs free LinuxCNC lathe tools.
The output is plain G-code, so with the G32/G33 switch and the pitch letter you can prepare it for another control too. But LinuxCNC is what it has been tested on, so for anything else check the code against your control’s manual - see Turn G-code on different CNC controls.
Which CNC controls it works with
Turn G-code writes basic ISO G-code: G0, G1, arcs, G33 or G32, with every pass written out and no control-specific canned cycles. Everything that differs between controls is a switch in the top bar. That covers most lathe controls, with one important exception:
| Control | Works? | What to set |
|---|---|---|
| LinuxCNC | Yes, native | Nothing |
| Tormach PathPilot (LinuxCNC-based) | Yes | G7/G8 mode for your machine |
| grblHAL in lathe mode | Yes | G7/G8, threading G33 with K |
| Fanuc, G-code System B or C | Yes | X as diameter, G7/G8 output off, threading G33 or G32 with F |
| Syntec, Siemens (ISO mode), Mitsubishi | In G-code system B/C | Same as Fanuc B/C |
| Fanuc System A, Haas, GSK, KND | No | Not supported |
Why not System A: there G90 and G94 are turning and facing cycles, and the feed is read per revolution, so a program written for LinuxCNC would run with the wrong meaning and a dangerous feed. How to tell which system your control uses, and what to check on the first run, is in Turn G-code on different CNC controls. Other PC-based controls (Mach3, Mach4, Centroid) have not been tested: check the first program against the manual and run it in the air.
G-code generator or CAM?
A generator is the better fit when:
- the part is turned from standard features: steps, faces, tapers, threads, grooves, chamfers, holes;
- you have a drawing or a sketch with sizes, and no model (nor any reason to make one);
- you want the program in a couple of minutes at the machine, and tomorrow you will change one dimension;
- the operator knows the job but does not want to work out every pass by hand.
You really do need CAM when:
- the profile is a complex contour of many blended arcs;
- the part already exists in 3D and the program should come from the model;
- it is a mill-turn machine: live tooling, C and Y axes, a sub-spindle;
- you want one program for the whole part, with a chain of operations and tool changes.
Plenty of shops use both: CAM for the complex parts, a generator for the steady stream of shafts, bushings and threads.
Online G-code generators or a desktop program?
Search for a lathe G-code generator and most results are free web pages: fill in a form in the browser, copy the code. For a quick look that is handy. Before you pick one for real work, check four things:
- Which control the code is for. Many online generators target Fanuc or Haas and use their canned cycles (G71, G70, G76 in Fanuc syntax). On a Fanuc System A or Haas lathe that is exactly right; on LinuxCNC the same lines mean something else, and the program has to be rewritten. Turn G-code is the other way round: built and tested on LinuxCNC.
- Which operations are covered. Typical web tools do OD turning, facing, grooving and a single-start thread. Turn G-code also does multi-start and tapered threads with run-in and run-out, taper, convex and concave sphere, internal and external chamfers and radii, and a spiral on the face.
- Whether it was tested on metal. Turn G-code cycles are checked on the author’s own LinuxCNC lathe, most of them by real cuts; each cycle page says which.
- Where it runs. A desktop program works on the machine PC itself, without a browser or a connection at the lathe, and keeps your settings (G7/G8, thread syntax, coolant codes) between jobs.
The free web tools are fine for learning and one-off checks. For the programs you actually run on a LinuxCNC lathe every day, a generator built for that control saves the editing.
Example: turning Ø12 down to Ø10
Take the simplest operation, OD turning: a Ø12 mm blank turned to Ø10 mm over a length of 20 mm.
What goes into the form:
- start diameter 12 mm, end diameter 10 mm, length 20 mm;
- 0.2 mm depth per pass, 0.1 mm finishing allowance;
- feed 100 mm/min for roughing and 80 mm/min for finishing;
- 500 rpm.
The check. The simulator shows five roughing passes and one finishing pass. The last roughing pass stops exactly at the allowance, with no extra hair-thin pass.
The output. The start and end of the program Turn G-code wrote (in G8 mode X is a radius, so Ø12 is X6 and Ø10 is X5; the middle passes are left out):
(Turn G-code)
(OD turning)
(Work offset: G54)
(Stock D12.0)
(Finish D10.0)
(Length L20.0)
G21 G18 G90 G8 G40 G80 G94
G54
G97 S500 M3
G0 Z2.0000
G0 X9.0000
(Roughing pass 1, X5.8000)
G0 X5.8000
G1 Z-20.0000 F100.0000
G0 X9.0000
G0 Z2.0000
...
(Finish pass 1, X5.0000)
G0 X5.0000
G1 Z-20.0000 F80.0000
G0 X9.0000
G0 Z2.0000
G0 Z2.0000
M5
M30
The full program, with every line explained, is on the OD turning page. By hand, this means working out five roughing diameters and typing about fifty lines. Here it is six fields in a form.
Checking the toolpath before you cut
Every cycle form has a live 2D toolpath simulator: a flat view of how the passes, approaches and retracts will run. It works before the file is generated, so a wrong diameter, length or depth of cut shows up on the screen, not on the part.
The simulator draws the path from the numbers you entered, but it knows nothing about your machine: where the chuck is, how the part is held, where your zero is set. So the check goes like this:
- the Turn G-code simulator - the passes land where you meant them to;
- the LinuxCNC toolpath preview - the file was read correctly and the work zero is where it should be;
- if needed, a dry run with the tool clear of the part.
Who Turn G-code is for
- Small shops with a LinuxCNC lathe, running typical parts in small batches without a dedicated programmer.
- Owners of converted machines - an old manual lathe retrofitted with CNC drives, or a benchtop lathe running LinuxCNC.
- Operators and setters who know turning but do not want to write every pass by hand.
- Training machines, where seeing the toolpath before the cut and comparing it with the code matters.
It is not the tool for mill-turn work, programming from a 3D model or a free-form profile - that is CAM territory.
FAQ
Is Turn G-code free? There is a 15-day free trial with every cycle, no key and no card. After that it is a one-time $99 lifetime licence, no subscription, for up to two computers.
Is it an online tool? No, it is a desktop program for Windows (Microsoft Store or installer) and Linux (.deb). Programs are generated on your own computer; the internet is needed to start the trial and to activate a key.
What file does it produce?
A plain-text G-code file: .ngc (the usual LinuxCNC extension), .nc or
.tap. Any control that reads ISO G-code opens it like a hand-written
program.
Does it use canned cycles like G71 or G76? No. Every roughing pass, finishing pass and thread pass is written out line by line. The program is longer, but it reads the same on any control that understands G0, G1 and G33/G32, and you can see exactly what the tool will do.
Does it support inches? Yes, millimeters and inches. The interface is in English or Russian.
Can it make one program for a whole part? No. One cycle gives one program. For a part with several operations you run the programs one after another, or join the files by hand.
Will it work with my control? LinuxCNC, PathPilot, grblHAL and Fanuc System B/C - yes; Fanuc System A, Haas, GSK and KND - no. See the table above.
Try it on your own parts: download Turn G-code - 15 days free, no key needed. After that, a lifetime license is $99: one payment, no subscription, up to two computers per key. All cycles, with parameters and screenshots, are on the features page.
