G-code is a programming language used to control CNC (Computer Numerical Control) machines, which are used in manufacturing to automate processes like cutting, drilling, milling, and more.
Here are some common G-codes along with some example:
G00 - Rapid Move: This command moves the tool at maximum speed to a specified location. It's used when you want the machine to quickly move without cutting material.
Example: G00 X20 Y8 Z10
Explanation: This moves the tool to the coordinates X=20, Y=8, Z=10 at rapid speed.
G01 - Linear Interpolation: This command moves the tool in a straight line from the current location to a specified location at a specified feed rate (cutting speed).
Example: G01 X25 Y18 F120
Explanation: This moves the tool to X=25, Y=25 at a feed rate of 120 units per minute.
G02/G03 -
Circular Interpolation: These commands move the tool in a circular arc.
G02 moves clockwise, and G03 moves counterclockwise.
Example (G02): G02 X40 Y30 I12 J8
Explanation: This command moves the tool in a clockwise arc to X=40, Y=30 with a center offset of I=12, J=8.
G17/G18/G19
- Plane Selection: These commands define the plane in which the tool moves.
G17 is for
the XY plane (default in most machines), G18 for the ZX plane, and G19 for the
YZ plane.
Example: G19
Explanation: This sets the YZ plane as the active plane for cutting.
G90/G91 - Distance Mode: G90 sets absolute positioning (coordinates are measured from a fixed origin), while G91 sets incremental positioning (coordinates are relative to the current position).
Example (G91): G91 G01 X10 Y-5
Explanation: This moves the tool 10 units in the X direction and 5 units in the negative Y direction relative to its current position.
M-codes: These are miscellaneous functions like starting or stopping the spindle, coolant, or other auxiliary functions.
Example: M03 S1200
Explanation: This starts the spindle clockwise at 1200 RPM.