Search This Blog

Tuesday, December 16, 2014

G90 and G91 Positioning gcodes

GCode G90 and G91 Absolute and incremental Positioning

In a CNC Programming the tool movement end point is always positioned by using two positioning G-Codes. They are:
1)      G90 Absolute positioning.
2)      G91 Incremental Positioning.

1)   G90 Absolute Positioning G-Code:

When Using G-code G90 (absolute positioning) Command, The end positioning of the tool movement is always from the absolute point (Absolute Zero) or the fixed point.  All the x y and z co-ordinate movements are calculated from the Zero point or the Axis Point. Absolute zero point is always set on the mid of the center table or the corner of the part or Center of the hole depending on the machines and the complexity of the part. In simple words “Absolute zero” is where the dimensions of the part program are defined from.
When using G90 the end point movement is the machine would go to that exact location from part zero, regardless of where it began, within the travel of the machine tool.

Example for G-Code G90 (Absolute Positioning):

N170 G90 G01 X-3 Y-2 F50;
As shown in the above code line the tool want to move to a position of 3 inches to the left, and 2 inches down from part zero was programmed, suppose if your tool somewhere in X500 Y500 position and when the G90 is called it moves to X-3 and Y-2 compared from absolute Zero.

2)   G91 Incremental Positioning G-Code:

When using G-code G91 (Incremental Positioning) Command, the tool always moves incrementing the last position value i.e., the control thinks that the last position of the tool is zero point and adds up the new position coded.  When using a G-code G91 incremental position command, each measurement or move is the actual distance to the next location is always from the current location. This G-code is modal G-code and is not cancelled until G90 is called. G91 makes all subsequent x y and z incremental throughout the program until it is cancelled.

In general, the G91 Incremental positioning G-code is used when repeating motions within a subprogram, for example, if you have four identical pockets to machine, then you can specify the motions incrementally to machine one pocket. Then just call up the subroutine again to repeat the commands to do another pocket at a new location. By doing this you can save programming effort to all the pockets.

Example for G-Code G91 (Incremental Positioning):

N170 G91 G01 X-3 Y-2 F50;
As shown in the above code line the tool want to move to a position of 3 inches to the left, and 2 inches down from the last tool position, suppose if your tool somewhere in X500 Y500 position and when the G91 is called as above example it moves to X497 and Y498 compared from absolute Zero.



Monday, December 15, 2014

G52 Offset Local Coordinate System


G52 - Offset Local Coordinate System:

In CNC Programming G52 G-Code used to shift the program to given distance locally.
·         The G52 works the same as G54. This code sets the origin of the local (child) coordinate system to the command location, relative to the current work system origin.
·         G52 shifts the local coordinate system origin by a specified distance.
·         Multiple G52 codes are not cumulative; subsequent shifts replace earlier ones. The G52 shift may therefore be cancelled by specifying a shift of zero.
·         If you are using multiple coordinate systems, the G52 shift amount will affect all coordinate systems.
·         G52 is a non-modal, no motion code. The G52 coordinate system will stay in effect for all work systems until it is cancelled.
·         The G52 is cancelled when RESET is pressed and at the end of a program. It is also cancelled during a program by M30, G52, X0 Y0 Z0.

Example for G52:

G0 X0 Y0; move to origin
M98 P9100; call subprogram
G52 Y4; shift coordinate system 4 inches in Y
G0 X0 Y0; move to new origin
M98 P9100; call subprogram again with new coordinates

G52 Y0; restore un-shifted coordinate system

G50 and G51 Scaling and Mirroring


G50, G51 - Scaling / Mirroring (Optional):
G51 scales program G-codes relative to a scaling center point defined as position (X, Y, and Z).
G50 – Cancels the scaling factor applied

 A G51 applies scaling/mirror to all positions, lines, and arcs following this G-code until a G50 are entered. Specify scaling factors with a value I, J, K. The X, Y, and Z parameters are the coordinates of the scaling center. If the scaling center is not specified, the default scaling center is the current cutter position. To mirror, enter a negative value for the scaling factor.

Example, Scaling:

