Skip to content

How to run Real Time Level

Mark edited this page Feb 28, 2025 · 55 revisions

Note

1. This feature only works with the BDsensor and Z motors are connected in the same MCU.

2. Install the sensor coil as close as possible to the nozzle in the X/Y axis.

3. the Real Time Level and the mesh bed level are different and they cannot work together.

4. Be careful,if you first use this feature. When printing, make sure the sensor will not go too close to the bed edge (>5mm) or out of the bed where the measurements will be incorrect that would damage the plate.

For Klipper:

1. Test First:

G28
BDSENSOR_SET REAL_TIME_HEIGHT=0.3
G1 Z0.2

You can see the z axis will move up and down automatically if you press the bed plate or the x carriage with hand.

2. Start Gcode in your slicer:

  • Disable the auto leveling: removing the BED_MESH_CALIBRATE and adding BED_MESH_CLEAR in the start gcode.

  • Enable the Real Time Level at the first layer start BDSENSOR_SET REAL_TIME_HEIGHT=0.3 and disable it after first layer BDSENSOR_SET REAL_TIME_HEIGHT=0

For example, adding the following line in the orca slicer which is in the Printer settings-->Machine G-code-->Before layer change G-code:

{if layer_num == 0}
G1 Z[first_layer_height] 
BDSENSOR_SET REAL_TIME_HEIGHT=0.3
G4 P1000
{endif}
{if layer_num == 1}BDSENSOR_SET REAL_TIME_HEIGHT=0 {endif}

BDSENSOR_SET REAL_TIME_HEIGHT=xx xx is the max z axis height that will do real time leveling automatically, here we just let this value the same as the first layer height in slicer setting.for example 0.2 or 0.3mm

  • Set the first layer speed < 50mm/s.

z_offset

Please set the z_offset to 0. if you want to modify the z_offset, please modify it in the printer.cfg and not recommend to adjust the z_offset while printing.

FAQ:

1. Error:Timer too close

Reason: This Real time level feature will create a new software task in the MCU to read sensor data and adjust the z motors.That task will consume some MCU time, if the MCU can not run fast enough or the printing is too fast, then it may cause this timer too close. BTW, This task only runs in the first layer printing.

Solution: increase the interval process time( modify the value rt_sample_time ) or slow down the first layer print speed.

For example:

[BDsensor]
....
rt_sample_time:16 # ms

The value of rt_sample_time depends on the MCU speed, please increase this value if the MCU speed is too slow. Here are the default value for different speed MCU:

MCU Freq: default rt_sample_time
above 100MHz 11ms
60MHz~100MHz 16ms
<60MHz 19ms

2. Error: shutdown: Invalid oid type

Make sure the sensor and the z motors are not connected in the same MCU. because it's not possible to do real time adjust from the high level python between different MCU during printing.

3. Motor noise in first layer

The Real time leveling consume some cpu time in the MCU that will cause some delay and make noise from XY motors especially in high speed of nozzle travel while printing in first layer.

For Marlin Firmware:

https://github.com/markniu/Bed_Distance_sensor/wiki/Installing-Bed-Distance-Sensor