CNC Customize Parts Professional Solution & Processing Provider

How to Program Arcs and Linear Movement in G-Code Manually

by:QY Precision      2019-09-22
IntroductionG-
Code is used in many automated manufacturing processes.
For example, CNC machines and 3D printers use G-
Code for manufacturing parts.
Programming arc and linear motion in G-
The code may be a bit tricky.
I noticed that there are not many sources on the Internet that can solve the problem.
So I decided to be my own guide.
I will introduce the basic steps and techniques for programming arcs and linear motion in G-code.
This will only include the motion on the 2D plane and is intended to give an overall overview of programming.
Instructure does not take into account material properties, tool diameter, speed, and feed.
I do encourage you to do all your calculations yourself while browsing my instructions.
This will give you a better understanding of the code and keep in mind that the tool can be a cane.
Don\'t forget to use the tool path size.
Pdf for reference. Materials-Paper-
Writing utensils-
Scientific Calculator.
PDF file of technical drawings provided-Time-
About 60 minterminogyabsolute-
A series of numerical positions calculated from a fixed origin. Clearance plane-
Specifies the aircraft used to travel safely between cutting functions. End point-
Point of Arc ENDF variable-Feed rate (
Inches per minute)G00-
Fast straight motion
Linear interpolation 02-
Clockwise circular interpolation 03-
Cyclic interpolation of I variables counter-clockwise-
Used to define the incremental coordinates of points in the X direction. Incremental-
A series of numerical positions referenced from the previous position, independent of the absolute origin. IPM-
The unit of speed used to determine the feed speed. (
Inches per minute)J variable-
Incremental coordinates used to define Y-direction coordinates. Origin-
A fixed center point in a Descartes coordinate system.
The value of the origin is zero. Start point-
The point at which the arc begins. X variable-
Used to define the absolute coordinates of points in the X direction. Y variable-
Used to define the absolute coordinates of points in the Y direction. Formulas1)Xs=Xc+(R*cos(Theta1))2)Ys=Yc+(R*sin(Theta1))3)Xe=Xc+(R*cos(Theta2))4)Ye=Yc+(R*sin(Theta2))5)I=(Xc-(R*cos(Theta1)))-Xc6)J=(Yc-(R*sin(Theta1)))-
I will specify some requirements for this project before we start.
All units are traditional units in the United States.
Z = 0 will be the top surface of the part.
Clearance plane.
5000 \"will be used with a feed of 20 IPM.
Deep Cutting.
1250 more is needed.
The next few slides will introduce g-
We will use the code command.
The G00 command machine moves to the specified position at maximum feed speed.
General structure G00 X #. #### Y#. #### Z#.
# G01 command the machine moves to the specified position at a specific feed rate.
General structure G01 X #. #### Y#. #### Z. #. #### F#.
# G02 command the machine moves clockwise to the specified point at a specific feed rate.
General structure G02 X #. #### Y#. #### I#. #### J#. #### F#.
# G03 command the machine moves to the specified point counter clockwise at the specified feed speed.
General structure G03 X #. #### Y#. #### I#. #### J#. #### F#.
# NoteI and J define the position of the rotation center---
Relative to the current (STARTING)
Point X and point Y are the endpoint coordinates of the arc.
The first thing you should do is specify the source of your parts.
The origin is the point that references all absolute coordinates.
I will use the center of the part as the origin.
The point is defined as the place where the translation changes.
For example, a point is the starting and ending point where the x direction moves to the y direction or the arc.
In the section I introduced, there were 22 points in total.
Each point has a unique set of coordinates through g-code.
The sorting of points will ultimately determine the structure of your program.
For this example, I will start cutting at the first point and continue cutting in a clockwise direction around the part.
Find the ARC Center from the technical drawings I provided.
There are a total of 6 arcs in the part.
The arc center is critical to finding the starting and ending points of the arc and the I and J variables.
You can calculate the starting and ending points of the arc by specifying the coordinates of the center point of the arc.
Using the formula I provided, just insert the corresponding value of the variable.
I encourage you to do these calculations yourself.
This will help to understand the concept.
Define the variable = radius of arcTheta1 = angle of the starting point relative to the position of the X axis ta2 = angle of the endpoint relative to the position of the X axis xc = arc center X coordinate Y coordinate arc starting point arc center xs = X coordinate ys = Y coordinate xe of arc starting point = X coordinate of arc ending point = Y coordinate of arc ending point ti = incremental X coordinate of starting point j = Y coordinate of incremental starting point Formula 1)Xs=Xc+(R*cos(Theta1))2)Ys=Yc+(R*sin(Theta1))3)Xe=Xc+(R*cos(Theta2))4)Ye=Yc+(R*sin(Theta2))5)I=(Xc-(R*cos(Theta1)))-Xc6)J=(Yc-(R*sin(Theta1)))-
YcTo calculates the required arc value, simply insert the number into the formula of the corresponding variable.
You need to enter these values into the code later.
Define variable R = arc radius =.
5 Theta1 = angle of the starting point relative to the position of the X-axis = 90 Theta2 = angle of the end point relative to the position of the X-axis = 0 Xc = X coordinate arc center = 2.
25 arc = arc center Y coordinate = 3 Formula 1)Xs=Xc+(R*cos(Theta1))= 2. 252)Ys=Yc+(R*sin(Theta1))= 3. 53)Xe=Xc+(R*cos(Theta2))= 2. 754)Ye=Yc+(R*sin(Theta2))= 35)I=(Xc-(R*cos(Theta1)))-Xc = 06)J=(Yc-(R*sin(Theta1)))-Yc = -.
5 to calculate the required arc value, simply insert the number into the formula of the corresponding variable.
You need to enter these values into the code later.
Define variable R = arc radius =.
5 Theta1 = angle of the starting point relative to the position of the X-axis = 0 Theta2 = angle of the end point relative to the position of the X-axis = 270 Xc = X coordinate arc center = 2.
Coordinate = Y coordinate of 25 arc center =-3Formulas 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)))-
To calculate the desired arc value, simply insert the number into the formula of the corresponding variable.
You need to enter these values into the code later.
Define variable R = arc radius =.
5 Theta1 = angle of the starting point relative to the position of the X-axis = 0 Theta2 = angle of the end point relative to the position of the X-axis = 180 Xc = X coordinate arc center = 0 arc = Y coordinate of the arc Center =-2Formulas 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)))-
To calculate the desired arc value, simply insert the number into the formula of the corresponding variable.
You need to enter these values into the code later.
Define variable R = arc radius =.
5 Theta1 = angle of the starting point relative to the position of the X-axis = 270 Theta2 = angle of the endpoint relative to the position of the X-axis = 180 Xc = X coordinate arc center =-2.
Coordinate = Y coordinate of 25 arc center =-3Formulas 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 to calculate the required arc value, simply insert the number into the formula of the corresponding variable.
You need to enter these values into the code later.
Define variable R = arc radius =.
5 Theta1 = angle relative to the starting point position of the X-axis = 180 Theta2 = angle relative to the end point position of the X-axis = 90 Xc = X coordinate arc center =-2.
25 arc = arc center Y coordinate = 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)))-
To calculate the desired arc value, simply insert the number into the formula of the corresponding variable.
You need to enter these values into the code later.
Define variable R = arc radius =.
5 Theta1 = angle of the starting point relative to the position of the X-axis = 180 Theta2 = angle of the endpoint relative to the position of the X-axis = 0 Xc = X coordinate arc center = 0 arc = Y coordinate of the arc Center = 2. 5Formulas 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 an easy way is to recreate the part you want in the CAD system.
This method allows the computer to perform all calculations.
If you do it manually, just assign your calculated value to the point on the arc.
The coordinates of the line can be exported from the technical drawings I provide.
An easy way to track all coordinates and points is to save tables for all points.
So, in order to program this section, you have to consider the position where the cutting is started and the direction in which the tool moves.
In this case, we will start cutting at 1 and continue cutting around the perimeter of the part in a clockwise direction.
The Last Command used should get you back to the starting point.
Therefore, for the initial cut, we need to tell the machine to reach 1 point at the specified gap plane.
5000 \"above the top surface of the part \".
To do this, we need to move to the desired coordinates using the G00 command.
The first line should be like this (
I will continue to add lines of code to the first line to help guide you)G00 X. 5Y3. 5Z. 5 (
At this point, no cutting has occurred as the tool still exists.
5000 \"above)
Now that we are already centered at the first point, we need feedback down.
At 1250 \"below the top of the face, reach the cutting depth.
Since the tool is already at 1 point, only Z variables need to be defined using the G01 command at 20 IPM.
Now the code should be like this G00 X. 5 Y3. 5 Z. 5 G01Z-.
The 1250F20Now tool needs to move to point 2.
Since the Y values of point 1 and point 2 are the same, only X values are required for command horizontal movement.
Now the code should be like this G00 X. 5 Y3. 5 Z. 5 G01 Z-. 1250 F20 X2.
This is the first arc.
Since the tool will scan along the arc clockwise, the G02 command is required.
Only one line of code is required for this arc.
Just insert the number you calculated for arc one. (
Keep in mind that the X and Y coordinates of the arc command are the endpoints of the arc.
Insert the calculated I and J values of Arc 1)
Now the code should be like this G00 X. 5 Y3. 5 Z. 5 G01 Z-. 1250 F20X2. 25 G02 X2. 75 Y3 I0 J-.
5 since this is a linear move, the G01 command needs to be inserted into the next line of the code along with the new Y coordinate.
Now the code should be like this G00 X. 5 Y3. 5 Z. 5 G01 Z-. 1250 F20X2. 25 G02 X2. 75 Y3 I0 J-. 5 G01 Y.
75 The path from point 4 to 5 is a diagonal path, but it is still linear, so it can still be defined with g01.
For diagonal lines, X and Y coordinates need to be defined.
Now the code should be like this G00 X. 5 Y3. 5 Z. 5 G01 Z-. 1250 F20X2. 25 G02 X2. 75 Y3 I0 J-. 5 G01 Y. 75 X1.
The path of 451 Y 0 from point 5 to 6 is another diagonal movement, so the X variable and Y variable need to be defined.
Now the code should be like this G00 X. 5 Y3. 5 Z. 5 G01 Z-. 1250 F20X2. 25 G02 X2. 75 Y3 I0 J-. 5 G01 Y. 75X1. 451 Y 0 X2. 75 Y-.
This is a linear move down the y-axis.
It can still be defined under the G01 command.
Now the code should be like this G00 X. 5 Y3. 5 Z. 5 G01 Z-. 1250 F20X2. 25 G02 X2. 75 Y3 I0 J-. 5 G01 Y. 75X1. 451 Y 0X2. 75 Y-. 75 Y-
3Arc 2 is another clockwise arc, so the G02 command needs to be used.
Only one line of code is required for this arc.
Just insert the number you calculated for Arc 2. (
Keep in mind that the X and Y coordinates of the arc command are the endpoints of the arc.
Insert the calculated I and J values of Arc 2)
Now the code should be like this G00 X. 5 Y3. 5 Z. 5 G01 Z-. 1250 F20X2. 25 G02 X2. 75 Y3 I0 J-. 5 G01 Y. 75X1. 451 Y 0X2. 75 Y-. 75Y-3 G02 X2. 25 Y-3. 5 I-.
5 j0 move to point 9 is a horizontal move in the X direction.
The G01 command needs to be inserted into the code and the X variable needs to be defined.
Now the code should be like this G00 X. 5 Y3. 5 Z. 5 G01 Z-. 1250 F20X2. 25 G02 X2. 75 Y3 I0 J-. 5 G01 Y. 75X1. 451 Y 0X2. 75 Y-. 75Y-3 G02 X2. 25 Y-3. 5 I-. 5 J0 G01 X.
5 Moving to point 10 is moving vertically along the y-axis.
The Y variable needs to be defined on the new line under the current G01 command.
Now the code should be like this G00 X. 5 Y. 3 Z. 5 G01 Z-. 1250 F20X2. 25 G02 X2. 75 Y3 I0 J-. 5 G01 Y. 75X1. 451 Y 0X2. 75 Y-. 75Y-3 G02 X2. 25 Y-3. 5 I-. 5 J0 G01 X. 5 Y-
2 Moving to 11 points is moving counter-clockwise.
A G03 command needs to be inserted into the code.
Just insert the number you calculated for Arc 3. (
Keep in mind that the X and Y coordinates of the arc command are the endpoints of the arc.
Insert the calculated I and J values of arc 3)
Now the code should be like this G00 X. 5 Y3. 5 Z. 5 G01 Z-. 1250 F20X2. 25 G02 X2. 75 Y3 I0 J-. 5 G01 Y. 75X1. 451 Y 0X2. 75 Y-. 75Y-3 G02 X2. 25 Y-3. 5 I-. 5 J0 G01 X. 5Y-2 G03 X-. 5 Y-2 I-.
J0This marks the halfway point of the code.
To complete the second half of the code, use the same technique I introduced in the previous steps.
Before proceeding to the next step, complete the second half of the code and compare the code with the main code.
Remember, your last line of code should take you back to the first point to finish the cut.
The finished code should be like this.
I will also include my copy.
Txt file for the full function code of the person using the CNC simulator. Congrats!
You created a G-code program.
By completing this structure, I hope it gives you some insights on programming.
Programming the arc can be a bit difficult at first, but it becomes easier through practice.
Please feel free to leave any comments.
Thank you for taking the time to use my Instructure.
Custom message
Chat Online
Chat Online
Chat Online inputting...
Sign in with: