5

I have a controller which has an active low input and an internal pull-up resistance of 200k tied 0.8V. I would like to use a BJT as a switch for the microcontroller to control the controller input. When there is a 3.3V output from the microcontroller, it will trigger a pull-down to ground the controller input.

The problem here is I am puzzled by choosing a value for R3. After I performed the calculation, the outcome is a very small current and very large resistor. How should I correlate this back to the BJT datasheet? Am I doing this right? The BJT I am using is an NPN BC847BW.

schematic

simulate this circuit – Schematic created using CircuitLab

I did below calculation.

Ic = 0.8V / 200K = 4uA

Using 1/10 of Ic rule of thumb:

Ib = Ic / B = 4uA / 10 = 0.4uA

R3 = (Vbb - Vbe) / Ib = (3.3 - 0.7) / 0.4uA = 6.5Mohm

Math Keeps Me Busy
  • 23,260
  • 4
  • 21
  • 75
sunny
  • 75
  • 7

3 Answers3

3

The base current you calculated is the minimum current needed to switch. You can drive more current into the base.

The switch design you propose is a so-called saturated switch, so the transistor saturates when it is turned on. Before the transistor can turn off, the base has to discharge. It will do so either through the base resistor when the MCU output is zero, or through a smaller base-emitter resistor added to the circuit. In your original circuit, the turn off will take a long time, and this time will also depend on how long the transistor was turned on. Up to some limit, the longer it stayed on, the longer it will take to turn off.

But, most importantly: the driver is entirely optional. The controller doesn't really need it. You can connect GPIO directly to the controller input. Set the GPIO pin to zero/low state, and then control the output by changing the direction of GPIO. Input direction: output floats up to 0.8V, output direction: output gets dragged to zero.

But if you insist on a driver, then the absolutely simplest solution is a logic-level threshold voltage NMOS transistor. It doesn't even need to be super special - 2N7000 will do. No resistors. Gate to MCU GPIO pin, drain to controller input, source to GND. Done. The load is so light that it should work in all circumstances.

  • does that mean the Beta number isn't critical or important. I need not to constraint my calculation to fix at 1/10 of Ic? – sunny Oct 12 '23 at 05:50
2

This is not a problem. Recognize that the Vce(sat) will not be zero. Increasing the base current drive will reduce the Vce(sat) .. up to a point.. above which the Vce(sat) will start to increase. With reasonable values of base drive you should be able to get Vce(sat) guaranted < 10mV over temperature. Here I would go with R3 = 10k ohm, which is a convenient value and results in a low Vce(sat).

enter image description here

A much higher value such as 2M ohm will also 'work' but the Vce(sat) will be much higher typically:

enter image description here

Such a high resistance on the base also leaves it more open to picking up EMI or detecting leakage on the PCB.

In some cases you may be able to configure your GPIO to be open-drain and connect it directly, but there are some pitfalls and it's outside the scope of this answer.

Spehro Pefhany
  • 397,265
  • 22
  • 337
  • 893
1

What you calculated for R3 is kind of the max value. An R3 value quite lower than the value you calculated should be used so that the NPN will properly pulldown the input to the controller to almost 0V. A low value of R3 will increase the base current so, may be you can use something like 100k as your R3 to keep the base current to a reasonable value.

sai
  • 3,822
  • 1
  • 3
  • 13
  • 1
    Any base resistor between 4k7 and 100k sounds reasonable (so the suggestions 100k and 10k don't contradict). You shouldn't go higher, to make sure that radio interference is drained into the uC output if the switch is supposed to be of. If you have a mobile phone at hand, set it to 2G GSM mode (assuming you have a GSM network where you live) and then call it, while placed next to the transistor, it is very likely that you get spurious activation of the controller with 1M or higher base resistors. Don't go 6M (yet your calculation is correct). – Michael Karcher Oct 12 '23 at 08:25