Install BDsensor-m
Connect the sensor cable to the EXP1 interface of the mainboard
*If the sensor cable is not long enough, you can use an extension cable from the package
- The CKL and SDA lines of BDsensor-m can be connected to any GPIO pin on the board. You can also directly connect the BD sensor cable to the BLtouch port, for example:
BLtouch | BDsensor-m
5V --> 5V
GND --> GND
S --> CLK/SCL (Input)
GND --> GND
Zmin --> SDA (Input/Output)
- Some pins in the mainboard connector may not be directly connected to the MCU's gpios (for example, they may have filtering capacitors or are isolated through a MOSFET, diode, or optocoupler, but if they are isolated through resistors or resistor pull-up/down, they also cannot be used with
BDsensor-m
). The firmware will report a connection error. For example: - Fan and heater connectors are isolated through MOSFETs
- In some boards, connectors used for temperature thermistors and endstops/probes are usually connected to GND through filtering capacitors
-
As shown in the figure below, install the BD sensor close to the hot end. 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 previous modifications to klipper files and update klipper
cd
cd ~/klipper
git checkout .
git pull -
Execute the following git command under the user directory to clone the latest BD sensor code
cd && git clone https://github.com/markniu/Bed_Distance_sensor.git
-
Then execute the following command to install
cd ~/Bed_Distance_sensor/klipper/
./install_BDsensor.sh
Compile the firmware only if it prompts that the host and device firmware are inconsistent
-
Refer to your own firmware compilation tutorial to compile and flash the firmware
-
Compile firmware
cd ~/klipper/ # Go to the klipper directory
make menuconfig # Command to enter klipper configuration interface
make clean # Clean command
make # Compile command -
Flash the firmware to the mainboard connected with BD sensor
If your printer is running Moonraker, add the following section to moonraker.conf, then you can update BDsensor with one click through the web interface 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 the
[BDsensor]
sda_pin
andscl_pin
. Also, don't forget to disable other probe sections such as BLtouch. You can connect the BD sensor to either the mainboard or the toolhead CAN module. -
In
[BDsensor]
, changespeed
to 0.8. This is only applicable for z tilt and PROBE_ACCURACY commands. The smaller the value, the higher the accuracy during probing, because the MCU reads the BD sensor in the main loop during homing, which is not as real-time as a normal endstop.[BDsensor]
-
To use the BD sensor as an endstop when homing the Z-axis, change the
endstop_pin
in[stepper_z]
toendstop_pin: probe:z_virtual_endstop
-
Make sure there is
[safe_z_home]
in printer.cfg -
Change the value of
[bed_mesh]
and[z_tilt]
or[quad_gantry_level]
to 1 (recommended 0.7-1.0mm). The default value in klipper is 5mm, otherwise it may easily exceed the sensor range. -
Nozzle height should only be adjusted using the
z_adjust:
setting. Positive values bring the nozzle closer to the bed, while negative values move it away. Other settings for adjusting nozzle height may cause bugs -
Remove the # before
no_stop_probe:true
to enable fast bed scanning -
Below is a configuration example.
[BDsensor]
scl_pin:PC6 # Servo signal pin
sda_pin:PC3 # Endstop 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, replace 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, recommend 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 gcode commands
M102 S-1 # Read sensor information
M102 S-2 # Read a distance value
Check connection
-
Send
M102 S-1
through the console, this is an example of the returned message. If the response is blank or another string, check the connection and wire orderSend: M102 S-1
Recv: V1.0 pandapi3d.com
Calibration
- Clean the nozzle, then manually move the Z-axis through the console until the nozzle just touches the bed (BDsensor-m will use this position as the zero position, so no
z_offset
is needed, which is why the value is 0 in the [BDsensor-m] section) - Send the gcode command
M102 S-6
through the console, the printer will slowly move the Z-axis up by 0.1mm each time until reaching 4mm. Do not run M102 S-6 before installing the sensor, and do not power off the printer during calibration, otherwise the old calibration data will be deleted. If in this case, simply recalibrate - Afterwards, you can check whether the BD sensor has been successfully calibrated by
M102 S-5
, which will return the stored calibration data in the BD sensor.
Notes:
-
The Z-axis homing speed is best at 5
-
If the first raw calibration data returned by M102 S-5 is greater than 400, it means the sensor is installed too high and needs to be reinstalled closer to the bed. The recommended first data value is 100. Also ensure that the value of the second data is more than 10 higher than the first data
-
FAQ: What does it mean if the calibration data starts with 1, the second value is 9, and the third is 24?
-
This means the resolution between 0-0.1mm is only 9, and the resolution between 0.1-0.2mm is 15. Therefore, it is recommended to recalibrate to make the first resolution between 0-0.1mm greater than 10.
-
-
Don't forget to adjust the Z-axis height after running G28 or for these commands
Z_tilt
andquad_gantry_level
-
The section names must be properly capitalized, otherwise klipper will report
Unknown pin chip name 'probe'