G-code

From Wikipedia, the free encyclopedia

Jump to: navigation, search This article is about the machine tool programming language. For the video recorder programming system, see Video recorder scheduling code. G-Code, or preparatory code or function, are functions in the Numerical control programming language. The G-codes are the codes that position the tool and do the actual work, as opposed to M-codes, that manages the machine; T for tool-related codes. S and F are toolSpeed and tool-Feed, and finally D-codes for tool compensation. The programming language of Numerical Control (NC) is sometimes informally called G-code. But in actuality, G-codes are only a part of the NC-programming language that controls NC and CNC machine tools. The term Numerical Control was coined at the MIT Servomechanisms Laboratory, and several versions of NC were and are still developed independently by CNC-machine manufacturers. The main standardized version used in the United States was settled by the Electronic Industries Alliance in the early 1960s. A final revision was approved in February 1980 as RS274D. In Europe, the standard DIN 66025 / ISO 6983 is often used instead. Due to the lack of further development, the immense variety of machine tool configurations, and little demand for interoperability, few machine tool controllers (CNCs) adhere to this standard. Extensions and variations have been added independently by manufacturers, and operators of a specific controller must be aware of differences of each manufacturers' product. When initially introduced, CAM systems were limited in the configurations of tools supported. Today, the main manufacturers of CNC control systems are GE Fanuc Automation (joint venture of General Electric and Fanuc), Siemens, Mitsubishi, and Heidenhain, but there still exist many smaller and/or older controller systems. Some CNC machine manufacturers attempted to overcome compatibility difficulties by standardizing on a machine tool controller built by Fanuc. Unfortunately, Fanuc does not remain consistent with RS-274 or its own previous versions, and has been slow at adding new features, as well as exploiting increases in computing power. For example, they changed G70/G71 to G20/G21; they used parentheses

Generally it is a code telling the machine tool what type of action to perform. There are other codes. or a decorative profile shape added to the edge of a workpiece. and are any word in a CNC program that begins with the letter 'G'. Contents [hide] • • • • 1 Common Codes 2 Example Program 3 See also 4 External links [edit] Common Codes G-codes are also called preparatory codes. change a pallet set tool information such as offset.for comments which caused difficulty when they introduced mathematical calculations so they use square parentheses for macro calculations. they now have nano technology recently in 32-bit mode but in the Fanuc 15MB control they introduced HPCC (high-precision contour control) which uses a 64-bit RISC processor and this now has a 500 block buffer for look-ahead for correct shape contouring and surfacing of small block programs and 5-axis continuous machining. This is also used for NURBS to be able to work closely with industrial designers and the systems that are used to design flowing surfaces. The NURBS has its origins from the ship building industry and is described by using a knot and a weight as for bending steamed wooden planks and beams. the type codes can be thought of like registers in a computer X absolute position Y absolute position Z absolute position . a workpiece cut (routed) to a specific dimension. such as: • • • • • rapid move controlled feed move in a straight line or arc series of controlled feed moves that would result in a hole being bored.

