top of page

CNC Programming

1. What is G Code? Although the official name of the code is RS-274D, most people refer to it as G code. This is because most of the commands in this code start with the letter G. The ‘G’ in G code stands for geometry. The G code is written in an alphanumeric format and is responsible for the movements of these machines. It tells the machine where to start, how to move, and when to stop when fabricating a part. Although this seems simple enough, G code programming can be quite complicated for machinists. This is because different machines read G codes in different formats. Most machines’ difference is in the presence or absence of spaces between commands and in the number of zeros between the letter and number in the commands. For example, a machine might use G3 while another uses G03. Machinists must always be conversant with the type of machine they’re using. This is because errors in the command can lead to serious problems in parts production. While G is the most common letter in G code CNC programming, it is not the only letter used. Other letters also have functions in the code, and these letters tend to have the same functions regardless of the company’s format. Examples of some letters in the G code includes: A: It directs the tool around the x-axis. R: It gives the radius of the arcs the machine makes. X, Y, Z: These three values indicate the tools’ position in three dimensions – X and Y represent the horizontal and vertical dimensions, respectively, while Z represents the depth. I and J: Both values designate the incremental center of any arc the machine makes. N: N gives the line number. The code also uses other letters which depend on the machine’s capabilities.

2. What is M Code? Like the G code, the M code also begins with the letter ‘M.’ The M code is a set of auxiliary commands that control all the machine’s non-geometric actions. Machinists refer to the code as miscellaneous codes as it controls non-cutting actions such as stopping programs, flooding the machine with coolants, and shutting it off after the temperature drops. When setting up CNC programs using G and M codes, M code should only have one command per block of information. This is because they mainly turn the machine on and off. Therefore, using them multiple times in one block could cause program problems. Just like G codes, M codes also vary between different machines. Some machines allow the omission of the zero between the letter and number, while some do not.

3.Difference Between G-Code And M-Code.

Although machinists use G and M codes concurrently in any CNC machining process, they differ. Here are some examples of how both CNC codes differ:

  1. G code commands tend to differ in most CNC machines, while M codes are similar in most CNC machines.

  2. G codes direct the machine’s motion and function, while M codes direct the operations outside movements.

  3. The G code activates the CNC machine while the M code activates the machine’s programmable logic controller. 3.How does CNC Programming Control CNC Machines? Before the advent of computers, machinists used cards or tapes to control machine movements. They punched holes on these cards in a specific order to create the codes. While this was also effective at the time, it was quite tedious. Also, these cards were prone to damage or getting lost in the machine shops. This led to several problems in productions at the time. When machinists started using computers for numerically controlled machines, they still came across a few problems. This was because they had to input the codes manually. This would, of course, be very tedious when they were making quite sophisticated parts that required a lot of instructions. However, with much more advanced computers and software, machinists can simply instruct the software on what to do. The software will then generate the G codes and M code that the machine understands. With CAD (computer-aided design) and CAM (computer-aided manufacturing) software, code generation for machine functions has become very easy.

A CNC machine operator’s monitor


To start the process, the programmer needs high-level computer-aided software. The programmer then imports the machine model and the machining fixture into the software. He/She also selects the tools and the tooling paths of the spindle. The software then generates the G and M codes that the machine needs to function.


A code generating software at work


This is the summary of the process through which CNC programming controls the function of CNC machines. Although the process above seems simplified, it could take weeks to generate the codes for a sophisticated part.



Comments


Post: Blog2_Post
bottom of page