Tutorial G Code Basics
Tutorial G Code Basics
Y X
Tutorial is designed to create a wireframe model of a part. This tutorial will not simulate a full G and M code
program for a 3D Print. The program for a 3D Printing is at minimum 15,000+ lines long because of the closeness
of the layers and the infill pattern.
Cube
Program Area
2D: Front, Top and Right (I.E Play, Stop, Pause, Fast Forward, Reverse, etc.
Coordinate Position
G90 = Absolute Position
G91 = Incremental Position
G92 = Offset Coordinate System
User needs to make allotment for the size of the tool they are using. The user can by using absolute position make
the change in the X, Y, Z coordinate when laying out the coordinate points or program the change using incremental
or offset positioning within the program setup phase.
Note: For this program we do not know the size of the tool we are using so absolute position will work best.
Homing
A series of X, Y, Z coordinate movements that moves the tooling away from the part for easy setup and removal of
the object; providing safety for the operator when working on the machine. For some machines specific sections of
code are preset based upon the machine build volume that is being used to find the traversing limits. Some machines
also contain a set of code that will set the home position of the extruder or milling tool. The home position is
typically a location up and away from the build plate (3D Printing) or off the stock material that is to be machined,
that way the build plate or stock material does not get damaged when the machine is extruder head heats up or the
cutting tool begins its motion. Some machines will use switches to locate the home position; this is done via a
function or sub routine set of code that gets added to all programs that are run on a particular machine.
NOTE: For this tutorial we will set a home position that is above and to the right of the right top most point on the
wireframe model. For this tutorial the user will not set this position as the origin of the virtual machine, but keep the
origin point as one of the corners of the object.
Code: Cube 10mm x 10mm x 10mm
NOTE: the Above Code can also be written on one line as follows. User needs to be careful in not combining too many
codes onto one line because more errors due to typos or wrong code declaration could occur when setting up the
machine.
3. The next set of code would be used to setup the machine for example
a. 3D Printer: Setting up Extruder Head Temperature, Build Plate Temperature (If Applicable),
b. CNC Machine: Tool number from the carousel, Tool Speed,
This program we will setup as if we were using a 3D printing to create the object
Copy the following code below the code typed from above
4. Homing Position
The Homing position should always be set away from where the object is being printed
Copy the following Code
Press Play in the work screen or Plot from the Coding window > you should notice an orange line (represents G00
rapid traverse movement.) moving from the center of the build plate up vertically and then on an angle towards the
third quadrant on the graph.
NOTE: G00 Rapid Traverse should only be used when the machine is moving to a point in space; NEVER to be used
when cutting, printing or any other machining process, result could be the tooling moving too fast and crash into the
build plate or workpiece breaking the machine and/or the part being created.
b. 2nd Wall (Left Surface): Copy down the following lines of code > Plot (Play) the code. Current location
Origin (x0 y0 z.1)
c. Reposition tool
Option 1: Trace a line to move tool (pen) back to start location of the back surface
Option 2: Would have the user move the tooling away from the part and reposition it using a
combination of G00 and G01. For Example
Home Position
Front
View (1st
Wall)
N200-N220 Movements to move
the tool off the part and
reposition it at desired location
(Back Wall)
e. Trace a line to move tool (pen) back top right corner of back surface
f. 4th Wall Right Surface Copy down the following lines of code > Plot (Play) the code. Current location
Bottom Left Corner on the Left Side View(x10 y10 z10.1)
NOTE: the Top and Bottom Surfaces are completed based on the shared edges from the other four surfaces
g. Return to Home Position
Once a part is complete it is important to return the tooling back to its home position. This makes it
easier and safer to remove the part from the machine. User should make sure not to make movements
that run into the part so we will move the tool away from the part with a series of moves.
Copy the following code > Plot Code
h. Machine Shutdown
Code: Curve/Arc/Circles
To create a curve/Arc/Circle the user will need to choose one of two methods. Method 1 uses radius for its
formation and Method 2 uses offset values from the start point. For both methods it is important that the user has
programmed the proper G code Axis’s (G17=XY, G18=ZX, G19=ZY), this will place the tool at the correct orientation to
create the Curve, Arc or Circle based upon its view plane. Note it is important to understand that not every machine
has the ability to rotate the tooling into the different axis positions. Read instruction manual of machine being used
before trying to run a series of code, so has to avoid possible damage to the equipment.
The Direction of the curve (Concave v. Convex) is dependent upon the direction of the tool
For example: Tool moves in a counter clockwise Direction (x0 y0 z.1 to x10 y0 z.1)
Radius does not always ensure the proper size arc/circle for when programming in G Code. I,J,K option allows the
user to check or even double check the location of arc/circle being created by setting offset values from the start
point to locate the center of the arc/circle.
The following shows the relationship between axis (X,Y,Z) and offset value (I,J,K)
I = X Axis
J = Y Axis
K = Z Axis
I, J, K Code represent the offset distance from the start point for the arc/circle in the direction of motion. Note the
I,J,K value can be either positive or negative based on the start point of the arc/circle and the direction the tooling is
drawing the arc/circle.
Y (J) Code
R50
G01 x0 y0 z0
X (I)
G03 x0 y0 z0 I-50
X (I)
Assignment: Add an arc of 5mm that is 180 degrees on the right face of the cube.
Student decides the following
- Choose Y or Z direction.
- Concave or Convex