Understanding digital level shifting In this article, we will talk about shifting real-world voltages and some of the oddball techniques for doing so. We will kick off with a 3V3 to 5V interface. By Aubrey Kagan Engineering Manager Emphatec On the off-chance you are under the misimpression that the plethora of supply voltages utilised in electronics systems these days is something new, you should know that level translation has been needed for a while. Many years ago, for example, we were wrestling with TTL/ECL interfaces and CMOS/TTL interfaces. I guess those of us of a certain vintage who enjoyed many years of 5V-only logic had our reverie shattered. A few of us (yours truly included) have continued with the 5V tradition, which means there is precious little I can tell you about 3V3 to 2V8 level shifters and the like. I looked up level translators on the Digi-Key selection tables, and there were 3409 parts, but this blog is not about advanced high-speed logic level translators. I will let you find your own way through the Digi-Key and/or Mouser tables--in this column I want to talk about shifting real-world voltages and some of the oddball techniques I have garnered along the way. Notwithstanding the previous paragraph, I thought I should kick off with a 3V3 to 5V interface. An early technique used the 74HCT series of devices as translators from 3V3 to 5V, because the guaranteed high on the input was less that the high output of CMOS 3V3 devices. Although somewhat less useful today, knowledge of this approach could be helpful in certain circumstances. We all know the simplest way to step down a voltage is by means of a resistor divider, but did you know you can use a resistor divider to step a voltage up as well? Take a look at the circuit in figure 1. Figure 1: Resistor network to shift voltage level up or down. A few years ago, I presented a design idea that explains the relationships and provides an Excel worksheet to calculate the resistor values. (It appears that the actual worksheet is no longer available in as part of the Design Idea, but you can access it by clicking here.) The original idea assumed an analog input, but there is no reason it can't be used with a digital signal also. With any resistor network, there are two additional things to consider. First, the source must be able to drive the load; and second, any capacitance on the output of the resistor network (even the parasitic capacitance of the digital circuitry) will slow the waveform down. While I am touching on analog circuits used in digital level translation, I should mention that you could use an opamp to scale a voltage up and even level shift it if it wasn't zero referenced. I only wanted to remind you that this can be done and you should consider it if the circumstances warrant such an approach. EE Times-Asia | eetasia.com Copyright © 2014 eMedia Asia Ltd. Page 1 of 3 Of much greater use, though, is a comparator with its ability to program the changeover level through external resistors. In addition, most of these have an open collector output that can be pulled to any value (within the chip's limits) resulting in the desired level shift. The fact that some comparators like the LM311 can work with bipolar supplies and refer the output to a reference (ground for instance) is particularly helpful in shifting the zero level. It is a good idea to add hysteresis, though, in order to prevent multiple transitions at changeover. Figure 2: Inverting (a) and non-inverting (b) comparators with hysteresis. The switching level is set by R1 and R2; the hysteresis is set by R3 and R4 (and R5 in (b)). In the case of (b), beware the fact that if Vin is derived from a resistor divider, the hysteresis values will interfere with it. Generally speaking, it is not a good idea to overdrive the input of any IC. The classic technique to handle this is shown in the circuit in figure 3. Schottky diodes are preferred so that they will turn on before the device's internal diodes. Be careful of the input current (limited by the input resistor) that you are forcing though the diode into the supply rail. If it exceeds the current needs of the total circuit, the supply voltage can go up and destroy some of the circuitry. A long-forgotten technique is to use CD4049 or CD4050 chips. These devices do not have internal diodes to the supply, and so can withstand voltages up to the breakdown voltage (20V max) of the IC, which could be well outside the supply voltage. There are also some other pretty old level translators that could prove useful, like the CD40109 and CD4504, which will allow higher and non-standard voltage shifts. EE Times-Asia | eetasia.com Copyright © 2014 eMedia Asia Ltd. Page 2 of 3 Figure 3: Standard input protection against overvoltage. In some cases, your input voltage may not be all that well regulated. In the HVAC industry, for instance, the input levels are derived from a nominal 24VAC transformer. My approach is to half-wave rectify, smooth, and then use a resistor divider followed by diode clamp protection, thereby combining several of the techniques mentioned above. We all think of opto-isolators only in the context of providing isolation, but they can actually be used as level translators as well. Provided there is enough drive in the source, you can interface to almost any input voltage and then--using a pull-up resistor at the open collector output (or a pull-down at an open-emitter output)--convert it to whatever voltage is required. Oftentimes, outputs require conversion from logic levels to high voltage and/or high current to drive something like a relay or solenoid. The voltage shift can be handled with a transistor output or dedicated drivers. There used to be quite a number of serial-in shift registers with high voltage outputs, but the industry trend seems to be moving away from them now. In a recent blog--Where are all the (MCU) outputs?--I bemoaned the paucity of options and I suggest you look at it whether this is the type of driver you need. An open-collector (or open-emitter, open-source, open-drain) is frequently used for simple level shifting, especially where there is a common rail, and some of the approaches described above use this technique. Here are some more. Going back a long way, but still available, is the TTL favourite 7406 (and 7407), which will handle up to 30V and sink 40mA on its open-collector outputs. If you wanted higher current, there are the ULN2803 (8 channel) and the ULN2003 (7 channel) drivers, although--being Darlington drivers--their outputs will not go down to zero. I'm sad to say that these drivers are getting a little long in the tooth now, and it appears that the number of manufacturers is diminishing. However, TI has brought out a device that is plug-replaceable with the ULN2003, but that uses MOSFETs instead of BJTs. Someone with a sense of the past must have given this new device its number: TPL7407L. Going back even further into the mists of time, we shouldn't forget that a relay is sometimes the ideal way of level shifting--with isolation thrown in--for either inputs or outputs. But just to prove that not everything is as old as the hills, both TI and Maxim have interesting devices (click here and here, respectively) that will take eight high-voltage (30VDC) inputs, convert them to 5V, and serialize them. In addition, serving as level shifter in terms of a pull-up or pull-down as well as through-isolation are the members of the Infineon ISOFACE family of parts for both input and output. Do you need to take your signals to the next level? What techniques do you use? About the author Aubrey Kagan is an Engineering Manager at Emphatec. EE Times-Asia | eetasia.com Copyright © 2014 eMedia Asia Ltd. Page 3 of 3