Author Topic: [I2C][UART] TXS0108e issues  (Read 773 times)

0 Members and 1 Guest are viewing this topic.

Offline mr_byte31Topic starter

  • Contributor
  • Posts: 38
  • Country: de
[I2C][UART] TXS0108e issues
« on: December 03, 2024, 09:10:22 pm »
Hi All,

I am trying to use TXS0108e module (in figure below) to interface my RPI 4 with 5v components (I2C ADC and GPS )



I connect the MPU6050 on the 3.3v SDA and SCL and connect the I2C ADC (+5v) to TXS0108e and then to the SDA and SCL (+3.3v). I attached a figure for that.

when I trigger "i2cdetec -y 1" command , I could see it give different values each time I execute it. I only have two I2C devices no more ( 3.3v and 5v modules).

The UART component doesn't work as well. I tested it with another Arduino and it works fine but it doesn't seem to work with TXS0108e.


The 3.3v and 5 volts are coming from voltage regulators (ams1117-3.3 and ams1117-5)


I appreciate your support. 
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 7133
  • Country: fi
    • My home page and email address
Re: [I2C][UART] TXS0108e issues
« Reply #1 on: December 03, 2024, 10:42:04 pm »
TXS0108E has very low logic low threshold, only 0.15V (meaning if your logic low output from RPi is say 0.2V, it is not guaranteed to be detected as logic low), and its own port A low level output can be as high as 0.55V.  Furthermore, when the TXS0108E misdetects the direction (when the logic level is low), it –– and all other similar bidirectional translators –– tends to have a "step" in its low level output, which can be interpreted as a logic high by some microcontrollers.  I'm not sure if that affects RPi 4 or not, though.

This means that for UART and SPI –– which are inherently unidirectional, each signal being in a specific direction and that direction does not change at run time –– you are much better off with unidirectional translators like TXU0102, TXU0204, TXU0304, or single signal translators like 74LVC1T45 (in SOT23-6).  I've used all of these at quite high baud rates for 1.8V to 3.3V and 3.3V to 5V, and they're worked extremely well for me.
I've seen many others have issues using bidirectional translators with UART and SPI, but they tend to be specific to particular components –– i.e., you need to have components that happen to have input/output logic level thresholds closer to the edge than the average –– so it can be very difficult to reproduce using different components from the exact same series.

Thus, while TXS0108E is pretty much perfect for I²C, I would NOT use it for UART or SPI.  I would use TXU0102 (RX+TX), TXU0204 (RX+CTS+TX+RTS), TXU0304 (SPI), or individual 74LVC1T45 in SOT23 (two for RX+TX, four for RX+CTS+TX+RTS), as I have done so and these have worked really well for me.  I do prefer the TXU0n0m, because they have Schmitt trigger inputs (robust logic level input detection).

I do also use 100nF = 0.1µF X7R or C0G/NP0 bypass capacitors between each VCC and GND (so two per TXU0n0m), as it ensures they work as promised in the datasheets; in practice, they may or may not be actually required.  See Dave's video about bypass capacitors to understand why.

For the cheapest possible solution, see my 74LVC1T45-based RX+TX translator board (in Public Domain).  It is absolutely tiny, 12.7mm × 12.7mm, and takes two 74LVC1T45W6-7 or SN74LVC1T45DBVR per board.  You can have five or ten boards manufactured at JLCPCB for $2 + shipping, buy the LVC1T45 chips off LCSC or Mouser or elsewhere for a couple of USD/EURO, and solder them yourself.  Just make sure you orient the pin 1 dot to the white silkscreen dot on the PCB, the two are rotated 180° with respect to each other.  I also have a TXU0304 SPI translator, which would also work with TXU0204 as-is (but the silkscreen O3 and I3 would need to be swapped, and the corresponding arrow/triangles mirrored).

Edited to add: Here is the corresponding TXU0204 UART translator (all files in Public Domain).  In addition to a TXU0204PWR (JLCPCB/LCSC C4363888, Mouser 595-TXU0204PWR), you need two 0.1µF = 100nF X7R capacitors in 0805 or 0603 footprint (perhaps Samsung CL21B104KBCNNNC in 0805, or CL10B104KB8NNNC in 0603).
« Last Edit: December 04, 2024, 02:25:34 am by Nominal Animal »
 

Offline mr_byte31Topic starter

  • Contributor
  • Posts: 38
  • Country: de
