Installing BDsensor-m
Connect the sensor cable to the EXP1 port on the motherboard
- If the sensor cable is not long enough, use the extension cable provided in the package
- The CKL and SDA lines of BDsensor-m can connect to any GPIO pin on the board. You can also connect the BD sensor cable directly to the Bltouch port, for example:
BLtouch | BDsensor-m
5V --> 5V
GND --> GND
S --> CLK/SCL (Input)
GND --> GND
Zmin --> SDA (Input/Output)
- Due to some pins in the motherboard connector not being directly connected to the MCU's gpios (e.g., they might have filtering capacitors or be isolated through MOSFETs, diodes, or optocouplers, but if they are isolated through resistors or pull-up/pull-down resistors, they can still be used), they cannot be used with
BDsensor-m
. The firmware will report a connection error. For example: - Fan and heater connectors are isolated through MOSFETs,
- Connectors for thermistors and endstops/probes on some boards are usually connected to GND through filtering capacitors,
-
As shown below, mount the BD sensor near the hotend. STL of mount, STL_mount_VzBot_Goliath short
Install the patch into the Klipper firmware
-
Do not do anything not mentioned in the tutorial
-
Discard any previously modified Klipper files and update Klipper
cd
cd ~/klipper
git checkout .
git pull -
In your home directory, execute the following git command to clone the latest BD sensor code
cd && git clone https://github.com/markniu/Bed_Distance_sensor.git
-
Then execute the following command for installation
cd ~/Bed_Distance_sensor/klipper/
./install_BDsensor.sh
Here's how to compile the firmware if it indicates a mismatch between the firmware of the upper and lower computers
-
Compile the firmware by following the tutorial for your board
-
Compile the firmware
cd ~/klipper/ # Navigate to the Klipper directory
make menuconfig # Enter the Klipper compile interface
make clean # Clean command
make # Compile command -
Flash the firmware to the motherboard connected to the BD sensor
If your printer is running Moonraker, add the following section to moonraker.conf, then you can update BDsensor with a single click via the web page or KlipperScreen.
[update_manager BDsensor]
type: git_repo
primary_branch: new
channel: dev
path: ~/Bed_Distance_sensor
origin: https://github.com/markniu/Bed_Distance_sensor.git
install_script: ./klipper/install_BDsensor.sh
is_system_service: False
managed_services: klipper
info_tags:
desc=Bed Distance Sensor
Edit printer.cfg
-
Copy this section into your printer.cfg and edit
[BDsensor]
sda_pin
scl_pin
, also don't forget to disable other probe sections like BLtouch. You can connect the BD sensor to the motherboard or the toolhead CAN module, -
In
[BDsensor]
, changespeed
to 0.8. This only applies to the z tilt and PROBE_ACCURACY commands. A lower value results in higher accuracy during probing because the MCU reads the BD sensor in the main loop during homing, unlike a normal endstop.[BDsensor]
-
To use the BD sensor as a limit switch during Z axis homing, change
endstop_pin
in[stepper_z]
toendstop_pin: probe:z_virtual_endstop
-
Make sure printer.cfg includes
[safe_z_home]
-
Change the value in
[bed_mesh]
and[z_tilt]
or[quad_gantry_level]
to 1 (recommended 0.7-1.0mm). The default value in Klipper is 5mm, which might exceed the sensor's range -
Nozzle height should only be set in
z_adjust:
; positive values bring it closer to the bed, negative values move it away. Other nozzle height settings might cause bugs -
Enable fast bed scanning by removing the
#
beforeno_stop_probe:true
-
Here's an example configuration.
[BDsensor]
scl_pin:PC6 # Servo signal pin
sda_pin:PC3 # Limit signal pin
delay: 20 # 20us per pulse, this value should be >=20 but must be below 50
z_offset:0 # this `z_offset` must be set to 0.
z_adjust:0.0 # z axis adjustment, replaces the z_offset function. within -0.3 to 0.3mm
x_offset: -34
y_offset: 0
#no_stop_probe:true # enable this for fast probe, the toolhead will not stop at the probe point.
position_endstop: 0.8 # the Z axis will stop at this position (mm) while homing z, recommended value is 0.4~1.0
#speed:0.8 # this speed only works for the z tilt and PROBE_ACCURACY command.
[stepper_z]
endstop_pin: probe:z_virtual_endstop
#position_endstop: 0.5
homing_speed: 5
second_homing_speed: 0.8
[bed_mesh]
speed: 200
horizontal_move_z:1
algorithm: bicubic
[quad_gantry_level]
horizontal_move_z:1
After installation, check by sending the following G-code commands
M102 S-1 # Read sensor information
M102 S-2 # Read a distance value
Check Connection
-
Send
M102 S-1
through the console; here's an example of the returned message. If it returns blank or any other string, check the connection and wire sequenceSend: M102 S-1
Recv: V1.0 pandapi3d.com
Calibration
- Clean the nozzle, then move the Z-axis via the console until the nozzle just touches the bed (BDsensor-m will use this position as zero, hence no
z_offset
is needed, which is why the value in the [BDsensor-m] section is 0) - Send the G-code command
M102 S-6
through the console, and the printer will slowly move the Z-axis up by 0.1mm each time until it reaches 4mm. Do not run M102 S-6 before installing the sensor, and do not power off the printer during calibration, or the old calibration data will be lost. If this happens, simply recalibrate. - Afterwards, you can check if the BD sensor has been successfully calibrated with
M102 S-5
, which will return the raw calibration data stored in the BD sensor.
Notes:
-
The best Z axis homing speed is 5
-
If M102 S-5 returns a first raw calibration data greater than 400, it means the sensor is installed too high and needs to be reinstalled closer to the bed. The recommended value for the first data is 100. Also, ensure the second data value is more than 10 greater than the first.
-
FAQ: What does it mean if the calibration data starts with 1, the second value is 9, and the third is 24?
-
It means the resolution between 0-0.1mm is only 9, while the resolution from 0.1-0.2mm is 15. It's recommended to recalibrate to ensure the first resolution from 0-0.1mm is greater than 10.
-
-
Do not forget to adjust the Z axis height after running G28 or for commands like
Z_tilt
andquad_gantry_level
-
The section name must be correctly capitalized, otherwise Klipper will report
Unknown pin chip name 'probe'