G-code

G-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 tool-Speed 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 ISO standard DIN 66025 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 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 (reduced instruction set computer) 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.

Common Codes

G-codes are also called preparatory codes, and are any word in a CNC program that begins with the letter 'G'. Generally it is a code telling the machine tool what type of action to perform, 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, a workpiece cut (routed) to a specific dimension, or a decorative profile shape added to the edge of a workpiece.
*change a pallet
*set tool information such as offset.

There are other codes; the type codes can be thought of like registers in a computer:X absolute position:Y absolute position:Z absolute position: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.:K Arc data Z axis, or optional word passed to a subprogram/canned cycle:D Cutter diameter/radius offset:H Tool length offset

(*) M codes control the overall machine, causing it to stop, start, turn on coolant, etc., whereas other codes pertain to the path traversed by cutting tools. Different machine tools may use the same code to perform different functions; even machines that use the same CNC control.

* Partial list of M-Codes

:M0=Program Stop (non-optional):M1=Optional Stop, machine will only stop if operator selects this option:M2=End of Program:M3=Spindle on (CW rotation):M4=Spindle on (CCW rotation):M5=Spindle off:M6=Tool Change:M7=Coolant on (flood):M8=Coolant on (mist):M9=Coolant off:M10=Pallet clamp:M11=Pallet un-clamp:M30=End of program/rewind tape (may still be required for older CNC machines)

A standardized version of G-code known as "BCL" is used, but only on very few machines.

G-code files may be generated by . Those applications typically use translators called post-processors to output code optimized for a particular machine type or family. Post-processors are often user-editable to enable further customization, if necessary. G-code is also output by specialized CAD systems used to design printed circuit boards. Such software must be customized for each type of machine tool that it will be used to program. Some G-code is written by hand for volume production jobs. In this environment, the inherent inefficiency of CAM-generated G-code is unacceptable.

Some CNC machines use "conversational" programming, which is a wizard-like programming mode that either hides G-code or completely bypasses the use of G-code. Some popular examples are Southwestern Industries' ProtoTRAK, Mazak's Mazatrol, Hurco's Ultimax and Mori Seiki's CAPS conversational software.

Example Program

This is a generic program that demonstrates the use of G-Code to turn a 1" diameter X 1" long part. 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. (Caution: This is generic, it might not work on any real machine! Pay particular attention to point 5 below.)

Several points to note:

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

Basic ISO CNC Code

:
:M03, M04, M05 Spindle CW, Spindle CCW, Spindle Stop:
:M08, M09 Coolant/lubricant On, Coolant/lubricant Off:M02 Program Stop(Is most commonly used):M30 Program end, rewind:M98 Subprogram call:M99 Return to call program:M00, M01 Program stop, optional stop:
:G96, G97 Constant surface speed, Constant Spindle speed:G50 Maximum spindle speed:G95, G94 Feed mm per revolution, feed mm/min:G00, G01 rapid movement, Linear Interpolation (cutting in a straight line):
:F Feed:S Spindle Speed:
:direction Coordinates X Y Z A B C U V W

ee also

*Direct Numerical Control
*Gerber file

External links

* [http://www.linuxcnc.org/handbook/gcode/g-code.html Tutorial for G-code]
* [http://www.cnc411.com/index.php Free Machinist Infomation, Calculators, and Forums]
* [http://www.isd.mel.nist.gov/personnel/kramer/pubs/RS274NGC_3.web/RS274NGC_3TOC.html The NIST RS274NGC]


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • Code Cyclique — En mathématiques et en informatique, un code cyclique est un code correcteur linéaire. Ce type de code possède non seulement la capacité de détecter les erreurs, mais aussi de les corriger sous reserve d altérations modérée. Les mathématiques… …   Wikipédia en Français

  • Code De Hamming — Un code de Hamming est un code correcteur linéaire. Il permet la détection et la correction automatique d une erreur si elle ne porte que sur une lettre du message. Un code de Hamming est parfait, ce qui signifie que pour une longueur de code… …   Wikipédia en Français

  • Code de hamming — Un code de Hamming est un code correcteur linéaire. Il permet la détection et la correction automatique d une erreur si elle ne porte que sur une lettre du message. Un code de Hamming est parfait, ce qui signifie que pour une longueur de code… …   Wikipédia en Français

  • code — [ kɔd ] n. m. • 1220; lat. jurid. codex « planchette, recueil » 1 ♦ Recueil de lois. Le code de Justinien, et absolt le Code. Ensemble des lois et dispositions légales relatives à une matière spéciale. Livre, article d un code. Le C ODE CIVIL ou… …   Encyclopédie Universelle

  • Code page — is another term for character encoding. It consists of a table of values that describes the character set for a particular language. The term code page originated from IBM s EBCDIC based mainframe systems,[1] but many vendors use this term… …   Wikipedia

  • Code Geass — Code Geass: Lelouch of the Rebellion First Code Geass DVD volume released in Japan. コードギアス 反逆のルルーシュ (Kōdo Giasu: Hangyaku no Rurūshu) …   Wikipedia

  • Code Civil (France) — Première page de l édition originale (1804) …   Wikipédia en Français

  • Code Correcteur — Un code correcteur est une technique de codage basée sur la redondance. Elle est destinée à corriger les erreurs de transmission d une information (plus souvent appelée message) sur une voie de communication peu fiable. La théorie des codes… …   Wikipédia en Français

  • Code Linéaire — En mathématiques, plus précisément en théorie des codes, un code linéaire est un code correcteur. Il est structuré comme un sous espace vectoriel sur un corps fini. L espace utilisé est souvent F2n le terme usuel est alors celui de code linéaire… …   Wikipédia en Français

  • Code MDS — Code parfait et code MDS Un code parfait (ou code MDS, pour maximum distance séparable) est un concept de la théorie des codes et qui traite plus spécifiquement des codes correcteurs. Un code correcteur est un code permettant au récepteur de… …   Wikipédia en Français

  • Code NAF — Le code NAF est l un des codes INSEE. C est la Nomenclature des Activités Françaises. Elle permet la codification de l APE, c est à dire de l activité principale exercée dans l entreprise ou l association. Cette nomenclature d activités… …   Wikipédia en Français

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”