Re: [I2C][UART] TXS0108e issues
« Reply #2 on: December 05, 2024, 10:17:34 pm »
Many thanks for the reply. Highly appreciate it.

I will definitely give a try to TXU0204 for UART.

when you say that TXS0108E is perfect for I2C , do you know how could I fix my issue to make it work ? this issue is annoying me and I can't figure out any option.

I have found other modules on internet that use BSS138 and few resistors to make the logic conversion. reference : https://www.adafruit.com/product/757
 do you believe this can be better option ?
« Last Edit: December 05, 2024, 11:04:05 pm by mr_byte31 »
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 7133
  • Country: fi
    • My home page and email address
Re: [I2C][UART] TXS0108e issues
« Reply #3 on: December 05, 2024, 11:47:56 pm »
when you say that TXS0108E is perfect for I2C , do you know how could I fix my issue to make it work ? this issue is annoying me and I can't figure out any option.
My sincere apologies: I absolutely forgot about that part!  (Me fail, once again.)

Did you forget the pull-up resistors?

You see, I²C is an open collector bus, which is just a name for a bus where all devices on the bus can only pull the signal lines to ground.  They cannot actually push or pull the signal line to any specific positive voltage.  To ensure the signal lines are high, we need to use specific resistors.

Note that only one resistor is needed per signal, i.e. one resistor between SDA and VCC, and one resistor between SCL and VCC.  You do not need one resistor per signal per device; just one per signal line.  (If you were using the 3Mbit/s or 5Mbit/s data rates, then it might be useful to use one resistor at each end of each signal line, twice the resistance of a single resistor, but those speeds are extremely rare in Arduino land.)

The lower the resistor value, the more current runs in the signal wires (when pulled to ground).  These resistors vary from 1k to 10k, with 2.2k most common.  The smaller the current, the closer to ground the device can pull the signal line.

When using bidirectional translators like TXS0108E for I²C, it is also important to realize that the signal line on each side of the TXS0108E requires their own pull-ups; the pull-up does not "pass through" the TXS0108E.

To connect the MPU6050 to RPi, you need:
  • Wire from RPi GND to MPU6050 GND
  • Wire from RPi +3.3V to MPU6050 VCC
  • Wire from RPi SDA to MPU6050 SDA
  • Wire from RPi SCL to MPU6050 SCL
  • 2.2k resistor between SDA and +3.3V
  • 2.2k resistor between SCL and +3.3V
Wire this up, and test.

To connect the ADC to RPi, use:
  • Wire from RPi GND to TXS0108E GND
  • Wire from RPi +3.3V to TXS0108E VCCA
  • Wire from RPi +5V to TXS0108E VCCB
  • Wire from RPi SDA to TXS0108E A3
  • Wire from RPi SCL to TXS0108E A4
  • Wire from RPi GND (or TXS0108E GND) to ADC GND
  • Wire from RPi +5V (or TXS0108E VCCB) to ADC VCC
  • Wire from TXS0108E B3 to ADC SDA
  • Wire from TXS0108E B4 to ADC SCL
  • 2.2k resistor between RPi SDA (or TXS0108E A3) and +3.3V.  (This is the same SDA resistor as in the previous test.)
  • 2.2k resistor between RPi SCL (or TXS0108E A4) and +3.3V.  (This is the same SCL resistor as in the previous test.)
  • 2.2k resistor between ADC SDA (or TXS0108E B3) to +5V.
  • 2.2k resistor between ADC SCL (or TXS0108E B4) to +5V.
I recommend you try the above separately first.  When both work separately, you can combine them.  Note that when combining, you only need four resistors, not six.

Note that TXS0108E cannot supply much current on its outputs.  If you want to switch power to peripherals on and off, you need something called a "high-side switch".  For +3.3V, a single P-channel MOSFET suffices (I like DMP3099L for Arduino peripherals); for higher voltages, you need a P-channel MOSFET and either an N-channel MOSFET or NPN transistor.  You'll also need a current-limiting resistor (for the GPIO pin –– MOSFET gates behave like capacitors, so when changing state, may draw uncomfortably much current from the GPIO pin, which the resistor limits to safe values, only slowing the switching action a tiny bit), and a pull-up/down resistor to set the state of the "high-side switch" when the GPIO pin is an input.

I have found other modules on internet that use BSS138 and few resistors to make the logic conversion.
These have their own problems, especially switching speed.  I consider them in the same class as other bidirectional voltage level translators.

In general, I do like BSS138 (although I tend to use NX138AK instead, which is slightly faster switching, but otherwise almost identical, in three-pin SOT23 footprint) for my 2.5V to 12V signal-related N-channel MOSFET needs.

I'm only a hobbyist myself, mostly using microcontrollers with native USB interfaces (like Teensy) to add user interfaces and other stuff to Linux-based SBCs and appliances like routers and TV boxes.  I don't like the hardware compromises in USB implementations on the Raspberry Pis, and I don't like how the Foundation does not directly interface to the open source projects they rely on and insist hiding anything Linux or Open Source by their own naming schemes.

It is exactly because of a lack of existing voltage translation modules for UART and SPI that I created my own.  (The very first one I did, was one using two 74LVC1T46 IC's in SOT23 footprint, to interface a Teensy LC to the 1.8V UART on Odroid HC1.)  After that, I noticed that when connecting separately-powered devices (like my desktop computer with a properly grounded supply) to other devices using wall warts (we have unpolarized "Schuko" sockets here; no live and mains, both are live, so ungrounded supplies 0V/GND level floats somewhere not even close to true ground), I was getting ground current loops (because their GNDs were at different potentials), and started using isolators too.  (I particularly like TI ISO6721, which is very similar to TI TXU0102, allowing different supply voltages on each side, but also isolates the two GNDs.)  Note, however, that I've been ridiculed for that here, so I might be doing things wrong.  I don't believe so, of course, based on the results I get.

The Schmitt trigger inputs on the TXU0n0m inputs also mean that when the GPIO pin they are connected to is floating (an input, during bootup when it is not yet configured as an UART pin), no excess current will flow.  When the pin floats at an intermediate voltage (for 3.3V CMOS logic like RPi 4 uses, 0.8V and below is "low", and 2.0V and above is "high"; so between 0.8V and 2.0V in this case), and it is connected to the gate or base of a transistor, the transistor may be in its linear region, and instead of either fully conducting or non-conducting, acts like a resistor (with its resistance depending on the voltage on the gate; as described by its gate-source voltage to on-state resistance curve, if given, in the datasheet).  That means it can waste power and generate excess heat.  The Schmitt trigger inputs avoid all that, even if their output is used to control a transistor gate or base.
« Last Edit: December 06, 2024, 11:36:49 pm by Nominal Animal »
 

Offline mr_byte31Topic starter

  • Contributor
  • Posts: 38
  • Country: de
Re: [I2C][UART] TXS0108e issues
« Reply #4 on: December 06, 2024, 09:51:53 pm »
Many thanks for the answer.

I am a bit confused when you use TXB0108E instead of my issue with TXS0108E.

I checked datasheet for TXB0108E and I see it is not recommended for I2C. Please check attached figure.


regarding TXS0108E, I checked the datasheet when I started my project and I understood that there is a smart pull-up resistors internally. The mentioned that external pull-up resistors are not required so I didn't connect any external pull-up resistors to both side of TXS0108E.
Please check attached figure.
« Last Edit: December 06, 2024, 09:54:33 pm by mr_byte31 »
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 7133
  • Country: fi
    • My home page and email address
Re: [I2C][UART] TXS0108e issues
« Reply #5 on: December 06, 2024, 11:36:06 pm »
I am a bit confused when you use TXB0108E instead of my issue with TXS0108E.
Just a typo.  (My concerns apply to both, though.)  I did mean TXS0108E throughout, the I²C-appropriate one, just got the two mixed up.  I've edited the post to avoid misleading/confusing others.

See section 7.2 in the TXS0108E datasheet (PDF).  The integrated pull-ups are equivalent to 4kΩ/40kΩ (depending on state, as they are active and not simply resistors), which may not be enough.  I would definitely add external pull-up resistors, and do the tests, as I described.  Only after the tests are successful, would I consider testing without the pull-up resistors.

The exact pull-up strength (resistance needed) depends on the devices connected.  Even in of the same PCB no pull-ups would be needed between TXS0108E and other devices, when you use wires the pull-ups may be necessary for a number of reasons, biggest reason being capacitively or inductively coupled noise.  Adding external pull-up resistors means more current is used, which means such coupled noise affects the signal voltage less.
« Last Edit: December 06, 2024, 11:37:52 pm by Nominal Animal »
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6332
  • Country: es
Re: [I2C][UART] TXS0108e issues
« Reply #6 on: December 06, 2024, 11:38:13 pm »
It'll probably work with pullups to 3.3V, skipping the level shifter entirely.
Which ADC?
« Last Edit: December 06, 2024, 11:42:13 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline mr_byte31Topic starter

  • Contributor
  • Posts: 38
  • Country: de
Re: [I2C][UART] TXS0108e issues
« Reply #7 on: December 07, 2024, 07:49:44 pm »
I added 2K ohm pull-up to SDA and SCL on both sides (+3.3v and 5v )

still the I2C is crazy and giving random values. :(
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6332
  • Country: es
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 7133
  • Country: fi
    • My home page and email address
Re: [I2C][UART] TXS0108e issues
« Reply #9 on: December 08, 2024, 02:16:42 am »
I added 2K ohm pull-up to SDA and SCL on both sides (+3.3v and 5v )
still the I2C is crazy and giving random values. :(
So, do what I suggested, and start by connecting the 3.3V MPU6050 directly to your RPi (with 2K pull-ups on both SCL and SDA), and see if that works.

You see, right now there are dozens of places where the problem might be.  It could be any of the hardware, even the RPi.  Or it could be some kind of misconfiguration; perhaps you're using the wrong pins.  (See the GPIO pin mapping in Linux to the pin labels on the RPi silkscreen.)  You might be using the wrong Device Tree Overlay (say, one for RPi 2 instead of what you're using now).

By doing things one step at a time, you limit the possible candidates, making troubleshooting much easier.

By avoiding that, you're making it very difficult to find the actual problem.  I don't like the "throw spaghetti at the wall, and see what sticks" approach (trying the easiest thing to see if it fixes the problem), and I don't like that you're refusing to test things one step at a time like any engineer or scientist or practical hobbyist should, and I suspect my posts are too long for you to bother to even read fully, so I will not waste both of our time any longer interacting with you.  I do hope you solve your problem, though!
 

Offline mr_byte31Topic starter

  • Contributor
  • Posts: 38
  • Country: de
Re: [I2C][UART] TXS0108e issues
« Reply #10 on: December 08, 2024, 02:12:03 pm »
https://e2e.ti.com/support/logic-group/logic/f/logic-forum/909479/txs0108e-txs0108e-connected-i2c-devices

I am aware about this topic and it is not working for me since the thread is based on wrong assumptions ( remove VCC_A)

I added 2K ohm pull-up to SDA and SCL on both sides (+3.3v and 5v )
still the I2C is crazy and giving random values. :(
So, do what I suggested, and start by connecting the 3.3V MPU6050 directly to your RPi (with 2K pull-ups on both SCL and SDA), and see if that works.

You see, right now there are dozens of places where the problem might be.  It could be any of the hardware, even the RPi.  Or it could be some kind of misconfiguration; perhaps you're using the wrong pins.  (See the GPIO pin mapping in Linux to the pin labels on the RPi silkscreen.)  You might be using the wrong Device Tree Overlay (say, one for RPi 2 instead of what you're using now).

By doing things one step at a time, you limit the possible candidates, making troubleshooting much easier.

By avoiding that, you're making it very difficult to find the actual problem.  I don't like the "throw spaghetti at the wall, and see what sticks" approach (trying the easiest thing to see if it fixes the problem), and I don't like that you're refusing to test things one step at a time like any engineer or scientist or practical hobbyist should, and I suspect my posts are too long for you to bother to even read fully, so I will not waste both of our time any longer interacting with you.  I do hope you solve your problem, though!

My devices on I2C ==> MPU is connected to 3.3v and I2C compass is connected to 5v


Let me tell you what is the test cases I did:
  • MPU(3.3v) connected directly to RPI with no pull-up: it works fine
  • MPU(3.3v) connected directly to RPI with 2K pull-up : it works
  • MPU(3.3v) connected directly to RPI with 2K pull-up and TXS0108e connected to compass (5v): it doesn't work
  • MPU(3.3v) connected directly to RPI with 2K pull-up and TXS0108e connected to compass (5v) and connected to 2K pull-up: it doesn't work
  • MPU(3.3v) connected directly to RPI and connected directly to compass (5v) without pullup and without TXS0108e: it works

Note: RPI max voltage is around 4.5 and shall not be connected to 5v. I just did that to prove that all my configurations are correct and the issue starts when TXS0108e is in the middle.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf