Visualize bed flatness with gnuplot

Visualize bed flatness with gnuplot

Even a badly-warped bed can look pretty flat to the eye. I used the following procedure to visualize my printer’s bed using gnuplot. I used manual bed leveling to measure, and I took advantage of auto-scaling in gnuplot to accentuate variance in Z rather than worrying about dimensions.

I have Marlin set to do manual bed leveling with 5 points. There’s not much point in doing this with fewer, I think.

I brought up a spreadsheet program and entered in the readings in cells that followed the boustrophedonic testing pattern, so that the readings were arranged the same way in the spreadsheet as the test points on the bed. (Note that because of the way gnuplot interprets the data, you’ll want to put the front row as the first line; visualize the data as “looking up at the bottom of the bed” and it will make sense.) I saved the readings in a tab-separated value (TSV) file, which looks like this:

-1 -0.93 -1 -0.97 -1.02
-0.8 -0.71 -0.8 -0.75 -0.72
-0.83 -0.77 -0.8 -0.74 -0.7
-0.92 -0.81 -0.81 -0.8 -0.8
-1 -1.03 -1.02 -1.02 -1.03

(I had intentionally set Z high for this test; only the variance is interesting.)

Then I plotted it with gnuplot:

splot ‘grid-5.tsv’ matrix using 1:2:3 with lines

After this, I can rotate the 3D plot with the mouse to see the variations better. Here’s how it accentuated where .33mm of total Z variance was distributed across my Tronxy X5S bed. It let me see that the middle is pretty flat, and that variance is concentrated in Y.

(All this confirms that rolled aluminum plate 330mm x 330mm hot bed looks like a lost cause and I should buy milled cast plate, but that’s another post!)

a9d6f0e83ba28853640c74a7f1d631f3.png

Cool! This reminds me of this new project that has a nice visual too:

You should compare hot vs cold.

@Julien_Dodokal thanks for the link! For me, seeing the 3d surface projection is easier to visualize. I was really happy to find the gnuplot matrix mode!

@Stephanie_A what benefit from checking cold, though? I never print on a cold bed anyway…

Have you locked st http://marlin3dprintertool.se?

Lovely!

@mcdanlj You should be able to pick the bed level data right from the terminal if you are using Redeem as well. The data is transferred as a action command from Redeem to OctoPrint, so you can just copy-paste it if you are interested.

It is not just the bed that needs to be straight. If the frame or rails are not straight it will appears as the bed is wrong. Some types of printers are very susceptible to this, although maybe not so much the cube design.

@Elias_Bakken Ethernet didn’t come up when I hooked up the replicape, so switched back to the stock board until I can debug. But very good to know, thank you!

@Johnny_Linden I’m not running Windows, so not the target market.

ReprapFirmware does this visualization by default.

@mcdanlj if the bed is flat when cold, is it possible it could be rising in the middle due to heat expansion? Looking at your data the z values in each corner is very close to each other, indicating points of attachment.

Exactly, it’s definitely expanding when heated. This is a Tronxy X5S with six (!) anchor points and you can see in the graph exactly where they are; at the corners and at the middle of the supported edge.

@mcdanlj Did you ever check the bed when cold as well? It could be deformed due to the position of the holes not being 100% correct. I’m thinking that the order of how one is tightening the screws might deform the bed (for instance if you tightened first one side, and then the other).

I didn’t measure it by bed mesh level but it doesn’t pass the straightedge test.

Thank you for mentioning tightening technique. I was lucky enough to have a dad who taught me really young proper technique for tightening sets of bolts or screws, so a gradual pattern is well ingrained. :slight_smile:

It’s useful to know when tightening bed screws that the thread pitch of M3 screws so often used is 0.5mm.

I mentioned it because I’m a bit suprised it could deform that much by heat expansion. I would expect that the printer wouldn’t be 100% rigid and allow some flexing where the bed is attached with screws, when the bed expands.
I don’t own a 3D printer myself (yet), so I find this problem very interesting on a theoretical level. I work as a manufacturing engineer so flatness, hole position etc is something I’m somewhat familiar with :blush: Heat expansion too, but that’s more of a couple of degrees C…
Once I get a 3D printer i will most certainly want to use your tip on using gnuplot! Thank you :blush: