BMOW title
Floppy Emu banner

The Quest For A Simple Level Converter

Sometimes the simplest things give me the most trouble. I’ve been working on a downloader cable adapter for the Backwoods Logger, with the goal of supporting both 5V and 3.3V FTDI cables. Because the Backwoods Logger is a 3.3V design, the incoming TXD (transmit data) signal from a 5V cable needs to be lowered to 3.3V for safe operation. However, the incoming TXD signal from a 3.3V cable should be passed through unmodified. Outgoing signals from the Logger require no conversion, because a 3.3V output is still a valid logic “high” for a 5V system. I need a level converter for a single input, that operates correctly with both 5V and 3.3V inputs with no configuration or jumper settings.

Level Converter Chip

One solution is to use a 3.3V chip with 5V tolerant inputs, like a 74LVC244. That would work, but I’d prefer something simpler and smaller if possible, since I only have a single input to convert.

Clamp Diode

A second solution is to use a series resistor and a clamp diode, like this (image from daycounter.com):

That prevents the voltage at the 3.3V Backwoods Logger input from going more than a diode drop above the 3.3V supply. With a standard silicon diode’s drop of 0.6V, that clamps the voltage to 3.9V. For the ATmega328, that’s not safe: its maximum rated voltage on any input is just 0.5V about VCC. A germanium diode has a drop of 0.2 to 0.3V, so that would work, but it’s not a part that many people typically have handy in their parts bin.

This solution also has the drawbacks of consuming current from the 5V output, and dumping current into the 3.3V supply, raising the supply voltage. The FTDI outputs have a maximum output current of 24 mA. Assuming a germanium diode with a 0.2V drop, that means R1 needs to be at least 62.5 Ohms. Frankly I’m not sure how to quantify the risk of dumping current into the power supply. In the case of the Logger Classic with its tiny CR2032 battery, dumping 24 mA into the battery in the wrong direction definitely doesn’t sound good.

Zener Diode

The approach that appealed to me most was to use a series resistor and a Zener diode connected to ground, like this (image from daycounter.com):

The Zener has a known reverse-bias breakdown voltage called the Zener voltage. Raise the voltage above the Zener voltage, and the diode conducts. The series resistor produces a voltage drop, so that the voltage at the Backwoods Logger input never rises above the Zener voltage. You can get 3.0V or 3.3V Zeners (or lots of other values too).

So I ran out and bought some Zeners, and built this circuit, and it didn’t work at all how I’d expected it to. I used a 3.0V Zener, and a 100 Ohm series resistor, to limit the current drawn from the FTDI cable to 20 mA. When I connected a 5V dummy output, I got 2.91V at the Logger input. That seemed odd, it was off by 0.09V, but it was still close enough. Then I connected a 2.95V dummy input (the actual voltage from my crummy “3.3V” breadboard regulator), and I got 2.4V at the Logger input. Huh? That’s not going to work. I had expected that for any voltage below 3.0V the Zener would do nothing, and for anything above 3.0V it would clamp it to 3.0V, but that’s clearly not what happened.

What went wrong? Truthfully, I’m not exactly sure. The datasheets talk about a minimum current necessary to get the Zener effect, but I’m not sure that applies here. I can’t safely increase the current further anyway without damaging the FTDI cable. But would more current even solve this problem? It makes sense that the Zener wouldn’t really turn on instantaneously at 3.0V, but rather would begin to conduct more and more as the voltage approaches 3.0V. With a voltage of 2.95V, the Zener would already be partly conducting, pulling the voltage seen at the Logger input below 2.95V. But how much below? How can this be quantified?

One thing in particular bugs me about all the Zener diode datasheets: every datasheet lists values for standard measurements called Izt, Rzt, Izk, Rzk, Rz, and a few others. These are standard measures from some hypothetical standard Zener graph, but the datasheets never actually show this graph, and I’ve never been able to find one anywhere. I know “k” is for “knee” and I believe “t” is for “test”, but what I really need is an actual IV curve for a Zener with these values labeled. Then I think I’d understand this better.

Further Complications

Just to make things more interesting, there’s one more constraint to consider. The Logger Classic uses an unregulated battery as its supply. It can work just fine at battery voltages of 2.8V, and probably down to 2.5V or even lower. In order to stay within the VCC + 0.5V margin of the ATmega328P, the input voltage must not go more than half a volt above the potentially fading battery voltage. A standard 3.3V input when the battery is 2.7V would actually damage the ATmega. That’s why I chose to use a 3.0V Zener rather than a 3.3V one. That should be safe down to a battery voltage of 2.5V, below which I could configure the ATmega’s brownout detector to engage.

The Way Forward

I’m going to sleep on this, and see if anything brilliant comes to me. If anyone else has a suggestion, please reply in the comments. Assuming I can’t find a way to make the Zener work while still meeting the other constraints, then I’ll probably cave in and use a level converter chip. Without really understanding the implications of current flowing into the supply battery under the clamp diode method, I wouldn’t feel comfortable relying on that approach.

Read 19 comments and join the conversation 

