### Author Topic: Trouble Understanding Level Shifting  (Read 1591 times)

0 Members and 1 Guest are viewing this topic.

#### Sylvestre

• Robot Overlord
• Posts: 221
##### Trouble Understanding Level Shifting
« on: September 22, 2013, 10:31:34 PM »
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

• Jr. Member
• Posts: 44
##### Re: Trouble Understanding Level Shifting
« Reply #1 on: September 23, 2013, 12:41:38 AM »
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

• Jr. Member
• Posts: 44
##### Re: Trouble Understanding Level Shifting
« Reply #2 on: September 23, 2013, 12:43:20 AM »
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

• Full Member
• Posts: 120
##### Re: Trouble Understanding Level Shifting
« Reply #3 on: September 23, 2013, 06:47:30 AM »
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?

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

• Supreme Robot
• Posts: 1,343
##### Re: Trouble Understanding Level Shifting
« Reply #4 on: September 23, 2013, 01:53:36 PM »
Quote
5v output to 3v input may use a single limiting resistor. the higher voltage is clamped by internal zeners.

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.

#### Sylvestre

• Robot Overlord
• Posts: 221
##### Re: Trouble Understanding Level Shifting
« Reply #5 on: September 23, 2013, 03:25:49 PM »
Thanks for all the responses. I made mistake in my earlier post. I meant less than 1.8v not greater than.

Quote

Like I said earlier,  the Beaglebone Black can only accept analog voltages 1.8v or less.  The current sensor Im using outputs I assume voltages higher than 1.8v.  I just realized it doesn't expicitly say this, but I assume it does (Does it?).  I figured I would need something to translate that voltage f of the output to under 1.8v
http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=111040360152&var=410166550830

Quote
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.

I have two current sensors that need to be shifted.  The BBB has internal pullups.  Im confused on how a transistor shift levels?

Also just an FYI, the voltage available is 5v.

I can't find anywhere where it says the maximum output voltage, but I did find that sensitivity is 12.8mv/A and that the output voltage= VCC/2

Have a look to see if you see anything.
« Last Edit: September 23, 2013, 03:43:28 PM by Sylvestre »

#### johnwarfin

• Full Member
• Posts: 120
##### Re: Trouble Understanding Level Shifting
« Reply #6 on: September 23, 2013, 05:13:23 PM »
those Zeners aren't generally specified for continuous operation.

they generally arent specified for transient operation either. in fact not specifiied at all. general consensus is 2.5ma is safe so down to couple hundred ohms works. but what you say is true about high rates. in the mhz range there may be speed problems but most are khz so rarely an issue.

the whole point is moot though because we missed that op referred to ANALOG voltages when our comments refer to DIGITAL signals. roman seems to be the only one who was aware of that and divider is the solution. (note to self: read posts more carefully!)

#### jwatte

• Supreme Robot
• Posts: 1,343
##### Re: Trouble Understanding Level Shifting
« Reply #7 on: September 23, 2013, 07:33:26 PM »
Yes, I just saw the clarification that the request was for analog signals -- very different from digital signals! (The original post did not talk about analog, in my defense :-)

The simplest way to level shift is with a resistor ladder. Make sure it's low impedance enough to be able to drive the ADC inputs! (For example, the AVRs need a source impedance < 10 kOhms; don't know about the BBB.)

An alternative would be to re-buffer with an opamp set for partial gain.

#### Sylvestre

• Robot Overlord
• Posts: 221
##### Re: Trouble Understanding Level Shifting
« Reply #8 on: September 24, 2013, 06:19:50 AM »
Sorry for the not stating that in the original post.  Thanks for the advice.  I will look into  resistor ladder.  Never heard of that before.

#### johnwarfin

• Full Member
• Posts: 120
##### Re: Trouble Understanding Level Shifting
« Reply #9 on: September 24, 2013, 12:40:41 PM »
huh?

I have a sensor that outputs an analog voltage at 3.3v

the only real confusion if any was use of "bbb". normally this refers to avr Bare Bones Board.

#### johnwarfin

• Full Member
• Posts: 120
##### Re: Trouble Understanding Level Shifting
« Reply #10 on: September 24, 2013, 12:52:16 PM »
Make sure it's low impedance enough to be able to drive the ADC inputs!
...

An alternative would be to re-buffer with an opamp set for partial gain.

unfortunately an op amp, aside from costing 10x more, would require negative supply to function properly. imo simple divider is best. ratio but not actual values would be the concern. a cap not only solves the impedance issue there but added benefit of reducing noise.

#### Sylvestre

• Robot Overlord
• Posts: 221
##### Re: Trouble Understanding Level Shifting
« Reply #11 on: September 24, 2013, 01:26:14 PM »
Quote
the only real confusion if any was use of "bbb". normally this refers to avr Bare Bones Board.
I must be on the Beaglebone forums too much, I've gotten accustomed to that abbreviation.

Quote
imo simple divider is best. ratio but not actual values would be the concern. a cap not only solves the impedance issue there but added benefit of reducing noise.

Ok sounds good.  Thanks.

#### jwatte

• Supreme Robot
• Posts: 1,343
##### Re: Trouble Understanding Level Shifting
« Reply #12 on: September 24, 2013, 10:46:50 PM »
An alternative would be to re-buffer with an opamp set for partial gain.

unfortunately an op amp, aside from costing 10x more, would require negative supply to function properly. imo simple divider is best. ratio but not actual values would be the concern. a cap not only solves the impedance issue there but added benefit of reducing noise.
[/quote]

Right. If you can live with the RC filter (or even desire it) then the resistor divider is best.

A rail/rail opamp doesn't need a negative supply, and can run at much higher frequencies with lower current draw. Whether the \$0.90 instead of the \$0.09 matters is of course very application specific.

• Full Member
• Posts: 120