What is G Codes & M Codes in CNC machining

What is G Codes & M Codes in CNC machining

What is G Codes & M Codes in CNC machining ?

 

CNC machining or you can say CNC Programming is solely depends on “G Codes” and “M Codes”.

Each and every program in field of automatic machining must contain some “G&M” codes, one can’t assume a part machining without it.

Some fresh operators have some myth that they have to remember and use all the “G&M” codes on daily basis, But believe us you don’t have to do that all “hallabalu”. We have discussed some important “G&M” codes here . They are very less in count and you just need this much code to remember to be a “manual programmer”.

Manual programing is the pure game of playing with “G&M” codes.

After reading this article you might be much more familiar with CNC programming.

G Codes:

www.cadcamx.com

 

“G codes” are basically address code means whenever you put a “G” code in your program it will give some command to the machine that you have to perform this action or have to go there.

There are several “G Codes” in the machine manual but not all codes are used offenly.

Some common codes are as below_

G00 — Rapid mode ( machine will use its full feed to move along the axes eg. X,Y,Z,A,B,C)

G01— Feed mode (machine will use the given feed to travel from one point to other)

G02 – Circular interpolation CW (machine will make radius in clockwise direction)

G03 – Circular interpolation CCW (machine will make radius in counter clock direction)

G17 – XY plane (machine movement will be in given XY plane)

G18 – XZ plane (machine movement will be in given XZ plane)

G19 – YZ plane (machine movement will be in given YZ plane)

G20 – Inch programming (machine will read all given values in inches)

G21 – Metric programming (machine will read all given values in millimeters)

G28 – Return to machine zero (machine will move given axes to its homing position)

G40 – Cutter compensation Cancel (Tool side of a particular curve will be cancel)

G41 – Cutter compensation left (while running with a 2D program cutter will be on left side of the 2D curve)

G42 – Cutter compensation right (while running with a 2D program cutter will be on right side of the 2D curve)

G43 – Tool compensation on (while using this code machine will follow the tool length in the tool pocket number)

G47 – Text Engraving (this code is used for engraving text on a part)

G52 – Offset in Z – axes ( program will run about the shift value given in this column)

G54-G59 – Work co-ordinate system (Job center and offset will be stored in this column)

G80 – Cancel canned cycle (this code is used for cancelling a drilling program)

G81 – Center drill (this code is used for drilling in center drill or direct drilling method)

G82 – Spot drill (this code is used for drilling in spot drill or full peck drilling method)

G83 – Normal drill (this code is used for drilling in chip break drilling method)

G84 – Tapping (this code is used for tapping or making tread in the hole)

G86 – Boring (this code is used for making bore finish in a hole)

G90 – Absolute mode (when this code is used in a program all the given values will be calculated from the given workpiece center position)

G91 – Incremental mode (when this code is used in a program all the given values will be calculated from the current tool position)

G92 – Work co-ordinate shift mode (this code is use to shift the coördinate of the tool from the given work piece center position)

G98 – Canned cycle initial point return

G99 – Canned cycle reference point return

*** So these all were the common G-codes which are normally used to program a CNC machine in a better way. Don’t scare of so much of G-codes, use given above codes to make your desired program.

Now, let’s move on other code which is M-code.

M Codes:

www.cadcamx.com

 

“M codes” are basically switch code means whenever you put a “M” code in your program it will turn on/off particular function of the machine that you have to perform this action.

There are severel “M Codes” in the machine manual but not all codes are used offenly.

Some common codes are as below_

M00 – Stop program (The M00 code is used to stop a program. It stops the axes, spindle, turns off the coolant.The next block (block after the M00) will be highlighted when viewed in the program editor. Pressing Cycle Start will continue program operation from the highlighted block)

M01 – Optional program (works same as M00, bur optional stop function should be on in machine controller)

M02 – Program stop (this will end the program as stays at last block number)

M03 – Spindle start CW (this code will turn on spindle in clockwise direction. eg. S500 M03)

M04 — Spindle start CCW (this code will turn on spindle in counter clock direction. eg. S500 M04)

M06 – Tool change (this code is used to change the tool from ATC pocket to the spindle. eg. T01 M06)

M08 – Coolant on ( this code is used to turn on coolant line to the part)

M09 – Coolant off ( this code is used to turn off coolant line running on the part)

M30 – Program end and Reset (if this code is used program will stop and reset to first block)

M97 – Local Sub-program call (using this code will call a sub-program which is available within a main program eg. On the same page program)

O0001
M97 P1000 L2 (L2 command will cause the program to run the N1000 line twice)
M30
N1000 G00 G90 G55 X0 Y0 (N line that will run after M97 P1000 is run)
S500 M03
G43 H01 Z1.
Z-.5
G01 G41 X.5 F100.
G03 YI-.5
G01 X0 G40
Z1. F50.
G91 G28 Z0
G90
M99

M98 – Sub program call (using this code will call a sub-program which is available in the main list of program eg. Program is avilable outside of the same page)

M98 Example:
O0001 (Main Program number)
M98 P100 L4; (Call Sub-program, Sub-program Number, Loop 4 Times)
M30 (End of program)
O0100 (SUB-PROGAM NUMBER)
G00 G90 G55 X0 Y0
S500 M03
G43 H01 Z1.
Z-.5
G01 G41 X.5 F100.
G03 YI-.5
G01 X0 G40
Z1. F50.
G91 G28 Z0
G90
M99

M99 – Return to main-program or Loop (using this code will return to main program first block after completing the supplied command or sub-program)

M99 Example:
calling program: Haas
O0001
N50 M98 P2
N51 M99 P100 …… N100 (continue here)
M30
subroutine: O0002
M99 P100

*** So these all were the common M-codes which are normally used to program a CNC machine in a better way. Don’t scare of so much of M-codes, use given above codes to make your desired program. Keep in mind making a manual CNC program is not rocket science, you just have to remember common codes and place them properly on the CNC control, That’s it…… !!!

*** In our next article we are going to make some common CNC manual program like. Drilling, Facing, Countering, Boring, Pocketing, Circular milling, Slotting etc.

So don’t forget to read our next article which will really helpful to those who are fresher in this field. And share the information with others. Cause sharing is good though !!

If you like our post share it with your friends and on social media also. If you have any questions and suggestions regarding the post above please feel free to put your thoughts in the comment box below.

You can share our blog directly from your phone or tablet to whats-app, Facebook or twitter.

And if you really like our article and wanna stay connected and informed about the upcoming articles which are interesting and full of knowledge.

please do subscribe to our newsletter.

 

Thank you !!

 

 

2215total visits,1visits today

Mr. Sharma

He is very passionate about learning new things and teach them to others as well. He have experience in several software for installation and usage. He has started this blog to keep the world updated regarding new invention in CNC technology.

This Post Has 5 Comments

  1. Very help full by you pradeep bhai

    So many people are spending so munch money for learn this

    Really Good work

    Keep it up….

  2. Very help full information about CNC Machine opration by you pradeep bhai

    So many people are spending so munch money for learn this

    Really Good work

    Keep it up….

Leave a Reply

Close Menu
%d bloggers like this: