Go Down

Topic: TCA9548a (Read 441 times) previous topic - next topic

Matthewp179

Hello I was wondering if I could get some help with the TCA9548a. I was trying to use it to connect multiple slaves and have a master TCA9548a which has the A0 pin pulled high for an address change. It is just I need to make a scanner that scans for the other TCA9458a and then scans for I2c addresses on those busses. Help please!

DrDiettrich

Do you know how the TCA9548 works?

The code varies, depending on how you connect the two chips. In either case it's a modification of the I2C sniffer.

TomGeorge

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html 

Have you googled      tca9548a arduino

Thanks.. Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

Matthewp179

Yea I've been doing a lot of research everywhere. I actually have been getting a lot of help from the adafruit admin. You can find a link to that post here:
https://forums.adafruit.com/viewtopic.php?f=8&t=136752&start=30
I'm about to change my pin connections to those as suggested by the admin to connect all the SDA and SCL lines together. He has been helping me a lot and we have been debugging my project.

Wawa

#4
Jun 15, 2018, 02:21 am Last Edit: Jun 15, 2018, 02:41 am by Wawa
Why do you think you need the TCA9548.
Multiple slaves can all have their own I2C address, and can be connected to the same two I2C bus pins.
Multiple MPU9250 can be connected to the same I2C bus, with their CS pin changed 'on the fly' by a digital pin.
Tell us what you're really trying to do.

And why the cross-posts.

https://forum.arduino.cc/index.php?topic=550359.0
https://forum.arduino.cc/index.php?topic=544584.0

Leo..

Matthewp179

Oh I don't know. I was just experimenting. I didn't know that you could just wire mpu9250s together and still get a fast data read from them. I don't even know that much about arduino in the first place. In fact I am pretty new to all this so I ended up trying to find some help across the web. I tried to delete those posts and it is mainly because no one replied. Either way I don't think what arduino I chose really matters. Nor do my project specifictions I just want to make it work so I can work on other things. I really just want to make mocap.

Wawa

#6
Jun 15, 2018, 02:58 am Last Edit: Jun 15, 2018, 03:03 am by Wawa
You can only read one sensor at the time, no matter how you connect it.

No one replied, because you didn't provide the information required to help you.
Read the forum rules.

Did you already Google something like "Arduino multiple MPU9250".
Leo..
 

Matthewp179

Basically so far I have tried wiring it two ways...

Method #1

With all the SCL SDA line wired together sent to the arduino

the other...

Method #2

Having a master TCA with A0 pulled high and having the others connected to SC0 SD0 and SC1 SD1

Method #1 didn't seem like the solution as it didn't register the separate ports on master bus along with it registering the two 0x70 addresses on all ports.

Method #2 worked with it scanning all the ports and also registering two different 0x70 addresses on seperate ports.

I just now need code that does the same scan of the master 0x71 TCA, which we already have I believe, but needs to have one port active at a time with the 0x70 TCA. It also needs to scan the active port and its data then scan its ports as well.

Code: [Select]
#include "Wire.h"
extern "C"
{
#include "utility/twi.h"  // from Wire library, so we can do bus scanning
}

#define TCAADDR_0 0x71
#define TCAADDR_1 0x70

void tcaselect(uint8_t tcaAddr, uint8_t i) {
  if (i > 7) return;
 
  Wire.beginTransmission(tcaAddr);
  Wire.write(1 << i);
  Wire.endTransmission(); 
}


// standard Arduino setup()
void setup()
{
   while (!Serial);
   delay(1000);

   Wire.begin();

   Serial.begin(115200);
   Serial.println("\nTCAScanner ready!");

   for (uint8_t mux = 0x70; mux <= 0x71; mux++)
   {
      Serial.println("Multiplexer #"); Serial.println(mux, HEX);
      for (uint8_t port=0; port<8; port++)
      {
         tcaselect(mux, port);
         Serial.print("TCA Port #"); Serial.println(port);

         for (uint8_t addr = 0; addr<=127; addr++)
         {
            if (addr == mux) continue;

            uint8_t data;
            if (! twi_writeTo(addr, &data, 0, 1, 1))
            {
               Serial.print("Found I2C 0x");  Serial.println(addr,HEX);
            }
         }
      }
   }
   Serial.println("\ndone");
}

void loop()
{
}

Wawa

No idea yet what MPU6250 module you have (read the forum rules).

Method#1 should work if you use an address pin as chip select (connected to a digital pin).
You should post a wiring diagram (read the forum rules).
Leo..

Matthewp179

#9
Jun 15, 2018, 03:18 am Last Edit: Jun 15, 2018, 03:18 am by Matthewp179
Like I said I've already googled this and found that you actually can connect multiple sensors. Actually with a TCA you can connect up to 64 seperate I2C busses. There is a ton of projects suggesting this. It is just no one gives out code and no one is willing to help. Like I said it doesn't matter about what I've posted because I happened to post this topic and all I am doing is asking. I can't delete them anyway. I'm pretty sure I provided a lot of information. I talked about the product I was using and how I was trying to apply it. You can't expect me to add much more than that because I don't have code for it nor much experience. I also changed my design idea since making those posts so there is no way I am gonna stick with the same post that is six pages under.

TomGeorge

Hi,
google        arduino using multiple i2c devices

Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

Matthewp179

I am talking about the TCA, but I am using the mpu9250. Thanks

Wawa

#12
Jun 15, 2018, 03:32 am Last Edit: Jun 15, 2018, 03:38 am by Wawa
Still don't know if you actually NEED the an I2C muxer.
How many MPU6250 boards are you planning to use.

Still no idea which board you're using. It might also have (faster) SPI.

Multiple I2C or SPI devices should be easy.
It's exactly the same as one device (one ever use one I2C address).
You just switch to the next board with the chip select pin, and read the data in a second set of variables.
Leo..

Matthewp179

As far as I am concerned that you couldn't connect thirty five of the same i2c busses with the same address because you could only change one mpu to 0x69 and the rest would be 0x68. There aren't enough pin ins on the arduino to accomplish because having them all registered the same would just cause conflicts. Are you saying I can just have a master and slave, but just read one sensor at a time and just have it repeat?

Matthewp179

I mean that is what I read on the internet. I guess you could just disable all separate devices when reading one.

Go Up