**Introduction**

G-code is used in a lot of automated manufacturing processes. For example, CNC machines and 3D printers use G-code to make parts. Programming arcs and linear movement in G-code can be a little tricky. I've noticed that there aren't many sources on the internet that address this topic. So, I decided to make my own guide. I will be presenting basics steps and tips in programming arcs and linear movement in G-code. This will only include movement on a 2D plane and is designed to give a general overview of programming. The instructable will not take into account material properties, tool diameter, speeds, and feeds. I do encourage you to do all the calculations yourself as you go through my instructable. This will give you a better understanding of the code and remember a tool can become a crutch. Don't forget to use the tool path dimenisions .pdf as a reference.**Materials**

- Paper

- Writing Utensil

- Scientific Calculator

- .pdf file of supplied technical drawing

-Time-approximately 60 min**Terminology****Absolute**- A series of numerical positions that are calculated from a fixed point of origin.**Clearance Plane**- A plane designated for safe tool travel in between cutting functions.**End point-**The point where an arc ends**F variable**- Feed rate (inches per minute)**G00**- Rapid linear movement**G01**- Linear interpolation**G02**- Clockwise circular interpolation**G03**- Counter Clockwise circular interpolation**I variable**- Incremental coordinate used to define a point in the X direction.**Incremental**- A series of numerical positions that is referenced from a previous position and is independent of absolute origin.**IPM**-A unit of velocity used to determine feed rate. (inches per minute)**J variable**- Incremental coordinate used to define a coordinate in the Y direction. **Origin**- The fixed, central point in the Cartesian coordinate system. The origin has a numerical value of zero.**Start point- **The point where an arc begins.**X variable**- Absolute coordinate used to define a point in the X direction.**Y variable**- Absolute coordinate used to define a point in the Y direction.**Formulas*** 1)* Xs=Xc+(R*cos(Theta1))

*Ys=Yc+(R*sin(Theta1))*

**2)***Xe=Xc+(R*cos(Theta2))*

**3)***Ye=Yc+(R*sin(Theta2))*

**4)***I=(Xc-(R*cos(Theta1)))-Xc*

**5)***J=(Yc-(R*sin(Theta1)))-Yc*

**6)**## Step 1: Program Requirements

The next few slides will be addressing the general structure of g-code commands we'll be using.

## Step 2: G00 Structure

**General**

**Structure**

G00 X#.#### Y#.#### Z#.####

## Step 3: G01 Structure

**General Structure**

G01 X#.#### Y#.#### Z.#.#### F#.####

## Step 4: G02 and G03 Structure

**General Structure**

G02 X#.#### Y#.#### I#.#### J#.#### F#.####

G03 commands the machine to move in a counter clockwise direction to a designated point at a specified feed rate.

**General Structure**

G03 X#.#### Y#.#### I#.#### J#.#### F#.####

**Note**

**I and J define the location of the center of rotation --- RELATIVE TO THE CURRENT (STARTING) POINT**

X and Y are the end point coordinates of the arc.

X and Y are the end point coordinates of the arc.

## Step 5: Designating the Origin

## Step 6: Designate and Order Points

Points are defined as places where a change in translation occurs. For example, a point would be where an x direction movement changes to a y direction movement or the start and endpoints of an arc. In the part I'm presenting, there are a total of 22 points. Each point has a unique set of coordinates that will translate into movement via g-code. Ordering the points will ultimately determine the structure of your program. For this example, I'll be initiating my cut at point 1 and continue in a clockwise direction around the part.

## Step 7: Designate Arc Centers

## Step 8: Calculating Start and End Points of Arcs

**Defining Variables**

**R**=Radius of arc

**Theta1**=angle of the position of the start point relative to the X axis

**Theta2**=angle of the position of the end point relative to the X axis

**Xc**=X coordinate of arc center

**Yc**=Y coordinate of the arc center

**Xs**=X coordinate of arc start point

**Ys**=Y coordinate of arc start point

**Xe**=X coordinate of arc end point

**Ye**=Y coordinate of arc end point

**I**=Incremental X coordinate of start point

**J**=Incremental Y coordinate of start point

**Formulas**

*Xs=Xc+(R*cos(Theta1))*

**1)***Ys=Yc+(R*sin(Theta1))*

**2)***Xe=Xc+(R*cos(Theta2))*

