7 February 2017

What is G code

G code is simply a language used to tell machine.
G code has many variants, but it is the common name for the most widely used Numeric Control (NC) programming language.
G code is mainly used in computer-aided manufacturing for controlling automated machine tools.
In a modern-day desktop CNC machine and software, you will never have to enter G-code manually, unless you want to
The CAD/CAM software and the machine controller will take care of all of this for you. 

Now let we know some most common programming code with example and how its use and how it work?

G0 - Rapid motion 

G0 Rapid motion
Code for a figure - G0 X7 Y18

The G0 command moves the machine at maximum travel speed to whatever coordinates follow G0. 
The machine will move in a coordinated fashion, and both axes complete their travel at the same time. G0 is not used for cutting. Instead, it’s used to move the machine quickly to begin a job or move to another operation within the same job. 

G1 - Controlled motion
G1 Controlled motion

Code for a figure - G1 X7 Y18 F500
A G1 command is similar to G0.
G1 tells the machine to move at a specified rate called the feed rate (F).

G2 - Clockwise motion 

G2 clockwise motion
Code for a figure - G21 G90 G17
                         G0 X0 Y12
                                      G2 X12 Y0 I0 J-12

G2 is used for specifying the offset from the centre creates clockwise motion between the starting point and specified ending point.

Another figure for G2

G2 clockwise motion

G3 - Counterclockwise motion
G3 Counterclock wise motion

Code for a figure - G21 G90 G17
                         G0 X-5 Y25
                                     G3 X-25 Y5 I0 J-20

Just like G2, the G3 command creates an arc between two points. Whereas G2 specifies clockwise motion, G3 specifies counterclockwise motion between the points as shown in the figure. 

G17/G18/G19 - Working Planes

These codes are used to set the plane to be machined. 
Typically G17 is used and is the default for most hobby machines, but two other planes can be used in a three-axis machine:
  • G17 = x/y plane
  • G18 = z/x plane
  • G19 = y/z plane
G20/21 - Inches or Millimeters
The G21 and G20 commands used for units, either inches or millimetres.
  • G21 = millimeters
  • G20 = inches
Here’s an example that’s set to inches:
G21 G17 G90

G28 - Referencing Home
A simple G28 command sends the machine to its home position
Code - G28 Z0

G90 - Absolute Mode
G90 causes units to be interpreted as absolute coordinates
This is the most common mode for hobby-grade CNC machines; it’s the default mode.
Absolute coordinates will be interpreted as exactly that absolute. 
If we write code G0 X10 will send the machine to x = 10. It will not send the x-axis to “10 more” units from where it’s currently located.

G91 - Incremental Mode
G91 is the opposite mode of G90
Setting an incremental mode means that every command issued will move your machine the specified number of units from its current point not like that in G90 likes from x-axis only.
For example, in incremental mode, G1 X1 will advance the machine 1 unit in the x-direction, regardless of its current location.