CNCCookbook: Be a Better CNC'er

Do you want to be a better CNC'er in 37 Seconds?

Get Better Tool Life, Surface Finish, and Material Removal Rates Fast.

It's that easy. You can install and get results now.

 

CAM Post Processors for Different G-Code Dialects

CNCCookbook's G-Code Tutorial

What's a Post Processor?

We've seen that there are many dialects of G-Code. CAM software has to take geometry from a CAD model and convert it to g-code. Doing so obviously requires an awareness of the exact g-code dialect that is being targeted. The Post Processor is the component of your CAM software that is responsible for translating to the exact g-code dialect. We often refer to a particular instance of a translation as a "Post". There will be a different Post for each g-code dialect your CAM software supports.

While translation to specific g-code dialects is the primary task of a Post Processor, they can do a lot more besides to customize your part programs to work using the Best Practices of your shop. For example, you might use a 4th axis in a certain way, but you don't use the 4th axis for every job. It might make sense to have one Post for standard jobs and another for 4th Axis jobs. The Post can change the initial setup of a part program and it can change how particular operations work. Another example might be a post that automatically subsitutes a deep hole drilling cycle whenever the length to diameter ratio of the hole is too large.

We'll talk in greater length about some of these other possibilities below. First, let's understand the translation role better.

Post Processor Schematic Overview

Typically, although not always, Post Processors don't convert g-code from one dialect to the next. Instead they work from an intermediate format that captures what g-code does in a dialect-independent way. Most CAM software accomplishes this with an intermediate format that bears no resemblance to g-code called "CL Data." The "CL" stands for "Cutter Location." There are many formats for how CL Data is represented in a file but one common format is called "APT".

If you think about it, deciding cutter locations is basically what CAM does. Here's a schematic overview of what's happening:

What is a CAM Post Processor?

What is a CAM Post Processor?

A CAD Model of the part is fed into the CAM software. The CAM software analyzes the CAD model, determines what the toolpaths should be, and outputs a CL Data file. Most of the time you don't see the CL Data directly, although it is accessible in many CAM packages for use by utility software such as simulators. The Post Processor grabs the CL Data and converts it to g-code. The Post is a little file that provides the "recipe" for converting CL Data to the particular g-code dialect you've targeted.

CL Data, Simulators, and the Reason to Use a G-Code Simulator

Most CAM packages include a simulator of some sort that's able to display a simulation of the tool cutting a part. These simulations are often quite impressive, and they're useful, but they also have a critical weakness: 99% of the time the simulation is based on the CL Data, not on the G-Code the CNC machine will actually be executing. What that means is that if there is a bug in the Post Processor, or if the Post doesn't quite accurately reflect your machine's g-code dialect due to a bug or omission, you'll see a perfect simulation and then you'll have a problem when you go to run the part program on your machine.

This is why the Best Practice is to run all CAM-generated g-code through a g-code simulator. It's like getting a second opinion from an alternate doctor, and it can save you a lot of time and trouble at very low cost. Our G-Wizard Editor software is a great example of a g-code simulator. And our customers tell us it frequently catches problems that otherwise would've turned up on the machine.

You must be wondering, "Is CAM software really that buggy that we can't trust the built-in simulator?" In most cases, it isn't a function of major bugs but rather of little issues that go undiscovered. Perhaps the simulation looks fine but there's something wrong in the g-code that will cause an alarm on your CNC machine so it just won't execute. That's time wasted running back and forth between machine and CAM trying to figure out the cause of the alarm and how to fix it.

A good g-code simulator does a lot more than just plot the toolpath--it will check for all sorts of alarm conditions.

Post Processors for Shop Best Practices

While the primary role of a Post is to convert generic geometry to the particular dialect of G-Code your machine uses, the Post also gives you a lot of flexibility to tailor your CAM output to the practices your shop likes to use, so it is a handy way to customize the G-Code output of your CAM.

If you frequently are making the same hand edits over and over again to your G-Code, it's worth investigating whether a change to your Post would eliminate that hassle. Some examples of shop-specific customization might include your standards for safety blocks or required comments. 

You can even modify the Post to save your operators some time. Maybe you want the table on your mill to move as close to the enclosure door as possible at the end of a job to facilitate loading and unloading. That's a logical thing to have the Post do for you. Depending on the CAM package and its Post capabilities, sometimes very powerful flexibility is an option. For example, the Post may be able to popup a custom menu allowing you to choose some options you've specifically designed for your shop's needs on every Post.

Example Customizations of Post Processors

Here are some typical kinds of customizations that go above and beyond just making a post that'll work for your machine's g-code dialect:

