Posted by: davidhayden | February 28, 2010

Proven Tips, Tools and Tactics: Understanding G01


The shortest distance between two points is a straight line. G01 is the CNC code that tells your machine to move to the next point in a straight line, but it takes more than a simple G01 to make the machine actually make the move.

Code Data

Code: G01
Modal: Yes
Group: 01
Action: Linear Moves
ANSI Std: Yes
Requirements: Point to move to, Feed Rate at which to move
Options: G09 Exact Stop, R to create radius at end, A to create chamfer at end
Conflicting G Codes G00, G02, G03, G04, All Canned Cycles, Any other G code in Groups 00, 01 or 09

Description and How to Use G01

G01 is the preparatory G code used to program CNC machines to make straight moves.
Because it is a modal command, you can place the G01 anywhere in your program and the machine will stay in that mode until it receives a conflicting G code command. For the machine to actually move, you have to give it a destination point that is different from the current point.

Also, in order for the machine to move, a feedrate must be active. The G01 will not move the machine until it knows how fast it is supposed to move. Like G01, feedrate codes are modal.

This is best explained with a couple examples:

Assume the current location of the tool is at X0, Y0, Z0 and that the programming is in inches.

G01 X-1.031

G01 sets the mode of machine to straight moves or linear interpolation as it is known in CNC jargon.
X-1.031 tells the machine to move 1.031 inches in a negative direction

Seeing what you see here, would the machine actually move?

Hopefully you said no. Based on the code written above, the machine still does not know how fast to move. So let’s add a feedrate.

G01
X-1.031 F15. The F15. in this example tells the machine to move at 15 inches per minute (IPM)

The feedrate command (F) does not have on the same line as the coordinates, it can be before the end point coordinates are specified. Putting a feedrate on a line after the line with end points, will only affect future lines, not the ones listed before.

You can also put the G01, the end point and feedrate all on one line as shown below.

G01 X-1.031 F15. This is a complete line and will cause the machine to move to X-1.031 at 15 IPM

G01 is also used on CNC lathes in conjunction with Inches Per Revolution (IPR) feedrates. When using IPR, the axis will move the distance in the F Code in one revolution of the machine. So in the case above, if the mode of the machine was IPR, it would try to race across the face of the part moving 15 inches for each revolution of the machine.

If this were a lathe move, and you wanted the machine to move in inches per revolution, you would first need to set the machine mode to IPR using the G95 code. Then you would adjust the feedrate to an appropriate for the machine to move in one revolution. For Example:

G95 Sets the machine to IPR mode
G01 X-1.031 F.012 In this case the move is still in the X- direction but the feed rate is now .012 IPR

One more thing. Unless you are working with very old NC equipment, you need only use the G and F codes once unless you want to change them. For example:

G01 X-1.031 F15. This command sets the machine mode to linear interpolation at a feedrate of 15 IPM.
Z- .85 New destination point, no change in type of move or feedrate.
X-.75 Moves to new X destination, same feedrate.
X-1. Z-1.25 Moves at an angle, but still in a straight line, same feedrate.
X-1.031 F30. moves to X-1.031 at the faster 30 IPM
G00 X0 Y0 G00 takes the machine out of Linear Interpolation mode and sets it to Rapid Travel Mode to return to start point

Options To Use with G01

Depending on your control, there are a couple of options you can use with the G01 command.
The G09 is non-modal option telling the machine to stop exactly at the programmed end point.

Why would you need this you ask, aren’t CNC machines accurate? Yes CNC machines are accurate, but they are also designed for optimum efficiency. What that means is the control is always looking ahead to the next move. So if it sees it needs to move in a new direction once it reaches the destination point, to cheats a little and actually starts that new move slightly before reaching the end point. Also, if the machine does not keep moving, it may leave a witness mark on the part where the motion stops before moving to the next location.

In most cases, you the amount of error is very small, less than .001. But if you need dead on accuracy, you may want to use the G09 to make sure the machine stops at the target point before moving on.

Sample Code:
G01 G09 X-1.031 F15. This command tells the machine to stop at exactly before moving on to Z-.85
Z- .85 This end point is not affected by G09 because G09 is non-Modal and only affects the line it is on.

Finally by using an R or A Command, you can tell the control to move the machine so that when it changes direction it automatically puts a blend radius or chamfer at the intersection of your current move and the next move. That is a discussion for another article.

Summary

Remember, to use G01 to cut a straight line you need to know where you are starting, where you are going, how fast you want to get there and what you want to do when you get to the end point.


For a complete introduction to the fundamentals of CNC programming, take a look at 7 Easy Steps to CNC Programming . . . A Beginner’s Guide or 7 Easy Steps to CNC Programming . . . A Beginner’s Guide, the Ebook

Advertisements

Categories

%d bloggers like this: