Installing BDsensor-m
Connect the sensor cable to the EXP1 interface of the motherboard
- If the sensor cable is not long enough, you can use the extension cable included in the package.
- The CLK and SDA lines of the BDsensor-m can be connected to any GPIO pins of the circuit 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)
- Some pins in the motherboard connector may not be directly connected to the MCU's gpios (e.g., they may have filter capacitors or be isolated via MOSFETs, diodes, or optocouplers, but it is also acceptable if they are isolated via resistors or resistor pull-ups/pull-downs). Therefore, they cannot be used with
BDsensor-m, and the firmware will report a connection error. For example: - Fan and heater connectors are isolated via MOSFETs.
- Connectors for temperature thermistors and endstops/probes in some boards are typically connected to GND via filter capacitors.
-
Install the BD sensor close to the hotend as shown in the image below. STL of mount, STL_mount_VzBot_Goliath short
Loading...
Install the patch into the Klipper firmware
-
Do not do anything not mentioned in the tutorial.
-
Discard previously modified klipper files and update Klipper.
cdcd ~/klippergit checkout .git pull -
Execute the following git command in the user directory to clone the latest code for the BD sensor.
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
Compile firmware Only compile new Klipper firmware if prompted that the firmware versions of the upper and lower computers are inconsistent
-
To compile firmware, find the compilation tutorial for your own firmware to compile and flash.
-
Compile firmware.
cd ~/klipper/ # Go to the Klipper directorymake menuconfig # Enter the klipper compilation interface commandmake clean # Clean commandmake # Compilation command -
Flash the firmware to the motherboard to which the BD sensor is connected.
If your printer runs Moonraker, add the following section to moonraker.conf. You can then update BDsensor with a 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 to your printer.cfg and edit
[BDsensor]sda_pinandscl_pin. Also, remember to disable other probe sections like BLtouch. You can connect the BD sensor to the motherboard or the toolhead CAN module. -
In
[BDsensor], modifyspeedto 0.8. This only affects the z tilt and PROBE_ACCURACY commands. Smaller values result in higher probing accuracy, as the MCU reads the BD sensor in the main loop during homing, unlike a normal endstop which is real-time.[BDsensor] -
To use the BD sensor as an endstop during Z-axis homing, change
endstop_pinin[stepper_z]toendstop_pin: probe:z_virtual_endstop. -
Ensure that your printer.cfg contains
[safe_z_home]. -
Change the value of
[quad_gantry_level]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 may exceed the sensor range. -
Nozzle height should only be set in
z_adjust:; positive values move the nozzle closer to the bed, negative values move it away. Other methods for adjusting nozzle height will have bugs. -
To enable fast bed probing, remove the
#beforeno_stop_probe:true. -
Below is a configuration example.
[BDsensor]scl_pin:PC6 # Servo signal pinsda_pin:PC3 # Endstop signal pindelay: 20 # 20us per pulse, this value should be >=20 but must be below 50z_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.3mmx_offset: -34y_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.5homing_speed: 5second_homing_speed: 0.8[bed_mesh]speed: 200horizontal_move_z:1algorithm: bicubic[quad_gantry_level]horizontal_move_z:1
After installation, please check by sending the following gcode commands
M102 S-1 # Read sensor information
M102 S-2 # Read a distance value
Check the connection
-
Send
M102 S-1via the console. Here is an example of the returned message. If blank or other strings are returned, please check the connection and the wiring order.Send: M102 S-1Recv: 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 the zero position, so
z_offsetis not needed, which is why the value is 0 in the [BDsensor-m] section). - Send the gcode command
M102 S-6from the console. 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 turn off the printer power during calibration, or the old calibration data will be deleted. If this happens, simply calibrate again. - Afterwards, you can check if the BD sensor has been successfully calibrated using
M102 S-5, which will return the raw calibration data stored in the BD sensor.
Notes:
-
The Z-axis homing speed should preferably be 5.
-
If the first raw calibration data returned by M102 S-5 is greater than 400, it means the sensor is mounted too high and needs to be reinstalled closer to the bed. The recommended value for the first data point is 100. Also, ensure the second data point is at least 10 larger 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?
- This means the resolution between 0-0.1mm is only 9, while the resolution between 0.1-0.2mm is 15. It is recommended to calibrate again so that the first resolution (0-0.1mm) is greater than 10.
-
Please remember to adjust the Z-axis height after running G28 or for these commands
Z_tiltandquad_gantry_level. -
Section names must be correctly capitalized, otherwise Klipper will report
Unknown pin chip name 'probe'.