Measuring a 3D Printer Bed’s Flatness

Once I got my printer’s z-probe and autoleveling set up I was struck with a sudden paranoia that my printer bed was saddled. The standard autoleveling in Marlin can deal with a printer bed that is not level, but it cannot fully correct for a bed that is not entirely planar*, e.g. one that is bowed or saddled. To try and set my paranoia to rest I decided to test whether my bed was truly flat.

To measure the bed I needed gcode that would tell the printer to move the z-probe around the print bed and get a grid of measurements. I made a script to generate this gcode in an iPython notebook. Once I had the gcode ready I could then run it on the printer and capture the console output created by each measurement. I did this by running it in pronterface, which is a printer controller with a command line option. Because it is command line based I could capture all of the printer console output to a text file using tee.

To visualise the result I wrote some more python that would parse the text file to make a cloud of points and rotate them so that the point cloud was as flat as possible. I needed to do this rotation because otherwise even the slightest tilt in the bed’s position would make it impossible to see any high or low spots. Rotating the point cloud required digging up decade-old linear algebra notes and much gnashing of teeth.

You can see the code I used and the results for one set of measurements in this iPython notebook.

I ran the process three times to see how repeatable it was. You can see the results below. The contours are measured in millimetres and show the height of each part of the bed above the lowest part of the bed.

The first set of results shows a high point at the bottom of the bed. That high point isn’t consistent with the other two sets of results. Otherwise they look pretty consistent and seem to show a high spot in the center of the bed and two low spots at the top left and bottom right. Fortunately almost all of the bed is within a range of 0.05mm. I think I can put my paranoia aside.

To see whether the autoleveling was working correctly I deliberately adjusted the bed to be skewed and then printed a test part. You can see in the video below that the printer seems to be doing a good job of compensating for the bed tilt.

The part printed on the tilted bed was indistinguishable from a part printed on a level bed.

One of these was printed on the tilted bed shown in the above video. I can't remember which one it was.
One of these was printed on the tilted bed shown in the above video. I can’t remember which one it was.

I’m very happy with the autoleveling and I’m hoping that with it active I can reduce the number of my prints that end up as scrap to some number less than 50%.

*I think there is an option in Marlin that can adjust for a saddled bed, but it can’t measure the saddle at the start of each print.

One thought on “Measuring a 3D Printer Bed’s Flatness

Leave a Reply

Your email address will not be published. Required fields are marked *