Every CNC machinist should know g-code even if you plan to let your CAM software write most g-code. G-Code is the language your CAM software writes and the language your CNC machine reads. You'll see it on your machine's console while it executes the program and it'll help you no end to know just a little bit of what's going on there. Best of all, it isn't hard to grasp the basics.
We were impressed at how many readers can write g-code programs from scratch. In fact the overwhelming majority read, write, or tweak programs on a regular basis. If you're not yet able to do that, you should learn. If you're at the "Read or Tweak" stage, you should advance to being able to write programs from scratch.
Armed with a good understanding of g-code, you can:
- Avoid having to run back to your CAM program when simple changes to the g-code would do the job.
- Learn how to improve the g-code the CAM program puts out for better results.
- Understand better how to tweak your CAM software's post processor so it produces better code from the start.
- Get a second opinion on the CAM's g-code before you find out something's wrong at the machine.
- Figure out what's wrong when your CAM generated g-code isn't doing what you'd expect.
- Make it faster and easier to fix the g-code when you run into a problem due to a bug in the CAM or post processor.
- Create quick and dirty g-code programs that allow you to get on with machining faster without having to sit down with your CAD/CAM.
- Develop a greater facility for working at the console of the machine directly.
These are all valuable skills that increase your productivity as a CNC machinist. According to the survey, many of you have already figured that out!
A Little CNC History
CNC started in the 50's and 60's when it was called "NC" for Numerical Control. It didn't really take off until the 70's and then particularly in the 80's when the small computers of the Personal Computer revolution made possible a computer in every machine tool. For more detail, see our in-depth article on CNC Machines and their History.
Advantages of CNC
CNC has many advantages over manual machining including:
- Setup Time Reduction
- Lead Time Reduction
- Accuracy and Repeatability
- Contouring of Complex Shapes
- Simplified Tooling and Workholding
- Cutting Time and Productivity Improvements
G-Code from the Machine's Perspective
There are a handful of basic concepts you should know before we dive into what individual g-codes do and how to use them. Most importantly, you must understand what a computer language is and how to think about it. G-Code is a computer language aimed at telling your machine what to do. The trouble with computer languages like g-code is that unlike people, machines are very literal. They assume you know exactly what you want, they don't question you about it, and they immediately try to comply, even if that means hurting themselves!
For that reason, you need to adopt an approach of being protective of your machine, perhaps even over protective bordering on paranoid. It will do exactly what you tell it to even if that means rapiding a spinning cutter with 20HP behind it directly into your expensive fourth axis and destroying it.
There's no need to be afraid of g-code, but it is important to understand it and to respect it in order to be successful. Getting to that stage is another excellent reason to spend time learning the g-code. It will give you insights into your machine that enable you to extract more performance and to protect it better from accidents.
G-Wizard G-Code Editor
Speaking of understanding g-code and protecting the machine, throughout this course we will be setting up to do exercises using the G-Wizard G-Code Editor. Think of it as a convenient etch-a-sketch on which you enter g-codes and can immediately see the toolpath that results. This makes learning a lot faster and easier when you have that immediate response versus trying to plot things on graph paper or work with your machine controller. In addition, you can make your mistakes on a simulator rather than with the actual machine until you get a lot more comfortable in your ability to command the machine successfully.
GWE has a "Hints" window that shows you what each code does in plain English...
With GWE, you can study the g-code from the comfort of your armchair and let it sink in. More importantly, GWE gives you lots of additional information that's hard to get at with most controllers, and it has a host of features to help you through the process of learning g-code. For example, it's "Hints" feature tells you what each code does in plain English.
We'll be including some exercises with each section that involve working with GWE. From time to time we'll also include videos that help illustrate how to go about using GWE for the exercises.
You should go ahead and take the free 30-day trial of G-Wizard Editor, even if you have no intention of purchasing it, so you can work through all the examples and use it as a learning tool.