ForemkaCAD

CNC milling, turning and cutting: toolpaths and G-code

The MANUFACTURE tab turns a model into a program for a CNC machine: a mill, a lathe or a cutting machine (laser, plasma, waterjet). You say what piece of material you start from, what you cut it with and what has to go, and Foremka works out the toolpath, shows the tool removing material, compares the result with the model and writes the G-code, the plain-text list of moves the machine follows. Milling covers 2.5D operations, where the cutter works at fixed heights and steps down layer by layer (plates, pockets, outlines, chamfers, slots, lettering, holes, threads), and 3D operations, where the cutter follows a curved surface, such as the bottom of a bowl or a mold cavity. The browser does all of this on separate threads, so long calculations don't freeze the window.

What you can do

Setup and tools

  • New Setup describes the machine and the material you work with. The Operation type is milling, cutting (laser, plasma, waterjet) or turning. The stock, the raw block the part is cut from, is a box with an allowance around the model or of fixed size, and for turning a bar or a tube. You also pick the tool axis (top, bottom or a side of the model) and the work origin, the point every coordinate is measured from: a corner, a face center or the box center. On the Post Process tab you set the program number, the WCS offset (G54 to G59, the zero position stored in the machine) and the units: millimeters or inches.
  • An operation clicked on the ribbon when the project has no matching setup creates one with default values. Turning goes into a turning setup, cutting into a cutting setup.
  • Tool Library: flat, ball and bull nose end mills, face mills, drills, chamfer mills and thread mills, plus turning tools, boring bars (tools that turn inside a hole), grooving tools (narrow tools for grooves and parting), threading tools and cutting tools: laser, plasma and waterjet. Each has sizes, a holder and cutting data. A sample library of 23 tools and six holders (ER collets, SK40, HSK63) gets you started.
  • The holder is what the tool is clamped in. Pick one of the samples or describe your own: as a cylinder or as segments with given diameters and lengths. The simulation and the 3D operations check that the holder doesn't touch the stock or the model.
  • My library saves your own tools and post processors on the server, so you have them in every project. Without a connection a copy in the browser keeps working, and the changes are sent once the connection is back. Copy to my library copies a tool there from the document or the samples.
  • Operation dialogs have Tool, Geometry, Heights, Passes (Cycle when drilling) and Linking tabs. Operations that don't need some of them have fewer tabs. A height is a reference, such as Stock top or Model bottom, plus an offset. After OK the toolpath is generated at once.

2.5D milling

  • Face skims the top of the stock in zigzag passes down to the top of the model.
  • 2D Pocket clears material down to a flat floor. Islands rising from the floor stay. When a pocket opens onto the edge of the part, the cutter comes in from the air beside the stock instead of plunging into material. Rest machining clears only what earlier operations or a larger cutter left behind, such as material in the corners.
  • 2D Adaptive also clears pockets and lowers flat faces, but keeps the cutter under the same load the whole time, corners included. Optimal load is how wide the cutter bites into the material on a straight pass (usually 5 to 15% of the diameter). A narrow, even bite lets the cutter go down close to its flute length at once and move faster than a regular pocket. Across an edge without a wall the cutter clears material out to the stock outline.
  • 2D Contour follows an outline from the outside or a hole from the inside, in layers. The Side passes field adds finishing passes along the wall. Tabs (rectangular or triangular, with a width, height and spacing) leave thin bridges so the part doesn't break loose on the last layer. A contour also runs along an open chain of edges, from end to end.
  • 2D Chamfer bevels the edge of an outline or a hole to a set width with a chamfer mill.
  • Slot runs the cutter down the middle of a slot as wide as the tool, straight or ring shaped, ramping down in a zigzag.
  • Trace runs the tool center along sketch curves or model edges, for example to engrave lettering.
  • Drill has four cycles: drilling (G81), dwell (G82), deep drilling with full retract (G83) and chip breaking (G73). Holes run in shortest-path order.
  • Thread mills a thread with a thread mill that follows a helix inside a hole or around a boss. A zero diameter takes the size and pitch from the metric thread table: a 5 mm hole gives an M6 × 1 thread. Threads are right hand unless you clear Right-hand thread.

3D milling

