simple code employed in manufacturing engineering for the purpose of machine control consisting of a BASIC-like incremental scheme with each block of code containing at least one geometrical position and at least one tooling operation. e.g.

N100 M03 S1000 ---turns spindle on at 1000 RPM
N200 M08 G03 X200 Y75 Z-50 R75 F150 --- coolant on, cut circle to point (200, 75,-50) with radius of 75mm at feedrate of 150 mm/min

you do not want to manually program g-code, it is tedious and you will end up killing someone if the part you WILL screw up on is big and hard enough. Leave the programming to compilers that generate g-code from CAD drawings
As g3n3ru5 says, writing your own G-Codes is hard for complex items. I don't recommend it if you have good, automated software available. If you don't have access to good software, however, it is entirely possible to work out G Codes by hand.

Note: I have never formally learned to write G-Codes. All I know, I reverse-engineered from my school's CNC milling machine and software. As such, everything I write is from a milling machine perspective. Oh, and I set the machine to 'Metric' mode.

CNC G-Code commands can be broadly divided into two categories, G Codes and M Codes. These may be followed (on the same line) by a number of parameters, or on a new line to repeat the command with different commands.

M codes are typically non-geometry commands, whilst G codes are typically geometry-related commands. Each is expressed as a letter followed by a number.

An example M code would be:

M6T1

This would execute M code 6, which is 'select tool', and it would select tool 1. Another command could be:

M3S1500

This would execute M code 3, which is 'Rotate cutter clockwise', and the speed is 1500Rpm

An example G code could be:

G0X10Y70

This would move the tool to 10mm on the X axis, 70mm on the Y axis. The positions are relative to the point of origin, and the tool moves at high speed (i.e. the speed used when not cutting). Another example could be:

G1Z-0.5F100

This would move the tool - at feed speed - to 0.5mm below the point of origin on the Z axis at a feed speed of 100mm/min.

G-codes may be generated from CAD/CAM software which gets input from one of two ways: the geometry of a CAD drawing; or the source code of the CAD/CAM program, which is simply geometric data entered by the CAD/CAM programmer. Modern CAD/CAM software generally has provision for documenting the entire machining process, from the selection of cutting tools and fixtures to special instructions on finishing or preparation for a later process.

G-codes are also routinely entered by CNC machine operators at the machine console keyboard and stored in the memory of the machine. This method is generally preferred in small machine shops where accountability for the manufacturing process is not as important as in large companies. Many modern CNC machines have operating system software that includes improved G-code libraries and conversational or intuitive programming modes that work much like a wizard on a home computer.

In the early days of CNC or NC machining, as it was then called, there were no CAD/CAM software or programmers. G-codes were entered into portable typewriter-like machines that punched precisely-positioned holes into endless lengths of paper or nylon tape. This tape was then fed into the NC machine once for every cycle or unit of production, since the machines had no permanent memory. Later, when machines came with memory, the tapes only had to be read once by the machine. At this point, the capacity of machine memory was minimal, so the tapes had to be stored for later use. Modern machines can store literally hundreds of programs and can be uploaded and downloaded with floppy discs or other media or directly from a central network or portable notebook computer.

Most of the code referred to as G-code consists of codes that begin with a letter other than G. But this borders on the trivial.

Log in or register to write something here or to contact authors.