2012-08-04 20:34:57 (CET)

G Codes ( G43 - G80 )

Tool Length Offsets - G43, G43.1, and G49  

To use a tool length offset from the tool table, program G43 H…, where the H number is the desired index in the tool table. It is expected that all entries in this table will be positive. The H number should be, but does not have to be, the same as the slot number of the tool currently in the spindle. It is OK for the H number to be zero; an offset value of zero will be used.


If the H number is omitted, the actual tool in the spindle is used.


It is an error if:

  • the H number is not an integer, is negative, or is larger than the number of car­ousel slots.


To use dynamic tool compensation (not from the tool-table), use G43.1 I.. K.. where I.. gives the tool X offset (turning) and K.. gives the tool Z offset (for turning and milling)


To use no tool length offset, program G49. It is OK to program using the same offset already in use. It is also OK to program using no tool length offset if none is currently being used.


#5401 - #5416 is the tool-Z (length) offset.

#5501 - #5516 is the tool-diameter (length).

#5601 - #5616 is the tool-X (width for turning) offset.

The variables can be modified runtime (in the G-Code file) if needed to compensate for tool-wear.

Move in Absolute Coordinates - G53  


For linear motion to a point expressed in absolute coordinates, program
G1 G53 X… Y… Z… A… (or use G0 instead of G1), where all the axis words are optional, except that at least one must be used. The G0 or G1 is optional if it is the current motion mode. G53 is not modal and must be programmed on each line on which it is intended to be active. This will produce coordinated linear motion to the programmed point. If G1 is active, the speed of motion is the current feed rate (or slower if the machine will not go that fast). If G0 is active, the speed of motion is the current traverse rate (or slower if the machine will not go that fast).


It is an error if:

  • G53 is used without G0 or G1 being active,

  • G53 is used while cutter radius compensation is on.



Select Coordinate System - G54 to G59.3  


To select coordinate system 1, program G54, and similarly for other coordinate

systems. The system-number-G-code pairs are: (1-G54), (2-G55), (3-G56), (4-G57), (5-G58), (6-G59), (7-G59.1), (8-G59.2), and (9-G59.3).


It is an error if:

  • one of these G-codes is used while cutter radius compensation is on.



Set Path Control Mode - G61, and G64, or G64 Px  

Some work pieces require absolute accuracy and some other require nonstop milling for best surface quality. One must understand that it is physically impossible to move around sharp corners without a standstill at the corner. This isn’t possible with a car and also not with a CNC machine, since that would require infinite acceleration. The user can make a choice here, absolute accuracy with standstill at every corner (G61) or no standstill and corner round off with specified accuracy (G64Px.x).



G61 puts the machining center into exact path mode, In G61, the motion velocity between motion segments goes to zero, the end position in corners is exactly reached, use this if you require maximum accuracy. When a work piece consists of many small lines this gives a quite vibrating machine because of the continuous acceleration-deceleration-stop behavior.

G64 Px.x for continuous mode. In G64, subsequent moves are blended, when previous move starts to decelerate and reaches a velocity such that the specified accuracy isn’t violated, the next move starts to accelerate, the two motions are added. The result is smooth motion with highest possible speed to achieve required accuracy. The corners however are rounded. specifies the distance reached to the corner while blending. The next move is blended with current such that the tool path remains no more than P from the corner. The figure below is a rectangle of 10x10 milled with F 2000. This is done with P values from 0.1 to 1, you can see the impact. This gives the best compromise between accuracy and smooth motion.




To make a move from stand still we need to accelerate, then have a certain cruising speed and after decelerate. Short moves typically never reach the requested velocity the accelerate and then at half the distance the decelerate.


This table shows the distance traveled so that the given speed is reached. When the line segments generated by the CAD/CAM program are shorter, the actual speed on the machine will be lower than requested value. Example, you want a milling speed of 900 mm/minute, then the segments generated by the CAD/CAM program must be smaller than 1.88 mm. If the lines are only 0.21 mm, the feed will go down to 300



































































If you machine has higher accelerations which requires bigger motors, also higher milling velocities are possible. The values given here are for a moderate hobby machine. This illustrates that when the G-Code file exists of small segments, e.g. 0.08 mm, that with an acceleration of 120 a feed can be reached of 180 mm/minute at most.


Look Ahead feed


To explain this, I will compare a running CNC machine with driving a race car.

The road maximum velocity signs have to be obeyed and you have to drive your car exactly over the white line in the middle of the road. You will try to reach the maximum allowed velocity where possible. When you see a curve coming up ahead, you will brake so that you will not drift off the road. You will try to look ahead as far as you can see and you take care that you can stop in time if the road suddenly stops.


When you would maintain your speed in sharp curves, you will drift off the road resulting possibly into a car accident. When the road has many short curves, then you will not be able to reach the desired speed. The more PS you have in the car, the higher speed you will reach because you can accelerate faster.


I think this is a good comparison with a CNC machine, the same issues apply. A machine cannot suddenly change velocity, to reach a velocity the motors must accelerate first for a certain time to reach the velocity.


