G Code

What is a G code? Mr Beam explains

You may have read the term "Gcode" in connection with Mr Beam 's laser cutter. But what is that? And what is this code used for? Mr Beam answers all important questions about Gcodes and their use.

What is a Gcode?

G code stands for Geometric Code. It is a kind of simple programming language used for controlling machines. With the code, a machine receives clear instructions on how to produce a workpiece. The design for this piece is created on the computer and then translated into Gcode for the machine to understand.

What can G-codes be used for?

So Gcodes are used to control machines. More precisely, it is about CNC machines. CNC stands for Computer Numerical Control and is a method for automating manufacturing processes on a machine with the aid of a computer. CNC machines can read the Gcode and then work independently on a workpiece exactly according to these instructions. These machines are often found in industry, e.g. B. CNC milling machines in metal processing. But other production machines also use the code, e.g. B. Laser cutters or 3D printers - also those that you can use at home.

Who Invented G-Code?

The basis for the Gcode was developed at the Massachusetts Institute of Technology (MIT) in America in the 1950s. Since then, this basis has been further developed from many sides and also laid down in various national and international standards. In Germany today there are e.g. B. DIN 66025, which describes the command coding for program creation for CNC milling machines in more detail.

How do G-codes work?

Gcodes contain all the instructions for your device to complete your project on its own. The code consists of a list of instructions that sequentially list all the necessary steps for your project, e.g. B. go to coordinate XY, prepare the tool for use, pause here for x seconds or exit the program. Your project is broken down into individual steps that can be described geometrically, e.g. B. lines or arcs. In addition, instructions for the machine are added, e.g. B. relate to the tool or the program flow. The entire manufacturing process from start to finish is written in code that the machine can execute independently step by step. If the code is error-free, the device can create the desired result from it reliably and as often as required.

How are G-codes created?

G code

You don't have to read or write the Gcode for your project yourself. Thanks to modern software, the instructions for the device are automatically generated from a 2D or 3D design. In the industrial environment, CAD software and CAM software are used. CAD stands for Computer-Aided Design, i.e. the creation of drafts with the help of a computer system. The model is then converted into Gcode using CAM software (Computer-Aided Manufacturing). These programs offer complete design freedom for a project. However, they are also very complex and difficult to use without the appropriate specialist knowledge. For some devices, however, there is more easily accessible software that you can use intuitively even without the appropriate training, e.g. B. the laser cutter software BeamOS for your Mr Beam or a so-called slicer like Cura for 3D printers. These programs take your design and automatically break it down into all the necessary individual steps for the respective device.

Can a human understand Gcode?

Yes, there are people who can read and understand the code. Some are simply interested in it, others have to do with it professionally. For example, a skilled worker working on CNC machines might B. often understand many of the instructions from experience, but in practice still works more with software as an aid. An engineer who wants to make the hardware for a machine usable also has to deal with the code for his work.

You, too, can look at a project's Gcode if you're curious. It is human-readable but needs to be interpreted. Because the instructions for your machine are given in clearly defined codes, e.g.:
G90
G01 X15 Y23

Below, you can see a table with the meanings of the most important commands you can try to interpret your gcodes with. Usually, however, you don't need to delve into the details of the code. If there is a problem in your project, a look at the software, which is much easier to understand, will help you. Alternatively, you can view your Gcode with a Gcode Viewer or directly with the Mr Beam software.

 

G code commands at a glance

Gcode / Mcode

Description

Example

Explanation

G90

absolute position information

G91

relative positions

G20

units in inches

G21

Units in mm

G0

Positioning in rapid traverse

G0 X19 Y40 Z-2

Movement on the shortest path to the specified coordinates

After G91, move from the current position by the specified values, i.e. X + 19, Y +40 and Z -2

G1

Positioning with feed

G1 X15 Y-9 Z-50 F200

Like G0, but with a feed rate of 200 mm/min

G2

arc clockwise

G2 X30 Y25 I5 J0

Circular movement from the current position (eg X20, Y10) to X30, Y25. The arc leads over the centre of the circle (Xact - I5) = 25 and (Y25-J0) = 25. The starting point (i.e. the current position) must be on the circular path.

G3

counterclockwise arc

see G2

see G2

G4

dwell time, break

G04 P2

Waits 2 seconds* until the next command is executed

M3

spindle clockwise

M5

spindle stop

M2

Termination of the executed program in automatic mode

M8

coolant 2 on

M9

Coolant all off

 

*The unit depends on the machine, with Mr Beam it always seconds.

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.