Hardware selection seems to get all the attention while talking about auto bed leveling but let us enlighten you about the pivotal role software configuration plays in setting it up. So, make yourself comfortable because we have written a detailed guide about setting up a Marlin for your auto bed leveling.
Before we get started
Leveling a 3D printer bed is a pretty tedious job if you are not well experienced in it. As such manual leveling is not much fun at all. You need to make repeated modifications until you get it just right. This is the reason why auto bed leveling has been gaining this much traction in 3D printing circles. It makes sure that the nozzle always aligns at the optimum height throughout the bed automatically, without any kind of manual intervention.
Marlin is a popular firmware used for this task but configuring it for auto bed leveling might prove to be a bit of a daunting task for some people. So we have created this guide to counsel the uninitiated in the art of modifying and flashing firmware.
It is very important to keep in mind that most of the of the configuration process is closely entwined to something called “comments”
- A commented line In the Marlin code, a commented line is started with two slashes : //
- No attempt will be made to execute such a line by the firmware i.e it will be ignored
- Active codes are only those lines with no slashes
Alright, let’s get busy
The Configuration.h file of the Marlin firmware will contain all the configuration changes. It is interesting to note that the Marlin package of firmware already incorporates a folder containing sample configurations for many of the popular 3D printers.
Before we proceed any further, please note.
Disclaimer: Any changes to your firmware can result in unpredictable and detrimental consequences. So it is advisable to always create a copy of any working configuration. We cannot measure the scale of your skill and are not responsible for any damage that might occur to your property.
Auto bed leveling in Marlin is around 25% of the Configuration.h and meanders around several sections of it while completely skipping some. In this guide, we’ll simulate the required code. We’ll be using a short string of tildes (~~~~~~) for all the omissions and skips for clarity. There might be some sizable gaps between some of the essential sections, but fret not we’ll be pointing out all the landmarks along the way so you don’t get lost.
Electrical Configuration For Probe Hardware
We begin about a quarter of the way through Configuration.h right under the “Endstop Settings”. We’ll basically be calibrating some electrical characteristics for the Z sensor.
You can go right ahead and try uncommenting the “ENDSTOPPULLUP” lines, unless you are having issues with the sensing. Also, since the microcontrollers generally used for these printers have internal pull-up resistors, you don’t really need to concern yourself with them.
If you want to configure whether the triggered sensors sets a high or low signal, the “ENDSTOPINVERTING” lines are used. Cardinal law here is that if yours is a
- NPN type sensor you need to set “Z_MIN_PROBE_ENDSTOP_INVERTING” to true, while for a
- PNP type sensors set both “Z_MIN_PROBE_ENDSTOP_INVERTING” and “Z_MIN_ENDSTOP_INVERTING” to false. Like for instance a moving pin probe like a BLTouch would have to be set to false.
By chance if you get any of this wrong, it shouldn’t hurt too much provided you test your sensor senses proximity accurately before you start moving your bed or extruder apparatus.
The Z Probe
We’re going to bypass quite a bit of information until we get to the Z probe options. This is where you need to calibrate some more electrical and mechanical functions of the sensor.
Next,we need to designate where the probe is connected.
- Uncomment “Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN” if the sensor has its own exclusive port. Then type the pin number at the end of that line. Whereas if it replaces an endstop, then the line would become commented and we would need to uncomment “Z_MIN_PROBE_ENDSTOP” instead.
- If the sensor lacks any moving parts, then “FIX_MOUNTED_PROBE” is uncommented slightly down the line. In contrast, if your probe has some sort of servo mechanism which helps in swinging an arm. You need to uncomment and set the options Deploy and Stow angles in the servo port next.
Next we move on to the settings for a BLTouch. They are comparatively pretty easy to work with. All you need to do is uncomment the BLTouch line. Don;t mess around with the delay unless you’re having issues with the pin being inconsistent.
And with the probing heaters line, if you feel disoriented or are thinking why you’re here. We advise not disturbing anything as that’s mostly for troubleshooting stuff like vibration problems and configuring what might be called as unconventional hardware.
Everything in Its right Place
We’re still under the “Probe Options”, but there’s this particular indicator you need to explore a bit about.. It’s called ASCII art, this defines how to describe where the sensor and nozzle are in correspondence to each other. The point worth noting here is that if your sensor is directly in front or somewhat to the left of the printer’s nozzle, then the X and Y offset values will always be negative.
Try to measure as accurately as possible the X and Y values, from the point of the nozzle to the middle of the sensor. Try to be as careful as possible with this task. Otherwise just set ‘Z’ value to 0 for now and assign values to it later. Or you may just leave it at zero itself and save the value to your controller’s memory.
Next we turn our attention to the “MIN_PROBE_EDGE 10”. As you can see it is already uncommented, but might want to check that 10 mm gives you enough clearance from the edges of your print bed.
You may comfortably skip the next few lines about the speed of probing and data about how many times the sensor probes a spot. Next to it are some default position stepper motor, rest positions and servo defaults etc. You can adjust them at your leisure, as none of it really concerns the task at hand to be honest.
Important: Please carefully peruse through the comments along the way and decide if they directly apply to your needs in the situation. In many cases, defaults need not be tampered with too much and they are capable of giving you the desirable results as they are.
From here on Some things configuration options such as the ones that define your bed size and selection of software endstops etc, need not be concerned with too much, so we are skipping them. You also don’t need to pay any special attention to them as they are already pre configured for you optimally.
Next you’ll encounter the “MIN_SOFTWARE_ENDSTOP_Z” option, you’ll need to disable that temporarily by commenting it. It basically prevents your nozzle from smashing into the print bed. But it might keep you locked out from setting the Z offset because you are not allowed to send the nozzle to a negative value. Please, uncomment it again once you are done setting your sensor’s Z offset.
And with that, we have finally exhausted all of the available probe options. Nothing else really concerns us until we get to “Bed Leveling”.
Bed Leveling Settings
Now to set the protocol for the bed leveling process. Here you are provided with a choice between 2 options, which are “AUTO_BED_LEVELING_3POINT” or “AUTO_BED_LEVELING_LINEAR” if you’re certain that your bed is perfectly flat with no warps or unleveled spots. But, If you’re uncertain about that, Marlin auto bed leveling firmware allows you to compensate with “AUTO_BED_LEVELING_BILINEAR”. It’s worth noting that there is another much advanced option also available at your disposal. The “AUTO_BED_LEVELING_UBL” is more or less and lets you create a mesh diagram or a framework of the high and low areas of the print bed. Commonly, linear and bi-linear would be great choices for most people out there. Make sure you uncomment your choice.
Finally under this sub topic we have the G28 command. This takes your printer’s carriage to the neutral or ‘home’ position, which is the prerequisite for printing to start. One thing to keep in mind you could even call this a ‘problem’ is that issuing this command clears the leveling information that’s been collected by the firmware beforehand. So make absolutely sure that you uncomment “#define RESTORE_LEVELING_AFTER_G28”.
After the first layer or two, your bed shouldn’t affect the subsequent layers of the model you’re creating. You’ll see why “ENABLE_LEVELING_FADE_HEIGHT” is uncommented and a lesser number value (3 should be good enough) is added right at the end of the command
Then there’s the “Mesh Validation Tool” which is basically a bed test that prints a grid of squares all over your print bed. Turning it on it makes that option visible in your LCD display. If you decide to use it, you’ll also have to define other settings like the layer height, nozzle diameter etc, settings for the filament
Deeper Bed Settings
Next, we need to define the grid with the number of X and Y points. A 3 x 3 grid is generally used for a square bed. Add a row or a column accordingly if you want a rectangular grid. But, be very careful because increasing the number of points increases the load on the firmware and could cause it to crash.
Now you need to enter your commands such that your probe is able to move around without moving past the edges or crashing into something. The X or Y values for minimum and maximum positions should be entered here and uncomment each line individually here.
Since an offset probe doesn’t have too much freedom to move around from front to back if you are using bilinear leveling. You have to uncomment “EXTRAPOLATE_BEYOND_GRID”.
If you’re tired and think this is getting a bit too boring, well fret not we are almost at the end. The following section of the guide just enables a more advanced variation of bilinear probing that you can mess around or experiment with if you want.
Something Ends, Something Begins
We’re almost done, If you are using universal bed leveling, you don’t have to change too much in that section. But since mesh leveling is a manual process please stay tuned for our detailed guide on that!
The last thing left to decide is if you want an auto-leveling option to show up on your LCD menu. If the answer is yes, then uncomment “#define LCD_BED_LEVELING”.
We need to reiterate this fact that there are a lot of options available but if you understand your equipment and are down with the basics. Those options shouldn’t confuse you too much. Concern yourself only with the options that are worthwhile to the task you’re doing and everything should feel pretty straightforward.
And with that we are at our journey’s end, we hope with this end you begin to grasp at the basics of using the marlin firmware! It’s also ironic that we finish our adventure at roughly the half-way point of the Configuration.h file.