Computer Numerically Controlled (CNC Code) – G and M codes

CNC Code – G and M codes

cnc machine

We provide a list of G and M-codes for the reader to have an idea of the kind of functionality that can be realized using these codes. These codes were originally designed to be read from paper tapes and are designed to direct tool motion with simple commands.

Typical Specifications of a CNC System
1. Number of controlled axes: Two/Four/Eight, etc.
2. Interpolation : Linear/circular/parabolic or cubic/cylindrical
3. Resolution: Input resolution (feedback)
: Programming resolution
4. Feed rate: Feed/min
: Feed/revolution
5. Rapid traverse rate: Feed rate override
: Feed/min
6. Operating modes : Manual/Automatic/MDI(editing)/Input/Output/
Machine data set-up/Incremental, etc.
7. Type of feedback: Digital (rotary encoders with a train of pulses)
: Analog (transducers, etc.)
: Both
8. Part program handling: Number of characters that can be stored
: Part program input devices
: Output devices
: Editing of part program
9. Part programming: Through MDI
: Graphic simulation
: Blueprint programming
: Background editing
: Menu-driven programming
: Conversational programming
10. Compensations: Backlash
: Lead screw pitch error
: Temperature
: Cutter radius compensation
: Tool length compensation
11. Programmable logic controller : Built-in (integrated)/External
: Type of communication with NC
: Number of inputs, outputs, timers, counters, and flags
: User memory
: Program organization
: Programming Languages
12. Thread cutting/Tapping: Types of threads that can be cut
13. Spindle control: Analog/Digital control
: Spindle orientation
: Spindle speed overrides
: RPM/min; constant surface speed
14. Other features: Inch/metric switchover
: Polar coordinate inputs
: Mirror imaging
: Scaling

A basic list of ‘G’ operation codes is given below. These direct motions of the tool.

list of ‘G’ operation codes

G00 – Rapid move (not cutting)
G01 – Linear move
G02 – Clockwise circular motion
G03 – Counterclockwise circular motion
G04 – Dwell
G05 – Pause (for operator intervention)
G08 – Acceleration
G09 – Deceleration
G17 – x-y plane for circular interpolation
G18 – z-x plane for circular interpolation
G19 – y-z plane for circular interpolation
G20 – turning cycle or inch data specification
G21 – thread cutting cycle or metric data specification
G24 – face turning cycle
G25 – wait for input to go low
G26 – wait for input to go high
G28 – return to reference point
G29 – return from reference point
G31 – Stop on input
G33-35 – thread cutting functions
G35 – wait for input to go low
G36 – wait for input to go high
G40 – cutter compensation cancel
G41 – cutter compensation to the left
G42 – cutter compensation to the right
G43 – tool length compensation, positive
G44 – tool length compensation, negative
G50 – Preset position
G70 – set inch based units or finishing cycle
G71 – set metric units or stock removal
G72 – indicate finishing cycle
G72 – 3D circular interpolation clockwise
G73 – turning cycle contour
G73 – 3D circular interpolation counter clockwise
G74 – facing cycle contour
G74.1 – disable 360 deg arcs
G75 – pattern repeating
G75.1 – enable 360 degree arcs
G76 – deep hole drilling, cut cycle in z-axis
G77 – cut-in cycle in x-axis

G78 – multiple threading cycle
G80 – fixed cycle cancel
G81-89 – fixed cycles specified by machine tool manufacturers
G81 – drilling cycle
G82 – straight drilling cycle with dwell
G83 – drilling cycle
G83 – peck drilling cycle
G84 – taping cycle
G85 – reaming cycle
G85 – boring cycle
G86 – boring with spindle off and dwell cycle
G89 – boring cycle with dwell
G90 – absolute dimension program
G91 – incremental dimensions
G92 – Spindle speed limit
G93 – Coordinate system setting
G94 – Feed rate in ipm
G95 – Feed rate in ipr
G96 – Surface cutting speed
G97 – Rotational speed rpm
G98 – withdraw the tool to the starting point or feed per minute
G99 – withdraw the tool to a safe plane or feed per revolution
G101 – Spline interpolation

list of ‘M’ operation codes

M-Codes control machine functions.
M00 – program stop
M01 – optional stop using stop button
M02 – end of program
M03 – spindle on CW
M04 – spindle on CCW
M05 – spindle off
M06 – tool change
M07 – flood with coolant
M08 – mist with coolant
M08 – turn on accessory (e.g. AC power outlet)
M09 – coolant off
M09 – turn off accessory
M10 – turn on accessory
M11 – turn off accessory or tool change
M17 – subroutine end
M20 – tailstock back
M20 – Chain to next program
M21 – tailstock forward
M22 – Write current position to data file
M25 – open chuck
M25 – set output #1 off
M26 – close chuck
M26 – set output #1 on

M30 – end of tape (rewind)
M35 – set output #2 off
M36 – set output #2 on
M38 – put stepper motors on low power standby
M47 – restart a program continuously, or a fixed number of times
M71 – puff blowing on
M72 – puff blowing off
M96 – compensate for rounded external curves
M97 – compensate for sharp external curves
M98 – subprogram call
M99 – return from subprogram, jump instruction
M101 – move x-axis home
M102 – move y-axis home
M103 – move z-axis home

Some other typical codes and keywords used in part programs are given below.
Annn – an orientation, or second x-axis spline control point
Bnnn – an orientation, or second y-axis spline control point
Cnnn – an orientation, or second z-axis spline control point, or chamfer
Fnnn – a feed value (in ipm or m/s, not ipr), or thread pitch
Innn – x-axis center for circular interpolation, or first x-axis spline control point
Jnnn – y-axis center for circular interpolation, or first y-axis spline control point
Knnn – z-axis center for circular interpolation, or first z-axis spline control point
Lnnn – arc angle, loop counter and program cycle counter
Nnnn – a sequence/line number
Onnn – subprogram block number
Pnnn – subprogram reference number
Rnnn – a clearance plane for tool movement, or arc radius, or taper value
Qnnn – peck depth for pecking cycle
Snnn – cutting speed (rpm), spindle speed
Tnnn – a tool number
Unnn – relative motion in x
Vnnn – relative motion in y
Wnnn – relative motion in z
Xnnn – an x-axis value
Ynnn – a y-axis value
Znnn – a z-axis value
; – starts a comment , or end of block

Please follow and like us:

2 thoughts on “Computer Numerically Controlled (CNC Code) – G and M codes”

Leave a Comment