markniu / Bed_Distance_sensor

Auto bed level with High resolution distance sensor
268 stars 26 forks source link

No data or corrupt data from BDsensor( ) #111

Closed hidara2000 closed 4 months ago

hidara2000 commented 5 months ago

Hi, I have two of these devices and am getting the same error on both

WIRING

IMG20240405144735

EBB sb2209 from guide

image

image

Servos = PB9 Probe = PB8

Klipper Settings

[BDsensor] 
# Don't use aliases for the board pins
sda_pin: EBBCan: PB9 # from https://github.com/markniu/Bed_Distance_sensor/issues/50
scl_pin: EBBCan: PB8
delay: 20 # 20us per pulse, this value should be >=18 but must be below 30
z_offset:0 #  within -0.6 to 0.6mm
x_offset: 0
y_offset: 25.0
no_stop_probe: # fast probe that the toolhead will not stop at the probe point,disable it by commenting out.
position_endstop: 0.5 #the Z axis will be triggered after it measured the distance is below this value(mm) while homing z, recommend value is 0.5~1.0
#speed:0.8 # this speed only works for the z tilt and PROBE_ACCURACY command.
collision_homing:0 #  set it 1 to enable homing with nozzle collision sensing.
collision_calibrate:0 # set it 1 to enable auto calibrate BDsensor with nozzle collision sensing.

Flashing using canbus result

image

BDsensor.py exists before compiling and flashing clean

image

WHAT I'VE TRIED

Results from commands

M119

x:open y:open z:TRIGGERED # whether triggered or not NOTE: I can see the light triggering to detect metal when I bring a spanner close to the sensor

M102 S-1

No data or corrupt data from BDsensor( ), Please check connection

BDSENSOR_VERSION

No data or corrupt data from BDsensor( ), Please check connection

BDSENSOR_READ_CALIBRATION

No data or corrupt data from BDsensor( ), Please check connection BDSensor mounted too close! please mountthe BDsensor 0.2~0.4mm higher

hidara2000 commented 5 months ago

Also tried direct connection to SKR v1.3 board and same issue. Bl touch with confi changes works perfectly using the same pins

markniu commented 5 months ago

Hello, Seems you need to switch the SDA and CLK pin in the printer.cfg:

sda_pin: EBBCan: PB8
scl_pin: EBBCan: PB9
hidara2000 commented 5 months ago

Cheers for the reply. That's what I had originally but changed it as per the comment in this post https://github.com/markniu/Bed_Distance_sensor/issues/50

either way I've tried both

markniu commented 5 months ago

you can change it back to the correct order and try again. if still the same, try to connect the bdsensor to the mainboard for finding out where the problem is.

hidara2000 commented 5 months ago

I've already tried that and connected directly to the SKR v1.3. Same errors I did buy off this link. Is this legit and tied to you?

cheers

https://www.aliexpress.com/i/1005006169022237.html

hidara2000 commented 5 months ago

Also just a quick one. The pins for the BDsensor mention sda and clk. Does it use I2c? if so, I wonder if the pins for BLTouch on the EBB SB2209 are compatible?

image

markniu commented 5 months ago

the endstop pin on the skr v1.3 for the bltouch doesn't work with bdsensor, you can use the pin in EXP1 or EXP2 for bdsensor.

SKR v1.3

hidara2000 commented 5 months ago

I have the EBB SB2209 canbus and need to get it working with this. If it needs I2C I found (image below) in the schematics but cant figure out which pins these are.

image

markniu commented 5 months ago

BDsensor use the i2c, but not standard i2c. I have tested the other version of EBB board that can work with bdsensor with the BLtouch port. do you check the wires with multimeter?

Also just a quick one. The pins for the BDsensor mention sda and clk. Does it use I2c? if so, I wonder if the pins for BLTouch on the EBB SB2209 are compatible?

hidara2000 commented 5 months ago

do you check the wires with multimeter?

I checked for continuity and shorts on my crimps.

I also connected to the SKR directly using the supplied cables and am getting the same errors. cheers for the help

markniu commented 5 months ago

ok, because I have met the connection loosen problem to the mainboard before. are there any other unused pins on the board?you can try that, but don't use the endstop pins.

markniu commented 5 months ago

also did the led work? the led on the bdsensor should be light on if it detects the metal.

hidara2000 commented 5 months ago

LED works as expected

markniu commented 5 months ago

you can also try to increase the delay value in the [BDsensor] section from 20 to 40, that will slow down the data transfer speed.

Terrradives commented 5 months ago

I also have been having the same symptoms and issues the last few days. I'm plugged into a octopus 1.1. pb6 &7 pins. lights work. triggered always active. M102 codes return the same.

hidara2000 commented 5 months ago

Hi @Terrradives , Did you manage to get it working?

hidara2000 commented 5 months ago

I just:

Still the same issue. Device led triggers when close to metal but still getting the error message

No data or corrupt data from BDsensor(), Please check connection
hidara2000 commented 5 months ago

@markniu

Any suggestions on how to connect directly to a Pi and if there is a Python script I can run to test the device?

markniu commented 5 months ago

yes, you can test it with the gpio on the Pi, connect the bdsensor to the gpio on the PI like gpio17 and gpio27.

