Electronics > Electronics

Trouble Understanding Level Shifting

(1/3) > >>

Sylvestre:
Hello, I was wondering if someone could explain level shifting to me?  I understand it is need to go from say 5v to 3.3v, but that's about it.  Why do you need a chip for this?  Couldn't you just use a voltage divider?

I have a sensor that outputs an analog voltage at 3.3v max and the BBB only accepts >1.8v.  I was planning on just using a voltage divider, but then I heard something about level shifting..

Thanks

Roman505:
Briefly, if your input voltage and current draw are stable or the current draw and variations are extremely low, then a voltage divider is fine. If you intend to draw a varying load then you need a level shifter, in effect a new power supply at a different voltage for the subsidiary circuit.

The reason can be seen by thinking about different currents drawn at the tap between the divider resistors. Whether sourcing or sinking, the effect will be to change the current across one of the divider resisters but not the other, so the voltage level will shift.

Example: Assume you have a 180 ohm and 330 ohm resistor pair across 5V, +ve to -ve. The current draw will total about 10 mA and the tap will sit at about 3.24V. Now add a 5 mA load at 3.3V. You now have effectively a 220 ohm rather than 330 ohm resistor as your bottom half, and the voltage will want to drop to 2.25V. You see the problem?

Reducing the R of each of the divider resistors will reduce the voltage effect at a cost of greater standing current draw and greater heat. It is really pretty useless except as a crude voltage reference.

With a level shifter, the current (and much more) will be supplied with zero voltage change.

HTH

Roman505:
Incidentally, I have talked about why you need level shifting rather than dividers for current delivery. If your actual problem is that you have a sensor output moving around 3.3V and an input sensor ranging around 1.8V then your problem is quite different.

johnwarfin:

--- Quote from: Sylvestre on September 22, 2013, 10:31:34 PM ---I understand it is need to go from say 5v to 3.3v, but that's about it.  Why do you need a chip for this?  Couldn't you just use a voltage divider?
--- End quote ---

in most cases neither chip nor voltage divider are needed. specially going from 3v output to 5v input because switching threshold is around a volt or two so they play well together.  in those cases where input is not "5v tolerant", 5v output to 3v input may use a single limiting resistor. the higher voltage is clamped by internal zeners.

i predict internet "experts" will chime in with expensive and complicated level shifter circuits but this is based more on tradition and urban myth than reality. for mission critical applications (medical, miltary, etc) its best to use recommeded circuits but this is based more on insurance and liabilty issues than sound design practice.

best of all though is to run everything off the same supply. most modern ics and modules use 3.3v and, even though avr/arduino for example are spec for 5v at 16mhz, thousands of hobbyists find they work fine at 3.3v. there has never been credible evidence of any problem doing so.

jwatte:

--- Quote ---5v output to 3v input may use a single limiting resistor. the higher voltage is clamped by internal zeners.

--- End quote ---

I think this is very poor advice, because those Zeners aren't generally specified for continuous operation. When you use a resistor that is sufficiently high resistance to make that safe, your slew rate is going to be slow, and thus you will be limiting the throughtput on the signal. If you're running 9600 baud serial, then that may be fine; if you're running 1 Mbps serial or 4 Mbps SPI; not so much!

Bidirectional level shifters are easy, btw. You need one N-channel MOSFET, and a pull-up resistor on each side if that side isn't already pulled up. If each side is already pulled up, it's a single MOSFET transistor to shift levels bidirectionally. If you have many lines to shift (3 or more) then a simple chip, that also includes the pull-ups, may be worth it, because it will use less board area than discrete TO-92 MOSFETs like BS-170 or 2N7000 or whatever.