Problem with ADXL on SB2240

Basic Information:

Printer Model: Voron 2.4r2
MCU / Printerboard: Octopus 1.0
Host / SBC: RPI 4B+
klippy.log

Fill out above information and in all cases attach your klippy.log file (use zip to compress it, if too big). Pasting your printer.cfg is not needed
Be sure to check our “Knowledge Base” Category first. Most relevant items, e.g. error messages, are covered there

Describe your issue:

hello,

I installed on my Voron 2.4r2 the can-bus-system with U2C and SB2240. My Octopus board is connected via USB to the pi4B+. Everything is working fine now except the ADXL sensor. When I try a “accelerometer_query” I get the error: Invalid adxl345 id (got 0 vs e5). Yes, I tried it several times. Normally this results after a bad cable connection but in my case there is no cable and the rest of the bus-systems works fine.

Does anybody have suggestion what to do?

Thanks in advance!
klippy.log (581.4 KB)

I agree. No suggestions, but did you read what glabifrons wrote here Reddit - Dive into anything? Might also be a faulty adxl345 chip.

Thanks a lot. I will try the changed code in the adxl345.py and see what happens.

I also had a closer look to the schematics on the btt homepage and found this here:

The picture says that the adxl is on spi2 but I always get the error “spi_bus not allowed in [adxl345]” when I add the line:
spi_bus = spi2

In the klipper-documentation there are examples where the spi_bus is defined.

The pins should be defined correctly:
[adxl345]
cs_pin = EBBCan: PB12
spi_bus = spi2
spi_software_sclk_pin = EBBCan: PB10
spi_software_mosi_pin = EBBCan: PB11
spi_software_miso_pin = EBBCan: PB2
axes_map = z,-y,x

You can either use the hardware SPI (SPI2 in your case) or software SPI, but not both.

Try:

[adxl345]
cs_pin = EBBCan: PB12
spi_bus = spi2
# spi_software_sclk_pin = EBBCan: PB10
# spi_software_mosi_pin = EBBCan: PB11
# spi_software_miso_pin = EBBCan: PB2
axes_map = z,-y,x

or

[adxl345]
cs_pin = EBBCan: PB12
# spi_bus = spi2
spi_software_sclk_pin = EBBCan: PB10
spi_software_mosi_pin = EBBCan: PB11
spi_software_miso_pin = EBBCan: PB2
axes_map = z,-y,x
1 Like

Thanks a lot für your suggestions!
When I try version 1 (spi2) then the error: “pin PB13 is reserved for spi2” occurs.
Version 2 is the standard version with no error but also not working ADXL345.

But with checking all the pin definitions I saw that in the standard-config from BTT the pins for the adxl and the extruder are the same. Is this possible?

[adxl345]
cs_pin: EBBCan: PB12
spi_software_sclk_pin: EBBCan: PB10
spi_software_mosi_pin: EBBCan: PB11
spi_software_miso_pin: EBBCan: PB2
axes_map: z,-y,x

[resonance_tester]
probe_points: 175, 175, 20
accel_chip: adxl345

[extruder]
step_pin: EBBCan: PD0
dir_pin: !EBBCan: PD1
enable_pin: !EBBCan: PD2
microsteps: 16
heater_pin: EBBCan: PB13

sensor_type:MAX31865
sensor_pin: EBBCan: PA4
spi_bus: spi1
rtd_nominal_r: 100
rtd_reference_r: 430

[tmc2240 extruder]
cs_pin: EBBCan: PA15
spi_software_sclk_pin: EBBCan: PB10
spi_software_mosi_pin: EBBCan: PB11
spi_software_miso_pin: EBBCan: PB2
driver_TPFD: 0
run_current: 0.650
stealthchop_threshold: 999999

Just looking at the Schematics for the SB2240 and cross referencing them to the STM32G0B1 datasheet.

On the schematic, the following pins are defined for the SPI bus:
PB10 - CLK
PB11 - MOSI
PB2 - MISO
PA15 - “EO NSS” (Actually CS)