3D operations work on the whole model of the setup, with nothing to select. The Machining boundary says where the tool may go: inside the stock outline, inside the model bounding box or inside the model silhouette seen from above. Roughing usually comes first: it removes most of the material quickly and leaves a thin layer of stock. Finishing then runs over the model surface itself.

  • Roughing: 3D Adaptive and 3D Pocket clear material in levels over the model and leave stock to finish (0.3 mm by default). 3D Adaptive cuts at a constant cutter load, like 2D Adaptive, while 3D Pocket runs in rings from the model walls. Flat areas of the model get a level of their own. The Rest from earlier operations of the setup option removes only what those operations left.
  • Parallel runs the tool over the surface in straight passes side by side, at a set angle. It works best on flat areas and gentle slopes.
  • 3D Contour runs at constant heights along steep walls, level by level. Ramp does the same without breaks between levels: the tool descends along the wall continuously, never steeper than the set angle.
  • Scallop keeps the stepover constant as measured along the surface, so the scallops, the narrow ridges of material between neighboring passes, are the same height on a flat floor and on a slope.
  • Steep and Shallow combines 3D Contour and Scallop: walls steeper than the threshold angle get contour passes, flatter areas get scallop passes.
  • Horizontal finishes only the flat areas of the model, in rings from the walls to the middle, and leaves walls and slopes alone.
  • Pencil runs along inner corners and fillets where the tool touches two walls at once, usually after a larger cutter. It can add passes on both sides of the corner.
  • Spiral and Radial move the tool in a spiral or along radii around the center of the machining boundary or a given point. They suit round shapes.
  • Project projects sketch curves or edges along the tool axis onto the model surface, for example to engrave lettering on a curved wall.
  • The Shaft and holder field of the 3D operations: no check, a warning with the number of places where the shaft or holder would touch the model, or a toolpath trimmed at those places (material stays there).

Several setups for one part

  • Start a part machined from two sides with Second side (on the ribbon and in the setup menu in the tree). The new setup has the tool axis reversed, the same bodies and the stock From preceding setup, that is the same piece of material with everything the first side already removed. 3D roughing on the second side removes only the material that is left.
  • Simulating such a setup runs through all setups of the part from the first one and shows the stock as a full solid, so you see the machining from every side.
  • Post Process builds one program from several setups (the Setups in program list). Without rotary axes each setup runs on the WCS offset from its own Post Process tab (G54, G55...), and when two in a row share one, the program stops (M0) so you can refixture the part. With a 4th axis or a trunnion table (A-C, B-C) the machine turns the part itself before each setup and keeps milling in three axes (known as 3+2 positioning). Coordinates are recalculated about the rotary center, and a Fanuc control can get a tilted work plane G68.2 instead.

Turning

  • A setup with the Turning operation type has a spindle axis, the origin on that axis at the stock front and a bar or tube as stock. A diameter and length of 0 come from the model plus stock, and a bore diameter of 0 means a solid bar.
  • In the TURNING group: Face squares off the bar front, Profile Roughing and Profile Finishing turn the part profile on the outside or inside a hole (boring), Groove plunges a grooving tool into recesses of the profile, Thread turns a thread with a threading tool on a selected cylinder, Part cuts the finished part off behind its back, and Drill drills a hole on the spindle axis.
  • Constant surface speed (G96) raises the spindle speed by itself as the tool gets closer to the axis, up to the Maximum spindle speed field. Feed is set in millimeters per revolution. The program gives X as a diameter, the way a lathe reads it. Post processors: Fanuc, Haas and LinuxCNC lathe versions.

Laser, plasma and waterjet cutting

  • A setup with the Cutting (laser, plasma, waterjet) operation type and the Cutting operation cut parts out of a flat sheet. You pick a contour edge (the whole chain is selected) or closed sketch curves, for example a sheet laid out with Nest (see file formats). With nothing picked it cuts the outlines of all setup bodies: the largest flat face of each body with its holes, for example a sheet metal flat pattern.
  • Holes go first, then the outline, and parts lying in the holes of other parts before those, so nothing drops out too early. Lead-ins and lead-outs stay on the scrap side.
  • The kerf is the width the beam burns or the jet cuts away. It belongs to the tool, along with the pierce time, pierce height and cut height. Kerf compensation decides who offsets the toolpath by half the kerf: the program, the control (G41) or nobody, and then the beam center runs on the line.
  • Post processors: "Cutting machine: generic G-code", "LinuxCNC (plasma)", "Mach3 (plasma)" and "GRBL (laser)", the last one without a Z axis.

Simulation, program and setup sheet

  • Generate (Ctrl+G) recalculates the selected operations, or all of them when nothing is selected. Rapids show yellow, lead-ins green, plunges red, cutting blue.
  • Simulate shows the tool removing material and reports collisions: a rapid through material, material above the flutes and the holder in material.
  • Compare to model on the simulation bar colors the stock: red is a gouge (the tool cut into the model), green matches the model within 0.05 mm, and yellow to orange is material left (orange from 2 mm). Next to it you see the largest gouge and the most material left at that moment.
  • Post Process shows the finished program and saves it to a file. Custom post processors… are copies of the built-in ones where you change the file extension, line numbers, comments, arcs (G2/G3 or plain line segments), drilling cycles, the tool change and your own lines at the start, at a tool change and at the end of the program. Lines can contain fields, such as the tool number or spindle speed, and the dialog shows a sample program right away.
  • Setup Sheet is a page for the machine operator: stock and origin, the tool list, operations with cutting data, estimated time and Z range, and a top view of the toolpaths. Save HTML downloads it as a file, Print sends it to a printer or to PDF.

