5
\$\begingroup\$

For an Arduino project I needed both 5V and 12V voltages. Specifically, for an IC I needed 5V and I needed to be able to switch it on and off using an Arduino PIN. Since the current drawn by the IC might exceed what can be drawn from the Atmega328 pins, and since I couldn't tolerate any less than 5V, I tried using the following circuit. enter image description here

So the idea was to control the 12V source using the BC547 transistor with the base controlled by an Arduino pin, and then to feed the emitter of the transistor into a standard 7805 regulator setup (with cap sizes taken from the 7805 datasheet).

However, the circuit doesn't work as expected. I'm only seeing 4.32V on the emitter of the transistor - not 12V as I had expected. I can see that the input to the base is drive to 5V, and given the 4K resistor there should be amble current for the base (at least for 100-200 of collector-emitter current). Yet it seems the only voltage I'm seeing at the emitter is the mentioned 4.32V which seems to be just the base voltage minus some voltage drop. Changing the 4K resistor to e.g. 800 ohm didn't change this.

So what is the problem here? It is not possible to control 12V using 5V at the base? If so, from what values in the datasheet can this fact be derived?

I tried replacing the BC547 with a 2N7000 MOSFET, and that actually worked and I'm seeing 11.3V at the emitter of the transistor, and 5V at the output PIN, as expected. But I don't see why the BC547 couldn't do the job.

\$\endgroup\$
10
  • \$\begingroup\$ No - it can't work. With 5V on the base of the transistor you only get 4.3V to the input of the 5V regulator. It would be much better to use a P channel MOSFET to switch the supply. \$\endgroup\$ Feb 7, 2015 at 13:13
  • \$\begingroup\$ Thanks - but how come it seems to work in other situations. See for instance the answer to: electronics.stackexchange.com/questions/51522/…. The exact same situation and the diagram in the answer seems to suggest this setup. Is that wrong too? \$\endgroup\$
    – Morty
    Feb 7, 2015 at 14:28
  • \$\begingroup\$ Also, please see: electronics-tutorials.ws/transistor/tran_4.html, specifically the "Digital Logic Transistor Switch". \$\endgroup\$
    – Morty
    Feb 7, 2015 at 15:01
  • \$\begingroup\$ How much current does the 5 V regulator need to supply? \$\endgroup\$ Feb 7, 2015 at 15:36
  • 1
    \$\begingroup\$ Get a more modern regulator with an "enable" pin and you could save parts count. \$\endgroup\$
    – pjc50
    Feb 8, 2015 at 1:00

3 Answers 3

10
\$\begingroup\$

The problem is that your transistor is connected in emitter follower configuration. The output will always be a bit less than the input. The point of a emitter follower is usually current gain, you actually get a small loss in voltage.

It would be better to use a PNP to switch the voltage into the regulator, instead of the NPN you show:

When the digital signal goes high, the emitter of Q2 will be about 700 mV less, or about 4.3 V. That will cause 10 mA to flow thru R1, most of which will be coming thru the collector of Q2, which also means it will be going thru the base of Q1. R2 is only to guarantee Q1 will be off when intended, despite a little leakage and maybe some noise in the system.

You didn't say how much current you need at 5 V, but this needs to be considered. The maximum current Q1 can handle will be its base current times its gain. In this example, the base current is about 10 mA as already shown. With a gain of 30, for example, this setup can support up to 300 mA. If you need more current than that, then changing Q1 to a darlington or a P channel FET will probably be a better tradeoff than increasing the base current.

This circuit is intended to be simple and work with a wide range of parts. Q2 can be just about any small signal NPN transistor. Q1 could be a jellybean PNP if you only need 100 mA or so. Otherwise, a small power transistor may be better.

Added:

You now say that the regulator only needs to supply 30 mA maximum at 5 V. In that case Q1 can be most any jellybean PNP transistor, like a 2N4403. Such small transistors will have more gain than a power transistor. Figure you can count on a gain of 50 minimum, so the base current only needs to be 600 µA. A couple of mA base current would then be enough to put Q1 solidly into saturation. That allows making R1 larger, like 2 kΩ. So here is the final circuit:

\$\endgroup\$
5
  • \$\begingroup\$ Thanks for the detailed explanation. However I'm not sure I understand the circuit. What is the individual purpose of Q1 and Q2? Q1 seems to always be on? \$\endgroup\$
    – Morty
    Feb 7, 2015 at 14:38
  • \$\begingroup\$ Also try and see this page: electronics-tutorials.ws/transistor/tran_4.html, specifically the "Digital Logic Transistor Switch". This seems to be the same usage I need and configured the same way. so is this guide wrong? According to the answers here, the circuit they display should open just 4.3V, not 12V. \$\endgroup\$
    – Morty
    Feb 7, 2015 at 14:50
  • 2
    \$\begingroup\$ @Morty: When the digital signal is low, Q2 is off. Current then can't flow out of the base of Q1, so it will be off too. The net result is that the 5V output will be on when the digital signal is high, and off when the digital signal is low. \$\endgroup\$ Feb 7, 2015 at 15:34
  • \$\begingroup\$ Ah thanks I had seen the Q1 as an NPN but now see it is an PNP. Makes sense :) \$\endgroup\$
    – Morty
    Feb 7, 2015 at 17:02
  • \$\begingroup\$ Olin, was thinking if the following circuit using two NPN's could work as well. I've left out the 7805 but it's supposed to be connected to the output of Q1. In this circuit, the meaning of the input PIN is reversed so 0 means the voltage to the regulator is on and vice versa. The idea is that a one in input, would drag away the current from the base of Q1, so it would close. \$\endgroup\$
    – Morty
    Feb 8, 2015 at 11:10