Which matches in your configuration information.

Now, on the STM32G0B1 datasheet, (the primary use of SPI2) is defined as:
PB13 - CLK
PB15 - MOSI
PB14 - MISO
PB12 - Default CS pin for SPI2 (This is required for the built in bootloader and not required for general operations)

So, it looks like the board designer didn’t get the primary SPI2 pins right for the STM32G0B1 - I’ve worked through this and you need to reference more than just the pin mux table in the datasheet; you need to look at the DFU Guide as well as the Klipper docs. I’ve just spent a half hour going through documents to verify the information here.

To net things out, you can’t use the spi_bus = spi2 command in your config - you have to use the software SPI.


Now, what do you mean when you say “also no working ADXL345”? Going over the schematic, your specification of:

[adxl345]
cs_pin: EBBCan: PB12
spi_software_sclk_pin: EBBCan: PB10
spi_software_mosi_pin: EBBCan: PB11
spi_software_miso_pin: EBBCan: PB2
axes_map: z,-y,x

Looks correct - some more information here would be helpful (ie your klippy.log and any error messages that you get).

Yes, the same SPI bus pins (spi_software_sclk_pin, spi_software_mosi_pin & spi_software_miso_pin) will be the same for both the TMC2240 and the ADXL345 - the important difference is that the Chip Select (CS for the ADXL345 and EO-NSS for the TMC2240) pins are different.

Thank you very much, that’s very kind!
I’m very sorry, but I described the problem with the adxl and attached the klippy.log in my first post of this thread:
"hello,

I installed on my Voron 2.4r2 the can-bus-system with U2C and SB2240. My Octopus board is connected via USB to the pi4B+. Everything is working fine now except the ADXL sensor. When I try a “accelerometer_query” I get the error: Invalid adxl345 id (got 0 vs e5). Yes, I tried it several times. Normally this results after a bad cable connection but in my case there is no cable and the rest of the bus-systems works fine.

Does anybody have suggestion what to do?

Thanks in advance!"
klippy.log (581.4 KB)

Does everything else work okay on this SB2240?

Did the ADXL345 ever work with this board? Has the board sustained any kind of damage or have to put a soldering iron to it?

I’m wondering if the chip (or how it is soldered to the board) has a problem.

Yes, everthing works like a charme except the ADXL which never worked.
I had a closer look to the pcb with a magnifiying glass and couldn’t see any damage. Till now I didn’t solder anything but I thougt about changing the chip on the board because I have an old standalone adxl345 board lying around.

Maybe I have to consider that the chip is faulty. But unfortunately the SB2240 is not available at the moment and I’m very satisfied with it. The extruder motor is so silent - you can hardly hear it working…

Sorry, I wish I had something better than to suggest than the ADXL345 chip or its soldering onto the board is bad. It’s the last place I want to be but it looks like you’ve done everything right and if everything else is working correctly…

If you’ve never soldered anything before then the LGA (Land Grid Array) package of the ADXL345BCCZ is not a good place to start.

I don’t know where you’re located but on AliExpress, the “BIQU Store” has 11 of them available at the moment:

https://www.aliexpress.com/item/1005007495318084.html

It’s not a bad price (better than the “BTT Store”) but you have to pay for shipping.

I found it on both Amazon and EBay but at much higher prices (and shipping).

If you’re fine spending a bit more, FYSETC sells an ADXL345 built into an RP2040 (called a portable input shaper), which you can plug in with a USB-C to your Klipper host. It has mounting holes for the SB, too.

Thank you guys! I will try to solder it first. I can‘t damage it more because it‘s not working anyway :wink:
If it is not working I‘ll buy something new…

The best results will be achieved when mounting the IMU directly to the nozzle for measurement. You will not need it on a daily basis anyway.
I’d recommend form factors like https://biqu.equipment/products/adxl-345-accelerometer-board-for-36-stepper-motors