9
\$\begingroup\$

I am trying to make a logic level converter using transistor BC547. This is to convert Voltage level of Rpi Gpio from 3.3 to 5V. I have wired the circuit according to this diagram: enter image description here

I have done this to convert 3.3V to 5V for PWM application. I have connected the circuit to GPIO no 17 and set it high

Questions :

1) why is there no ground in the circuit?

2)I tried to measure voltage at the other end wrt ground, does not show anything.what is the problem?

Thankyou.

\$\endgroup\$
16
  • 1
    \$\begingroup\$ Please clarify #2. Other end of what with respect to what and what voltage is at the other other end.. whatever THAT is..... \$\endgroup\$
    – Trevor_G
    Commented Apr 5, 2017 at 19:29
  • \$\begingroup\$ @Trevor it is a bidirectional converter so i have connected the gpio to 3v end of converter and i am expecting to get 5v on the 5v end of converter when gpio is set to high . voltage with respect to ground of rpi ..i am too confused on this one !! \$\endgroup\$
    – Mr.Sky
    Commented Apr 5, 2017 at 19:31
  • 1
    \$\begingroup\$ @Trevor Nah. It's not as bad as you imagine, I think. Try it out in spice and see what you think. About equally clean (and ugly) in either direction. \$\endgroup\$
    – jonk
    Commented Apr 6, 2017 at 17:34
  • 1
    \$\begingroup\$ @Trevor All I meant is that the second BJT doesn't add much that's useful. Now, there is a difference in the rising vs falling edge. But I'm almost sure that's not improved with the extra BJT. I'd have to double-check, though. \$\endgroup\$
    – jonk
    Commented Apr 6, 2017 at 17:37
  • 1
    \$\begingroup\$ @Trevor By the way, the way that schematic is laid out is terrible for trying to understand it. It's also a terrible, and completely useless description about "dogs swallowing tails." It's almost as though it was intentionally meant to mystify rather than to clarify. \$\endgroup\$
    – jonk
    Commented Apr 6, 2017 at 18:04

2 Answers 2

25
\$\begingroup\$

I hate adding an answer here, especially since the OP doesn't even need bidirectional operation. But the circuit is laid out terribly (for understanding it.) And the description about dogs and tails does not help, excepting perhaps alchemists trying to write down allegorical and mystifying bits of their "art."

(There are shared terms, developed over time and used in electronics to help communicate. A "pull-down" might be such an example. But they have survived the test of time and they do communicate using the general idea of pulling at a node, which isn't difficult to communicate when someone asks and is trying to learn the term. And it can be adapted easily to discuss "pulling harder", for example, without a loss of meaning. The idea of weak and strong are commonly held, as is the idea of pulling, and these are easily applied once someone has acquired the ideas of Ohm's law, voltage, current, and resistance.)

One way to use a BJT for level shifting is to use it in a common-base mode. Just wire the base to a rail and "pull down" on its emitter. You can place the resistor either at the base or at the emitter. All that's left to do is to use a pull-up on the collector. Given that we hope to achieve bidirectional use, the resistor will be placed at the base.

Here's an example when going from a \$3\:\textrm{V}\$ logic output towards a \$5\:\textrm{V}\$ logic input:

schematic

simulate this circuit – Schematic created using CircuitLab

Going in the the other direction it is very tempting to use a symmetrical approach:

schematic

simulate this circuit

But that doesn't work. Why? Because the base has \$5\:\textrm{V}\$ available to it and the collector's pull-up is hooked towards a lower voltage, \$3\:\textrm{V}\$. This means that the base-collector diode (no longer commonly shown on the symbol, though it once was when BJTs were themselves made more symmetrically) can be (and will be) forward biased. So when the BJT is supposed to be turned off, it actually isn't. Instead, there's a forward biased diode caught between \$5\:\textrm{V}\$ and \$3\:\textrm{V}\$ with two resistors to limit the current. So the output will be at some middling value above \$3\:\textrm{V}\$ but also not quite \$5\:\textrm{V}\$.

The symmetry fails.

It's easy to fix. We can just change the base voltage back to \$3\:\textrm{V}\$:

schematic

simulate this circuit

And that works.

Suppose you want to make this bidrectional. Could you just use two of these circuits, one for each direction?

schematic

simulate this circuit

And the answer is, yes you can. In fact, what I did is simply reproduce that dog-eating-tail circuit that the OP presented. It's the same thing. But now you can see the progression that led to it. And it's not as confusing as some odd, cross-wired dog-tail thing anymore. It's just two individually worked out circuits put together into one larger one.

But do you remember the earlier problem with the wrong circuit? The fact that there is sneaky base-collector diode that caused the circuit to operate incorrectly? This fact should remind us that all BJTs can also be operated in a reverse-active mode. Doing so, especially with the modern asymmetrical designs for their collectors and emitters, means that the \$\beta\$ in one mode will be different than the other (among some other differences.) But it does not mean they don't work.

