# PROBE\_ACCURACY always performs one sample only (BD sensor)

**URL:** <https://klipper.discourse.group/t/probe-accuracy-always-performs-one-sample-only-bd-sensor/13815>\
**Category:** General Discussion\
**Created:** [February 4, 2024, 1:38pm UTC](https://klipper.discourse.group/t/probe-accuracy-always-performs-one-sample-only-bd-sensor/13815 "2024-02-04T13:38:14Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![LifeOfBrian](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/lifeofbrian/32/2380_2.png) [@LifeOfBrian](https://klipper.discourse.group/u/LifeOfBrian)\
**Post date:** [February 4, 2024, 1:38pm UTC](https://klipper.discourse.group/t/probe-accuracy-always-performs-one-sample-only-bd-sensor/13815/1 "2024-02-04T13:38:14Z")

</div>

### Basic Information:

Printer Model: NoName (custom CoreXY)  
 MCU / Printerboard: BTT SKR 2 + EBB36  
 `klippy.log`  
[klippy.log](https://klipper.discourse.group/uploads/short-url/uE0WBmCv8OZlwaJhp3qSnqzhzHF.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.

---

<div class="post-metadata">

**Author:** ![hcet14](https://avatars.discourse-cdn.com/v4/letter/h/ecd19e/32.png) [@hcet14](https://klipper.discourse.group/u/hcet14)\
**Post date:** [February 4, 2024, 5:36pm UTC](https://klipper.discourse.group/t/probe-accuracy-always-performs-one-sample-only-bd-sensor/13815/2 "2024-02-04T17:36:19Z")

</div>

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](https://github.com/markniu/Bed_Distance_sensor/commit/99dfa550dc8f0a66abd2b3265f68b73223d8d6cc?diff=split&w=0)  
No clue if this is helpful!

---

<div class="post-metadata">

**Author:** ![Sineos](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/sineos/32/18_2.png) [@Sineos](https://klipper.discourse.group/u/Sineos)\
**Post date:** [February 4, 2024, 6:03pm UTC](https://klipper.discourse.group/t/probe-accuracy-always-performs-one-sample-only-bd-sensor/13815/3 "2024-02-04T18:03:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![LifeOfBrian](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/lifeofbrian/32/2380_2.png) [@LifeOfBrian](https://klipper.discourse.group/u/LifeOfBrian)\
**Post date:** [February 4, 2024, 10:32pm UTC](https://klipper.discourse.group/t/probe-accuracy-always-performs-one-sample-only-bd-sensor/13815/4 "2024-02-04T22:32:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![LifeOfBrian](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/lifeofbrian/32/2380_2.png) [@LifeOfBrian](https://klipper.discourse.group/u/LifeOfBrian)\
**Post date:** [February 5, 2024, 9:24am UTC](https://klipper.discourse.group/t/probe-accuracy-always-performs-one-sample-only-bd-sensor/13815/5 "2024-02-05T09:24:35Z")

</div>

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**.

---

<div class="post-metadata">

**Author:** ![Sineos](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/sineos/32/18_2.png) [@Sineos](https://klipper.discourse.group/u/Sineos)\
**Post date:** [February 5, 2024, 10:00am UTC](https://klipper.discourse.group/t/probe-accuracy-always-performs-one-sample-only-bd-sensor/13815/6 "2024-02-05T10:00:48Z")

</div>

> [@LifeOfBrian](#):
>
> so it will stop at the position and then just read samples.

> [@LifeOfBrian](#):
>
> probe accuracy results: maximum 0.990000, minimum 0.990000, range 0.000000, average 0.990000, median 0.990000, standard deviation 0.000000

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

---

<div class="post-metadata">

**Author:** ![LifeOfBrian](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/lifeofbrian/32/2380_2.png) [@LifeOfBrian](https://klipper.discourse.group/u/LifeOfBrian)\
**Post date:** [February 5, 2024, 10:15am UTC](https://klipper.discourse.group/t/probe-accuracy-always-performs-one-sample-only-bd-sensor/13815/7 "2024-02-05T10:15:54Z")

</div>

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. 🙂  
And I can continue fighting my remaining Z artifacts…

---

<div class="post-metadata">

**Author:** ![garethky](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/garethky/32/956_2.png) [@garethky](https://klipper.discourse.group/u/garethky)\
**Post date:** [February 8, 2024, 7:56pm UTC](https://klipper.discourse.group/t/probe-accuracy-always-performs-one-sample-only-bd-sensor/13815/8 "2024-02-08T19:56:53Z")

</div>

This looks sus: [Bed\_Distance\_sensor/klipper\_Beta/BDsensor.py at da5e8334aac2502f32d837c15a2a0a6d840f6781 · markniu/Bed\_Distance\_sensor · GitHub](https://github.com/markniu/Bed_Distance_sensor/blob/da5e8334aac2502f32d837c15a2a0a6d840f6781/klipper_Beta/BDsensor.py#L329C30-L329C33)

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

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

print(bar)

```

Results:

```auto
[[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:

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

print(bar)

```

Results:

```auto
[[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]]

```

---

<div class="post-metadata">

**Author:** ![LifeOfBrian](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/lifeofbrian/32/2380_2.png) [@LifeOfBrian](https://klipper.discourse.group/u/LifeOfBrian)\
**Post date:** [February 9, 2024, 7:16am UTC](https://klipper.discourse.group/t/probe-accuracy-always-performs-one-sample-only-bd-sensor/13815/9 "2024-02-09T07:16:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![garethky](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/garethky/32/956_2.png) [@garethky](https://klipper.discourse.group/u/garethky)\
**Post date:** [February 9, 2024, 7:45am UTC](https://klipper.discourse.group/t/probe-accuracy-always-performs-one-sample-only-bd-sensor/13815/10 "2024-02-09T07:45:29Z")

</div>

Go for it!

---

<div class="post-metadata">

**Author:** ![LifeOfBrian](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/lifeofbrian/32/2380_2.png) [@LifeOfBrian](https://klipper.discourse.group/u/LifeOfBrian)\
**Post date:** [March 2, 2024, 1:51pm UTC](https://klipper.discourse.group/t/probe-accuracy-always-performs-one-sample-only-bd-sensor/13815/11 "2024-03-02T13:51:28Z")

</div>

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:

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![garethky](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/garethky/32/956_2.png) [@garethky](https://klipper.discourse.group/u/garethky)\
**Post date:** [March 3, 2024, 2:14am UTC](https://klipper.discourse.group/t/probe-accuracy-always-performs-one-sample-only-bd-sensor/13815/12 "2024-03-03T02:14:14Z")

</div>

> [@LifeOfBrian](#):
>
> `range 0.022187`

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

> [@LifeOfBrian](#):
>
> ` - bd:0.750`

Looking at [the code](https://github.com/markniu/Bed_Distance_sensor/blob/465d260c0f83d3bc1a458a7136a5920bf44579e2/klipper/BDsensor.py#L202) 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.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/klipper/original/1X/64419bf2aac6639e6ef5cef200dcd456b0a01ac3.png) [@system](https://klipper.discourse.group/u/system)\
**Post date:** [May 2, 2024, 2:14am UTC](https://klipper.discourse.group/t/probe-accuracy-always-performs-one-sample-only-bd-sensor/13815/13 "2024-05-02T02:14:39Z")

</div>

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