How to Guide G-Code

From GT RoboJackets

Jump to: navigation, search

G-Code is a standard language used to talk to Computer Numerically Controlled (CNC) Machines. The idea is to take your part drawing and turn it into something which our mill can understand.

Contents

About Our CNC

The CNC in the Student Competition Center has only 2-axis (X and Y). There is no tool change, no Z-axis, no lubricant/coolant nozzle, etc. So you need to keep this in mind when writing code. When ever you need to plunge or retract the bit you need to have a pause. Files need to have a short name due to dos limitations and need to be .nc files.

Transferring your part to G-Code

Overview

The commands in G-Code represent the path the mill bit will follow. This will be different from the actual dimensions of your part because you must account for the size of the bit. Therefore the bit needs to be placed tangent to the face you need to create. If your cutting out the boundary or part the end mill is out side the boundary and if you are doing holes it will be inside. This means you will need to either add or subtract the size of the radius to get the right path.

How Its Done

In the real world there is Computer Aided Machining (CAM) Software. ie MasterCAM, SURFCAM, etc. They are nice and they can do a lot from simulating the entire machining job, tell you if part will get messed up, and of course give you the G-Code.

How We Do It

Because we only have 2 axis and not 6 we really don't need CAM software. You can either write it by hand or use GCAM. GCAM is a free OSS CAM package it is currently in its beginnings, but has just enough features to be really useful. It allows you to draw your part, select the paths, render the final thing, and give you G-Code. It exists both for Windows and Linux.

The last thing you should always do before you make the part is a marker run (this saves time and money) to check your code and make sure all the pauses are where they need to be. If a rapid occurs while a bit down you will either destroy your part, the end mill, or both. Possibly even the stock.

Notes on GCAM

When doing sketches remember to mark the check box for last layer only. There is not an option like this for holes to make thing easier set the resolution the a number higher than the thickness of the stock.

GCAM out puts for Z-Axis control and tool change. To get around this, once you export as G-Code, open the file in word (or some other program with find & replace capabilities).

  1. Search for all the G01 Z##.#### (plunge) and replace them with M0 (plunge).
  2. Search for all the G01 Z##.#### (retract) and replace them with M0 (retract).
  3. Search for all the T commands and replace them with M0 (change to - #/# ).
  4. For holes there will still be a top path and bottom path. You will need to go in and delete all of the extra paths (remember to preserve appropriate pauses).

Common Command List

Setup

G20 - Set to units to inches
G21 - Set units to millimeters
G90 - Absolute distance
F - Set feed rate
(Comment Text) - Comments are in parentheses they can be on their own line or inline after a command.
Very helpful for pauses and telling whoever is machining what they need to do (change tool, retract, plunge, etc)

Movement

G0 X##.#### Y##.#### - Rapid feed
G1 X##.#### Y##.#### - Linear movement at feed rate
G2 X##.#### Y##.#### I##.#### J##.#### R##.#### - Cut Arcs
I - X Center relative to starting point
J - Y Center relative to starting point
R - Radius
G3 - Same as above, but counter clockwise

Useful Links

  1. LinuxCNC G-Code Handbook
  2. LinuxCNC G-Code Quick Reference
  3. GCAM wiki
  4. GCAM Manual
Personal tools