0

NOT READING SENSOR ADDRESS ON ADAFRUIT TCA9548A MUX BREAKOUT
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: NOT READING SENSOR ADDRESS ON ADAFRUIT TCA9548A MUX BREA

by adafruit_support_bill on Tue Oct 16, 2018 8:06 pm

The tcaselect example code works well for a single multiplexer. but it does not allow you to de-select all channels. So when using multiple TCA9548, each multiplexer will have at least one channel active at all times.

Code: Select all | TOGGLE FULL SIZE
void tcaselect(uint8_t i) {
  if (i > 7) return;
 
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission(); 
}


To deselect all channels, you need to write a 0 to the multiplexer. If you modify tcaselect as follows, you can turn off all channels by passing a -1.
Code: Select all | TOGGLE FULL SIZE
void tcaselect(uint8_t i) {
  if (i > 7) return;

  if (i < 0){
    Wire.beginTransmission(TCAADDR);
    Wire.write(0);
    Wire.endTransmission(); 
    return;
  }
 
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission(); 
}

adafruit_support_bill
 
Posts: 70056
Joined: Sat Feb 07, 2009 10:11 am

Re: NOT READING SENSOR ADDRESS ON ADAFRUIT TCA9548A MUX BREA

by MICK_1985 on Tue Oct 16, 2018 10:42 pm

Thanks for your answer. It worked with just changing the type of variable from uint8_t to int8_t so it could take the (-1) negative value to deselect all channels.

Thanks for the quick response.

MICK_1985
 
Posts: 3
Joined: Tue Oct 16, 2018 7:33 pm

Re: NOT READING SENSOR ADDRESS ON ADAFRUIT TCA9548A MUX BREA

by adafruit_support_bill on Wed Oct 17, 2018 5:46 am

Good to hear. Thanks for the follow-up.

adafruit_support_bill
 
Posts: 70056
Joined: Sat Feb 07, 2009 10:11 am

Re: NOT READING SENSOR ADDRESS ON ADAFRUIT TCA9548A MUX BREA

by john_galt on Wed Oct 24, 2018 10:32 am

Mick,

Could you pleas share your modified "tsaselect" function? I'm having a heck of a time
getting mine to work.

Thank you,


Doug

john_galt
 
Posts: 55
Joined: Thu Oct 29, 2015 6:49 am

Re: NOT READING SENSOR ADDRESS ON ADAFRUIT TCA9548A MUX BREA

by MICK_1985 on Wed Oct 24, 2018 10:45 am

john_galt wrote:Mick,

Could you pleas share your modified "tsaselect" function? I'm having a heck of a time
getting mine to work.

Thank you,


Doug


Doug,

This is what I got working

void tcaselectmc2(int8_t i){
if (i > 7) return;
if (i < 0){
Wire.beginTransmission(TCAADDRMC2);
Wire.write(0);
Wire.endTransmission();
return;
}
Wire.beginTransmission(TCAADDRMC2);
Wire.write(1<<i);
Wire.endTransmission();
}

I changed the function variable from uint8_t to int8_t so it will take a negative value. I have three MUX in my project and this is for mux2 every time I want to activate one for the channels on mux2 I pass the value (o to 7) and pass (-1) to the other two mux to deactivate them.

void MuxPortDeactivator (int port){

switch(port){
case 1:
tcaselectmc2(-1);
tcaselectmc3(-1);
break;
case 2:
tcaselectmc1(-1);
tcaselectmc3(-1);
break;
case 3:
tcaselectmc2(-1);
tcaselectmc1(-1);
break;
}
}

I call this function every time I want to change the multiplexer I'm going to read and pass the number of the mux I want to read so the other two get deactivated.

Hope this helps.

Cheers.

MICK_1985
 
Posts: 3
Joined: Tue Oct 16, 2018 7:33 pm

Re: NOT READING SENSOR ADDRESS ON ADAFRUIT TCA9548A MUX BREA

by john_galt on Wed Oct 24, 2018 11:11 am

Mick,

Thank you so much! Now I think I may be able to get mine working.

Doug

john_galt
 
Posts: 55
Joined: Thu Oct 29, 2015 6:49 am

Please be positive and constructive with your questions and comments.