Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Has SPI mode been tested? #37

Open
caternuson opened this issue Oct 28, 2022 · 13 comments
Open

Has SPI mode been tested? #37

caternuson opened this issue Oct 28, 2022 · 13 comments

Comments

@caternuson
Copy link
Contributor

Re this thread:
https://forums.adafruit.com/viewtopic.php?p=946036#p946036

The guide currently does not cover SPI usage.
https://learn.adafruit.com/adafruit-9-dof-orientation-imu-fusion-breakout-bno085/python-circuitpython

The library example has some code that looks copy-pasta'd (D9 ref'd twice, reset pin set as input) and the instantiation does not match the actual ctor:

wake_pin = DigitalInOut(board.D9)
wake_pin.direction = Direction.INPUT
reset_pin = DigitalInOut(board.D9)
reset_pin.direction = Direction.INPUT
bno = BNO08X_SPI(spi, cs, int_pin, wake_pin, reset_pin, debug=True)

Additionally, there does not appear to be any code in place to perform the required PS0/Wake pin assertion needed for SPI transactions:
image

@adam-rutkowski
Copy link

I see the same problem. When is it going to be fixed? I2C is hopelessly unreliable with this sensor and SPI software support is apparently non existent on Raspbery, it's hugely disappointing.

@juuuuulian
Copy link

Has anyone found a fix for this?

@tomy983
Copy link

tomy983 commented Sep 3, 2023

bno = BNO08X_SPI(spi, cs, int_pin, reset_pin, 1000000, debug=True)
this gets you just a bit further. All the rest is still not working.
It looks like the SPI implementation is completely broken.

@JeroenDelcour
Copy link

I was bummed to find out about this, because I bought this chip specifically for its SPI support. So I tried to fix it. I got a little further, but I'm stuck.

I added the SPI wake operation like so:

    def soft_reset(self):
        """Reset the sensor to an initial unconfigured state"""
        self._dbg("Soft resetting...", end="")
        data = bytearray(1)
        data[0] = 1
        _seq = self._send_packet(BNO_CHANNEL_EXE, data)
        time.sleep(0.5)

        for _i in range(3):
            try:
                _packet = self._read_packet()
            except PacketError:
                time.sleep(0.5)
        # wake up sensor
        self._wakepin.value = False
        self._wait_for_int()
        self._dbg("OK!")
        # all is good!

That seems to fix the initialization; reading the ID from the sensor worked. But doing any more reads gave me a packet with the continuation bit (0x80) set in the header's length field (see datasheet section 1.3.1). I'm not sure where that packet is coming from or how to handle it. In the current code, it's labeled as a "half packet" and it just throws a PacketError. I tried ignoring that packet, but I can't seem to get any more packets after that.

Maybe the Arduino version can provide some inspiration to someone who is better at C++ than I am.

@rotellini9809
Copy link

hi guys is a shame that spi support doesn't work on software,i hope they fix it soon

@tomy983
Copy link

tomy983 commented Jan 10, 2024

Hi @rotellini9809 and @JeroenDelcour ,
please check out my issue on the sparkfun library, I posted some code that works with spi, but had some issues with axis swapping while using spi while testing 2 bno086 (but not with i2c). Maybe you could let me know if you also have the same problem.

sparkfun/SparkFun_BNO08x_Arduino_Library#2 (comment)

@rotellini9809
Copy link

rotellini9809 commented Jan 11, 2024 via email

@rotellini9809
Copy link

rotellini9809 commented Jan 11, 2024 via email

@tomy983
Copy link

tomy983 commented Jan 11, 2024

I am unable to explain it clearly than I already did in the post I have linked 3 comments up...

@dbell37
Copy link

dbell37 commented Jul 16, 2024

Oh no, this is still broken in 2024? I started with i2c, but I'm trying to use two sensors (I set one to the alternate address and the other was kept on the stock address: 0x4B 0x4A), but unfortunately the CircuitPython code only supports one sensor. I modified the code to support adding two sensors on i2c, but it hangs at the i2c instantiation of the second sensor.
So I'm therefore trying to use SPI, but that also doesn't work.
I'll tear everything apart and try serial next. ;)

@j-wanner
Copy link

Has anybody achieved any progress in getting the BNO086 to run with SPI on a Raspberry pi? Are there any other available codebases that you could share?

Would be amazing, I'd really like to have the SPI option to increase the readout rates...

@norbinz
Copy link

norbinz commented Aug 31, 2024

Hi j-wanner,
In my experience with BNO085 in the Arduino environment, I don't see much performance difference between I2C and SPI. Also, increasing the bit rate doesn't help much. The report rate bottleneck seems to be inside the BNO's processing/firmware.

I2C experiment: https://forums.adafruit.com/viewtopic.php?p=857930#p857930
SPI experiment: https://forums.adafruit.com/viewtopic.php?p=859651#p859651

@WestJeremy
Copy link

I have just found that the git repo is out of date for this device. You can go to the circuit python website and download their 8xx bundles version and there is an up to date BNO08x example that should work on raspberry pi. In that library, they include the reset pin in the class definition of the BNO08x in the SPI.py file.

Here is the bundle version I am working off of.

adafruit-circuitpython-bundle-8.x-mpy-20240917.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants