05-31-2018 01:47 PM
I have a working i2C Labview program using NI USB-8451. I want to use a TCA9548A Muliplexer so I can switch SDA and SCL ports. The best I understand with the TCA9548A is you address at 70 and write 0 - 7 to switch the i2C channels. After writing 1, I thought it would open Channel 1 and I could then do normal i2C reading/writing.
I can read/write to the TCA9548A, but, I can never go past the TCA9548A to another port to read i2C data. What I did is simple, I took a known working i2C harness and spliced the TCA9548A into the SDA and SCL lines.
The error message is always the same from Labview:
"Error -301742 occurred at NI-845x I2C Write Read.vi:1370002
Possible reason(s):
NI-845x: The slave did not acknowledge an address+direction byte transmitted by the I2C master. If you are using ACK polling, consider increasing the timeout. Other reasons include the incorrect address set in the I2C configuration or the incorrect use of the 7-bit address. When entering an address to access a 7-bit device, do not include the direction bit. The NI-845x Basic I2C API internally sets the direction bit to the correct value, depending on the function (write or read). If your datasheet specifies the 7-bit device address as a byte, discard the direction bit (bit 0) and right-shift the byte value by one to create the 7-bit address."
Does anyone have a working example of Labview code and the TCA9548A? Or can anyone look at my code and tell me what I'm doing wrong?
Attached are some screenshots of my code and front panel.
Thank you!
Solved! Go to Solution.
05-31-2018 02:31 PM - edited 05-31-2018 02:33 PM
@Dhubbell wrote:
I have a working i2C Labview program using NI USB-8451. I want to use a TCA9548A Muliplexer so I can switch SDA and SCL ports. The best I understand with the TCA9548A is you address at 70 and write 0 - 7 to switch the i2C channels. After writing 1, I thought it would open Channel 1 and I could then do normal i2C reading/writing.
Writing a value of 1 to the control register doesn't open channel 1, it opens channel 0. To open channel 1 you need to write the value 2. The eight channels are mapped to the eight bits in the control register.
05-31-2018 04:48 PM - edited 05-31-2018 05:02 PM
Thank you arteitle for your reply and suggestion. I have tried different address values including 2 and I still cannot read data.
Can you confirm my belief on the behavior of this TCA9548A Chip?
I think the TCA9548A is supposed to take a MASTER SDA and SCL from the USB-8451, then switch to a channel PORT. This way I will only have one active PORT open at a time. I'm not trying any other i2C on the bus right now, I only have one connected. My hope is that I can have multiple i2C devices with the same address and switch to one port at a time using the TCA9548A.
Can you think of any other ways of checking these values in NI I/O trace? See my attached NI IO traces...with TCA9548A code and with TCA9548A removed.
Thank you!
06-01-2018 08:27 AM
Unfortunately I don't have any experience with the USB-8451, but I do have experience with I2C. You're correct about what the TCA9548A can be used for; you should be able to connect any or all of the eight channels to the master by sending the chip the appropriate command, allowing you to select between multiple devices with the same address. Can you share a drawing of your circuit so we can make sure the TCA9548A is connected correctly?
06-01-2018 02:00 PM
Thank you for showing Interest. I appreciate your help.
Here's a crude drawing I did by hand to help illustrate how I have it hooked up. I'm thinking I should be able to do this sequence:
1) Address the TCA9548A at the default address 0x70.
2) Write a Channel Number to the TCA9548A and the channel or port then becomes open to i2c commands.
So far I can verify I'm reading and writing values to the TCA9548A
3) At this point, my belief is after the channel or port is open, then I can address other i2C on the port that is open. When I try to read the Temp Sensor SE97B at Address 0x18, I get nothing.
After I open the port/channel on the TCA9548A, do I need to address the SE97B differently than the original address of 0x18? It's no longer a direct connect, but, it goes through the TCA9548A.
Thanks again for looking this over for me!
06-01-2018 02:34 PM - edited 06-01-2018 02:35 PM
Does the USB-8451 have built-in pull-ups on its SDA and SCL pins? From what I've been able to find it looks like no. There need to be separate pull-ups on all of the TCA9548A's I2C ports, as well as on its RESET# line. With the SE97B connected directly to the 8451, the 10k resistors you show will pull the I2C bus between the SE97B and 8451 up to 3.3V. But with the TCA9548A in between, if you're powering it from 5V like you show, then you'll also need separate pull-ups to 5V on its SDA, SCL, and RESET# pins. Regarding #2, again, you don't write a channel number to the TCA9548A, you write a 1 to the bit corresponding to the port(s) you want to enable. Once the port is enabled you can talk to the device on it just like you would if it were directly connected, no special addressing needed.
06-01-2018 03:33 PM
@arteitle
Thank you for the suggestion. Let me try this next week and I'll report my findings. You've been extremely helpful.
08-04-2018 02:42 PM
Hey could you share your solution , I am trying to use the I2C multiplexer and am not able to read the acknowledgement bit after writing the values to the driver board.
08-06-2018 09:48 AM
@Hazmat wrote:
Hey could you share your solution , I am trying to use the I2C multiplexer and am not able to read the acknowledgement bit after writing the values to the driver board.
Here's a simple vi that will toggle between two addresses on the TCA9548A using NI-USB-8451. I hope this helps. After you toggle the TCA9548A, then all normal i2c commands will be acknowledged as if you were directly connected.
08-13-2018 10:47 AM
Thank you... It worked!!