Hopefully these examples give a good idea of how you can benefit from custom posts. There are many more ways to benefit once you become aware of the possibilities.

The Ugly Secret About Closed Posts

Postprocessors can be open or closed. With a closed postprocessor, only authorized parties are allowed to customize a post. They typically won't do it for free either, so this is a hidden expense that you'll want to be aware of. Many CNC'ers starting out will assume this is not a big deal--after all, you only need a post that works for your machine and then you're done, right?

The truth is that it's absolutely critical you be able to modify your posts for maximum benefit, even if you have to pay a vendor to do it. A hobbyist will get away with one post, but production shops don't want to miss out on the advantages of having full control over their posts. A lot can be automated in this way and you won't know everything you want to do with the post until you've been at it for quite some time.

Given that the most powerful post processors have a variety of features like pop up menus or the ability to automatically generate setup sheets that go with the part program, it is easy to see why accessing all that power will require the ability to change the post.

What Does a Typical Post Look Like?

Posts are typical little programs done in a specific programming language intended for the task. The language may be proprietary to the particular CAM package, or it may be related to a 3rd party post processor that your CAM vendor has bundled in. Such third party post processors may work with multiple CAM packages, and therefore they may have a larger community of users out there who you can work with to learn and make changes to your posts.

Here's a sample post for a 3rd party post processor called PostHaste:

StartCode 

O[Program#] 
G90 G80 G40 G17 
End

1stToolChange 
N[Tool] T[Tool] M6 
M[Direction] S[Speed] 
G0 G[Work] X[H] Y[V] 
G43 Z[D] H[LComp] 
M[Coolant] 
End

Infeed    (apply diam. offset) 
G1 Z[D] F[Plunge] 
G[Side] X[H] Y[V] F[FRate] D[DComp]
End

ArcCode 
G[ArcDir] X[H] Y[V] I[CtrH] J[CtrV] 
End 

One of the neat aspects of PostHaste is it looks a lot like g-code. The idea is to write example code snippets in your desired g-code dialect and using the square bracket syntax describe how the syntax works. For example, an arc will often be coded as

G02 X0 Y0 I-1.0 J-1.0

Looking at the PostHaste "ArcCode" template, we see the various substitution templates:

You can see how it would be pretty straightforward to create a post using a syntax like that.

At the opposite end of the ease of use spectrum, but perhaps capable of far more powerful customization in the post, would be something like Fusion 360's Post Processor. It uses javascript as its programming language and a relatively simple post for someting like a Tormach CNC Lathe runs to 426 lines of fairly dense code. It's well beyond our scope to try to dig down into something like that in this article, just be aware that such things are out there.

If you're not a software developer, you may want to enlist help when modifying something as complex as a Fusion 360 post. If you are going to modify a post, you'll want to make sure you have a solid G-Code Simulator like our G-Wizard Editor available to help you debug the output.

Custom Post Processor Survey

Do you use a custom or off-the-shelf post processor?  If you’ve customized yours, what sort of customizations did you do?


Take Our CNCCookbook Post Processor Survey


Exercises

1. Read our article 37 Things Your CAM Won't Do For You That GCode Programming Can. This article will give you a sense of some of the Best Practices you might try to automate through custom Post programming.

2. Determine whether your CAM software's post is open or closed. If it is open, skim through the documentation and get an idea of what it might take to modify your post.

3. Make a small modification to your CAM's post that will enhance your productivity. Find something you always wish was different about your part programs and change the post to make it happen.

 

Try the Free Trial Version of G-Wizard G-Code Editor...

 

No credit card required--just your name and email.

 

Next Article: MDI: CNC For Manual Machinists

 

 

 

CNCCookbook's G-Code Course

 

Sale Details

Featured Articles

Step-By-Step Guide to Making CNC Parts

CNC Router Cutter Types

Why Use a Single Flute Endmill?

Step and Servo Motor Sizing

The Truth About Tool Deflection

10 TIps for Router Aluminum Cutting

2 Tools for Calculating Cut Depth and Stepover

CNC Machine Hourly Rate Calculator

Special Purpose CNC Calculators

Feeds and Speeds Guide

CNC Cutter Guide

Feeds and Speeds By Material

G-Code Tutorial

  Feed Rate Calculator

Sales, and Special Deals

 

GCode is complicated.
G-Wizard Editor
makes it easy.

Try It!

 

Feeds and Speeds:
Made Easy.

Try G-Wizard

 

 

Do you want to be a better CNC'er in 37 Seconds?

Get Better Tool Life, Surface Finish, and Material Removal Rates Fast.

It's that easy. You can install and get results now.

 

Start Now, It's Free!