Alright so you want to learn G Code? Here’s a quick and dirty G code tutorial to get you started in G code and being able to talk the talk when it comes to the G code language.
Learning G code is actually pretty easy. With a bit of practice and this tutorial, you will be ‘the G Code’ pro in no time.
Learn the different planes
Depending on how many axis the machine has, you will have to figure out where the x,y,z axis are. You will also get a,b,c axis when it comes to machines that have more than 3 axis, such as 4 or 5 axis cnc machines.
The z axis is almost always the spindle that moves up and down, and the x and y will be the table directions.
Coordinates in G Code
We are going to be using inches in this G code tutorial. You can change this to metric pretty easily within whatever program you will be using. You can choose to omit the spaces if you want to, also do not add commas to the code.
X2 Y2 Z2
The above is a position at each axis. So in the above we have a position that is 2 inches from 0 in all axis.
For rotational axis found on a 4 or 5 axis machine, you use angles instead of dimensions. So rotating an A axis (4th axis) 45 degrees would be written as A45.
Your starting coordinates may affect your G-code coordinates. So if your cutting material is not lined up at X0 Y0 Z0, then you will need to adjust for this.
You can also use offsets to create duplicates of the work on a cnc machine, this is a little more advanced, but is something definitely worth learning later on.
G code dialects
Remember that there are different cam and software packages out there. Each manufacturer may have slightly different G-code, or a different dialect of G-code. It’s like the difference between American and British English, different words for different things and extra words for others.
Your job is to decide what the differences are and see what is supported with your cnc machine and what is not. This is to make sure the G-code you write will work smoothly on your chosen machine.
Using CAM programs to get the job done
There are a variety of different cam programs out there that will help you get the job done. I’ve always recommended starting with a program and then working backwards and learning the G-code later if you really want.
Some cam programs I would recommend are: Mastercam, BobCAD-CAM, and CAMworks for SolidWorks.
There are a ton of different programs out there, so I always like to try before I but. A lot of cad/cam programs usually come with a free trial. The programs themselves can be expensive for a single licence or seat, so give them a free trial before commiting to paying a lot of money up front.
G Code Simulator
NCPlot.com has a great simulator. NCPlot v2 is available for free for 15 days as a trial.
CNCsimulator has a good simulator worth checking out. They are currently working on the new CncSimulator Pro, which will be cool when it comes out.
Cnccookbook has a good G code editor called G-Wizard G-Code Editor which also has a free trial worth checking out.
G Code Generator / cnc code maker
Here are all the free/open source ones:
For 3d printing generators, check out SkeinForge, RepRap Host Software or SuperSkein
For milling generators, check out Cad.py, Cam.py, CL-Mill, GCAM, Gcodetools, PyCAM and Gcode enabled xfig.
File types for export to CNC
Some of the most common file types that are exported are STL, DXF and BMP. Other file types may include SVG, CMP, PLC, SOL, STS, STC, GTL and JPG.
If you are outsourcing, then you need to make sure your cnc operator will be able to accept at least one of the above files.
Always double check files by reopening them in another program or the same program after export. I like to provide extra files of different formats to make sure there is no delay.