What does Marlin's G30 code do?
I'm using Marlin 1.1.0RC8 to control an MPCNC, using a RAMPS1.4. We've just added a touch-plate to do Z-probing, which works nicely for a single probe (I just want calibrated height for variant bit-lengths, not bed-leveling, but I think it amounts to the same thing). I've set it up in Marlin as FIX_MOUNTED_PROBE, which seems closest.
I can make it do a
G92 Z12.6(which sets Z to the height of the touch-plate, 12.6mm), which is ok to be going on with, but it seems I'm having to hard-code the Z offset, which I'm sure should really be set by eg
My feeling was that I should be able to invoke a G-code
G30, and it would do a nice fast-slow double tap, do the equivalent of a
G92 Z+zzzto set that height and then withdraw to a safe height. And after a bit of config, it does exactly that...
... except it doesn't do anything with the height that it measured! Seems odd. The
G30code seems to be an elaborate way to move the head up by the clearance amount, via a touch-plate (with the added excitement of being able to crash the bed if anything goes wrong)! What's the point?
Have I misunderstood what
G30is meant to do? I've read the docs here, and traced through
Marlin_main.cppand there really is no "outcome". Unless I've missed something?
G30is a carry-over from CNC (G-code originated for CNC not printers)
I believe it is for going to a secondary reference (home) position and includes an optional by-way-of address that can be included in the command.
Looking at Marlin 1.1.0-1 (latest release), it seems to do what you said:
- Move to the requested position (if selected in command, else N/C)
- Deploy probe
- Go home
- Stowe probe
- Report the requested position and probed Z position
- Report the current position (home?)
It appears that for Marlin, there is only one reference address (home); so, it would seem a
G30would be the same as a
G28(go to primary reference); but, not so.
It looks like
G28is a home of a different color. It looks like it homes the axis one-at-a-time and does not support a by-way-of location. Note that you can select which axis to home by adding the letters 'X' 'Y' and/or 'Z' to the command.
I am not sure what benefit this command has for a 3D Printer other than allowing you to alter the printer's path to home.
Note: Unfortunately I do not have Marlin code up and running on my printer now so I cannot confirm what I am seeing in the code.
Mark, I haven't forgotten you've written this! Your contrasting of G30 with G28 surprised me so much - I hadn't thought of G30 as a HOME variant - that it made me re-evaluate all my assumptions, and I'm waiting for a rainy weekend to sit down and properly update all my preconceptions! In particular, G30 does "report" the probe position (back to the monitoring app); I was expecting it to store it internally as a reference... will investigate further.
I’ve recently had a need to use Z-probe touch
plate on my MPCNC + Ramps 1.4 + Marlin 1.1.5 setup.
Thought I’d share what ended up working for me.
Configuration.h, I made the changes to enable Z-probe:
#define Z_MIN_ENDSTOP_INVERTING true
#define Z_MIN_PROBE_ENDSTOP_INVERTING true
#define Z_MIN_POS -100
However, the following might be the key to your issue.
G30did not do anything for me as well, until I changed
these values to 0. The
G30now lowers Z until the Z probe
is triggered. I needed to send a
G92to set the new Z value.
Works like a champ!
#define X_PROBE_OFFSET_FROM_EXTRUDER 0
#define Y_PROBE_OFFSET_FROM_EXTRUDER 0
In case you’re interested, in ultralcd.cpp under
lcd_prepare_menu(), I added the a menu item to perform
the probe. This way I don’t need a computer to setup
the machine and launch a gcode file from the sd card.
MENU_ITEM(gcode, MSG_PROBE_Z, PSTR("G30\nG92 Z19.05"));
Hope this is helpful for you, even after a couple years late.
It is unclear which parameters are set to zero. If you mean the **probe offset values**, that is **not a good idea**. Note that this question deals with Marlin 1.1.0, in between 1.1.3 and 1.1.4, the `G30` command has undergone a change.
SusanW 5 years ago
I note that I don't have end-stops on Z, so I can't home/`G28` that axis. I can't see that it makes any difference, but I'll go through the code later and see if that's what's wrong.