G51 X0.0 Y0.0 Z0.0 I3.0 J2 K1; turn scaling on
G00 X0.0 Y0.0 Z1.0; rapid to x0, y0, Z1
G01 X1.0 Y0.0 Z1.0; line to X1, Y0, Z1
G01 X1.0 Y1.0 Z1.0; line to X1, Y1, Z1
G01 X0.0 Y1.0 Z1.0; line to X0, Y1, Z1
G01 X0.0 Y0.0 Z1.0; line to X0, Y0, Z1
G01 X0.0 Y0.0 Z0.0; line to X0, Y0, Z0

G50; cancel scale
For this G51, the following program lines were scaled 3:1 in the X direction, 2:1 in the Y direction, and
1:1 in the Z direction. If no scale factor is specified, the default is 1:1 for all axes.

Example, Mirroring:

G51 X-0.5 Y0.0 Z.0 I-1 J1 K1; turn mirror on.
G00 X0.0 Y0.0 Z1.0; rapid traverse to X0, Y0, Z1
G01 X1.0 Y0.5 Z1.0; line to X1, Y.5, Z1
G01 X0.0 Y1.0 Z1.0; line to X0, Y1, Z1
G01 X0.0 Y0.0 Z1.0; line to X0, Y0, Z1
G50; cancel scale
If scaling factors are the same for all the axes, parameter P can be used.

Example:

G51 X1.0 Y2.0 Z0.0 P2.5; scale all axes a factor of 2.5. If an arc is scaled with uneven scaling factors, the result will depend on how the arc center and radius were specified:

NOTE: If the arc radius was specified with R, the radius will be scaled by the larger of the two circular plane scale factors. The result will be a circular arc between the scaled arc start and the scaled arc end.

NOTE: If the arc center was specified with I, J, and/or K, the centers will be scaled by the appropriate axis scale factors. The result will be a circular arc from the scaled arc start, around the scaled center, and usually with a line from the end of the circular arc to the scaled arc end.

NOTE: In no case can an ellipse be generated using scaling.


Friday, December 12, 2014

G43 G44 and G49 tool length compensation

G-Code G43, G44 and G49 (TOOL LENGTH COMPENSATION)

 In an CNC Programming Tool length compensation Code is used to adjust for differences in length between different tools, without worrying about those differences in your part program.
This standard length is the Reference Tool. In general, you load the Reference Tool, jog the Z axis down until that tool touches some surface, and set the Z Reference position there. The control memorizes this position of its Z axis. You then load each other tool, bring that tool down until it touches the same surface, and tell the control to measure the tool. The control compares the Z axis position with this tool touching the surface to the previously stored Z Reference position. The difference in Z axis positions is stored as the length offset for the tool.

Clearly, to touch the same surface with a shorter tool, you have to move the Z axis down further. This results in a negative offset. The shorter the tool, the more the negative offset.  To touch the same surface with a longer tool, you don't have to move the Z axis down as far. This results in a positive offset. The longer the tool, the larger (or less negative) the offset.

Listed below are the Three G-Code used only for the tool length compensation,
G43 Tool Length Compensation + (plus)
G44 Tool Length Compensation - (Minus)
G49 Cancel Tool length Comp G43 and G44

G43 Tool Length Compensation + (plus):


This code selects tool length compensation in a positive direction. The tool length offsets are added to the commanded axis positions. An Hnn must be programmed to select the correct offset register from the offset display for that tool being used. During the setup process, each tool point was touched-off to the part zero surface. From this position a Tool length distance offset was recorded for that tool with the Tool offset measure key. This Tool length is referred to as the "Z" axis origin move to the part zero surfaces.

G44 TOOL LENGTH COMPENSATION - (MINUS)

This code selects tool length compensation in a negative direction. The tool length offsets are subtracted from the commanded axis positions. A Hnn must be programmed to select the correct entry from offsets memory. G44 is a rarely-used alternative to G43. It tells the control to begin applying tool length compensation, by subtracting the current length offset from all Z axis positions. In this scheme, larger length offset numbers identify shorter tools (as if they were measured from the table up rather than from the spindle down).


G49 CANCELS G43/G44

This G code cancels tool length compensation. Putting in a H00 will also cancel tool length compensation. M30 and RESET will also cancel tool length comp.

Example for G43 and G44 Programs:

O1234
N170 T02 M06
N171 G90 G54 G00 X50 Y50 Z50 S800
N172 G43 H02 Z5 M08 (or G44 and H value will not be changed)
N172 G01 Z20 F50.

Monday, December 08, 2014

G40 G41 and G42 Cuttercompensation



G-Code G40, G41 and G42 (Cutter compensation):

Understanding cutter compensation can be very simple if one has a basic understanding of manual machining. There are two common types of cutting conditions associated with milling machines. They are CLIMB and CONVENTIONAL cutting. Two common rules for these types of cuts are:
If the programmed cutter path needs to mill CLIMB cutting, and it's a standard right handed tool, it will then be programmed with G41 cutter LEFT of the programmed path. If the programmed cutter path needs to mill with CONVENTIONAL cutting, and it's a standard right handed tool, it will then be programmed with G42 cutter RIGHT of the programmed path.

Listed below are the Three G-Code used only for the Cutter compensation,
G41 Cutter Compensation Left
G42 Cutter Compensation Right
G40 Cancel Cutter Comp G41 and G42

G41 Cutter Compensation Left:


G41 will select cutter compensation left; that is the tool is moved to the left of the programmed path to compensate for the radius of the tool. A Dnn must also be programmed to select the correct tool size from the DIAMETER/RADIUS offset display register.

G42 Cutter Compensation Right:

G42 will select cutter compensation right; that is the tool is moved to the right of the programmed path to compensate for the size of the tool. A Dnn must also be programmed to select the correct tool size from the DIAMETER/RADIUS offset display register.

G40 Cutter Comp Cancel:

G40 will cancel the G41 or G42 cutter compensation commands. A tool using cutter compensation will change from a compensated position to an uncompensated position. Programming in a D00 will also cancel cutter compensation. Be sure to cancel cutter compensation, when you're done with each milling cut series that's using compensation.

The Active Cutter compensation should satisfy the following points:


1) A G41 or G42 code must be contained with a G01 X, Y, or X and Y move is specified in the same block.
2) The distance of the linear move must be greater than the tool radius.
3) The tool radius value, "R", entered into the tool offsets table must not be 00.
4) A G02 or G03 circular interpolation command cannot be specified in the start-up block.


NOTE: The codes G4Ø, G41 and G42 are modal, belonging to the same modal family. They are incompatible with each other on the same block.


NOTE: The machine controller enters compensation cancel mode automatically when:

1) The machine power is first switched on.
2) The reset button on the CRT/MDI controller panel is pressed.
3) A program is forced to end by performing an M02 or M30 command.


Example for cutter compensation programming:

O 1234
N171 G00 X-15 Y-15 Z50;
N172 G01 Z0;
N172 G41 X0 Y0 F100; (Start-Up Move)
N173 Y40;
N174 X30 Y80;
N175 X60;
N176 G02 X100 Y40 R40;
N177 G01 Y30;
N178 G03 X70 Y0 R30;
N179 G01X0;
N180 G40 X-15 Y-15; (Cancellation Move)
N190 G00 Z50

ADVANTAGES OF CUTTER COMPENSATION:

1. The mathematical computations for determining a tool path are greatly simplified.
2. Because the geometry and not the tool center are programmed, the same program can be used for a variety of different cutter diameters.
3. When using cutter compensation you are then able to control and adjust for part dimensions using your cutter diameter/radius offsets register.
4. The same program path can be used for the roughing passes as well as finishing cuts by using different cutter offset numbers.

DIS ADVANTAGES WITH CUTTER COMPENSATION

1.      A cutter compensation command (G41, G42 or G40) must be on the same block with an X and/or Y linear command when moving onto or off of the part using cutter comp.
2.      You cannot turn on or off cutter compensation with a Z axis move.
3.   You can use cutter comp. in the G18 (X, Z) or G19 (Y, Z) planes using G141.
4.   You cannot turn ON or OFF cutter compensation in a G02 or G03 circular move, it must be in a linear G00 or G01 straight line move.

WHEN ACTIVATING CUTTER COMPENSATION, CARE MUST BE TAKEN TO:

1. Select a clearance point, without cutter compensation, to a start point in the X and Y axis at least half the cutter diameter off the part before you start initiating cutter compensation.
2. Bring the Z axis down without cutter compensation in effect.
3. Make an X and/or Y axis move with a G41 or G42 call-out on the same line, with a diameter offset Dnn command, which has the cutter diameter value in the offset display register being used.

WHEN DEACTIVATING CUTTER COMPENSATION, CARE MUST BE TAKEN TO:

1. Select a clearance point in X and/or Y axis, at least half the cutter diameter off the part.
2. DO NOT cancel cutter compensation on any line that is still cutting the part.
3. Cancel of cutter compensation (G40) may be a one or two axis move, but you may need values entered for both X and Y axis.

Very Important Note: In Practical the Cutcom should start before the Linear Movement with G01 and should end before the Linear Movement G01.





Friday, December 05, 2014

G28 Return Home

G-Code G28 Return home:

G28 Is the G-Code that instructs the Controller of the machine to move the tool automatically to the reference point.  The Reference point is the fixed position on the machine, to which the tool can be moved.  This reference point is also called the “Home position”. Machine has the reference point for  X, Y and Z Axis.

G28 G-Code Format:

N170 G90 G28 X_ Y_ Z_; (Absolute Code)
Or
N170 G91 G28 X_ Y_ Z_; (Incremental Code)
                    Where X, Y and Z can be used to indicate an intermediate point, through which the tool will pass, before continuing to the reference point.  If the intermediate point is not set, tool may move in non-vector type path.  It may collide with the part or the fixture, so you can put the intermediate values in X, Y and Z to move the tool first to safety plane.
                     The move to any intermediate point and the reference point are performed at a rapid traverse rate.

Example Below shows the collision scenario 1:

 The diagram below shows how the tool could collide with the billet when moving towards the reference point with Non-vector type movement.
To avoid this collision, the tool is sent on a path which includes intermediate point P2. The intermediate point is used to allow the tool to move completely clear from the billet, before continuing onto the reference point, P3.
The above tool path can be programmed as follows (In absolute mode, G9Ø):
G90 G28 X60 Z60;
The above tool path can be programmed as follows (In incremental mode, G91):
G91 G28 X0 Z40;
So that the Tool moves to the safety plane before it reaches the Reference Point.

Example Below shows the collision scenario 2:

In the diagram below, the tool is in a position (P1) where there is no obstacle to collide. The intermediate point, in this case, is not required, so the block can be written as follows:
(In incremental mode, G91): G91 G28 X0 Y0 Z0; 

NOTE :  G28 is a non-modal G code. It is only active in the block in which it is programmed.

NOTE: If no X, Y, Z, or A is specified, all axes will be moved directly to machine zero. Any auxiliary axes (B, C...) are returned to the machine home after the X, Y, Z, and A axes. G28 will not recognize any tool length offsets in this move.






Monday, December 01, 2014

G20 & G21 (Unit Selection Codes)

G-Code G20 & G21 (Unit Selection Codes):

The CNC Programming can be done either with Imperial Unit (Inches G20) or The Metric Unit (Millimeter G21).  The following items are also changed depending on whether G20 or G21 in the programs.
1) Positioning command values (X, Y and Z).
2) Incremental movement distances.
3) Feed rates commanded by the F code.
4) Offset values.
In the world the US, Canada region are particularly use in inches, and other part of the world used Millimeter and some parts they use both inches and Millimeter depending on their requirements.
Lowest input value in G20 (Inch) is 0.0001 inch and the Lowest input value in G21 (Millimetre) 0.001 mm, this give an advantage for G21 for more accuracy.

NOTE: G20 and G21 are the modal G-codes, so G20 can only be cancelled by G21 and vice versa.

NOTE:  Units have to be defined in the beginning of the program or else Machine considers the default set by previous programs.

NOTE: Units cannot be reversed by changing only G20 or G21 in your program. It has to be defined before Post processing the program.

Example G20 Inch programming selection:

N170 O1000
N171 T02 M06
N172 G20
N173 G94 G54 G00 X10 Y10 Z100


G21 metric programming selection:

N170 O1000
N171 T02 M06
N172 G21
N173 G94 G54 G00 X10 Y10 Z100