G-code is the lifeline for automated machines like 3D printers and CNC machines. Basically, it’s a programming language that serves as a set of instructions, and in the context of 3D printing, turns 3D models into real parts by sending hundreds, if not thousands, of commands to a machine.
G-code describes the basic movement and functions of a machine, translating a digital model into commands for a machine to follow. The commands are strings of letters and numbers that instruct the machine on what and where to move, among other functions.
For example, the line G01 Z10 F1000
instructs a 3D printer to lift the nozzle 10 mm (Z10) at a speed of 1,000 mm/min (F1000), whereas the line M0
pauses a machine to wait for user input. In 3D printing, this command can be used to pause the printer to allow you to change filament.
One of the most important aspects controlled by G-code is a machine’s positioning. Positioning refers to the methodology that a machine uses when reading a set of coordinates to move to.
When it comes to the algorithms used by a machine, there are two ways positioning is accomplished: absolute positioning and incremental or relative positioning. In this article, we’ll be going over these two different methods, discussing how they work, how to add them to G-code, and more.
First up, G90 is the G-code to set a machine to absolute positioning mode. Absolute positioning means that your machine tool moves relative to a set and stationary point, known as the origin. For 3D printers, this is typically the center of the print bed, or a specific corner.
When this mode is set, your machine will continue to interpret commands as absolute positions until instructed otherwise. When you command a movement to a specific point in this mode, your machine’s tool (hot end, spindle, etc.) will always move to the same location, regardless of where it is currently.
An excellent way to think about this mode of positioning is that it’s like reading a map. If you decide to go to a certain place on a map, no matter where you start from, you’ll always end up in the same place.
To use this G-code, place it once before the first action you want to be done in absolute mode. Below we’ve included an example with XYZ coordinates:
G90 G01 X25 Y40 Z30
This code tells your machine to use absolute positioning (G90) to move (G01) to a point 25 mm to the right of the origin (X25), 40 mm in front of the origin (Y40), and 30 mm above the origin (Z30). After you use G90 once, you never need to use it again unless you want to switch modes.
On the other hand, G91 is used to toggle to incremental positioning, also known as relative positioning. Incremental positioning means that your machine tool moves to a location relative to its current position. When G91 is activated, it will read movement coordinates as if its current position is the origin.
Unlike with absolute positioning, incremental positioning won’t take your machine to the same point every time the same instruction is given. A good comparison for this is that it’s like following directions from the GPS navigation in a car. If the navigation instructed you to drive one mile multiple times, you’d end up in a different location each time because your starting point has changed.
To use this G-code command, type “G91” before the first instruction you want to be completed in incremental positioning mode. Below is an example:
G91 G01 X10 Y20 Z10
This set of instructions tells your machine to use incremental positioning (G91) for the following instructions. The machine then moves (G01) 10 mm to the right from its current position (X10), 20 mm to the front from its current position (Y20), and 10 mm above its current position (Z10).
Not only are positioning methods used to set movement to a point, but they can also be used to describe a location. These positioning methods aren’t just for machine instructions and can be used for description as well as direction.
For example, you could say that point A is absolutely positioned 10 mm to the right, 20 mm in front, and 30 mm up. This allows you to locate a specific point relative to a stationary origin, exemplifying absolute (G90) positioning.
An example of using incremental (G91) positioning to observe a point would be saying that point B is 5 mm to the left of, 10 mm behind, and 10 mm below point A. This allows you to see where a point is in relation to another point.
All in all, understanding the difference between absolute and incremental positioning is a powerful weapon in your G-code arsenal, and using G90 and G91 in your commands will allow you greater flexibility in your creations!
Lead image source: Guardian Liberty Voice
License: The text of "G91 / G90 G-code: Absolute & Incremental Positioning" by All3DP is licensed under a Creative Commons Attribution 4.0 International License.