5
\$\begingroup\$

You need something called a "High-Side Driver" circuit. This allows you to control a higher voltage power supply from a low-voltage control input.

This can be made from either bipolar transistors or MOSFETS or a combination of both. I'll show a simple version using a pair of MOSFETs - note that the high voltage being switched is limited by the maximum voltage that can be applied to the gate of the high-side FET. But it will do for illustration purposes and can be enhanced with the extra components needed for voltages higher than the max allowable Vgs of the upper FET.

schematic

simulate this circuit – Schematic created using CircuitLab

R2 is included only a a precaution against Q1 oscillating, It should be mounted as close to the FET as possible.

\$\endgroup\$
4
  • \$\begingroup\$ Thanks but I'm unsure about what the individual purpose of Q1 and Q2 is (see also the diagram below where I was unsure as well). Why can't the effect be achived with a single MOSFET? \$\endgroup\$
    – Morty
    Feb 7, 2015 at 14:39
  • \$\begingroup\$ @Morty: because there's no way to provide the necessary voltage levels for a single-transistor/MOSFET solution by your MCU. \$\endgroup\$ Feb 7, 2015 at 16:31
  • \$\begingroup\$ What is the advantage of using a n-MOSFET for Q1, instead of a simple NPN transistor, like a 2N3904? \$\endgroup\$
    – not2qubit
    Feb 25, 2019 at 23:16
  • \$\begingroup\$ No real difference between using a BJT or MOSFET for Q1. I often use a BJT for Q2 as well but that requires an extra resistor or two. \$\endgroup\$ Feb 26, 2019 at 17:14
2
\$\begingroup\$

As Dwayne has given a very suitable working circuit (+1 from me) I will concentrate my answer on why your circuit does not work.

enter image description here

You have made three basic errors.

(1) You are using the BC547 (NPN transistor) as an emitter follower and not as a switch. This means that the voltage at the emitter will always be about 0.7V less than the base voltage. If you supply a 5V base signal the output cannot rise above about 4.3 volts no matter how much you reduce the base resistance value. Switching from the positive line use a PNP type transistor or preferably a P channel MOSFET (see Dwayne's answer)

(2) For a 7805 to work it must have a minimum of 2V difference between input and output. There are other regulators that require less (Low Drop Out or LDO). Even these could not work because they need the input to be higher than the output. There should be a minimal voltage drop across the switching device. MOSFETs are superior to BJTs.

(3) A 7805 (as distinct from a 78L05) is capable of a 1A output, if your circuit had managed to switch the regulator ON you would have fried the transistor if a current larger than a few hundred mA was drawn from the regulator. Ensure that any device you use to switch the regulator is capable of switching sufficient current.

\$\endgroup\$
5
  • \$\begingroup\$ Some things you say in point 2 are misleading at best. Yes, a 7805 needs considerable headroom on the input, up to 2.5 V. However, there is still plenty of room from the 7.5 V needed at the input to the 12 V power supply. "There should be minimal voltage drop across the switch" is wrong in this case. Even a darlington would be fine here, and may actually be a good answer. \$\endgroup\$ Feb 7, 2015 at 14:28
  • \$\begingroup\$ Thanks I will look up the emitter follower etc. Regarding error #2 it's really a consequence of error #1. If the NPN has been able to switch the 12V (with, say, some small voltage drop of 0.7V) it would have been plenty for the 7805. Regarding #3, actually all I need is around 20 ma on the output side, but it is still more than what I want to draw from the Atmega directly. \$\endgroup\$
    – Morty
    Feb 7, 2015 at 14:36
  • \$\begingroup\$ @OlinLathrop - point 2 is certainly not misleading given the information in the question. The point is that the circuit shown is an emitter follower that uses the transistor in its linear region. It is not a common emitter circuit used in its saturated region. The input signal is 5V. If the input signal was raised to about 8V or above you could get the circuit to work but it still doesn't work as a transistor switch. Personally I think it is good practice when using any electronic device as a switch to have the minimum voltage drop across it. This does not exclude any bjt or mosfet solution. \$\endgroup\$ Feb 7, 2015 at 18:33
  • \$\begingroup\$ If is often useful to minimize the voltage drop across a switch, but insisting that it is always good practice is just religious silliness. In this case, there is at least 4.5 V that will be dropped somehow somwhere, if not in the switch then in the regulator. This is a great example where it makes sense to allow a higher voltage drop across the switch to get better values for other parameters that do matter. \$\endgroup\$ Feb 7, 2015 at 20:16
  • 1
    \$\begingroup\$ @OlinLathrop Apparently it is such a good example that you totally fail to mention it in your answer. I also notice you have gone a 'minimal voltage across the switch' design. Do I accuse you of "religious silliness" - No. I'm certain that all experienced designers of switched mode power supplies, digital chips etc. have in their mind to minimise the voltage drop across a switch in order to improve efficiency (good practice). You are correct that in this particular case that energy will have to be lost somewhere. Changing to a 78L05 would help (point 3) by limiting a S/C output to about 100mA. \$\endgroup\$ Feb 10, 2015 at 12:54

Your Answer

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

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