CNC Programming with G Code: Easy Free Tutorial [ 2024 ] (2024)

You’ve learned a lot. If you followed through with the last 5 chapters and spent a little time drilling down into our g-code cheat sheet, you’re ready to tackle some simple programs. There’s just one more thing you need to consider, and that’s the machine setup work that goes hand-in-hand with any CNC program.

Let’s Start With Part Zero (also known as Program Zero)

We’ve already discussedCNC Coordinate Systemsin a previous chapter, so let’s talk about how to set up a machine coordinate system so it matches up to the part you want to make.

Let’s suppose you just got done drawing up a part in yourCAD software, and you’re about ready to generate some g-code for it. One of the key things to understand is where Part Zero is going to be. Your CAD program has some sort of coordinate system, and your part is positioned in the drawing relative to that coordinate system. If you’ve never done any CNC work before, you may not have paid much attention to that positioning. Perhaps you stuck the part well away from the 0, 0, 0 origin in the CAD program so it would be easier to see without the axis lines being too close.

You might want to reconsider that idea, at least until you get very comfortable with all the different coordinate systems that you’ll be using for CNC. Instead, what you want to do is put your “Part Zero” (for now, the CAD System’s origin or 0, 0, 0) some place that makes sense when you get ready to machine the material. When your g-code program refers to X0 Y0 Z0, that’s your Part Zero. Later on we can get all fancy with Work Offsets and other ways of transforming the coordinates, but when you first start the machine, think of X0 Y0 Z0 as Part Zero.

There are a lot of different theories on where to put Part Zero, and it matters for how easy and natural your CNC work will be.

When milling, a lot of emphasis is on the Z axis. When Z = 0, where should that be in relation to the part?

One theory has Z = 0 being the top of the workpiecebefore machining.This facilitates knowing when your cutter is cutting workpiece and when it is cutting air. Of course as you start making chips, you’re also making air down below Z = 0, but it is still a comfort to know where that original boundary started.

Another theory prefers that Z = 0 be some feature that doesn’t move and will not be milled away. For example, it might be the top of a vise jaw. This is handy should you need to remove your part for some reason. You won’t have to re-reference the machine to a new Z0. It is also handy if you’re machining workpieces with slightly differing dimensions. For example, even if you’re making identical parts, you may be starting with rough sawn material. The exact coordinates of the top of such material will vary from workpiece to workpiece because sawing is not a precision operation.

Cookbook Recipe: I like to use a Part Zero that corresponds to the fixed jaw of my vise when I will use a vise for machining. Once you get used to making your CAD drawings with that in mind, it means you can walk up to the machine, stick a piece of material in the vise, load a g-code program designed with that notion of Part Zero, and immediately begin machining after just homing the machine. Since the vise generally stays put on the machine, there are no touch offs required, which is a nice productivity booster. If I do need to move the vise or change jaws, no worries, I can just rezero on that location again.

Whatever you decide to use for your Part Zero, you need to be aware of it, and it is worth thinking about how to choose a Part Zero that might save you a little time or make things easier to understand.

What’s the difference between machine zero, work zero, part zero?

Machine Zero is the origin of the coordinate system that corresponds to the machines axis travels. Work Zero and Part Zero are the same thing, and they are the origin of the Work Coordinate System. Put another way, Work Zero/Part Zero establish a WCS by defining its origin. Your CAM program will have a way of specifying the WCS or Part Zero. When you setup the job, you will use edge finders or other sensors to tell the machine exactly where Part Zero is.

When you start up the machine, it doesn’t necessarily know anything about your preferred coordinate system. What it does know is something called “Machine Coordinates”. This is a fixed coordinate system that is baked into the machine. When you “Home” the machine, or “Reference the Axes”, you are causing it to use its Home Switches to accurately locate itself relative to machine coordinates. If your machine doesn’t automatically home when you start it up, it’s a good idea to get used to the idea of homing it before you do much else. If you crash or emergency stop, it can also be a good idea to home the machine so it can pick up its lost position.

“Work Coordinates” are the coordinates you want to think about. In other words, Work Coordinates are the ones where the machine is at Part Zero when its display shows X0 Y0 Z0. For that reason, Part Zero may also be called Work Zero. You can establish Work Coordinates in a variety of ways. By “establish”, I mean you can tell the machine how to equate Work Coordinates to Machine Coordinates.

A Work Coordinate system is something your machine will remember from one invokation to the next, though you probably shouldn’t count on that unless you know for sure you can. Since I use the system of Part Zero matching a point on my vise jaws, I can start the machine and Home it and I know the Work Coordinates are what I expect. You also have the ability to establish multiple Work Coordinate systems, which is convenient for a lot of reasons. We’ll talk more about using multiple Work Coordinate systems in a later article. For now, let’s just focus on one.

Establishing a Work Coordinate System via “Touch Offs” or “Zeroing”

