|
Understanding CNC G-Code and M-Code Programming
When a CNC Lathe or CNC Mill is properly programmed and set-up, it is a safe, productive, and high-quality method for production machining. Today’s CNC Machine Shop likely produces it’s G-Code with the aid of a CAM(Computer Aided Manufacturing) software package. Cam software used the geometry from the part drawing or blueprint. It utilize the dimensions drawn into the part and assigns 2D or 3D geometry to the part. This geometry is then used by the Cam software. The CAM Programmer assigns a group of machining processes, like drilling, facing, boring, pocketing, etc. to the geometry in the drawing. Once this is done, the Software quickly and automatically generated the G-Code program to be used in the CNC machine. Often this program can be several thousand lines long. The most popular Cam programs in use today are Mastercam, Gibbscam and BobCad. A Cam package price can range anywhere from $10,000 to $15,000 for a single seat of software. This is not meant to be an all-inclusive explanation of CNC G-code programming. It is meant to be a very basic primer. A first step to get you started on a pathway to a better understanding of CNC programming. Usually a CNC program will consist of anywhere from a few lines of code for a simple job, to thousands of lines of code for a larger job. In this article we will focus on the simple, and shorter version. Usually a CNC program will have N words at the beginning of lines in the program. N words may be at the beginning of every line, or they may be at the beginning of just a few lines. N1 Sometimes you will see them as N2 Or N10 In every case, the purpose of the N word is simply to number the line or block of code. It is meant to help identify a specific line of code or a block of code. This can be important! Imagine trying to track down an error in a huge program of several thousand lines of code if you had no numbering system to go by! Other than identifying a line…the N words are ignored by the CNC machine. Their only purpose is to be a method of identifying where you are at in the program. Think of N words as being similar to the page numbers of a book. Often you may see a G00 or G0 (G Zero) used interchangeably. In most cases, when using a G number such as G00, G01, G02, G03, G04, etc., on up to G09, one would be able to use the single digit version of the command. Examples would be: G0, G1, G2, G3, G4, etc.. Almost all machines today will accept either this single digit version or the 2 digit version of this code. In the extremely rare case where an error is caused by a single digit version, or when in doubt, use the standard 2 digit version. Example G00. What follows is a basic list of the most common G-Codes with a brief explanation of it’s use/purpose. It is not meant to be a complete list. This is also not meant to be complete description of each individual G-code’s use. When a G word offer’s more than one use, The most commonly used purpose to that G-code. In some cases a G word has a different use for lathe or mill. Again, the most commonly used G words are: G00 Rapid Transverse Motion M00 Program stop - Tells the CNC machine to stop in the middle of a program.
|