i2C multimaster arbitration for the cube

Hello

I have a bunch of I2C range finders that I want to use on the cube as a forward facing and downward facing rangefinders. But I also want to feed that range finder output to a logging board so I can separately log the data.

Currently we have a separate board for logging because we have many specialized sensors that we use and we have a specialized logging system that stores all of our data. So the range finder needs to be logged in this system. We also need that data to go to the cube for the auto pilot.

The way I have it configured is that the Cube and the logger (which is an RP2040) are both I2C masters that make requests to the rangefinders to acquire their data. However when I set this up it would work for a couple of seconds before the whole bus would crash. What I think is happening is that the RP2040 and the Cube are making I2C requests at the same time causing a message collision and causing the whole system to crash. In the I2C communication paradigm there is a concept known as multi-master arbitration, basically it allows for multiple masters to talk on the same bus, the RP2040 library I’m using for I2C communication uses this I believe by default from what I’ve read but I don’t think the Cube supports it (I may be wrong). I wanted to know if there was any way to configure ardupilot to operate in an i2c multimaster system?

Hey,
I’m also facing a similar issue, I have a TFMini-S and a airspeed sensor both works on I2C. As I’m using a orange cube plus, which has a single I2C port I have to use a I2C splitter.
When I connect the sensor to splitter and one sensor starts to work if I connect another sensor none work.
Individually anyone works.
I tried powering them externally, still didn’t work.

While I don’t know for sure, I’ll venture a reasonably educated guess that multimaster mode isn’t possible without a firmware change.

If you want a “right now” solution, use a Lua script on the Cube to poll the rangefinder data and dump it to serial (or I2C on a separate address). Then connect your companion hardware to the associated port to gather the data as you please.

@tailor - your issue is separate and does not concern multimaster I2C. Start a new topic and include the hardware details. You may be facing an I2C address conflict.

1 Like

So I did find a work around that worked for us,

What we did was we plugged the I2C range finders directly into the cube and then we connected a CM4 to the cube using a UART connection allowing us to read the data using MAVLINK. We then wrote a python script that runs on the CM4 and reads this data and then serializes it for our logging system to read. Then over another UART connection sends that serialized data to our RP2040 where it’s deserialized and logged.

This may seem like a very convoluted way of doing it but be aware this is a snippet of a much larger system and this makes sense when you account for that larger system.

Your specific case is a little different though, I think Yuri is right I don’t believe you’re having a multi master issue, the TFMini-S and airspeed sensor should both be slave devices. It may be an issue with both devices having the same address? like Yuri said make a new topic post if you haven’t already and then maybe link it here in a response just in case.