Bi-Directional Logic Level Converter

Trying to convert 5V to 3.3V for serial interface
With this module it works:

With chip SN74ALVC164245 it is not working: http://www.ti.com/lit/ds/symlink/sn74alvc164245.pdf
I connected DIR pin to gnd - so the chip should work in one direction and would expect Mega in a listening mode.

What I'm doing wrong?

Can't tell if you don't provide the circuit you are using.

I could guess failure to activate #OE input, failure to supply right voltage to both rails, failure to decouple the supply rails, getting the pinout wrong, bad solder joint or connection...

If you're only listening, then you only need one resistor. Two resistors is slightly better. No chips or modules required. Even the value of the resistor isn't very important. Anything between 1K and 100K should work unless the wires are long or there's something else you didn't tell us.

Thank you guys, I think I've figure out:
SN74 is configured only for one direction.
So Arduino says to Serial - 'give me data, I'm ready'
But SN74 is working only one way - to receive for arduino (in my case) i.e. whatever arduino says is blocked.
The only way is to configure part of the chip as receiver for RX and another part as transceiver for TX signals.
This bidirectional PCB from 1 transistor is working both ways without any explicit switch.
Now surprised: what was the reason to develop so complicated chip without this simple logic as it's done with mosfet transistor - that works good in a both ways without any external switch.
OK. with serial it's clear, at least in theory it can be done.
How to convert I2C?
There are 2 wires as well, it also should be a 'send message'/'receive message' which of them to transfer and which to receive?

NXP (the owner of the I2C standard) has a nice application note which tells you how to design that converter board in the first post. It tells you how the converter "knows" which direction to send data. If you haven't found that yet, you should search for it.

The "74" in that chip number tells me that it's part of the 7400 logic family. That's very old. Like 1970s old. The datasheet I find on a quick Google search is dated 1994, which is probably about the time that I2C was invented. So the chip wasn't designed for I2C but some other bidirectional communication system.

Datasheets like that can be a little bit weird. The name of the bus it was designed for was probably copyrighted by the owner of the bus standard. So TI couldn't use the name of the bus without paying a license fee. So they will use some other generic name or they won't name the standard at all, leaving us to guess 25 years later.

MorganS:
NXP (the owner of the I2C standard) has a nice application note which tells you how to design that converter board in the first post. It tells you how the converter "knows" which direction to send data. If you haven't found that yet, you should search for it.

The "74" in that chip number tells me that it's part of the 7400 logic family. That's very old. Like 1970s old. The datasheet I find on a quick Google search is dated 1994, which is probably about the time that I2C was invented. So the chip wasn't designed for I2C but some other bidirectional communication system.

Datasheets like that can be a little bit weird. The name of the bus it was designed for was probably copyrighted by the owner of the bus standard. So TI couldn't use the name of the bus without paying a license fee. So they will use some other generic name or they won't name the standard at all, leaving us to guess 25 years later.

The full name SN74ALVC164245
Meanwhile converter on simple mosfet transistors is working well it's not a best solution to convert 20 wires.
This chip is serving 16 lines.

The SN74ALVC164245 requires a “direction” input, without that input, it only converts in one direction. The I2C converter module requires no such direction control.

The only bi-directional level conversion chip without direction control that I’m aware of is the TI TXB0108

It sounds like you’re dealing with a half-duplex system without you knowing when the system is transmitting or receiving. Schematics would would be required to assist further.

kapelan:
The full name SN74ALVC164245
Meanwhile converter on simple mosfet transistors is working well it's not a best solution to convert 20 wires.
This chip is serving 16 lines.

What is the application for 20 bidirectional lines? Give us more detail to work with.

kapelan:
OK. with serial it's clear, at least in theory it can be done.

Serial is unidirectional - on a per wire basis. That makes Serial not just "in theory" doable but dead easy to do. 5V Tx to 3.3V Rx needs a voltage divider, the 3.3V Tx to 5V Rx usually nothing at all (for most 5V systems, including the AVR based Arduino, 3.3V is enough to read as logic high).

