6
\$\begingroup\$

I am looking to interface a 3.3V device with a 5V one. This will require the shifting of the logic levels between the two devices.

Doing this in one direction is a trivial matter, but I need to do it in both directions (reading and writing - it's a data bus).

I know there are bus drivers that can do this but I'm a skinflint, so I'm looking to see if I can do it with the discretes I have at my fingertips.

I came up with this circuit:

enter image description here

I don't know if it will actually do what I want, but from reading other sources (including Is it possible to drive TTL inputs from 3.3v microcontroller and Bi-Directional Step up and Step down (3.3v <-> 5, etc) [the latter mentions a sparkfun tutorial that no longer exists]) it might.

My thinking is, data from 5v to 3.3v goes through D2 and the series resistor R2 to drop the voltage. Data from 3.3v to 5v goes through D1 and gets pulled up by R1.

Would this work? Is it complete gibberish?

Update

Ok, so we have agreed that circuit is total gibberish.

I have made some tweaks, and come up with this:

enter image description here

Playing around with my scope gives me levels of around 1V-4V on the +5V side, and 0V to 3V on the 3.3V side. Both sides default to a high level and connecting to ground on one side causes a low level on the other side.

The resistors are all 10KΩ, and I have had both ends feeding through 100KΩ resistors to simulate some form of load. The diodes are all Schottky.

Thoughts?

\$\endgroup\$
  • \$\begingroup\$ How does the 3.3V side force the 5V side low, and vice versa? \$\endgroup\$ – Adam Lawrence Jul 13 '11 at 15:39
  • \$\begingroup\$ The sparkfun tutorial is now at sparkfun.com/tutorials/65 \$\endgroup\$ – Optimal Cynic Jul 13 '11 at 15:52
  • \$\begingroup\$ 1V is too high for a low level if you need TTL levels; low is 0.8V maximum. \$\endgroup\$ – stevenvh Jul 13 '11 at 16:09
  • \$\begingroup\$ @Brian - I rolled back because the original schematic is relevant, even if it's wrong. Answers refer to it, so you wouldn't know what they're talking about, and there's also something to be learned from a wrong circuit; why it doesn't work, for instance. \$\endgroup\$ – stevenvh Jul 13 '11 at 17:03
  • \$\begingroup\$ Do you have logic-level FETs available? I'm surprised you're not using some form of active level translation. \$\endgroup\$ – Kevin Vermeer Jul 14 '11 at 0:09
6
\$\begingroup\$

I think the easiest circuit that does what you want would use a N channel MOSFET like the bss138 and two pull-ups, hooked in the following way:

5-3.3V level converter

Tell me if it doesnt fit your needs, and why.

Having said this, I have to recommend you to take a look at the MAX3000 series of level converters. I have used them before and they are great bidireccional converters that "simply work" (in apple terms).

Hope it helps.

edit: It seems like the image appears broken with some browsers, you can see it here

\$\endgroup\$
  • \$\begingroup\$ Broken image - please may you reupload the image. \$\endgroup\$ – Dean Jul 13 '11 at 21:04
  • \$\begingroup\$ I have ordered a couple of MAX3000 series as samples, but they require 'business manager approval' before they can be sent... :L The only FETs I have are MOSFET power FETs - also :L \$\endgroup\$ – Majenko Jul 14 '11 at 7:34
  • \$\begingroup\$ The MOSFET technique is explained in this appnote (I also reference to it in my answer) \$\endgroup\$ – stevenvh Jul 14 '11 at 9:18
  • \$\begingroup\$ @Matt-Jenkins Yes, obtaining samples or even trying to buy electronic components is a wild adventure lately. We are having many problems at work because we use many ON semiconductor and nippon chemicon parts... they seem to be manufactured near Fukushima... \$\endgroup\$ – payala Jul 14 '11 at 15:33
3
\$\begingroup\$

I vote gibberish :-).
You won't get much voltage drop over R2 since there will hardly be any current, and therefore the diode won't drop much voltage either. If your 3.3V device isn't 5V I/O compatible you may fry it this way.
Also if the 3.3V device outputs a low level we can ignore D1, and the level at the 5V input will be determined by R1, D2 and R2. R1 + R2 will lift the low level up to a certain level, and the diode will add another 0.7V, so the level seen on the 5V side may not be low at all.

Back to the drawing board?

edit
Have a look at this NXP appnote. Very elegant solution, without special level shifter IC.

\$\endgroup\$
  • \$\begingroup\$ Hmmm... I am experiencing something like that on the breadboard. My 5V side low is ending up around 3V. \$\endgroup\$ – Majenko Jul 13 '11 at 15:50
  • \$\begingroup\$ @Matt - what values are the resistors? \$\endgroup\$ – stevenvh Jul 13 '11 at 15:51
  • \$\begingroup\$ Undefined as yet ;) \$\endgroup\$ – Majenko Jul 13 '11 at 15:58
  • \$\begingroup\$ See my edit.... \$\endgroup\$ – Majenko Jul 13 '11 at 16:05
2
\$\begingroup\$

That circuit is broken. Just for one, consider the case of the left side driving 5V and the right side high impedance. The right side will go to 5V minus the diode drop. It's also broken for other cases. Go thru all 4 possible cases you'll see the result isn't what you intended.

You are wasting time trying to play games with level shifting. If you really want to do it yourself, shouldn't you be starting with beach sand and refining your own silicon? At best you'll end up with something that's bigger and clunkier than a deliberate level shift IC.

Single line level shifters come in SOT-23 packages and include a direction line and resulting high impedance states depending on direction. If you need to translate multiple parallel lines with the same direction signal, then the integrated solution is even smaller per line.

However, the best way to deal with this is architect the system to need as few level shifts as possible. Sometimes that's impossible or impractical, but a whole bus requiring level shifts is a bit of a red flag. Also note that 5V inputs with TTL levels (like 74HCTxxx chips for example) work directly from 3.3V outputs since 3.3V is above the guaranteed high input threshold.

Added:

I see you have posted a revised circuit, but it still has problems. When the 5V side is driving low, it can bring the 3.3V side only down to 2 diode drops above ground. That is too high for some logic types. For example, many PIC microcontrollers have Schmitt trigger inputs operate from .2Vdd to .8Vdd. .2Vdd would be only 660mV with 3.3V supply, so two diode drops is too high to guarantee a logic low.

This is getting silly. Even if your circuit worked, it would only show that if you use enough chewing gum and duct tape and 6 parts you can sortof make something that's not quite as good as a single cheap IC in a SOT-23 packge.

\$\endgroup\$
  • \$\begingroup\$ Would my edited circuit solve the high impedance problem? \$\endgroup\$ – Majenko Jul 13 '11 at 16:06
  • \$\begingroup\$ Steven's supplied app note (nxp.com/documents/application_note/AN10441.pdf) does a marvellous job of using the beach sand and chewing gum to advantage. 2 lines in a SOT23-6 using a dual FET. \$\endgroup\$ – Russell McMahon Jul 14 '11 at 1:42
  • \$\begingroup\$ Hey, who's making fun of chewing gum and duct tape? \$\endgroup\$ – MacGyver May 26 '16 at 9:31
  • 1
    \$\begingroup\$ @Mac: Good one. In this case, level shifters are cheap, available, and work better than what most people can cobble together on their own. Keep the chewing gum, duct tape, and paper clips handy for when you have to improvise a nuclear bomb or something. \$\endgroup\$ – Olin Lathrop May 26 '16 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.