Home Artists Posts Import Register

Content

Automatic Bed Leveling allows a 3D printer equipped with a suitable probe to test the height of the print surface at multiple points and to use that information to compensate for its overall tilt. When set up properly, bed leveling guarantees a good first layer, and thus improves the whole print. The procedure itself is pretty straightforward, but the code grows in complexity when you have to support a variety of probes and machine geometries.


So it happened one week that we integrated two core pieces of this functionality around the same time. First, an improved leveling routine for cartesian printers was added, a great contribution from Roxanne. We were working on G28 (homing) code in tandem with G29 (leveling), cleaning up the probe deploy and stow functions, and everything looked great – until we got into testing. At times the Z height would be wrong at the end of probing, or sometimes the probe failed to raise before deploying. And of course everything depends on reading the probe switch or you might damage the switch … or the bed … so we had to constantly make sure that worked with each commit.


Implementing bed leveling —one of the more complex functions in Marlin— is a continuous lesson in complexity and the importance of careful planning. When code becomes distributed, especially in a system where the parts can interact in unpredictable ways, it makes it more likely that changes to any one part will affect others, and thus harder to find and fix bugs. It's even trickier when a problem only manifests in some configurations, so we ask a lot of questions and solicit a lot of testing from users to help track down issues. To gather more data, I made a branch to print out a slew of debug messages, helping to pinpoint errors in probe raise behavior and the final Z position calculation, and we found both subtle interactions (Z raise more than once?) and glaring errors (wrong final Z position value?). But it looks like we've finally solved all the major issues and are back on track.


The updated Automatic Bed Leveling procedure —combined with cleaned-up probe code— has been one of the main obstacles to the 1.1.0 release, so I'm relieved that we're making sense of the little monster and that it's finally so close to completion. After this experience I know I will be exercising more discipline and caution around new features, especially those that might depend on behaviors or states that aren't obvious. To help with that, I plan to do a lot more cleaning up of the code, but that's a topic for another day.


Next time: The Configurator!


RepRap, 3D Printing, 3D Printer

Files

(No title)

Comments

No comments found for this post.