Skip to main content

Installing BDsensor-m-m

Connect the sensor cable to the EXP1 interface of the mainboard

  • If the sensor cable length is insufficient, you can use the extension cable included in the package.
  • The CKL and SDA wires of the BDsensor-m-m can be connected to any GPIO pins on 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)
  • Since some pins in the motherboard connector may not be directly connected to the MCU's GPIOs (for example, they may have filter capacitors or be isolated via MOSFETs, diodes, or optocouplers, though it is acceptable if isolated via resistors or resistor pull-ups/pull-downs), they cannot be used with BDsensor-m. The firmware will report a connection error. For instance:

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

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

    Loading...

Install 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. However, it is recommended to download the latest bugfix version: https://github.com/MarlinFirmware/Marlin

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

Edit Configuration.h

  1. Enable BD_SENSOR

    Uncomment the following:

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

    Note: BD_SENSOR_PROBE_NO_STOP is only available in the latest Marlin bugfix: https://github.com/MarlinFirmware/Marlin

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

  2. Home with probe

    Ensure 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 bump homing speed and Z homing speed because the stop signals read from the BDsensor-m process are not as real-time as normal stop switches.

    Edit Configuration_adv.h

    Enable #define BABYSTEPPING for real-time bed leveling functionality.

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

Edit pins_boardname.h

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

#define I2C_BD_SDA_PIN PC6 // Please change to the actual pin number connected to the SDA wire on your mainboard
#define I2C_BD_SCL_PIN PB2 // Please change to the actual pin number connected to the SLK wire on 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 probing (G29) before printing, similar to a standard 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

  • Applicable for printers with status display (supports gcode M117), such as LCD12864 or some UART screens like Ender 3 V2.

Calibration

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

  2. Send the gcode command M102 S-6. 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, nor 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 if the BD sensor calibration was successful. This returns the raw calibration data stored in the BD sensor.

There is also a calibration tool available for this: https://github.com/markniu/Bed_Distance_sensor/raw/new/marlin/BD_Config_Tool_Marlin.zip Note: Data values of 1015 or > 1010 indicate the sensor is out of 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, the calibration is successful, as shown in the chart above.

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 repositioned closer to the bed. Also, ensure the second data value is more than 10 greater than the first.

Testing and printing

Menu -> Bed

Auto Bed Level

There are two methods for automatic bed leveling:

1. Use M102 to level the first few layers in real-time

You can easily enable or disable this automatic leveling by sending gcode commands or adding them to the gcode file.

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

To disable the BD sensor, send M102 S0. It is disabled by default. G28 M18

M102 S-1 // Read sensor information, used for connection checking.
M102 S-2 // Read current distance value
M102 S-5 // Read raw calibration data
M102 S-6 // Start calibration. Before this, ensure the nozzle just touches the bed, then restart the printer. Do not home the Z axis before this command.
M102 S4 // Set the adjustable Z height value. E.g., M102 S4 means it will adjust when the Z height <= 0.4mm. Disable it with M102 S0.

2. G29 Automatic bed leveling

Another way to auto-level the bed is similar to using G29 with BLtouch. Simply add the line G29 below G28.

Installation Video

Chris' Basement Installation Video

Check Z endstop with M119

Do not home the Z axis before performing this check, otherwise, the nozzle may crash into the print bed.

Below is the return message after sending the M119 command (report endstop status):

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

If the z min is not open, check your configuration. #define Z_MAX_ENDSTOP_HIT_STATE HIGH

  • Ensure the Z motor is disabled/unlocked
  • Manually move the Z axis down until the nozzle touches the bed
  • Send M102 S-2. The return value should be 0.00mm. Then send M119 again; you should see the z endstop is now triggered.
Send: M119
Recv: x:open y:open z:TRIGGERED

Check Connection

Check the connection using M102 S-1. Here is an example of the return message. Verify the connection and wire order return the expected string and not blank or something else.

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

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

Loading...