In today's episode I'm going to read out this marlin page.
If I did, would you watch it?
So - the main point of this episode isn't really M420, but more about how M420 interacts
with its related codes.
Because M420 is mostly used to "make the bed mesh work" and the instructions are to just
stick this one line into your start code.
But what does it do, why does it do it?
What happens if you leave it out?
So I am going to read a bit of this though.
Get and or set bed levelling state.
For mesh based levelling systems use Z parameter to set the z fade height...interesting.
Anyway.
For the ABL uninitiated, ABL means auto bed levelling.
Two "L"s if you want to spell it correctly.
Auto bed levelling at its very simplest consists of storing a measurement of where the center
of your bed is in the Z direction, optionally but usually referring to it being combined
with some kind of stored mesh of values for the printer to know the height of your bed
in somewhere between maybe 3 and 100 individual points, depending on how it's set up.
As you can see there's at least five different ways to level a bed but I think most of the
time these days we use one of these three, bilinear, manual or UBL which is the newest
one.
Bilinear is the most common I think on stock machines, I'm not sure I've seen anything
else used when combined with an automatic bed probe.
Manual though refers to when you do it yourself with paper without a probe, yes that's a thing,
but tends to be a thing you have to build marlin yourself for in my experience, on most
machines, It's also better than you'd think, I use a manual mesh on Janet here and it works
really well, arguably as well as a probe.
Now, notably, UBL works differently and doesn't necessarily use M420 although it still works
if you do use it, so it's kind of out of the scope of this video.
I can poke at that later in a separate episode.
If you're using UBL you probably already know this though.
Also this video is very marlin specific, other firmwares might support some codes but work
quite differently.
So what does M420 do in all this?
Well you see, once you've made your mesh by whatever method you choose, then marlin doesn't
automatically use it, at least normally, we'll get to that.
So you could spend ages creating a mesh, storing it on your EEPROM, slice your model in cura,
and your first layer looks awful.
This is because on stock marlin, and this is where it gets confusing because reasons,
but on stock marlin you need to EXPLICITLY load the mesh.
Or not.
Because...this is complicated, and that's why it's confusing.
I will demonstrate with some examples.
And a badly drawn flow chart.
In this start code we do a G28 home command, and that's all.
This WONT use a mesh because you haven't loaded or probed a mesh before printing, and if we
just turned the printer on or reset it, there may well be a mesh stored on EEPROM in the
printer but obtusely it won't use it.
This is just how marlin is designed, like it or hate it.
If you wanted to use a stored mesh here, you would invoke M420.
Importantly AFTER G28 unless you want to lose it again.
Because yes, G28 the home command disables bed levelling.
Why?
No idea.
It's all too easy to accidentally G28 after you M420 and not use your mesh so that's a
common pitfall.
So this is method number 1.
G28 in your start code, then M420, in this case M420 S1.
The S1 parameter on M420 seems to cause a lot of confusion and I've seen some crazy
explanations but in their defence it is particularly unclear in the documentation.
The S parameter for M420 appears to mean activate or enabled.
If you just use a plain S, it is equivalent to S1, so M420 S and M420 S1 are equivalent.
It is not the same S as used in other commands like G29, so pretty much if you're using M420,
you're using M420 S1.
You can pretty much just memorize it as one command and not worry about why it's M420
S1, it just is.
Indeed if you're interested M420 S0 disables the mesh, which has a specialist use case
I guess we'll get to.
We'll also discuss the other parameters in a second.
Method number 2 for using an auto bed mesh and the word auto is important here because
this normally wouldn't work for a manual mesh, is to re-probe the entire mesh every time
you print.
To do this, you invoke G-Code command G29 which is the command to make a mesh, this
is the one your printer's menu is probably using.
Normally you would choose a bare G29 with no parameters as the defaults are set up in
the marlin configuration but there are quite a few parameters you can invoke if you so
wish.
Using G29 creates the mesh in RAM as marlin puts it, but doesn't store it in EEPROM and
I suppose I need to explain the difference.
What marlin calls RAM is volatile working memory, volatile meaning not that it will
react with air but that it will disappear if you remove power.
EEPROM on the other hand is a nonvolatile block of memory that a microcontroller can
store stuff in, these days chips have a relatively large amount of EEPROM and it's usually not
an issue so really what marlin means by this is the results of G29 aren't "saved", they're
just used.
Of course if you want to save them you can issue an M500 command which is literally "store
current settings to EEPROM" and it is worth mentioning that this stores ALL current settings
to EEPROM not just your levelling data so if you've been messing around with anything
like acceleration then it would write that too.
But we digress.
Normally if you want to level every print, there's no huge reason to store it, you would
just use it, and then make a new one next print, so G29 normally would be used in isolation
and importantly, AFTER G28 as we already said, because homing the axes is both necessary
before making a mesh, AND it wipes any loaded mesh.
Method number 3 is to use a lesser known parameter in your marlin configuration, and by configuration
I mean when you compile it yourself.
The parameter in question is RESTORE_LEVELING_AFTER_G28 which as you might guess by the name it is
the literall equivalent of sticking an M420 S1 after a G28, which to remind you is a load
the stored mesh command.
I actually quite like this, and I think a few printers have this by default too, I think
the neptune 3 does for example in its build.
The upside of this is that you can use any old start gcode with or without a load mesh
command, and it will load the mesh when you home, which you would home, because you can't
print without homing.
If I had a print farm this would be something I'd probably be interested in.
So aside from any weird configurations I think that sort of explains how this stuff works,
I hope it clears it up a bit.
I also though it would be worth having a look at the parameters of M420 a bit closer, but
there aren't many of interest really.
The main one is V, which will spit out the current mesh into your console window as you
can see, this is quite useful.
Let me know what you think, also let me know if you are interested in going into G29 and
manual, auto, unified levelling as a separate episode because there's quite a bit there.
Otherwise I will see you next episode.
Thank you for watching.