**3)***Ye=Yc+(R*sin(Theta2))*

**4)***I=(Xc-(R*cos(Theta1)))-Xc*

**5)***J=(Yc-(R*sin(Theta1)))-Yc*

**6)**## Step 9: Calculating Values for Arc 1

**Defining Variables**

R=Radius of arc = .5

Theta1=angle of the position of the start point relative to the X axis = 90

Theta2=angle of the position of the end point relative to the X axis = 0

Xc=X coordinate of arc center = 2.25

Yc=Y coordinate of the arc center = 3

**Formulas**

*Xs=Xc+(R*cos(Theta1)) = 2.25*

**1)***Ys=Yc+(R*sin(Theta1)) = 3.5*

**2)***Xe=Xc+(R*cos(Theta2)) = 2.75*

**3)***Ye=Yc+(R*sin(Theta2)) = 3*

**4)***I=(Xc-(R*cos(Theta1)))-Xc = 0*

**5)***J=(Yc-(R*sin(Theta1)))-Yc = -.5*

**6)**## Step 10: Calculating Values for Arc 2

**Defining Variables**

R=Radius of arc = .5

Theta1=angle of the position of the start point relative to the X axis = 0

Theta2=angle of the position of the end point relative to the X axis = 270

Xc=X coordinate of arc center = 2.25

Yc=Y coordinate of the arc center = -3

**Formulas**

1) Xs=Xc+(R*cos(Theta1)) = 2.75

2) Ys=Yc+(R*sin(Theta1)) = -3

3) Xe=Xc+(R*cos(Theta2)) = 2.25

4) Ye=Yc+(R*sin(Theta2)) = -3.5

5) I=(Xc-(R*cos(Theta1)))-Xc = -.5

6) J=(Yc-(R*sin(Theta1)))-Yc =0

## Step 11: Calculating Values for Arc 3

**Defining Variables**

R=Radius of arc = .5

Theta1=angle of the position of the start point relative to the X axis = 0

Theta2=angle of the position of the end point relative to the X axis = 180

Xc=X coordinate of arc center = 0

Yc=Y coordinate of the arc center = -2

**Formulas**

1) Xs=Xc+(R*cos(Theta1)) = .5

2) Ys=Yc+(R*sin(Theta1)) = -2

3) Xe=Xc+(R*cos(Theta2)) = -.5

4) Ye=Yc+(R*sin(Theta2)) = -2

5) I=(Xc-(R*cos(Theta1)))-Xc = -.5

6) J=(Yc-(R*sin(Theta1)))-Yc = 0

## Step 12: Calculating Values for Arc 4

**Defining Variables**

R=Radius of arc = .5

Theta1=angle of the position of the start point relative to the X axis = 270

Theta2=angle of the position of the end point relative to the X axis = 180

Xc=X coordinate of arc center = -2.25

Yc=Y coordinate of the arc center = -3

**Formulas**

1) Xs=Xc+(R*cos(Theta1)) = -2.25

2) Ys=Yc+(R*sin(Theta1)) = -3.5

3) Xe=Xc+(R*cos(Theta2)) = -2.75

4) Ye=Yc+(R*sin(Theta2)) = -3

5) I=(Xc-(R*cos(Theta1)))-Xc = 0

6) J=(Yc-(R*sin(Theta1)))-Yc = .5

## Step 13: Calculating Values for Arc 5

**Defining Variables**

R=Radius of arc = .5

Theta1=angle of the position of the start point relative to the X axis = 180

Theta2=angle of the position of the end point relative to the X axis = 90

Xc=X coordinate of arc center = -2.25

Yc=Y coordinate of the arc center = 3

**Formulas**

1) Xs=Xc+(R*cos(Theta1)) = -2.75

2) Ys=Yc+(R*sin(Theta1)) = 3

3) Xe=Xc+(R*cos(Theta2)) = -2.25

4) Ye=Yc+(R*sin(Theta2)) = 3.5

5) I=(Xc-(R*cos(Theta1)))-Xc = .5

6) J=(Yc-(R*sin(Theta1)))-Yc = 0

## Step 14: Calculating Values for Arc 6

**Defining Variables**

R=Radius of arc = .5

Theta1=angle of the position of the start point relative to the X axis = 180

Theta2=angle of the position of the end point relative to the X axis = 0

Xc=X coordinate of arc center = 0