[mcu host] serial: /tmp/klipper_host_mcu

[BDsensor] .... scl_pin: host:gpio17 sda_pin: host:gpio27

compile and flash firmware: https://www.klipper3d.org/RPi_microcontroller.html

hidara2000 commented 5 months ago

Donno if this will help but I added the following lines to the BDsensor.py

def BD_version(self, gcmd):
   ...
   ...
   attrs = vars(self)
   attrs = ('\n'.join("%s: %s" % item for item in attrs.items()))

   self.gcode.respond_info(f"{attrs}")
   self.gcode.respond_info("No data or corrupt data from BDsensor(%s), "
                                    "Please check connection"%self.bdversion)

and the response was

printer: <__main__.Printer object at 0x7f7f9350d0>
config: 
name: BDsensor
z_adjust: 0.0
z_offset: 0.0
position_endstop: 0.5
stow_on_each_sample: True
no_stop_probe: 
collision_homing: 0
collision_calibrate: 0
activate_gcode: 
deactivate_gcode: 
collision_calibrating: 0
switch_mode: 1
bdversion: 
next_cmd_time: 0.0
action_end_time: 0.0
sda_pin_num: PB8
mcu: 
_invert: 0
oid: 2
mcu_endstop: 
_invert_endstop: 0
oid_endstop: 2
endstop_pin_num: PB8
endstop_bdsensor_offset: 0
cmd_queue: 
trapq: 
trapq_append: 
trapq_finalize_moves: 
stepper_kinematics: 
bd_sensor: 
gcode: 
I2C_BD_receive_cmd2: None
gcode_move: 
bedmesh: None
bd_value: 10.24
results: []
finish_home_complete: None
wait_trigger_complete: None
multi: OFF
adjust_range: 0
old_count: 1000
homeing: 0
reactor: 
status_dis: None
_rest_ticks: 0
_trdispatch: 
_trsyncs: [, ]
ncont: 0
z_last: 0
I2C_BD_receive_cmd: 
_home_cmd: 
toolhead:
markniu commented 5 months ago

Donno if this will help but I added the following lines to the BDsensor.py

that reported all the data is 10.24(bd_value: 10.24) , means no data returned from the sda pin.

hidara2000 commented 5 months ago

Interesing.... When I connected the device to the EBB canbus or directly to the SKR v1.3 I got errors

Now when connected directly to the pi I get

BDSENSOR_VERSION

image

Note I'm using the supplied cable for both the pi and SKR but using a crimped cable for the EBB

markniu commented 5 months ago

yes, that's weird.

markniu commented 5 months ago

you can try to test it by connecting it to the pins on the EXP1 of SKR

Terrradives commented 5 months ago

I have not yet.  I’m kind of hoping there are tests I can rule things out with.  I’ve switched pins I was using on the octopus board, so I don’t think it’s board or pins.  I’ve got a bltouch currently working on those pins.  It’s not wire.  So I’m left kind of thinking how do I verify I’ve got a correctly flashed boards or verify the sensor is fully functional.Sent from my iPhoneOn Apr 10, 2024, at 12:26 AM, hidara2000 @.***> wrote: Hi @Terrradives , Did you manage to get it working?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

hidara2000 commented 4 months ago

GOT IT WORKING :)

What didn't work

  1. Made 3 sets of cables from the supplied ribbon. Used the proper crimping tool. Checked for shorts and continuity. None of these cables worked on the BDsensor but all worked for a BL-touch I had lying around
  2. Reflashed firmware on EBB and SKR
  3. Updated the firmware on the BDsensor

What DID work

  1. Made a set of cables using some 26AWG silicone cables. 1st set worked on both BL touch and BDsensor

PS cheers for the help @markniu

hidara2000 commented 4 months ago

PS for anyone else, here's a mount I made for the CW2 & Stealthburner. You don't need to modify any existing parts.

https://www.printables.com/model/831679-lazy-bd-sensor-adapter-for-stealthburner-voron

markniu commented 4 months ago

PS for anyone else, here's a mount I made for the CW2 & Stealthburner. You don't need to modify any existing parts.

https://www.printables.com/model/831679-lazy-bd-sensor-adapter-for-stealthburner-voron

Thanks for share!

Terrradives commented 4 months ago

Is there any chance you’d be willing to make a1.5 meter set and ship them to the USA?Sent from my iPhoneOn Apr 13, 2024, at 12:59 AM, hidara2000 @.***> wrote: GOT IT WORKING :) What didn't work

Made 3 sets of cables from the supplied ribbon. Used the proper crimping tool. Checked for shorts and continuity. None of these cables worked on the BDsensor but all worked for a BL-touch I had lying around Reflashed firmware on EBB and SKR

What DID work

Made a set of cables using some 26AWG silicone cables. 1st set worked on both BL touch and BDsensor

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

hidara2000 commented 4 months ago

@Terrradives Honestly, I would recommend checking your wiring and settings. The problem I had was that my Canbus EBB needed a higher quality connection but connecting directly to the printer controller board worked with the supplied cable. I'm guessing this is what you are doing if you need a 1.5m cable. Send me:

I'll double check it for you