Marlin icon indicating copy to clipboard operation
Marlin copied to clipboard

[FR] Multiple-touch homing

Open VanessaE opened this issue 7 years ago • 70 comments

My bot generally works fairly well, but my probe isn't very accurate, at least I don't think so (in the M48 repeatability test, I get a standard deviation of as low as about 0.0015 to as high as about 0.006, depending on what options I use). That said, it's good enough to make auto-level work fine.

However, there's one thing about it that bugs me: homing occasionally results in a Z position that's slightly too high, by around 0.2mm (based on how printed lines look at the too-high vs. "normal" position).

I have Marlin configured to turn the heaters off during probing, and there's nothing anywhere near the probe points that could cause a false reading; it's a NPN NO inductive probe, 8mm sense distance, with four spots of aluminum tape on the underside of the glass bed (all have been burnished down smooth, and all are considerably larger than the diameter of the probe), and the probing positions, including safe Z homing, are tuned to hit each spot dead center. The Z axis on my bot is a pair of nearly brand new (less than a month old) T8x4 leadscrews with anti-backlash nuts. The X carriage and all extruder parts, including the mounted sensor, are all very tightly mounted. In short, I've done everything I can to eliminate intermittent mechanical problems in my bot.

So, I'd like to see an option added to allow Z to be probed for homing thus:

Have Z go down at normal home speed, trigger the sensor, bump up by the configured distance, then down again at low speed until the sensor triggers again (so exactly as it is now), then begin a configurable number of up-down-up-down... moves, watching for the probe to trigger each time, similar to what G29 does when configured for 3 or more probes per point. Have Marlin take the lowest position, relative the top of the first bump, as the Z=0 position.

VanessaE avatar Feb 25 '18 02:02 VanessaE

Does MULTIPLE_PROBING not apply to G28? It probably should if it doesn't.

teemuatlut avatar Feb 25 '18 09:02 teemuatlut

Nope, it doesn't. I have it configured for 4 probes per point, and it does exactly that during G29, but homing is just a simple double-touch.

VanessaE avatar Feb 25 '18 09:02 VanessaE

For homing the general recommendation is to use a larger HOMING_BUMP_DIVISOR for Z. Slow probing is known to greatly increase accuracy.

thinkyhead avatar Feb 25 '18 13:02 thinkyhead

I have the divisor at 8, but there seems to be no difference in accuracy compared to having it at 4.

