CAM program for CNC milling: from a contour and a pocket to G-code
Describe the part and the cutter, and the tool gives the toolpath and a finished program for the chosen controller. The program is read back, so you see the checks that pass and those that were not done.
Part of Pro, 15 EUR a month.
- 3 operationstwo contours and a pocket
- 5 controllersFanuc, Haas, LinuxCNC, GRBL, Marlin
- 4 checksthe program is read back
- Exact depththe last pass is the remainder
What CAM is and what this program does
CAM is the program that turns the shape of a part into a cutter toolpath and a finished G-code program for a CNC machine. The EduFacturing one is an online tool, part of Pro. The feature is one of three: a rectangle contour, a circle contour or a rectangular pocket.
You set the dimensions, the cutter diameter, the depth of cut, the two feed rates, the direction and the controller. The tool gives the number of passes, the cutting path and the G-code itself, which copies with one button.
The calculations run in the browser. The start and end blocks come from the shared module of controller dialects.
G-code for a mill from a contour or a pocket
Builds a toolpath for contours and pockets
The contour goes around the outside, with the cutter centre one radius out from the drawing. The pocket runs on concentric contours inward, and a circle is made of 48 segments.
Splits the depth into passes
The last pass is the remainder: 5 mm at 2 mm per pass gives Z −2, −4 and −5. Entry is ramped or vertical with its own feed rate, and the path direction is climb or conventional.
Writes G-code for your controller
Units, work offset, tool change, spindle, coolant, retract and the end of the program depend on the controller.
Checks the program and says what was not checked
Four checks on the G-code read back. A separate list shows the checks that were not done, and why.
When you need a CNC milling program
A toolpath makes sense when you can see how dimensions become lines.
A CNC programming course
A student changes the cutter diameter and sees how the coordinates and the cutting length change.
A simple job on a small machine
A pocket or a contour for a part on a GRBL or Fanuc-compatible machine, with no hand calculation of the offset.
Comparing controllers
Switching the controller changes only the start and end blocks: Haas and LinuxCNC retract with G53, and GRBL has no automatic tool change and no G43.
How the passes and the toolpath are worked out
The geometry is plain mathematics, with no table values. Rules from the rules core appear only as qualitative notes, with no invented numbers.
Path in the plane
The contour is offset outward by the cutter radius. The pocket starts one radius in from the wall and steps inward.
Lines of the program
For every pass and contour: safe Z, rapid to the start, entry, then the path at feed. The start and end blocks come from the chosen controller.
| Applies to | Formula | Meaning |
|---|---|---|
| Depth passes | n = ⌈H / h⌉, Z_k = −min(k·h, H) | H is the depth, h is the depth of cut; at 6 and 2 mm, n is 3 |
| Rectangle contour | half side of the path = W/2 + D/2 | W is the width, D is the cutter diameter; the centre runs outside |
o_k = D/2 + k·s·D, while o < min(W, H)/2 | s is the stepover as a fraction of D; the contour is W − 2·o by H − 2·o | |
| Cutting path | L = Σ perimeters · n | in the plane, without rapid moves; for a 50 × 30 mm pocket, D = 6, s = 0.5, H = 6, h = 2 mm: 400 mm · 3 = 1200 mm |
A program check, and what was not checked
G-code check after generation
The program is read back through the G-code module shared with the G-code checker. It checks that every line reads, that the program ends at a safe height, that every cut has a feed rate and that the deepest point is exactly the requested one.
The cutter radius is in the coordinates
Without G41 and G42 the cutter radius is in the coordinates and does not depend on the radius compensation in the controller. The tool length (G43) and the work offset (G54) still come from the machine.
It shows what was not checked
Depending on the setup, the ramp angle, the depth of cut and the stepover against the diameter are listed with a reason: the rules core has no rule for them, and a number is not invented.
Three operations: no arbitrary geometry, no 3D surfaces and no rest machining. Circles are made of segments, with no G2 and G3 arcs. The feed rates are an input and are not checked against the material. Climb is a path counterclockwise for all three operations, and the spindle is M3: by the geometry that is climb cutting for the pocket but conventional cutting for the outside contour.
The start and end blocks are fixed: millimetres, work offset G54 (not on Marlin), tool 1, 3000 rpm, coolant M8 and a safe Z of 25 mm. On GRBL and Marlin the tool change is a comment and M6. The program is copied, not downloaded as a file, and the toolpath is not drawn here.
Questions about the CAM program for CNC
What is CAM in CNC?
CAM is the program that turns the shape of a part into a cutter toolpath and G-code for the machine. Here there are three operations: a rectangle contour, a circle contour and a rectangular pocket.
How do I write G-code for a CNC mill?
Set the dimensions and the cutter, choose the controller and copy the finished G-code with one button.
Why is the offset in the coordinates, not G41 and G42?
The tool works out the cutter radius and puts it in the coordinates. G41 and G42 need a filled tool table and correct lead-in and lead-out moves.
What is the difference between vertical and ramped entry?
Vertical goes straight down and needs a centre-cutting cutter, with a lower feed than cutting. Ramped goes down along the first segment of the contour. Its angle is not checked.
Which controllers does it write G-code for?
Fanuc and compatible, Haas, LinuxCNC, GRBL and Marlin in CNC mode. The blocks differ in the % sign, the program number, G43, work offsets, retract and comments.
How much does it cost, and how do I get access?
The CAM program is part of Pro at 15 EUR a month. Pro also opens the other Pro tools in the catalog.
The CAM programs for milling is part of Pro
Pro costs 15 EUR a month and opens all 45 Pro tools.
Related tools
G-code checkerG-code checker for milling: follows the machine state line by line, finds 13 kinds of findings and checks speed and feed. Free, 3 times a day with no account.
G-code start and end blocksStart and end blocks of a CNC program, as a CNC post processor writes them for Fanuc, Haas, LinuxCNC and GRBL, from your settings. Part of Pro, 15 EUR a month.
CNC G-code viewerCNC G-code viewer online: paste a milling program and see the cutter path from above, with lengths and a time estimate. Part of Pro, 15 EUR a month.
Generate your first milling program
Part of Pro, 15 EUR a month.