So what if we just returned to our first circuit and merely add that extra pull-up:

schematic

simulate this circuit

Would this work? The answer is yes, it will indeed work. The only remaining question might be about which way to point the emitter. And this is where a good answer "depends." There are issues of charge storage to take into account, for example. (And this is a reason why there is a difference in behavior for the rising edge vs falling edge behavior shown in the graph by the OP.) The answer will depend on what you care about as there will be rising edge vs falling edge considerations and no one particular answer is always right. For my purposes here, I'm going to avoid dragging this out any further and instead leave that question as something to ponder. It's enough that this circuit works, regardless.


Note: The actual value of the resistors used in the above circuits isn't meant to imply that these are the only right values to use in some particular circumstance. Typically, digital outputs can sink more than \$1\:\textrm{mA}\$ of drive current and, typically, digital inputs will sink significantly less than \$100\:\mu\textrm{A}\$. But these assumptions may be wrong for specific cases. It's not hard to adjust the details, though. So the basic idea may still apply, though with reasoned changes in the resistor values.


There are more steps one might take, now. And Trevor found a nice example of where one might head. I'm going to include it here in order to capture that result. It's worth having. Those interested can consider the whys and wherefores. Without further explanation from me, enjoy Trevor's addition below:

enter image description here

\$\endgroup\$
8
  • \$\begingroup\$ good work.. here is another version of the same thing that piggy-backs two npns to make it more evenly bidirectional. i.cmpnet.com/planetanalog/features/Maxim_Level/FigSB5.gif \$\endgroup\$
    – Trevor_G
    Commented Apr 6, 2017 at 19:15
  • 1
    \$\begingroup\$ @Trevor Nice catch. Almost makes me want to add another bunch of paragraphs and progressive diagrams to my answer in order to reach that final result (which is worth including.) But my time for this is done, I think. So I think I'll simply upload your offering into my answer, without much comment, just by way of capturing it. Thanks! \$\endgroup\$
    – jonk
    Commented Apr 6, 2017 at 19:21
  • \$\begingroup\$ Interestingly that's almost back to where we started. Chasing tail transistors, but with common base. \$\endgroup\$
    – Trevor_G
    Commented Apr 6, 2017 at 19:29
  • 1
    \$\begingroup\$ You inspired me to update my own answer.. :) \$\endgroup\$
    – Trevor_G
    Commented Apr 6, 2017 at 19:55
  • 1
    \$\begingroup\$ @jonk I literally took notes on this answer and build the circuit, It worked both ways !! Thank you, Sirs, you Rock !! :) \$\endgroup\$
    – Mr.Sky
    Commented Apr 7, 2017 at 19:34
9
\$\begingroup\$

This is an emitter coupled convertor and as such needs no ground connection.

NOTE schematic labelling is a little ambiguous. "3V System" and "5v System" are the logic signals. +5V and +3V are the logic supply rails.

When you pull either side low you pull down the emitter of the opposite transistor which turns it on pulling the opposite output low.

The internal pull-ups handle the high logic states.

By the way, ground point is IMPLIED on that schematic. It is whatever +3V and +5V are referenced to.

Inspired by Jonk's answer I redrew the schematic this way to make it a little "clearer".

schematic

simulate this circuit – Schematic created using CircuitLab

But, in reality R3 and R4 can be combined, and the two transistors become a bi-direction transistor.

schematic

simulate this circuit

Which pretty much gets you to the same place as Jonk's answer.

\$\endgroup\$
12
  • \$\begingroup\$ Where should I measure to get voltage output 5V? \$\endgroup\$
    – Mr.Sky
    Commented Apr 5, 2017 at 19:36
  • \$\begingroup\$ 5v SYstem and 3V system are the logic signals. \$\endgroup\$
    – Trevor_G
    Commented Apr 5, 2017 at 19:38
  • 1
    \$\begingroup\$ @Mr.Sky Your ground.. which I assume is common to both sides. \$\endgroup\$
    – Trevor_G
    Commented Apr 5, 2017 at 19:43
  • 2
    \$\begingroup\$ It Worked !! Thank you so much! it was a hardware problem. Voltage needed to be measured between output pin and ground itself ! \$\endgroup\$
    – Mr.Sky
    Commented Apr 5, 2017 at 20:00
  • 1
    \$\begingroup\$ @Trevor Agreed about accepting this answer. Now that he knows it's only one direction, he should go look it up with past answers. It's been answered here a number of times (by me once or twice, not counting others.) So there's no real need for another question about it. \$\endgroup\$
    – jonk
    Commented Apr 5, 2017 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.