LAF behaves like the ideal racecar driver, it will reach the highest possible velocity without violating the maximum motor accelerations.


There is one additional problem while running CNC programs, some programs consists of short line pieces. When the line pieces connect tangentially (are in line), then LAF will accelerate through over the lines, reaching the maximum allowed speed.

The angle to which LAF considers the segments in line is a setup parameter. The theoretical ideal value would be very small, so that no acceleration value occurs.

More practical values are in the range of 1 to 4 degrees, the experience learns that most machines can handle acceleration spikes up to a certain limit.


The value can be set up to 180 degrees in this case you must know what you are doing, it can be useful during e.g. foam cutting wing profiles. Be aware however that if the curve contains real sharp angles that step pulse loss may be the result when using large minimum LAF angles.


In practice we have seen that milling times of complex 3D work pieces can be done in 50% of the time compared to competitors who do not have LAF.

Coordinate system rotation G68


G68 R.. X.. Y..


R Rotation angle in degrees, positive is counter-clockwise, negative is clockwise.

X Y Rotation point in current coordinate system.


Threading (Lathe) – G76  

G76 P- Z- I- J- R- K- Q- H- E- L-

Z driveline endpoin
I Outside thread diameter, always positive.
J First cut is J beyond I, always positive.
R Depth regression, use 1.0 for constant cutting depths or leave parameter away.
K Full thread depth beyond thread peak, always positive.
Q Compound slide angle, typical 30.
H Additional spring passes at full depth, use 0 for none.
E Taper distance along drive line.
L Taper place, none, enter, exit, both.

;Create a thread from z=20 to z=10, outside diameter=15, inside diameter=14, 10 passes.
G0 X20 Z20
G76 P1.0 Z10 I15 J0.1 K1.0

It is an error if:

  • The active plane is not the ZX plane

  • Other axis words, such as X- or Y-, are specified

  • The R- degression value is less than 1.0.

  • All the required words are not specified

  • P-, J-, K- or H- is negative

  • E- is greater than half the drive line length


The “drive line” is a safe line outside the thread material. The “drive line” goes from the initial location to the Z- value specified with G76. The Z extent of the thread is the same as the drive line.


The “thread pitch”, or distance per revolution, is given by the P- value.


The “thread peak” is given by the I- value, which is an offset from the drive line. Negative I values indicate external threads, and positive I values indicate internal threads. Generally the material has been turned to this size before the G76 cycle.


The “initial cut depth” is given by the J- value. The first threading cut will be J beyond the “thread peak” position. J- is positive, even when I- is negative.


The “full thread depth” is given by the K- value. The final threading cut will be K beyond the “thread peak” position. K- is positive, even when I- is negative.


The “depth degression” is given by the R- value. R1.0 selects constant depth on successive threading passes. R2.0 selects constant area. Values between 1.0 and 2.0 select decreasing depth and increasing area. Values above 2.0 select decreasing area. Beware that unnecessarily high degression values will cause a large number of passes to be used.

The “compound slide angle” Q- is the angle (in degrees) describing to what extent successive passes should be offset along the drive line. This is used to cause one side of the tool to remove more material than the other. A positive Q value causes the leading edge of the tool to cut more heavily. Typical values are 29, 29.5 or 30.


The number of “spring passes” is given by the H- value. Spring passes are additional passes at full thread depth. If no additional passes are desired, program H0.


Tapered entry and exit moves can be programmed using E- and L-. E- gives a distance along the drive line used for the taper. E0.2 will give a taper for the first/last 0.2 length units along the thread. L- is used to specify which ends of the thread get the taper. Program L0 for no taper (the default), L1 for entry taper, L2 for exit taper, or L3 for both entry and exit tapers.


The tool will pause briefly for synchronization before each threading pass, so a relief groove will be required at the entry unless the beginning of the thread is past the end of the material or an entry taper is used.


Unless using an exit taper, the exit move (traverse to original X) is not synchronized to the spindle speed. With a slow spindle, the exit move might take only a small fraction of a revolution. If the spindle speed is increased after several passes are complete, subsequent exit moves will require a larger portion of a revolution, resulting in a very heavy cut during the exit move. This can be avoided by providing a relief groove at the exit, or by not changing the spindle speed while threading.


The sample program g76.ngc shows the use of the G76 canned cycle, and can be previewed and executed on any machine using the sim/lathe.ini configuration.


Figure: G76 canned cycle


This is how it works:

  1. Before the start, the spindle rate is measured.

  2. The feed for de z-axis is calculated: F = pitch * spindleRate

  3. The CPU programmed such that a movement is started on the spindle pulse.

  4. The movement is calculated and send to the CPU.

  5. The movement is started when the spindle pulse passes.

  6. Before the treading starts, the spindle-rate is measured, averaged and the feed is calculated from this.

Not that the inside and outside thread diameter are determined by the start position, the position before G76 and the I, K parameters.


Cancel Modal Motion - G80


Program G80 to ensure no axis motion will occur.


It is an error if:

  • Axis words are programmed when G80 is active, unless a modal group 0 G code is programmed which uses axis words.