5v <-> 3.3V level shifting

16 Dec 2010

As most of my peripheral circuits run on 5V, I need some way of level shifting.

So far I have just ignored this, and most of the time it works, but I would like to avoid the 'unsafe' feeling it gives me.

I've seen discrete versions of bidirectional level translators consisting of just one FET.

I'd prefer a chip with 8-10 lines, not necessarily bidirectional.

 

What do you use?

 

16 Dec 2010

TXS0108EPWR,

from Farnell (1702548)

at £2, will work well, sadly it is a SMD package,

 

ROTH ELEKTRONIK RE933-04
£4.50
will also be needed.

 

16 Dec 2010

Normally for input I connect direct or with a resistor divider.For output direct connection without problems. 

16 Dec 2010 . Edited: 16 Dec 2010

Any of the 74HCTXXX parts should work for translating the mbed's 3.3 volt outputs into 5 volt signals for your peripheral's inputs.

You might choose the 74HCT244 -- that would give you 8 lines in a single package. And it's available in an easy-to-use through-hole package.

Going the other direction, you may not need a translator -- some mbed pins are 5-volt tolerant. Check the data sheet for the LPC1768.

16 Dec 2010

user Hexley Ball wrote:

Any of the 74HCTXXX parts should work for translating the mbed's 3.3 volt outputs into 5 volt signals for your peripheral's inputs.

Don't use the 74HCT series, use 74HC instead. HCT defines logic high as 70% of Vcc, which is (with Vcc=5 volt) 3.5 volts - so you cannot reach high safely. 74HC, on the other hand, use TTL logic levels which is 2 volts for high.

If your external devices are of 74HC or 74LS series, you can connect them safely and they will work reliably. You can look at the data sheets how the logic high voltage is defined (should be either 2 volts, 0.7xVcc or 0.5xVcc [CMOS 4000 series]). I have used the 74HC245 as logic converter, which worked flawlessly.

I haven't seen any logic level converter in DIP packages. But you can get samples of the sn74lvc8t245 or the txb0104 from Texas Instruments, which are available in SOIC.

17 Dec 2010

 

user Hendrik Lipka wrote:
Don't use the 74HCT series, use 74HC instead. HCT defines logic high as 70% of Vcc, which is (with Vcc=5 volt) 3.5 volts - so you cannot reach high safely. 74HC, on the other hand, use TTL logic levels which is 2 volts for high.

Actually, it's just the opposite. The "T" in "HCT" denotes TTL compatiblity, with its corresponding 2 volt logic high. (See Table 8 on page 9 of the 74HCT244 data sheet, under "VIH".) So a 74HCT244 is indeed the proper choice.

As Hendrik has found, it happens that HC parts also work much of the time, since at room temperature their "typical" spec for VIH actually falls below their guaranteed "minimum" spec of 3.5 volts. (See Table 7 on page 6 of this data sheet, under "VIH".)  But I wouldn't rely on "typical" values if you want a robust design.

17 Dec 2010

user Hexley Ball wrote:

Actually, it's just the opposite. The "T" in "HCT" denotes TTL compatiblity, with its corresponding 2 volt logic high.

I stand corrected. But I attribute this to lack of coffee - I should have verified my claims :) Sorry for the confusion.

04 May 2011

I just stumbled upon this thread again and got really embarrassed for not giving proper feedback.

I tried several HCT buffer type parts and all of them worked! To be fair, using a direct connection to/from the mbed also worked but this makes me feel a little safer, having a hopefully protective layer between beloved mbed and bad behaving extras.

Thanks all, with an added cheer for Hexley dominating the mbed challenge!

05 May 2011

http://mbed.org/handbook/mbed-NXP-LPC1768

Power and Logic Levels

The microcontroller I/O is all 3.3v logic, but 5v tolerant. A digital pin can drive 40mA, up to a total of 400mA.

Going to try some simple pullup resistors.

Edit: Limited results.

05 May 2011

Melchior Pau wrote:

The microcontroller I/O is all 3.3v logic, but 5v tolerant. A digital pin can drive 40mA, up to a total of 400mA.

While inputs are 5V tolerant, outputs are not. Also, the 40mA figure quoted in the handbook for output drive is related to the short circuit limits. Normal logic-level output current is lower.

The LPC1768 data sheet explains this in more detail.

Table 7 on page 45 gives the following limits for standard port pins:

  • VO "Output Voltage" maximum is VDD(3V3), not 5V1
  • IOH "HIGH-level output current" is -4 mA
  • IOL "LOW-level output current" is 4 mA
  • IOHS HIGH-level short-circuit output current -45mA
  • IOLS LOW-level short-circuit output current 50mA

NOTE1 Not to be confused with the guaranteed logic level for an output, which is only guaranteed to be > VDD(3V3) - 0.4V. Which is 2.9V, too low to drive 5V CMOS inputs, which is where this discussion about output level shifters started :-)

05 May 2011

There is one dirty trick that many of us use.

Most 74HCT parts when run on 5V require 3.15V minimum input for a HIGH. typically, 2.4V. Given that the LPC1768, and much other 3.3V Logic such as processors and FPGA's will give 3.3V out this trick has become common.

Run HCT parts on 5V and directly drive the inputs from 3.3V outputs. That works for outputs.

However the mopst popular device in my arsenal, which will translate both ways, from a variety of voltages to a variety of voltages is the 74LVC8T245. http://focus.ti.com/lit/ds/symlink/sn74lvc8t245.pdf which is cheap and very useful!

John

19 Sep 2013

In my opinion the 74HCT "trick" isn't really a trick, the voltage levels are right because the parts are designed that way.

If you know which way your signals are flowing then there are good reasons to NOT use an auto-sensing/magic bidirectional device. The problem is that generally you can detect a pin going to or from tristate OR transmit to the pin, but not both. As a result magic translators tend to have limited drive or are open-drain with a pull up.

In comparison a normal logic gate has well known logic levels and full drive capability so you won't get tripped up by pull-up resistors or loading. I notice that the 74LVC8T245 mentioned above has a direction pin, and does not rely on auto-sensing.

27 Sep 2013

These are also nice level converters and in DIP package available too:

74AHC(T)240 and 74AHC(T)244 OCTAL BUFFERS/DRIVERS WITH 3-STATE OUTPUTS

Power supply can be 2 to 5.5 Volts and it will accept input voltages higher than the supply voltage.