Skip to main content

Installing BDsensor

Connect the sensor cable to the mainboard or the CAN bus toolhead board.​

  • Please note that the SB2040 cannot use the BDsensor.
  • Please note that for the SHT36, the BDsensor's CLK/SCL (Input) needs to be connected to the high-voltage input port, and the jumper needs to be connected.
  • The BDsensor's CLK and SDA wires can be connected to any GPIO pin on the board. You can also connect the BD sensor cable directly to the Bltouch port, for example:
BLtouch | BDsensor
5V --> 5V
GND --> GND
S --> CLK/SCL (Input)
GND --> GND
Zmin --> SDA (Input/Output)
  • Since some pins in the mainboard connectors may not be directly connected to the MCU's GPIO (for example, they may have filter capacitors on them or be isolated through MOSFETs, diodes, or optocouplers, but they can also be isolated through resistors or resistor pull-ups/pull-downs), they cannot be used with the BDsensor. And the firmware will report a connection error. For example

  • Fan and heater connectors are isolated through MOSFETs,

  • In some boards, the connectors used for temperature thermistors and limit/probe are usually connected to GND through filter capacitors,

  1. As shown in the figure below, install the BD sensor near the hotend. STL of mount, STL_mount_VzBot_Goliath short

    Loading...

Installing the Patch into Marlin Firmware​

The BD sensor has been integrated into Marlin 2.1.x (since 2022.8.27),

You can download the release version. But it is now recommended to download the latest bugfix version: https://github.com/MarlinFirmware/Marlin

What you need is to modify the configuration files and pin files.

Editing Configuration.h​

  1. Enable BD_SENSOR

    Uncomment

    #define BD_SENSOR
    #define Z_SAFE_HOMING
    #define BD_SENSOR_PROBE_NO_STOP //adding this new line for fast bed leveling without nozzle stop,

    Only BD_SENSOR_PROBE_NO_STOP

    Latest Marlin bugfix: https://github.com/MarlinFirmware/Marlin

    Description: https://github.com/MarlinFirmware/Marlin/pull/25847

  2. Homing with the probe

    Make sure Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN is disabled, and USE_PROBE_FOR_Z_HOMING should be enabled as shown below

    //#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
    // Force the use of the probe for Z-axis homing
    #define USE_PROBE_FOR_Z_HOMING
  3. Slow down the second homing Z speed

    #define Z_PROBE_FEEDRATE_SLOW (Z_PROBE_FEEDRATE_FAST / 16)

    Here, we must slow down the homing bump speed and the Z-axis homing speed, because the limit signal read from the BDsensor is not as real-time as a normal limit switch.

    Editing Configuration_adv.h​

    #define BABYSTEPPING Enable this feature to achieve real-time leveling functionality

    #define HOMING_BUMP_DIVISOR { 2, 2, 8 } // Re-Bump Speed Divisor (Divides the Homing Feedrate)

Editing pins_boardname.h​

Configure the SDA and SCL pins of the BDsensor in the pin file pins_boardname.h by adding the following 3 lines (e.g., pins_PANDA_PI_V29.h):

#define I2C_BD_SDA_PIN PC6 // Please change to the actual number which the SDA wire is connected to your mainboard
#define I2C_BD_SCL_PIN PB2 // Please change to the actual number which the SLK wire is connected to your mainboard
#define I2C_BD_DELAY 20 // default value is 20, should be in the range [20,50].

If you want to perform automatic bed leveling probe (G29) before printing like a normal BLtouch, uncomment

#define AUTO_BED_LEVELING_BILINEAR

And edit the values as shown below

#define Z_CLEARANCE_DEPLOY_PROBE 0 // Z Clearance for Deploy/Stow
#define Z_CLEARANCE_BETWEEN_PROBES 1 // Z Clearance between probe points
#define Z_CLEARANCE_MULTI_PROBE 1 // Z Clearance between multiple probes

Display BD Sensor Values on the LCD Screen​

  • For printers with status display (supporting gcode M117), such as LCD12864 or some UART screens, such as ender3V2 ...

Calibration​

  1. Clean the nozzle, then move the Z axis via the console until the nozzle just touches the bed plate (the BDsensor will use this position as the 0 point, so no z_offset is needed; we set the value to 0).

  2. Send the gcode command M102 S-6. The printer will slowly move the Z axis upward 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, otherwise the old calibration data will be deleted. If this happens, simply calibrate again.

  3. You can send M102 S-5 to check whether the BD sensor has been calibrated successfully. This will return the raw calibration data stored in the BD sensor.

There is also a calibration tool that can do this: https://github.com/markniu/Bed_Distance_sensor/raw/new/marlin/BD_Config_Tool_Marlin.zip

Note: A data value of 1015 or > 1010 indicates that it is outside the sensor range. If the first 5 points (0~0.5mm) or more have values within the range of 0 to 1000, and the incremental value delta is >=10, then the calibration is successful. Just like the chart shown above.

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. Also make sure that the second data value is greater than the first data value by more than 10.

Test and Print​

Menu: Bed Leveling

Auto Bed Leveling

There are two methods to automatically level the bed:​

1. Use M102 for real-time leveling of the first few layers

We can easily enable or disable this auto-leveling feature by sending a gcode command or adding gcode to a gcode file.

To enable bed leveling in Cura, add the M102 code directly below the G28 (home all axes) code in the "Start G-code" section of the printer machine settings. For example, below G28, this means bed leveling will only be performed when the Z-axis height does not exceed 0.2mm. M102 S2

Send M102 S0 to disable real-time leveling of the BD sensor (G28, M18 will also disable it). By the way, this feature is disabled by default.

M102 S-1 //Read sensor information, and we can use this for connection checking.
M102 S-2 //Read current distance value
M102 S-5 //Read raw Calibrate data
M102 S-6 //Start Calibrate,before that make sure the nozzle is just touched the bed,and then the printer restarted. don't home z axis before this.
M102 S4 //Set the adjustable Z height value,e.g. M102 S4 means it will do adjusting while the Z height <=0.4mm , disable it by M102 S0.

2. G29 auto bed leveling

Another automatic bed leveling method is just like BLtouch's G29, simply add a line of G29 below G28.

Installation video

Chris's Basement installation video

Check Z endstop M119​

Before checking this step, do not home Z, otherwise the nozzle may hit the printer bed.

This is the return message after sending the M119 command (report endstop switch status).

Send: M119
Recv: x:open y:open z:open

If z min is not triggered, please check your configuration. #define Z_MIN_ENDSTOP_HIT_STATE HIGH

  • Make sure the Z motor is off/unlocked
  • Move the Z axis down by hand until the nozzle touches the bed surface
  • Send M102 S-2, the return value should be 0.00mm, then send M119 again, and you can see that the z endstop is now triggered.
Send: M119
Recv: x:open y:open z:TRIGGERED

Check connection​

Check the connection via M102 S-1. This is an example of the return message. If it returns blank or another string, please check the connection and wire order.

Send: M102 S-1
Recv: V1.0 pandapi3d.com

If all the steps above are correct, you can now home the Z axis.​

Loading...