Quantcast
Channel: Bit Bucket – Big Mess o' Wires
Viewing all articles
Browse latest Browse all 164

The Quest For A Simple Level Converter

$
0
0

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.


Viewing all articles
Browse latest Browse all 164




Latest Images