Marlin software 'auto bed leveling' algorithm
I'm waiting (impatiently!) for my mk3 to get here on Monday. I'm confident that auto bed leveling will be great, but as an engineer I can't help be curious about how it works and it's limitations, so I thought I'd ask here.
My general assumption of how it works:
This seems like a very nice approach.
However, I still think it is going to be important to have a flat/level bed, and there is only so much software can do. I have concerns about a non-flat bed, a significantly non-level bed, and a bed where the PEI varies in height from the metal that is being sensed.
(Please read the whole thing before you react negatively to my thoughts below!)
First, if my bed is not flat (warped in some way), there is nothing that software can do to make the bottom of my print flat. It's easy to visualize if you take it to an extreme: a bed that is 1 cm lower at the center than the edges. If I print a large flat plate, the firmware will curve my print up at the edges to compensate and ensure that the print conforms to the bed, and I should get a successful print. It'll still wobble like a bowl, though! 😉
[edit: my 1cm warped bed is a completely unrealistic example, btw. A quick check of your bed with a straight-edge, even a piece of paper, would immediately identify any such issue and you'd replace the bed. This is only an unrealistic example to explain the mechanism I'm describing)
Second, if my bed if perfectly flat, but not level (not parallel to the x-y movement plane of the printer, not perpendicular to the z movement plane), then I'm curious what the printer does. If the firmware takes the (reasonable) simple approach that I mentioned above, my print will be slightly skewed. Image an insanely unlevel plate that is 10 degrees tilted to the left. If I print a 20mm calibration cube, the bottom and top of the print will be parallel to the build plate, and the sides will be true vertical (parallel to the Z axis of the printer). If I set the print on flat ground, it will tip over to the right.
It would theoretically be possible for the printer to compensate in X/Y/Z and actually rotate the whole part (to the left in the above example). This might work for a flat plate that isn't level, but it seems like an insane amount of unnecessary math so I'm assuming Marlin doesn't bother.
Third, I assume the PINDA probe is measuring distance to the metal under the PEI sticker. If the PEI top surface varies in height from a perfectly flat/level steel sheet, the z-probe will have zero offset for the whole map. Any (hopefully minor) bubbles between the PEI and the steel will show up as first layer issues with the print. (My current ultimaker and rostock glass beds sometimes develop bubbles under the PEI where prints have been removed).
Before you flame me, I do not expect any of these to be a problem. I expect the mk3 to be a huge improvement over my current glass/PEI beds with manual leveling (3 point bed leveling on the ultimaker, painful delta calibration on the rostock)
My point is really that you should not simply rely on 'automatic bed leveling' and not worry about how flat/level your build plate is. I'm going to assume that the build plate assembly is very flat (which should be easy to check with a straight edge). Are there ways during assembly to ensure that the build plate is level relative to the print head cartesian system? Or is it 'level by design' based on the way the hardware is assembled, and any imperfections would need to be dealt with using shims or something equivalent?
Has anybody actually looked at a their mk2s z-probe data and determined how flat/level the bed tends to be? I'd be curious to know how much the firmware is compensating for (is it <.002mm local flatness variations and <0.1mm out of level across the width of the bed, or does it vary worse than that?)
I'm planning to see if I can dump the z-probe data once I do my build, just for curiosity.
Re: Marlin software 'auto bed leveling' algorithm
I think the concept of your concern is correct, but I am pretty sure it is not meant to cover up a manufacturing defect. At least not one that would render a machine without mesh leveling from working "normally" or properly.
I may have missed it, but I didn't see it mentioned that the mesh leveling tapers off with Z height, so any concerns connected there should be minimized.
I think the purpose of the mesh leveling is to do with the fairly sensitive adhesion distance extruded filament tends to have in my experience. Being off by half the layer height will manifest itself very obviously, and if there are not other areas that "did" work properly strategically located, a print can warp, peel, or move enough to cause a crash or even pop off the build plate on its own.
I think, the mesh leveling helps with that slight variance that can create a localized "bad" surface adhesion issue.
As well as I think it can acomidate a surface that technically could be "flat" but is skewed slightly from the True Z plane?
I am going to guess different bed temperatures produce slightly diferent bed profiles? I assume it could also help with that?
If someone has a better interpretation, I would love to have it defined better and with more clairity.
I fully intend to "blueprint" my machine so that it doesn't require this functionality as more than a backup. Don't wish to add to the already loose tolerances of 3D printing and then add a variable fudge factor.
Having the data as a statistical refence would be a nice validation to track the surfaces dimensional integrity.
Re: Marlin software 'auto bed leveling' algorithm
Thanks for this thread, guys. Most thought provoking. As an physicist/engineer having been on the receiving end of control engineers' work I have a great interest in how these things are conceived to work and how they do, in fact, achieve the designers' intentions. And my coming-in-Feb i3 Mk3 is my first 3d printer.
I fully intend to "blueprint" my machine so that it doesn't require this functionality as more than a backup. Don't wish to add to the already loose tolerances of 3D printing and then add a variable fudge factor.
I have this same objective. Loosely, initially I am thinking of mounting a dial gauge over the bed and traversing it to establish flatness, after a quick initial check with a straightedge.
I hope we can compare notes later.
Re: Marlin software 'auto bed leveling' algorithm
First, if my bed is not flat (warped in some way), there is nothing that software can do to make the bottom of my print flat. It's easy to visualize if you take it to an extreme: a bed that is 1 cm lower at the center than the edges. If I print a large flat plate, the firmware will curve my print up at the edges to compensate and ensure that the print conforms to the bed, and I should get a successful print. It'll still wobble like a bowl, though! 😉
It is technically possible to do this using a raft, even in your extreme example. I'm not sure what Prusa is doing after a glance at their firmware, but Marlin's built in bed leveling procedure allows you to taper off the compensation so that the layers are "perfectly flat" after a little while. So, for example, if you set the bed leveling procedure to taper off in 20 layers and put a 20 layer raft in the gcode, the bottom of your part would be flat, the price being that you'd have to deal with a raft. I hate rafts.
Second, if my bed if perfectly flat, but not level (not parallel to the x-y movement plane of the printer, not perpendicular to the z movement plane), then I'm curious what the printer does. If the firmware takes the (reasonable) simple approach that I mentioned above, my print will be slightly skewed. Image an insanely unlevel plate that is 10 degrees tilted to the left. If I print a 20mm calibration cube, the bottom and top of the print will be parallel to the build plate, and the sides will be true vertical (parallel to the Z axis of the printer). If I set the print on flat ground, it will tip over to the right.
It would theoretically be possible for the printer to compensate in X/Y/Z and actually rotate the whole part (to the left in the above example). This might work for a flat plate that isn't level, but it seems like an insane amount of unnecessary math so I'm assuming Marlin doesn't bother.
This sounds hard, but I don't think it's really that bad. Remember, Prusa already implemented a procedure to compensate for skew between x and y. This is a little harder, but if you think about it as the machine correcting it's coordinate system rather than rotating the part, it becomes a much simpler problem. Other printers (core-xy, delta, r-theta...) deal with wacky coordinate systems all the time.
Third, I assume the PINDA probe is measuring distance to the metal under the PEI sticker. If the PEI top surface varies in height from a perfectly flat/level steel sheet, the z-probe will have zero offset for the whole map. Any (hopefully minor) bubbles between the PEI and the steel will show up as first layer issues with the print. (My current ultimaker and rostock glass beds sometimes develop bubbles under the PEI where prints have been removed).
Yeah, this is a very real problem I've run into on other printers, but not yet with a Prusa. Mostly because Prusa is better at attaching PEI than I am. Hopefully the powder coating will help on this front.
I like this thread. This is a good thread.
PS: sorry for any repeat info, a few others posted while I was writing this.
Re: Marlin software 'auto bed leveling' algorithm
Thanks for this thread, guys. Most thought provoking. As an physicist/engineer having been on the receiving end of control engineers' work I have a great interest in how these things are conceived to work and how they do, in fact, achieve the designers' intentions. And my coming-in-Feb i3 Mk3 is my first 3d printer.
I fully intend to "blueprint" my machine so that it doesn't require this functionality as more than a backup. Don't wish to add to the already loose tolerances of 3D printing and then add a variable fudge factor.
I have this same objective. Loosely, initially I am thinking of mounting a dial gauge over the bed and traversing it to establish flatness, after a quick initial check with a straightedge.
I hope we can compare notes later.
Exactly my intention.
I bet there is some gcode out there for this exact task...now to find it quickly!
Anyone know of a repository of test gcode avalible?
It might also be a advantageous thing to build a pull off point for a indicator..
Maybe as easy as making an adaptor that clips onto the PINDA2 probe threaded shaft? Any good ideas to make it easy without adding to the mass of the system in use?
Re: Marlin software 'auto bed leveling' algorithm
I like this thread. This is a good thread.
Just to comment in agreement. The quality and scope of the responses here so far suggest to me that I'll be able to learn a lot from it directly and from "spin-off stimuli". I aspire to be smart enough to contribute once my feet are wet.
Re: Marlin software 'auto bed leveling' algorithm
First, thanks for the very high quality responses! When I brought up similar discussions on reddit/r/3dprinting a while back, I ended up in a bit of a flame war with a guy telling me "You don't need to know how flat your bed is! Firmware magically takes care of it, that's the whole point!" and not recognizing that I enjoy tinkering, understanding how it works, and wanted a flat bed.
Random thoughts:
The 'tapering' discussion is very useful. For any given level of unevenness (even a full layer or three), I could compensate by printing a raft 2-3x the size of the unevenness, and have a hard taper on the bed-leveling to completely end at the top of the raft. That would allow me to 'generate' a truly flat print bed on the fly, in effect. (I don't expect to ever need to do this [I hate rafts!] but it is very illustrative of how the taper can help)
I do plan to write some gcode to use the PINDA2 probe to measure my bed flatness and level. I'll only compensate for it mechanically if it is causing a problem, though, or if it is big enough I can clearly improve it with some bed shimming or chiropractice adjustements to the frame.
I do like the idea of pulling out my dial gauge and using it to check the PINDA measurement vs. actual PEI height. Agreed, it should be less of an issue with powdercoat. Hopefully Prusa's PEI sticker quality is higher than my current setup. I'm printing large/flat "Settler's of Catan" edge pieces on my ultimaker right now, and I've got the printer pretty well dialed in. On the first layer, however, I can see an area where my PEI sheet is clearly a bit higher than the rest. In a 1" strip off to the left, the first layer is much more transparent than the solid blue across the rest of the bed. By the second layer, everything is good, and it isn't noticeable in the final product. I'm guessing it came down to inconsistencies in my taping job when I replaced the PEI sheet last month, with maybe a 0.1mm delta in height.
Re: Marlin software 'auto bed leveling' algorithm
By the way, here is one useful comment that came out of the reddit thread I referred to:
I haven't done anything with it yet, but the guy was writing code to generate gcode to create and graph a bed flatness image. It's on my list.
Re: Marlin software 'auto bed leveling' algorithm
What you wrote is correct but keep in mind that a typical auto leveling adjustment is probably going to be much less than 10mm like in your example. Ideally you want to get the bed manually adjusted within +/- 0.2mm or so to avoid needing such extreme adjustments that would noticeably affect the dimensions of the print.
I have another printer where I just replaced the glass bed and found the new glass is extremely warped; the Marlin auto bed leveling grid ends up being +/- 0.5mm at the corners. While I can see the Z motors working to compensate, they aren't compensating enough to counteract this. I wonder if Marlin is limiting the maximum adjustment to something less than 0.5mm.
Re: Marlin software 'auto bed leveling' algorithm
What you wrote is correct but keep in mind that a typical auto leveling adjustment is probably going to be much less than 10mm like in your example. Ideally you want to get the bed manually adjusted within +/- 0.2mm or so to avoid needing such extreme adjustments that would noticeably affect the dimensions of the print.
I have another printer where I just replaced the glass bed and found the new glass is extremely warped; the Marlin auto bed leveling grid ends up being +/- 0.5mm at the corners. While I can see the Z motors working to compensate, they aren't compensating enough to counteract this. I wonder if Marlin is limiting the maximum adjustment to something less than 0.5mm.
I completely understand this, sorry I wasn't clear on that point. My 1cm variation "bowl" example was taking the issue to a completely unrealistic extreme simply to help people visualize the theoretical issue I'm talking about. If I had anything >1mm of warping, I would quickly detect it with a straightedge and replace the bed.
I'll edit my post so that nobody else thinks that is a realistic possibility.
I do think that a flat bed that is higher or lower by >1mm from one edge to the other is more possible and harder to detect easily. The impact of that is also much less noticeable, and might not even be an issue depending on how the firmware deals with it.
Re: Marlin software 'auto bed leveling' algorithm
I have a MK2S and have been attempting to refine and customize the autoleveling process so wanted to share my experience for what its worth.
Just wanted to mention that the Prusa printers use a fork of Marlin that is pre Marlin 1.0 (based on github start date of Dec 2015 for Prusa firmware) and is significantly customized to handle the skew calibration (can handle X and Y axis not being exactly perpendicular). The main trunk Marlin 1.0 and 1.1 have seen lots of general improvements (stability and features) since the prusa branch. So doing any sort of refinement requires understanding the idiosyncrasies in the prusa code (see https://github.com/prusa3d/Prusa-Firmware/issues/16#issuecomment-346991604 )
In the MK2S printer there is a known issue that the Pinda 1.0 probe is temp sensitive. This means it works for PLA due to lower bed temp, but for ABS it requires manual tweaking of the Z height to get it to work for every print. Supposedly the MK3S fixes that., with temp compensation in the new PINDA probe. My attempt at a solution for the MK2S was to try to have it auto bed level before the first print, and then reuse the calibration on subsequent prints, (also mentioned in the thread here). So far I have not been able to do it in a straightforward way in gcode (see my link, but basically a 'g28 XY' also changes the Z calibration/homing in the prusa firmware).
Just so you know I have been very happy with my MK2S printer for PLA, but was hoping to get into printing ABS and other materials with the same ease of PLA.