Let’s talk about establishing a Work Coordinate system via Touch Offs. We’ll use my vise jaw system, just to make the discussion concrete, but the principle works for any work coordinate system.

Simply put, a “Touch Off” is where you use the cutter to locate the Work Zero. We do it one axis at a time, so let’s start with the “Z” axis. There are lots of ways to do Touch Offs. Each has varying accuracy and requires you to work on your technique a bit. The Old School method uses paper–cigarette rolling papers were very thin and commonly available. Use a little dab of oil to hold the paper in place and slowly jog the spinning cutter until it moves the paper. Stop. The cutter is now located at the Zero, with the exception of the thickness of the paper. Some trial cutting and a micrometer will establish what that is. Be sure to use the same kind of paper each time so the thickness is repeatable.

A more modern and accurate method would involve the use of a gage block. Gage blocks are precision machined to a very high tolerance and will include an inspection report that tells how much error there is in the block.

DO NOT TRY TO TOUCH THE TOOL OFF THE GAGE BLOCK!

If you’re using gage blocks, your cutter should not be spinning. But whether the cutter is spinning or not, it’s bad for your expensive gage blocks and bad for your cutters. Instead, move the cutter up, stop moving, and try to slide the gage block between the cutter and the workpiece. At some point, you will have jogged the machine a little too far and can jog back until you can slide between the two.

Here’s another tip from a reader (thanks Paul!) if you don’t want to use gage blocks–try a wrist pin from an engine. They’re machined from hardened material, they’re precise, they usually have a fine finish, and you can roll them under the cutter to check the fit. In fact, from many standpoints, a cylinder or ball shape (large ball bearings are precise too!) makes a lot of sense for this measurement as they’re less sensitive to whether the surface under them is flat and level. Take your micrometer to establish the wrist pin’s diameter and make sure it isn’t worn too badly if it’s used.

When you have located the machine in one axis at a point you want to “Zero”, your CNC Control will have a way for you to tell it that’s the zero for that axis. This is an important operation, so make sure you know how to do it on your controller. There’s usually a one touch button to zero a given axis and perhaps another to zero all the axes.

Note that you don’t have to measure strictly Part Zero. Your controller will have a way for you to enter an arbitrary value in and tell it that is where the tool tip is currently located. This is convenient for many cases and something you’ll be doing fairly often as well as Zeroing. For example, you may want to enter the thickness of your cigarette paper instead of “0.0000.”

Edge Finders and Probes for Establishing Work Coordinates

You won’t be CNC’ing for long before you’ll be wishing for an Edge Finder or a Probe. These are tools that make it quick and easy to find the edge of some object so you can Zero on it. Edge Finders come in all shapes and sizes from simple spinning contraptions all the way to fancy, accurate, and easy to use contraptions such as the Haimer 3D “Taster”. Yep, that’s not a misprint, they call them “Tasters” from the original German.

Here is a good video tutorial fromTormachon how to use a simple edge finder:

A simple edge finder…

And here is a demonstration of a Haimer 3D Taster:

Haimer 3D Taster…

A probe can be the ultimate in convenience for doing these kinds of Zeroing operations. Here is a Renishaw probe setting up work offsets:

Renishaw probe setting up work offsets on a VMC…

Each of these tools is similar in purpose, just with increasing capability, automation, and expense. There are a wide variety of other tools available for precisely locating features on your parts and workpieces. Some are more specialized, such as the Blake Coaxial Indicator, which is used to locate bore centers.

You’ll want to have some of these gadgets all fixed up in a tool holder and ready to pop into your spindle for job setups.

For even more examples of how to find Part Zero, see our article which gives8 ways to do locate Part Zero.

We won’t spend much more time on such things as they’re more properly part of CNC setup and general machinist measuring techniques than g-code programming per se.

Exercises

1. Take out your CNC machine’s manual and figure out how to zero your CNC machine to establish Work Coordinates. Look up how to read Machine Coordinates versus Work Coordinates on the control panel too.

2. Try some touch offs on your machine. Use the corner of a piece of scrap stuck in a vise for starters until you get good at it.

3. If you have an edge finder, 3D Taster, or probe, give it a try as a way of precisely locating part zero.

4. Decide what your convention for Z = 0 and perhaps Part Zero will be and stick to it.

CNC Programming with G Code: Easy Free Tutorial [ 2024 ] (2024)
Top Articles
Latest Posts
Article information

Author: Tuan Roob DDS

Last Updated:

Views: 5851

Rating: 4.1 / 5 (42 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Tuan Roob DDS

Birthday: 1999-11-20

Address: Suite 592 642 Pfannerstill Island, South Keila, LA 74970-3076

Phone: +9617721773649

Job: Marketing Producer

Hobby: Skydiving, Flag Football, Knitting, Running, Lego building, Hunting, Juggling

Introduction: My name is Tuan Roob DDS, I am a friendly, good, energetic, faithful, fantastic, gentle, enchanting person who loves writing and wants to share my knowledge and understanding with you.