PROBE_ACCURACY always performs one sample only (BD sensor)

Basic Information:

Printer Model: NoName (custom CoreXY)
MCU / Printerboard: BTT SKR 2 + EBB36
klippy.log
klippy.log (87.0 KB)

As I could not find any related information or I’m just blind I’ll have to ask here for any hints or maybe a solution.

My printer uses the BD sensor for probing and Z homing.
Due to massive upgrades on the Z motion system and some minor issues I wanted to run the PROBE_ACCURACY to check the repeatability of this sensor.
However it only performs one sample though it says otherwise.

probe accuracy results: maximum 0.990000, minimum 0.990000, range 0.000000, average 0.990000, median 0.990000, standard deviation 0.000000
PROBE_ACCURACY at X:127.000 Y:105.000 Z:1.000 (samples=5 retract=2.000 speed=0.8 lift_speed=0.8)

Same with the defaults where 10 samples should be performed.

As I can’t remember having this performed with the old inductive probe I don’t know whether this worked in the past or not.

Tested it in sensor nonstop and normal mode with same results.

I don’t know the probe and was just curious about it. I stumbled over this commit clear some unused code · markniu/Bed_Distance_sensor@99dfa55 · GitHub
No clue if this is helpful!

My understanding is that this sensor overwrites / modifies some core functions of Klipper.
As such, I’d address such topics directly to the BD sensor project.

Yeah looks like this is the best approach.
Will do this tomorrow.

I opened a ticket and this is the answer from Mark:

Here the BDsensor no need to move the z axis up and down to measure the distance like normal inductive switch sensor, so it will stop at the position and then just read samples.

Also updated to the latest code and even flashed all MCUs to latest Klipper as of now v0.12.0-102-g9f41f53c.

Interesting. Given that we have noise and potentially backlash in the z-axis system, I’m not sure if

  1. This is a valid assumption in general
  2. How readings like above with all same values can realistically happen
1 Like

Yeah those are my thoughts as well.

Ok this sensor like the Beacon3D can measure on the fly (bed mesh without moving z up and down on the probe points) but this then reads/shows the supposed repeatability of the sensor only without the z motion system being involved.

At least nothing seems to be wrong on my side with that behavior. :slight_smile:
And I can continue fighting my remaining Z artifacts…

This looks sus: Bed_Distance_sensor/klipper_Beta/BDsensor.py at da5e8334aac2502f32d837c15a2a0a6d840f6781 · markniu/Bed_Distance_sensor · GitHub

They are overwriting the z coordinate in the array object and then appending that same object into a collection multiple times. Same as this:

foo = [1, 2, 3]
bar = []
for i in range(0,10):
    foo[2] = i
    bar.append(foo)

print(bar)

Results:

[[1, 2, 9], [1, 2, 9], [1, 2, 9], [1, 2, 9], [1, 2, 9], [1, 2, 9], [1, 2, 9], [1, 2, 9], [1, 2, 9], [1, 2, 9]]

All the z coordinates are 9 because these are all the same array object. Meaning all the other probes in the loop were lost.

You can fix this with:

foo = [1, 2, 3]
bar = []
for i in range(0,10):
    qux = foo.copy()
    qux[2] = i
    bar.append(qux)

print(bar)

Results:

[[1, 2, 0], [1, 2, 1], [1, 2, 2], [1, 2, 3], [1, 2, 4], [1, 2, 5], [1, 2, 6], [1, 2, 7], [1, 2, 8], [1, 2, 9]]
2 Likes

Thanks @garethky!
I recently had the same issue with my Cura plugin that was driving me crazy until I found the same solution as you did.

Are you fine with me posting this in my ticket on github to have this officially being fixed?

1 Like

Go for it!

So finally Mark changed to code seemingly back to the original one and now the probe_accuracy behaves like expected with the following result for my BD-sensor:

14:49
probe accuracy results: maximum 0.042813, minimum 0.020625, range 0.022187, average 0.037125, median 0.038906, standard deviation 0.006229
14:49
probe at 127.000,105.000 is z=0.039688 (pos:0.799688 - bd:0.760)
14:48
probe at 127.000,105.000 is z=0.041875 (pos:0.791875 - bd:0.750)
14:48
probe at 127.000,105.000 is z=0.034375 (pos:0.794375 - bd:0.760)
14:48
probe at 127.000,105.000 is z=0.036250 (pos:0.796250 - bd:0.760)
14:48
probe at 127.000,105.000 is z=0.038125 (pos:0.798125 - bd:0.760)
14:48
probe at 127.000,105.000 is z=0.040313 (pos:0.800313 - bd:0.760)
14:48
probe at 127.000,105.000 is z=0.042500 (pos:0.802500 - bd:0.760)
14:48
probe at 127.000,105.000 is z=0.020625 (pos:0.800625 - bd:0.780)
14:48
probe at 127.000,105.000 is z=0.042813 (pos:0.792813 - bd:0.750)
14:48
probe at 127.000,105.000 is z=0.034688 (pos:0.784688 - bd:0.750)
14:48
PROBE_ACCURACY at X:127.000 Y:105.000 Z:1.000 (samples=10 retract=2.000 speed=0.8 lift_speed=0.8)
1 Like

The klipper documentation says 0.025mm is the bar for a usable probe. This is just slightly less than that.

Looking at the code that seems to be the value from the sensor itself. That number appears to be a value in mm and has a resolution limit of 0.01mm. All other things being perfect, the probe shouldn’t be able to do better than that.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.