What Are the G0, G1, G2, and G3 G-Codes? (Detailed Analysis)

While G-code being a software programming language often repels most 3D printing enthusiasts from learning about it, the fact of the matter is that G-code isn’t as complex and confusing as it looks from the outside.

Even though it’s true that slicers and printer interfaces allow you to perform most tasks without having to know about G-code, it’s undeniable a certain level of G-code knowledge can easily make your 3D printing experience a lot smoother.

Today, we will be looking at some of the most fundamental G-code commands – responsible for the overall movement of the 3D printer during the printing process.

So, what are the G0, G1, G2, and G3 G-codes?

G0 and G1 are the G-codes for the Linear Move command, which is responsible for the movement of the extruder.

G2 and G3 are the G-codes for the Arc Move command, which allows the extruder to perform an arc (curved) move to the specified destination.

While the functionality of these G-codes is simple, understanding the parameters they use and how they operate on a deeper level is a significant part of mastering the G-code language.

Without further ado, let’s take a look at the G0, G1, G2, and G3 G-codes in more depth.

What Are the G0 and G1 (Linear Move) G-Codes?

G0 and G1 are perhaps the commands a 3D printer executes the most, as they are entirely responsible for all the linear movement during the printing process.

Both G0 and G1 G-codes cause the printer to execute the Linear Move command, allowing the extruder to move towards the desired location.

While the G0 G-code is for movements without extrusion, the G1 G-code allows the printer to extrude plastic during the linear move.

Now, let’s look at the parameters the G0 and the G1 G-codes accept, which are the same.

  • E – The amount of plastic that the extruder will extrude during the movement.
  • F – The feed rate per minute of the movement.
  • X – The X coordinate of the destination.
  • Y – The Y coordinate of the destination.
  • Z – The Z coordinate of the destination.

To make things more understandable, let’s take a look at an example G0 command input:

G0 F1200 X10 Y25 Z10

In this example, the feed rate is set to 1200mm per minute, and the extruder moves to the X=10, Y=25, Z=10 coordinate.

In the case of G1, the input wouldn’t change other than the G-code itself:

G1 E20 X20 Y30 Z15

In this example, the extruder moves to the X=20, Y=30, Z=15 coordinate while extruding 20mm of plastic in the process.

As you can see, both the G0 and G1 G-codes are very straightforward to execute once you know what the parameters stand for.

What Are the G2 and G3 (Arc Move) G-Codes?

While not as widely used as the G0 and G1 commands, G2 and G3 G-codes are also a significant part of a 3D printer’s movement toolkit.

The G2 and the G3 G-codes tell the printer to execute an Arc Move, essentially causing the extruder to make a curved movement towards its destination.

While the G2 G-code performs a clockwise arc movement, the G3 G-code triggers a counter-clockwise one.

Here are the parameters you can use with the G2 and G3 G-codes:

  • E – The amount of plastic that the extruder will extrude during the movement.
  • F – The feed rate per minute of the movement.
  • X – The X coordinate of the destination.
  • Y – The Y coordinate of the destination.
  • I – X offset for determining the center of the arc.
  • J – Y offset for determining the center of the arc.
  • R* – Radius for determining the center of the arc.
  • Z* – The Z coordinate of the destination.

Parameters marked with * are only available in some firmware.

Here is an example of the G2 G-code in use, with an assumed starting point of X=0 and Y=0:

G2 X10 Y20 I5 J10

In this example, the offsets between the current position of the extruder and the center of the arc are 5 (I) for the X-axis and 10 (J) for the Y-axis.

As the starting point is X0 Y20, the center of the arc between the st will be X5 Y10 from the I and J values.

Finally, the movement is to the X=10 Y=20 position with a clockwise pattern, which is where the extruder will end up.

Similarly, here is an example for the G3 G-code, once again with an assumed starting position of X=10 and Y=20:

G3 X30 Y40 I15 J20

In this example, the offsets between the current position of the extruder and the center of the arc are 15 (I) for the X-axis and 20 (J) for the Y-axis.

With a simple calculation, we can find the center of the arc will be X20 (10+15) and Y40 (20+20).

Finally, the movement is to the X=30 Y=40 position with a counter-clockwise pattern, which is where the extruder will end up.

While the Arc Move command is slightly more complex, the logic remains the same.

G0 vs. G1 G-Code – What Is the Difference?

While G0 and G1 G-codes are both responsible for the linear movement of the extruder, there is a vital difference that separates one from the other.

Despite both these G-codes performing the same action of Linear Move, G0 triggers a movement without extrusion, whereas G1 causes the hotend to extrude plastic as it moves.

You can think of the number “0” as no extrusion and the number “1” as the presence of extrusion to make it easier to remember.

G2 vs. G3 G-Code – What Is the Difference?

Executing either the G2 or the G3 G-code causes the printer to perform the Arc move command, where the extruder moves in an arc.

So, what is the difference between these two commands?

While both G2 and G3 trigger an Arc Move, G2 performs a clockwise arc movement, whereas G3 is the opposite, which is a counter-clockwise arc movement.

Even though the destination remains the same in both cases, the path taken shows a difference.

Does Marlin Support G2 and G3 G-Codes?

A common question is whether the Marlin Firmware supports the G2 and G3 G-codes, which is understandable as Marlin is perhaps the most popular firmware in the 3D printing realm as of now.

Marlin firmware supports both the G2 and the G3 G-codes, listed as Arc or Circle Move in their documentation.

The parameters for G2 and G3 in Marlin are identical to RepRap, with a few extra parameters specific to Marlin itself.

How Do You Do Arcs in G-Code?

While doing arcs in G-code is slightly more complex than performing linear movement due to the geometrical complexity of a curved line compared to a straight line, the methodology remains the same for the most part.

To do an arc in G-Code, all you have to do is use the G2 (clockwise) or G3 (counter-clockwise) Arc Move G-Codes with the desired offsets for the angle of the arc and the destination of the extruder.

For instance, let’s look at the command:

G2 X50 Y20 I5 J10

This command will trigger an Arc Move in the clockwise direction to the X50 and Y20 coordinates, with an X offset of 5 (I) and a Y offset of 10 (J).

Wrapping Up

While the G0, G1, G2, and G3 G-codes are automatically generated by the slicer during standard usage, we believe that understanding how these commands work is a fantastic way of expanding your 3D printing knowledge.

To quickly recap, G0 and G1 are the G-codes for Linear Move, where G0 refers to movement without extrusion, and G1 allows the printer to extrude while moving.

On the other hand, G2 and G3 are the G-codes for Arc or Circle Move, where G2 is for clockwise arc movement, and G3 is for counter-clockwise arc movement.

Happy printing!