How it works in practice

  1. Model a 100 × 60 × 20 mm plate with a rectangular pocket and four 6 mm through holes (Extrude and Hole, see solids).
  2. On the MANUFACTURE tab click New Setup. The Operation type defaults to milling, and the origin sits at the front left corner on top of the stock. The Stock tab keeps 1 mm side and top offsets and reports a 102 × 62 × 21 mm block.
  3. Each new operation picks a suitable tool by itself. Choose another on the Tool tab and its speed and feeds come with it.
  4. Face needs no selection. Click OK and the toolpath is generated at once.
  5. 2D Pocket: click the pocket floor. The cutter ramps down in a helix (a downward spiral), then clears rings from the center out to the wall, layer by layer, until it reaches the floor.
  6. 2D Contour: click the top edge of the outline and the whole closed chain is selected. Tool side Automatic keeps the cutter outside, entering on an arc. On the Heights tab set Bottom to Model bottom to cut the full thickness.
  7. Drill: click the circle of one hole, then Select same diameter. Pick the 6 mm drill (the dialog warns about a size mismatch) and, on the Cycle tab, tick "Drill tip through bottom of through holes" so each hole breaks through at full diameter.
  8. After changes, Generate (Ctrl+G) recalculates the toolpaths.
  9. Simulate opens a playback bar with a slider split into operations and the program time. The stock darkens with depth, so a pocket floor stands out even from above. Collisions are marked with red ticks on the slider.
  10. Post Process translates the toolpaths into G-code for your controller: Fanuc (ISO), Haas, LinuxCNC, Mach3 / Mach4 or GRBL. You get a preview, and Save file downloads it named after the project, as .nc, .ngc (LinuxCNC) or .tap (Mach3 / Mach4).

A second example, with a 3D surface:

  1. Model an 80 × 80 × 25 mm plate with a smooth bowl 50 mm across and 12 mm deep: draw the bowl profile in a sketch and cut it with Revolve.
  2. New Setup: on the Stock tab set Stock side offset to 0, because the plate is already cut to size. The dialog reports an 80 × 80 × 26 mm block.
  3. In 3D Adaptive you select nothing: the operation takes the whole model, and the dialog suggests a flat end mill by itself. On the Passes tab lower Maximum stepdown to 2 mm so the steps on the bowl slopes stay low. Roughing leaves 0.3 mm of radial and axial stock.
  4. Scallop picks a ball end mill. With the 6 mm cutter and the default 0.6 mm stepover the scallops between passes are about 0.015 mm high. The Model silhouette boundary covers the whole plate, so its top gets finished too.
  5. Simulate and tick Compare to model on the bar. After roughing the bowl is yellow, since 0.3 mm is left on it. After finishing it should turn green, and any red mark is a place where the tool cut into the model.

Things to keep in mind

  • A full-depth contour cuts the part free. Turn on Tabs, leave a thin skin (Bottom at Model bottom, offset 0.3 mm) or screw the part down.
  • Inside pocket corners come out rounded to the cutter radius. A smaller cutter with Rest machining makes that radius smaller.
  • Sample cutting data suits aluminum on a small mill for the milling tools, structural steel for the turning tools and 3 mm steel sheet for the cutting tools. Check it for your machine and material.
  • Parallel leaves the roughing steps on steep walls. Finish walls with 3D Contour, Ramp or Steep and Shallow.
  • 3D finishing goes into the program as short line segments, without G2/G3 arcs. Lathe programs have no arcs or built-in control cycles either: every move is written out. Such files are longer.
  • Turning sees the part as a solid of revolution: the profile is the largest radius in each section. Flats and off-axis holes don't make it into the program, and recesses the insert can't reach are left for another tool (the dialog warns about it).
  • The tool axis always runs along one of the model axes, so in a 3+2 program the part turns in 90° steps. There is no machining with the rotary axes moving while cutting. The rotary center is the origin of the first setup in the program, so put the machine work offset there, on the rotary axis.
  • 2D operations are generated without a holder check. A holder hitting the material shows up only in the simulation.
  • The simulation doesn't show thread turns: in it a thread mill removes material like a plain cylinder.
  • Cutting with nothing picked skips loops that don't go through, such as pockets in a body.
  • GRBL can't change tools: at a tool change the program stops (M0) with a comment naming the next tool, and drilling cycles become plain moves.
  • With many operations, jumping the simulation straight to the end can take ten seconds or more, without a progress bar. Until then the stock and the comparison show the state before machining.
  • Toolpaths aren't saved with the project. Simulate, Post Process and Setup Sheet recalculate anything missing or out of date.