19 Comments so far

  1. Steve - October 19th, 2011 7:48 pm

    Hmm, it looks like the Zener approach can’t work with the Logger Classic, if the input must be guaranteed not to go more than half a volt above the battery voltage. The brown-out detector isn’t actually accurate enough for my purposes, and turning it on would also more than double the current drain on the battery while the ATmega is sleeping.

  2. Keenan - October 19th, 2011 8:19 pm

    A single-transistor inverter is pretty simple and foolproof. Use a MOSFET with sufficiently low Vgs(th) and it’s a single-component solution – use the built-in pull-ups (2N7000 is ubiquitous and 3V max), or a BJT will work down to very low voltage. Obviously you need to compensate for the inversion, but given your plan of attack on this problem I don’t think that’s a problem.

    TI (and possibly second-sources) also makes a series of single-gate SOT-23 ICs that can tolerate up to 5.5V and run on 1.65V+ that would be suitable for this. 74LVC1G34 is a single-gate buffer.

    Either will track your supply voltage.

  3. Steve - October 19th, 2011 8:30 pm

    Here’s one more approach I think would work. Enable the internal pull-up on the Logger input, and connect a standard silicon diode from the Logger input to the FTDI output.

    If the FTDI output is 0V, then the diode will conduct through the pull-up, and the voltage at the Logger input will be 0.6V. If the FTDI output is 3.3V or 5V, then the diode won’t conduct, and the pull-up will pull the Logger input to VCC. 0.6V is getting pretty close to the Vih threshold, though.

    Keenan, thanks, I will look at the single-transistor method too.

  4. gm - October 19th, 2011 9:48 pm

    If you want to convert from 5v to 3.3v, why not just use a simple resistive voltage divider?

  5. Joel - October 19th, 2011 10:06 pm

    In a recent mixed-voltage design, I fiddled around with FETs, transistors and resistor dividers, but ended up using the MC74VHC1GT50 non-inverting buffer / CMOS logic level shifter. It is small (five pins) and has a single input/output with 5V tolerant inputs.

  6. Erik Petrich - October 19th, 2011 10:17 pm

    Take a look at this schematic:
    http://www.sparkfun.com/datasheets/BreakoutBoards/Level-Converter-v10.pdf

    This actually does bi-directional level conversion, but since you just need one way on one channel, you can simplify to just Q1 with R3 being a pull-up in the Atmel. R4 is unneeded for one way conversion. Connect TX_HV to the FTDI, TX_LV to the Atmel, and LV to the Atmel’s supply voltage.

    If the FTDI’s output goes below Vgs less than the Atmel’s supply voltage, the FET switches on and the Atmel sees the FTDI’s voltage with negligible loss (assuming the Ron of the FET is much lower than the pull-up). Otherwise, the FET is off and the pull-up takes care of generating a logic high at a compatible voltage. So this works similarly to your diode idea, but without the problem of the Vf of the diode raising logic lows dangerously close to Vil. There’s also no inversion of the signal to fix elsewhere.

  7. Stephen Trier - October 20th, 2011 3:38 am

    My go-to chip for this kind of thing is the SN74LVC2G34. It comes in a 6-pin SOT-23 or SC-70, along with some even smaller packages, and has two buffer gates that have 5V-tolerant inputs and can run on anything from 1.65V to 5V. There are inverting and open-collector equivalents, too, and all have a healthy 24 mA drive spec.

    For this application, you might prefer the ‘1G34, which has a single buffer gate and one less pin. For some reason, it has a much lower ICC rating (1 uA instead of 10 uA).

  8. John Honniball - October 20th, 2011 5:07 am

    A 3.3V Zener will have a pretty soggy response curve. It won’t have a sharp switch-on at precisely 3.3V, but it will begin to conduct well below that. This is what you’re seeing when the voltage gets up to 2.8V or so and the diode starts “leaking”. If you put a Zener on a curve tracer (I have the mighty Tek 575), you’ll see a quite pronounced curve in the response. Zeners nearer to 5.6V will behave a bit better, due to the basic physics of the Zener diode. If you want a sharp switch-on, have a look at the variable Zeners like the LM295 and TL431. TL431 in particular is one you’ll find in scrap PC power supplies and the like (non-SMT ones look like a TO-92 transistor).

    Also, remember that a Schottky diode has a voltage drop of about 0.2V, similar to a germanium diode. They’re easier to find than germanium diodes, and can handle much higher currents.

  9. Steve - October 20th, 2011 8:06 am

    Wow, lots of comments! Thanks everyone!

    “Soggy” is a great way to describe the Zener curve. In the end, I think you simply can’t use a Zener at voltages right around the Zener voltage, which was exactly what I was trying to do. So scratch that idea.

    I’m going to go with the diode idea that I mentioned in my previous comment, and use a Schottky diode. This is a low speed signal (56000 bps serial), so I think the response time should be OK, but I’ll check it. I want to keep it to a through-hole design if possible, so other people can easily build the circuit or breadboard it without needing a PCB. Erik’s FET suggestion is similar and would also work, assuming a through-hole FET package. The other suggestions would be great if I were building just for myself, or didn’t care about through-hole options.

    What’s that parallel diode in the schematic for the BSS138 FET? Is that normal? Does it actually create a 0.6v drop? I’m not very familiar with FETs.

  10. Steve - October 20th, 2011 8:53 am

    Am I correct that any enhancement mode, N-channel MOSFET would work here, and it doesn’t need to specifically be the BSS138? For example, the 2N7000 MOSFET?

  11. John Honniball - October 20th, 2011 9:23 am

    I think that diode in the BSS138 datasheet is a parasitic diode that’s formed by the construction of the FET. It will be reverse-biased in normal usage, hence non-conducting, but it’s drawn in the diagram to remind you it’s there and will indeed conduct in certain circumstances.

  12. Steve - October 20th, 2011 1:12 pm

    That’s where I’m confused, because it’s not reverse biased in this example. If you look at the Sparkfun diagram that Erik linked to, the anode on the left has a pull-up to 3.3V, and the cathode on the right is connected to the 5V logic output from the FTDI. So when the FTDI output drives 0v, the diode will conduct.

  13. Doug - October 20th, 2011 3:11 pm

    How about using something like this. I think this is what the Sparkfun part uses.

    http://ics.nxp.com/support/documents/interface/pdf/an97055.pdf

  14. Erik Petrich - October 20th, 2011 6:36 pm

    Somewhere Sparkfun references the NXP appnote Doug linked to, but I was having trouble finding it myself yesterday. The diode is the PN junction between the substrate (which is also connected to the source pin) and the drain pin.

    When the FTDI drives its output low, the diode will briefly conduct, but this pulls the source pin low enough below the gate voltage that the FET switches on. If the pull-up resistance is sufficiently higher than the Ron resistance of the FET, the voltage divider they effectively form lowers the voltage at the source pin (the anode side of the diode) to the point that the diode is no longer conducting, and the current flows solely through the FET.

  15. Anonymous - November 2nd, 2011 12:22 pm

    You want to drop 5V to 3.3V ? You already have a Schottky diode that drops 0.2V when forward-biased, right?
    5-3.3= 1.7
    1.7-0.7-0.7-0.2= 0.1(two Si diodes and a Schottky)
    close enough

  16. Chris - November 12th, 2011 11:05 am

    Usually CMOS chips have internal protection diodes from the inputs to VDD, and to a large extent what you are concerned about is putting too much current through those and damaging them. As a result, you can “probably” be okay just by using series resistors and nothing else. For some FPGA’s the literature says even 100-200 ohms is okay. Chances are your serial interface will work fine with 1K or even 1.5K, which is not much current over a 5v to 2.8v drop.

    That said, can’t you configure the FTDI chip to have 3.3v I/O?

  17. Erik Petrich - November 12th, 2011 2:49 pm

    Chris, that strategy presumes that the voltage regulator for VDD can sink current on its output to keep VDD from rising above the target voltage. Some regulators (such as the classic 78xx series), are only designed to source current to keep their output at the target threshold, but do nothing if the something else drives VDD above that target. And in the case of an unregulated VDD driven directly from a battery, as the battery is depleted, its internal resistance increases allowing an ever large swing above (or below) the nominal voltage.

  18. Steve - November 12th, 2011 9:25 pm

    The problem described in the original post has already been solved with a FET, using Erik’s suggestion in the 6th comment. But for the sake of discussion…

    Chris – I did consider using the clamp diode (it was the second option mentioned in the original post), but I decided against it due to the unknown effects of current flowing *in* to the battery / power supply that Erik mentioned. Have you used this method successfully? Especially in the case of the Logger Classic that has just a CR2032 battery and no regulator, pushing more current into the battery seemed unwise.

  19. MValdez - January 15th, 2017 1:44 pm

    Hi. This post is old but for anybody finding this I’ll add my two cents. I have searched before for level translation (between 5 and 3.3V) and found the level translators using BSS138 transistors use too much power (not a problem here, as you were not integrating the translator in your battery-powered device).

    Also found that zeners for low voltages (with nominal zener voltages lesser than 6V) has a very soft Iz/Vz curve, so the leaked current start to raise long before they reach the nominal zener voltage. For example, one 3.6V zener starts conducting from 2.2V. This can be seen in most zener datasheets Iz vs Vz graphs. The problem with this is that the signal never reach 3.3V (in this case) and increase power consumption a lot, specially for normally-high signals like serial TTL. And this changes with temperature.

    I tested other solutions (dropping with 1N4148 diodes, voltage dividers, voltage dividers with buffering, TXB010x, 74HC4050, optoisolators) but at the end (for non-open collector lines) I used (and still use) the 74AHC125 (powered by 3.3V) or the single buffers versions 74AHC1G125. The 74AHC family is 5V-tolerant when powered by 3.3V, they are very fast, low power and relatively cheap.

    I still use optoisolators if true isolation is required (the 6N137 works great at moderate speeds, for example, serial lines at 115200 bps or faster) but then you’ll need an inverter (I suggest inverting the signal before the optoisolator if using normally-high signals, to reduce power and increase the life of the isolator).

    Regards, MV.

Leave a reply. For customer support issues, please use the Customer Support link instead of writing comments.