Skip to content

Support multiple of a device through mux #6

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

Closed
nseidle opened this issue May 5, 2020 · 5 comments
Closed

Support multiple of a device through mux #6

nseidle opened this issue May 5, 2020 · 5 comments

Comments

@nseidle
Copy link
Member

nseidle commented May 5, 2020

Some I2C devices support only one I2C address but benefit greatly from multiple devices being read. The NAU7802 digital scale is probably at the top of this list.

Additionally, the OLA firmware does not support multiple of a device that does have multi-address support (for example, the LPS25HB). It would be nice to support both of these if possible.

@artemtk
Copy link

artemtk commented May 6, 2020

2nd this request. Support for Sparkfun Qwiic I2C Mux would be great!

@nseidle
Copy link
Member Author

nseidle commented May 27, 2020

Alright! I think I've got a release candidate: OpenLog_Artemis-v14-RC1.zip

The branch is here. This is a large change from previous versions of OLA. Instead of creating one class at power on for each library, the classes are created dynamically.

During the detection phase, we create a linked list of detected devices. Once detection is complete, pointers from the linked list are pointed to newly formed classes. Each device has its own config setting pointer - this means you can have 17 NAU7802s and configure each one individually.

This is how the autodection algorithm works:

  1. Scan bus for muxes (0x70 to 0x77)
  2. Begin() any muxes. This causes them to turn off all their ports.
  3. With any possible muxes turned off, finish scanning main branch
  4. Any detected device is stored as a node in a linked list containing their address and device type,
  5. If muxes are found, begin scanning mux0/port0. Any new device is stored with their address and mux address/port.
  6. Begin() and configure all devices in our linked list. Connections through muxes are performed as needed.

What you get is something like this:

image

Note in the image above that there are two VL53L1Xs (a device that has only one I2C address). They both play nicely. There are also 2x BME280 and 2x CCS811. These have different address capabilities, but where hung off of various mux ports for testing.

Known issues:

  • Power cycling. See issue OLA & GPS-RTK2 - Hanging at Boot #9.
  • U-blox GPS modules can fail to detect at startup due to too many pull up resistors. See this issue but just know that removing all the I2C pullups on the bus should fix this.
  • Some sensors don't like to be power cycled. I still need to implement a way to avoid it.
  • Not really an issue, but of course the one board I don't have to test with currently is an NAU7802. It should work but I haven't tested it yet.

Overall it's a great improvement to flexibility and usability. Please kick the tires and let me know what you find.

@nseidle
Copy link
Member Author

nseidle commented May 27, 2020

More notes:

  • This RC has ExFat turned on. I haven't had any logging issues recently but it's still suspect. We can revert back to FAT if anyone has concern.

@PaulZC
Copy link
Collaborator

PaulZC commented Aug 4, 2020

I had to change the autodetection algorithm slightly:

  1. Scan bus for muxes (0x70 to 0x77)
  2. Begin() any muxes. This causes them to turn off all their ports.
  3. With any possible muxes turned off, finish scanning main branch
  4. Any detected device is stored as a node in a linked list containing their address and device type,
  5. If muxes are found, begin scanning mux0/port0. Skip any device addresses found on the main bus (otherwise we end up with ghost duplicates). Any new device is stored with their address and mux address/port.
  6. Remember to disable mux port7 when we're done scanning ports on that mux.
  7. Begin() and configure all devices in our linked list. Connections through muxes are performed as needed.

Seems to work nicely - with the NAU7802 too. This fix is currently only implemented in the V15_Candidate branch.

image

@nseidle
Copy link
Member Author

nseidle commented Aug 10, 2020

Supported in v15. Closing.

@nseidle nseidle closed this as completed Aug 10, 2020
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

3 participants