How to convert I2C?

That's a harder one. SCL is easy - it's always from master to slave; SDA is bidirectional and the normal Wire library is not equipped with a "direction" signal. It would be in theory possible with that chip, but the MOSFET solution is much easier, though won't work for high speed I2C (>400 kHz).

Now what is your application, really? What signals do you try to shift?

Hi,
What devices are you trying to connect via I2C?
Some devices, although they are 3V3 powered are 5V I2C tolerant.
Also the I2C lines need pullup resistors which will help select the 3V3 or 5V level.

Link to spec/data of the device you are trying to connect to the Mega please.

Thanks.. Tom.. :slight_smile:

WattsThat:
...The only bi-directional level conversion chip without direction control that I’m aware of is the TI TXB0108...

I've tried TXB0108 it does not work with Mega2560 serial.

MorganS:
What is the application for 20 bidirectional lines? Give us more detail to work with.

Touch screen requires a lot of connections. And for those who loves resistors - yes it works with resistors,
but what is better 1 chip or 20 resistors?

TomGeorge:
...Some devices, although they are 3V3 powered are 5V I2C tolerant....

not all of them : https://www.digikey.com/en/datasheets/honeywellmicroelectronicsprecisionsensors/honeywell-microelectronics-precision-sensors-hmc5883l

kapelan:
I've tried TXB0108 it does not work with Mega2560 serial.

Wrong tool for the job: Serial signals are not bidirectional; one has to be shifted down, the other up (and only if <3V). One direction per signal only.

Touch screen requires a lot of connections. And for those who loves resistors - yes it works with resistors,
but what is better 1 chip or 20 resistors?

20 resistors that do the job at hand is better than 1 chip that doesn't. It depends on what exactly you want to do, which you STILL didn't explain.

I thought a touch screen would need just 5 wires, not 20. 3x for the SPI and 2x SS to select display or touch panel. But if it's SPI those MOSFET based level shifters won't work... and anyway only the signals from Arduino to display need shifting (CLK, MOSI and the SS lines), the return signals (MISO) not.

If you want a suggestion that works for your special touch screen (20 signal wires?!) do post link to your specific display and let us know which exact interface you intend to use with it (had you done so in post #0 you'd probably have a complete working solution already...).

Okay, a parallel LCD may have 20 connections but none would require a bi-directional converter.

Pretty much any device with both inputs and outputs that require level conversion use two devices unless you use the inputs at the lower voltage and don’t bother to level shift as is done with just resistors on the high voltage side.

Until you post a schematic and part numbers, or at least a block diagram, this thread cannot provide a solution.

[sarc]
If you had things working with resistors and you now just want to complicate the solution with active devices, at least you're wasting your time (as well as ours).
[/sarc]

Hi,
Can you please post link to data/specs of the Touch Screen?

Thanks.. Tom.... :slight_smile:

TomGeorge:
Hi,
Can you please post link to data/specs of the Touch Screen?

Thanks.. Tom.... :slight_smile:

touch: 3.2 TFT LCD Touch Shield

WattsThat:
If you had things working with resistors and you now just want to complicate the solution with active devices, at least you're wasting your time (as well as ours).

That's wrong assumption.
I have things working with the chip and trying to add to the same chip serial lines to make life simple.
Also tested TXB0108 and surprised that it is not working as described.

W

kapelan:
touch: 3.2 TFT LCD Touch Shield

That one doesn't appear to need any level shifting at all, as it can operate at both 5V and 3.3V levels:

When using the Arduino 3.2 TFT Touch shield V1 with 5V operation level development board – like Arduino MEGA and so on, set the operation voltage level switch to 5V side.

When using the Arduino 3.2 TFT Touch shield V1 with 3.3V operation level development board set the operation voltage level switch to 3.3V side.

So, why bother?