or optional word passed to a subprogram/canned cycle D Cutter diameter/radius offset H Tool length offset (*) M codes control the overall machine. K Arc data Z axis. even machines that use the same CNC control. turn on coolant.A position (rotary around X) B position (rotary around Y) C position (rotary around Z) U Relative axis parallel to X V Relative axis parallel to Y W Relative axis parallel to Z M code (another "action" register or Machine code(*)) (otherwise referred to as a "Miscellaneous" function") F feed rate S spindle speed N line number R Arc radius or optional word passed to a subprogram/canned cycle P Dwell time or optional word passed to a subprogram/canned cycle T Tool selection I Arc data X axis J Arc data Y axis. causing it to stop. machine will only stop if operator selects this option M02=End of Program M03=Spindle on (CW rotation) M04=Spindle on (CCW rotation) M05=Spindle Stop M06=Tool Change M07=Coolant on (flood) M08=Coolant on (mist) M09=Coolant off M10=Pallet clamp on M11=Pallet clamp off M30=End of program/rewind tape (may still be required for older CNC machines) . whereas other codes pertain to the path traversed by cutting tools. Different machine tools may use the same code to perform different functions.. start. • Partial list of M-Codes M00=Program Stop (non-optional) M01=Optional Stop. etc.

Common FANUC G Codes for Mill .

G05 P10000 G07 G09 G10/G11 G12 G13 G17 Rapid positioning Linear interpolation Description CW circular interpolation CCW circular interpolation Dwell Ai Nano contour control HPCC Imaginary axis designation Exact stop check Programmable Data input/Data write cancel CW Circle Cutting CCW Circle Cutting X-Y plane selection .1 Q1.Code G00 G01 G02 G03 G04 G05.

G18 G19 G20 G21 G28 G30 X-Z plane selection Y-Z plane selection Programming in inches Programming in mm Return to home position 2nd reference point return Skip function (used for probes and tool length measurement systems) Constant pitch threading Variable pitch threading Tool radius compensation off Tool radius compensation left Tool radius compensation right Tool offset compensation negative Tool offset compensation positive G31 G33 G34 G40 G41 G42 G43 G44 .

1 P1 to Extended work coordinate systems P48 G73 G74 G76 G80 G81 High speed drilling canned cycle Left hand tapping canned cycle Fine boring canned cycle Cancel canned cycle Simple drilling cycle .G45 G46 G47 G48 G49 G50 G53 Axis offset single increase Axis offset single decrease Axis offset double increase Axis offset double decrease Tool offset compensation cancel Define the maximum spindle speed Machine coordinate system G54 to G59 Work coordinate systems G54.

but only on very few machines. Such software must be customized for each type of machine tool that it will be used to program.G82 G83 G84 G84. G-code files may be generated by CAM software. if necessary.2 G90 G91 G92 Drilling cycle with dwell Peck drilling cycle Tapping cycle Direct right hand tapping canned cycle Absolute programming (type B and C systems) Incremental programming (type B and C systems) Programming of absolute zero point Inch per minute/Inch per revolution feed (type A system) Note: Some CNCs use the SI unit system Constant surface speed Constant Spindle speed Return to Initial Z plane/R plane in canned cycle G94/G95 G96 G97 G98/G99 A standardized version of G-code known as BCL is used. Post-processors are often user-editable to enable further customization. Gcode is also output by specialized CAD systems used to design printed circuit boards. Those applications typically use translators called post-processors to output code optimized for a particular machine type or family. Some G-code is written by .

Hurco's Ultimax and Mori Seiki's CAPS conversational software. index . which is a wizard-like programming mode that either hides G-code or completely bypasses the use of G-code. use tool offset values located in line 3 of the program table. Some popular examples are Southwestern Industries' ProtoTRAK. Mazak's Mazatrol. (Caution: This is generic.hand for volume production jobs. [edit] Example Program This is a generic program that demonstrates the use of G-Code to turn a 1" diameter X 1" long part. it might not work on any real machine! Pay particular attention to point 5 below. Assume that a bar of material is in the machine and that the bar is slightly oversized in length and diameter and that the bar protrudes by more than 1" from the face of the chuck. In this environment. Some CNC machines use "conversational" programming. to ensure the starting position of the tool N02 N03 G50 S2000 Set Maximum spindle speed N04 M01 N05 T0303 M6 Optional stop Select tool #3 from the carousel.) Tool Path for program Sample Lin e Code Description N01 M216 G00 X20 Z20 Turn on load monitor Rapid move away from the part. the inherent inefficiency of CAM-generated G-code is unacceptable.

High spindle gear.the turret to select new tool G96 S854 N06 M42 M03 M08 G00 X1. Turn off the coolant Home X axis in the machine coordinate system. Turn the mist coolant on N07 Rapid feed to a point 0. 854 ft/min.1" away from the end of the bar Rapid feed up until the tool is standing at the finished OD Feed in horizontally cutting the bar to 1" diameter all the way to the datum Stop the spindle. rewind to beginning of the program N08 N09 X0. Start spindle CW rotation. then home all other axes Turn the load monitor off Program stop.1 Z1.05 Variable speed cutting.1 G01 Z1.1" from the end of the bar and 0.Face the end of the bar Rapid feed 0.1 N11 X1.0 N12 G01 Z0.05 N13 M05 M09 N14 G28 G91 X0 N15 M215 N16 M30 .05" from the side Feed in horizontally until the tool is standing 1" from the datum Feed down until the tool is on center .0 F.0 F.0 N10 G00 Z1. pallet change if applicable.

They are usually not necessary for operation of a machine. 4. For pedagogical purposes. or ram the tool into the part under high power. How close that "safe" distance is. there is a high probability that the machine will crash. depends on the skill of the programmer and maximum material condition for the raw stock. This can be costly. The grouping of codes in line N06 could have been put on multiple lines. if branching or looping statements are used in the code. so they are seldom used in industry. It is common practice to bring the tool in rapidly to a "safe" point that is close to the part . On small or hobby machines. For example. especially in newer machining centers. G03) was selected. line numbers have been included in the program above. Doing so may have made it easier to follow program execution. 3. There is room for some programming style. It is possible to intersperse the program with optional stops (M01 code) which allow the program to be run piecemeal for testing purposes. Many codes are "Modal" meaning that they stay in effect until they are cancelled or replaced by a contradictory code. even in this short program. most CAD/CAM software ships with CNC simulators that will display the movement of the tool as the program executes. it can warn of a tool that is becoming dull and needs to be replaced or sharpened. it stayed in effect until the end of the program.in this case 0.and then start feeding the tool. The optional stops remain in the program but they are skipped during the normal running of the machine. 5.Several points to note: 1. The job of the load monitor is to prevent machine damage in the event of tool breakage or a programming mistake. In operation. 6. once variable speed cutting had been selected (G96). Depending on the size of the part. The load monitor will stop the machine if the spindle or feed loads exceed a preset value that is set during the set-up operation. This enables programmers to discover semantic errors (as opposed to syntax errors) before losing material or tools to an incorrect program. Many modern CNC machines also allow programmers to execute the program in a simulation mode and observe the operating parameters of the machine at a particular execution point. However. the spindle speed would increase as the tool neared the center of the work in order to maintain a constant cutting speed.1" away . G02. Similarly. It is common practice to use a load monitor with CNC machinery. Thankfully. once rapid feed was selected (G00) all tool movements would be rapid until a feed rate code (G01. 2. If the program is wrong. then line . wax blocks may be used for testing purposes as well.

numbers may well be included as the target of those statements (e.g. . GOTO N99).

Sign up to vote on this title
UsefulNot useful