Yc=Y coordinate of the arc center = 2.5

**Formulas**

1) Xs=Xc+(R*cos(Theta1)) = -.5

2) Ys=Yc+(R*sin(Theta1)) = 2.5

3) Xe=Xc+(R*cos(Theta2)) = .5

4) Ye=Yc+(R*sin(Theta2)) = 2.5

5) I=(Xc-(R*cos(Theta1)))-Xc = .5

6) J=(Yc-(R*sin(Theta1)))-Yc =0

## Step 15: Assign Coordinates to Each Point

## Step 16: Beginning the Program

## Step 17: Moving to Point 1

**This is what the first line should look like**

(I will continue to add lines of code to the first line to help guide you)

G00 X.5 Y3.5 Z.5

(At this point there is no cutting happening as the tool is still .5000" above the part)

## Step 18: Moving to Cut Depth

**Now the code should look like this**

G00 X.5 Y3.5 Z.5

G01 Z-.1250 F20

## Step 19: Moving to Point 2

**Now the code should look like this**

G00 X.5 Y3.5 Z.5

G01 Z-.1250 F20

X2.25

## Step 20: Moving to Point 3 Along Arc 1

(Remember the X and Y coordinates of an arc command is the end point of the arc. Plug in the calculated I and J values for Arc 1)

**Now the code should look like this**

G00 X.5 Y3.5 Z.5

G01 Z-.1250 F20

X2.25

G02 X2.75 Y3 I0 J-.5

## Step 21: Moving to Point 4

**Now the code should look like this**

G00 X.5 Y3.5 Z.5

G01 Z-.1250 F20

X2.25

G02 X2.75 Y3 I0 J-.5

G01 Y.75

## Step 22: Moving to Point 5

**Now the code should look like this**

G00 X.5 Y3.5 Z.5

G01 Z-.1250 F20

X2.25

G02 X2.75 Y3 I0 J-.5

G01 Y.75

X1.451 Y 0

## Step 23: Moving to Point 6

**Now the code should look like this**

G00 X.5 Y3.5 Z.5

G01 Z-.1250 F20

X2.25

G02 X2.75 Y3 I0 J-.5

G01 Y.75

X1.451 Y 0

X2.75 Y-.75

## Step 24: Moving to Point 7

**Now the code should look like this**

G00 X.5 Y3.5 Z.5

G01 Z-.1250 F20

X2.25

G02 X2.75 Y3 I0 J-.5

G01 Y.75

X1.451 Y 0

X2.75 Y-.75

Y-3

## Step 25: Move to Point 8 Along Arc 2

(Remember the X and Y coordinates of an arc command is the end point of the arc. Plug in the calculated I and J values for Arc 2)

**Now the code should look like this**

G00 X.5 Y3.5 Z.5

G01 Z-.1250 F20

X2.25

G02 X2.75 Y3 I0 J-.5

G01 Y.75

X1.451 Y 0

X2.75 Y-.75

Y-3

G02 X2.25 Y-3.5 I-.5 J0

## Step 26: Move to Point 9

**Now the code should look like this**

G00 X.5 Y3.5 Z.5

G01 Z-.1250 F20

X2.25

G02 X2.75 Y3 I0 J-.5

G01 Y.75

X1.451 Y 0

X2.75 Y-.75

Y-3

G02 X2.25 Y-3.5 I-.5 J0

G01 X.5

## Step 27: Move to Point 10

**Now the code should look like this**

G00 X.5 Y.3 Z.5

G01 Z-.1250 F20

X2.25

G02 X2.75 Y3 I0 J-.5

G01 Y.75

X1.451 Y 0

X2.75 Y-.75

Y-3

G02 X2.25 Y-3.5 I-.5 J0

G01 X.5

Y-2

## Step 28: Move to Point 11 Along Arc 3

(Remember the X and Y coordinates of an arc command is the end point of the arc. Plug in the calculated I and J values for arc 3)

**Now the code should look like this**

G00 X.5 Y3.5 Z.5

G01 Z-.1250 F20

X2.25

G02 X2.75 Y3 I0 J-.5

G01 Y.75

X1.451 Y 0

X2.75 Y-.75

Y-3

G02 X2.25 Y-3.5 I-.5 J0

G01 X.5

Y-2

G03 X-.5 Y-2 I-.5 J0