Marlin UBL (Unified Bed Leveling)

Bed Leveling 101

Unified bed leveling is best used with an automatic bed leveling sensor
Unified bed leveling is best used with an automatic bed leveling sensor (Source: voltlog via Instructables)

If you have a 3D printer, you’re probably familiar with the pain of achieving a level bed (where the nozzle is an equal distance above the print surface across all areas of the build plate). There are a few ways to go about leveling the bed, with the two most common being manually (using knobs) and bilinearly.

If you’re unfamiliar with bilinear leveling, it’s a leveling system that’s most commonly used with an automatic bed leveling (ABL) sensor, like a BLTouch. This system uses an ABL sensor to measure the distance from the probe to the bed surface at different points across the build plate. Then, these measurements are compiled into a mesh that the printer uses to keep the nozzle at an equal distance above all points.

However, even though bilinear leveling is automatic and doesn’t require you to adjust any leveling knobs, it can still be a pain to use. That’s because you typically have to run the multi-point ABL sensor leveling routine every few prints, which can take time. You also have to rerun the leveling routine every time the bed height is adjusted. Enter unified bed leveling.

Unified Bed Leveling

Unified bed leveling (UBL) is a digital leveling system present on Marlin firmware and some of its forks. It’s similar to bilinear leveling but with a few extra features.

The main difference between UBL and other ABL systems is that UBL combines features of other leveling techniques to provide users with more control. Moreover, UBL allows you to easily store, adjust, and swap multiple digital leveling meshes on your printer. This enables you to have different mesh configurations readily available for different printing surfaces (very convenient if you have multiple build plates).

Now that you know the basics of what UBL is, we’ll go over exactly how UBL works on a 3D printer and explain how you can add it to your Marlin-operating 3D printer. Happy leveling!

Back to Contents

Advertisement
Advertisement
Advertisement
Marlin UBL (Unified Bed Leveling)

How UBL Works

UBL typically uses many more mesh points than other leveling techniques
UBL typically uses many more mesh points than other leveling techniques (Source: c0m1c5an5 via GitHub)

Unified bed leveling is mesh-based, meaning it uses multiple measurements of the distance from the printhead to the print surface to create a digital diagram of the bed’s topography. While these measurements are usually taken with an ABL sensor, you’re not technically required to have one. If you don’t have an ABL sensor, you could manually fabricate the mesh components (e.g. measurements).

Automatic bed leveling sensors, like BLTouch probes, don’t have an attached default leveling system because this information is stored in the 3D printer’s firmware. However, most pre-compiled firmware programs for machines equipped with an ABL sensor use bilinear leveling. So, if you want to use UBL, you’ll have to build and edit your own custom Marlin firmware, which we’ll go over in the next section.

UBL meshes are meant to be long-lasting and adjustable, usually involving 81-100 points across the bed. This is a lot more thorough than the meshes for other leveling systems. Bilinear meshes, for example, typically contain 9-16 points. This is because they are meant to be redone every few prints, so they use fewer points to make the process quicker. (Of course, the amount of points is always adjustable!)

With so many points, creating UBL meshes can take a long time compared to other systems, but once the process is done, you don’t really have to rerun the routine because of the available features for UBL.

UBL in Marlin

You can store multiple UBL meshes on your printer
You can store multiple UBL meshes on your printer (Source: Chris Warkocki via YouTube)

The UBL system in Marlin integrates many control features that allow you to store, adjust, and reuse multiple meshes; you can save up to seven meshes, which is great for printing different materials (because some materials like more nozzle space) and on different surfaces.

These features allow you to make small adjustments to the mesh when necessary rather than creating a new one every time something doesn’t work. For example, if you see that the nozzle is too high above the bed in the back left corner of the bed, you can use a specific G-code command to change the distance value.

The UBL feature on Marlin also includes a mesh validation system (G26 command) that will print a pre-designed and pre-sliced pattern. This allows you to test your new mesh if you made any changes, and the print is a single-layer grid pattern.

Back to Contents

Advertisement
Advertisement
Advertisement
Marlin UBL (Unified Bed Leveling)

How to Add UBL

Make sure to delete the
Make sure to delete the "//" in front of the "AUTO_BED_LEVELING_UBL" feature (Source: Jackson O'Connell via All3DP)

Now that you know what unified bed leveling is and how it works on Marlin, let’s look at how to add it to your 3D printer. Below, we’ll briefly go over how you can activate this feature on your machine.

Keep in mind that this guide doesn’t go over every detail of installing the firmware on your machine. If you don’t know how to do this, make sure to check out our guide to installing Marlin firmware.

  1. Open your Marlin firmware folder in Microsoft VSCode.
  2. Import the desired release of Marlin firmware into Platform.io in VSCode.
  3. Open the file labeled “Configuration.h”, search for “#define AUTO_BED_LEVELING_UBL”
  4. Uncomment (delete the “//”) in front of the UBL phrase to activate the feature. Make sure to add “//” in front of the other leveling methods if you switch to UBL.
  5. Uncomment the phrase “RESTORE_LEVELING_AFTER_G28”.
  6. Uncomment the phrase “#define G26_MESH_VALIDATION”.
  7. Make sure that the phrase “#define EEPROM_SETTINGS” is uncommented (it should already be).
  8. Compile and build the firmware with the Auto Build Marlin VSCode plug-in and upload it to your 3D printer.

And that’s it!

Remember that these steps are only the major ones and not all the nitty-gritty stuff. For more installation and operation information, you can check out some more in-depth installation guides, such as the video tutorial by Chris Riley.

Back to Contents

Advertisement
Advertisement

Lead image source: JangusMcDangus via Reddit

License: The text of "Marlin UBL (Unified Bed Leveling): How to Make It Work" by All3DP is licensed under a Creative Commons Attribution 4.0 International License.

Stay informed with notifications from All3DP.

You get a notification when a new article is published.

You can’t subscribe to updates from All3DP. Learn more… Subscribe to updates

You can’t subscribe to updates from All3DP. Learn more…

Advertisement