(EDITED, I originally thought I'd changed it to 4. Nope)

VanessaE avatar Feb 25 '18 13:02 VanessaE

What kind of repeatability do you get with your probe? How out is it typically? What kind of probe design is it?

I suppose it makes sense to have the probe follow probe settings instead of Z homing settings. I'll look into implementing this in my copious free time.

thinkyhead avatar Feb 25 '18 13:02 thinkyhead

Sorry for the delayed response, can't exactly run M48 while there's a print going. :smile:

For repeatability, that's what I meant by the 0.0015/0.006 values, but here's some representative best and worst output, done with the nozzle at 215°, bed at 65° (idled there for a minute or so before starting):

>>> M48
SENDING:M48
M48 Z-Probe Repeatability Test
Finished!
Mean: -0.004000 Min: -0.006 Max: -0.002 Range: 0.004
Standard Deviation: 0.001611

>>> M48 S E
SENDING:M48 S E
M48 Z-Probe Repeatability Test
Finished!
Mean: -0.056437 Min: -0.074 Max: -0.033 Range: 0.041
Standard Deviation: 0.013308

That higher reading is actually worse than before, which I guess is a good thing in this case.

I'm not sure what you mean by how "out" it is... how wrong, you mean? That's what I meant by the 0.2 mm guess; either it's dead on where I wanted it, and I get a perfect first layer, or it's off by a few tenths of a millimeter (I'm not sure how to measure it), there seems to be no in-between.

As for the probe design, it's one of these: https://www.ebay.com/itm/292154003394

VanessaE avatar Feb 25 '18 15:02 VanessaE

there seems to be no in-between.

Do you get good probes after a reboot, but worse ones if the machine has been on a while?

Do you notice differences with a heated versus cold bed?

thinkyhead avatar Feb 25 '18 15:02 thinkyhead

I have not tried to print on a cold bed. Haven't had occasion to do so, and being Printbite-covered,[*] I'm not sure that I could, except with flexible filament, which I don't have.

It does seem like the home position is wrong most often right after a reboot or when the machine has been idle for a while, but not as a factor of bed heat - I tried to control for that by letting the machine sit, heated and ready, for a good 15 or 20 minutes, and still got a bad home.

It also seems like if I get a bad home, it's virtually guaranteed to be good on the next print, and the next several after that, so long as I don't let the printer sit for too long between good prints.

It's almost as if the loss of precision that comes with the steppers shutting off during M84 or idle hold timeout, is not being corrected-for initially. That's the only thing I can see that's common between bad homes.

FWIW, here's the best and worst M48's with the entire printer cold (room temp ~19°C when I sat down, guess I shoulda turned the heat on today :smile: )

>>> M48
SENDING:M48
M48 Z-Probe Repeatability Test
Finished!
Mean: -0.050062 Min: -0.051 Max: -0.048 Range: 0.004
Standard Deviation: 0.000946

>>> M48 S E
SENDING:M48 S E
M48 Z-Probe Repeatability Test
Finished!
Mean: -0.075625 Min: -0.107 Max: -0.057 Range: 0.050
Standard Deviation: 0.017930

So, similar to when heated.

Oh, I should mention, the sensor that's on my bot is fairly new, having been purchased to replace one that went bad. It's been a problem for quite some time, with both sensors, and even back when I was just using a Z end stop switch, but I always dismissed occasional bad homing as normal behavior.

[*] I've experienced this "bad homing" on plain, unadorned glass, too.

VanessaE avatar Feb 26 '18 01:02 VanessaE

so long as I don't let the printer sit for too long between good prints.

So obviously, static buildup. 😉

Hmm… Well multiple probing can definitely help then.

thinkyhead avatar Feb 26 '18 07:02 thinkyhead

Static? Heh. You know, it wouldn't surprise me if it were exactly that. :smile:

VanessaE avatar Feb 26 '18 10:02 VanessaE

@thinkyhead Can we include an outlier filter into the mix when a higher number of probes is configured? Just keep track of the min and max results and exclude them when averaging for the final value. Especially the piezo sensors can be sensitive to false triggers where just bumping the table will cause the probe to trigger.

teemuatlut avatar Feb 27 '18 21:02 teemuatlut

It gets tricky. Homing sets the current position to Z_HOME_POS at the end, wherever the nozzle happens to be. This is requesting some tweaking of the final position (and a move back to 0 possibly), so it's a bit of extra work. It should be ok in the meantime to set the HOMING_BUMP_DIVISOR for Z to a larger value, and perhaps increase the HOME_BUMP_MM.

thinkyhead avatar Mar 11 '18 14:03 thinkyhead

@thinkyhead add feature request label ?

boelle avatar Feb 20 '19 09:02 boelle

missing label

boelle avatar Jun 22 '19 09:06 boelle

This exists and now there is a hysteresis to throw out results that differ too much. This can be closed.

InsanityAutomation avatar Jun 22 '19 14:06 InsanityAutomation

I can see the outlier filter has been added, but at what point was more-than-double-touch homing added?

VanessaE avatar Jun 22 '19 15:06 VanessaE

Its been awhile, but the extra_probing bit is only a few days old.

/**

  • Multiple Probing
  • You may get improved results by probing 2 or more times.
  • With EXTRA_PROBING the more atypical reading(s) will be disregarded.
  • A total of 2 does fast/slow probes with a weighted average.
  • A total of 3 or more adds more slow probes, taking the average. */ //#define MULTIPLE_PROBING 2 //#define EXTRA_PROBING 1

InsanityAutomation avatar Jun 22 '19 16:06 InsanityAutomation

Right, but MULTIPLE_PROBING is only for sensing the bed during G29 leveling, is it not?

VanessaE avatar Jun 22 '19 16:06 VanessaE

No, it applies during G28 as well.

InsanityAutomation avatar Jun 22 '19 16:06 InsanityAutomation

Just out of academic curiosity, can you point me to the commit that made that particular change?

VanessaE avatar Jun 22 '19 16:06 VanessaE

At a quick read of the code, it seems to have G28 trigger bump for a second hit not actually looping using the number since it sets just as a true/false. Also the extra_probes isnt applied in G28, just G29 so it does appear there is room for a bit more improvement at least to bring the two into parity completely.

InsanityAutomation avatar Jun 22 '19 16:06 InsanityAutomation

May I add something here?

You are looking at repeatbilty, I copied it from above:

>>> M48
SENDING:M48
M48 Z-Probe Repeatability Test
Finished!
Mean: -0.050062 Min: -0.051 Max: -0.048 Range: 0.004
Standard Deviation: 0.000946

>>> M48 S E
SENDING:M48 S E
M48 Z-Probe Repeatability Test
Finished!
Mean: -0.075625 Min: -0.107 Max: -0.057 Range: 0.050
Standard Deviation: 0.017930

Now I don't want to comment on how good or bad these Range values are, compared to other probe types, ok? But a range of 0.050mm is definitely not the cause of your probe being off by .1mm or more. What these numbers DO NOT tell you, is that the probe will measure a different absolute value on different occasions over the period of hours or days. You would need to run this M48 thing over a couple of days spaced at one every hour (which it cannot do) to see long time drift. So when the probe has a "bad hair" day, it will report a different value 10 times in a row with good repeatabilty but off by 0.2mm (perhaps) from yesterdays tries.

Inductive sensors and their siblings, capacitative sensors are slightly temperature dependant. And even if you have prepared the bed well with the aluminum foils and are able to supress stray magnetic fields, I don't trust them so much anymore.

And yes, @InsanityAutomation is right after looking at that code. G28 does not repeat like G29. But I really feel that even if it did, it wouldn't make things better - just 5 nice measurements all of them off by a millimeter or so since yesterday.

ghost avatar Jun 23 '19 17:06 ghost

If you are interested in how much and why z-home could shift, watch Advanced heated bed tests Averaging some probes does not help at all.

AnHardt avatar Jun 23 '19 19:06 AnHardt

(22 minute video.... tl;dw)

Wouldn't that only apply to setups that do not sense the position of the print surface, i.e. if a sensor reads the bed under the glass, or if you're just using an end stop switch mounted on the frame?

VanessaE avatar Jun 23 '19 23:06 VanessaE

No, it'll move the top surface as well depending on temp probed at, soak time and potentially other variables.

InsanityAutomation avatar Jun 23 '19 23:06 InsanityAutomation

... or if you're just using an end stop switch mounted on the frame?

That's a good solution to have the beds mounting points always at the same height. But usually with that you don't have problems with the repeatability of homing. So averaging will not help.

However. That will not help to get the first layer stick better. The beds surface moves in relation to the mounting points.

My recipe for our machines is:

  • Prelevel the bed mechanically as good as possible to keep the z ways short while probing.
  • A constant workflow ** home on cold bed (room temperature) ** bring the bed to temperature ** wait ** wait longer ** wait another bit ** be really patient here until the beds temperature stabilized ** probe the bed fast to give the (inductive) probe no chance to change temperature much (9 points in 15 seconds) ** print a good first layer (if the probes z offset is right. It's constant for me)

AnHardt avatar Jun 24 '19 00:06 AnHardt

You may have missed earlier: I already controlled for bed temperature early-on in this thread, to the tune of testing first-thing in the morning, after sitting turned-off overnight (and waking-up to 19°C room temp) as a "cold" test, and also testing only after allowing 15-20 minutes just sitting at the target temperature, for a "hot" test.

Plus, being TR8 screws, Z-homing after most prints is quick since I don'y routinely print big stuff. I don't run G29 per-print anymore, either.

I'm 100% certain that whatever issue my bot has with homing, it is not temperature-related (or the majority of the difference, anyways).

VanessaE avatar Jun 24 '19 00:06 VanessaE

Temperature is not the only thing that throws off inductive probes.

It's enough to place a metal tool or something close to the printer.

Here's a small test for you:

Lower the nozzle using the LCD by .1 mm steps until the probe's red light goes on (it triggers). Then back off .1mm and the probe light will just go off.

Now they have a very slight hysteresis, but now move your hands, or a metal screwdriver close to the probe slowly and note how the probe suddenly triggers. Try moving other stuff, and try to get a feel for what else might be influencing the trigger point of the probe by 0.1mm, which is the amount we are more or less looking at right now.

Once you get a feel for how flaky this inductive sensor really is, you will see the problem.

You could also position the sensor as I described above, .1mm above the trigger point, and then check a day later if going down .1mm will trigger the probe same as the day before.

ghost avatar Jun 24 '19 08:06 ghost

If occasionally triggering to early/high - it could be a false positive caused by electrical noise. Sometimes inducted by a surprising source like a near by desk lamp being on or off.

How are your noise filtering settings? Did you try to increase them? Is there any hardware denoising? Is the processors internal pullup resistor on or off? What voltage gets the probe? How is that made? What else gets this voltage from this power supply? For example cold-end-fan. Are that users always in the same (on/off) state? How do you get the signals 5/3.3V level? If by a voltage divider - are the resistors values very high?

AnHardt avatar Jun 24 '19 10:06 AnHardt

@BigIronGuru I have controlled for stray bits of metal and magnetic fields, too.

@AnHardt

  • Noise filtering/Denoising: I have none in place that aren't already part of the hardware, and no firmware-based filtering that I'm aware of.
  • Internal pullups: no idea on that. Probably enabled, though.
  • Supply voltage: probe is fed 12v from the main 30A power supply, which handles motors, heaters, etc.
  • Usage: everything that draws power is in a consistent state i.e. when homing, X/Y/Z motors are on, extruder motor is usually off, cold-end and controller fans always on, hotend and bed at their needed temperatures, and so on.
  • Probe signals: it's a NPN-NO probe, so there are no voltage divider resistors -- this type of probe uses an open-collector output, and pulls the signal line to ground when triggered, or tri-stated/high-Z when idle.

VanessaE avatar Jun 24 '19 14:06 VanessaE