# How to calculate the resistor values for the zener diode and the BJT base?

I try to convert ~12V signal from a car button (the input voltage can be from 10V to 14V) to a logic level signal for MCU, but the signal should to be inverted (1 = 0, 0 = 1).

Below is my schema, but I'm not sure how to calculate the resistor values for the zener diode and for the base of the transistor to make sure that the transistor will be saturated and active.

I'm using a zener diode because the car voltage is not always 12V, so I want to regulate the voltage that is controlling the transistor base.

If you know a much better way to achieve my needs, they are welcomed, but please help me understand how to calculate those resistors in my schematic.

Below, I describe the schema as I understand it in my knowledge limits (I may make mistakes).

1. The resistor R4 is needed to reduce the current passed through the zener diode.

(12V - 4.7V) / ((5mA + 1mA) / 1000) = 1216.7 Ω

12V is the input signal.

4.7V is the zener value.

5mA is the minimal current needed for zener to work properly.

1mA is the current needed for my needs (to saturate the transistor).

2. The capacitor C4 is used to make sure the zener works stable.

As I understand, at this point, we have a stable 4.7V, and the maximum current we can use for our needs is ~1mA.

1. The resistor R5 is a pull-down resistor with a big value. In my opinion this resistor can be ignored during the math, because its resistance is big, and I do not need a very precise math.

2. The resistor R6 is the resistor for the BJT base of the BJT 2n2222. Normally, without the zener diode, the math would be like this:

(4.7V - 0.7V) / (5V / 10000 Ω / 50 hFe) = 400000 Ω

But 400 kΩ looks like extremely big value...

3. The transistor 2n2222 is used to inverse the signal from high to low.

• Zener is not necessary in that schematic. Dec 13, 2022 at 19:37
• @user263983 I understand that I can drive the BJT base directly from my 12V signal, but I would like to learn how to do that with a zener diode. Dec 13, 2022 at 19:39
• Please edit your question to reword all the places where you say "open the transistor" to "turn the transistor on". English engineering usage is that a transistor is either an "open circuit" (not conducting) or a "closed circuit". Other languages, and some beginning English-language circuit designers who use the "it's just like plumbing with electrons" use "open" to mean "conducting". As you can imagine, this confuses the heck out of the experienced crew who wants to help you. "Conducting" and "not conducting" are unambiguous. Dec 13, 2022 at 20:05
• OK -- given that it's in a car, the zener may be a good idea, to protect from over- or reverse-voltage. You should edit your question to explain why you're using it. Dec 13, 2022 at 20:06
• @TimWescott Thank you for explanation. I edited the question, I hope now it is simpler to understand. Dec 13, 2022 at 20:25

5mA is the minimal current needed for zener to work properly

Define "properly". In this circuit, you really only need that to protect against load dumps, when the automotive rail may go from the normal 11-15V range to 60V. So it's OK for this current to be zero, even, in normal operation.

1mA is the current needed for my needs (to saturate the transistor).

(4.7V - 0.7V) / (5V / 10000 Ω / 50 hFe) = 400000 Ω

I assume you're going from some cookbook, and don't realize that you're contradicting yourself.

A 2N2222 has an $$\\mathrm{H_{FE}}\$$ of around 10 when it's saturated good and hard. If you're using a specific part here you can look at the data sheet -- but I assume that calling out 2N2222 here (which is, specifically, a metal can transistor, in a TO-18 case) means that you're using a generic. $$\\mathrm{H_{FE_{SAT}}} = 10\$$ is proper for pretty much all the small-signal transistors from the 1970's, although it's too pessimistic for a "superbeta" transistor from the 1990's.

Your collector current is $$\\frac{5 \mathrm V}{10 \mathrm{k}\Omega} = 500\mu \mathrm A\$$. So the base current needed to reliably saturate the transistor is more like $$\50 \mathrm{\mu A}\$$.

However, you call out "50 hFe" above. That's appropriate for more modern transistors, but for a 2N2222 or other devices of its class, you want to use 10.

So to flow $$\5 \mathrm{mA}\$$ into the base, you need

$$\frac{4.7\mathrm V - 0.7 \mathrm V}{5 \mathrm{\mu A}} = 80\mathrm{k \Omega}.$$

Then select a resistor value below this.

For a "good" circuit testing, you should use a FREE interactive simulator like this one.
Although your calculations seem "correct", you should be aware for some problems with the temperature of the circuit if you want a "reproducible" behavior.

Here is how should be the behavior of your schematic (some modifications were made for a "more" stable circuit).
To see how it is working, do a DC Analysis with a parameter (your Vin) and show the output voltage needed (I added a BJT for inverting the "function").

I added another stepped parameter which is the temperature (0°, 25°, 50°)...
Youn can note a "large" dispersion of the characteristics.

Other means could be used as HC MOS gates or op-amps.

• Rather than a zener, a transzorb or varistor would be a better choice as they will provide better ESD performance. You’d select a device that wouldn’t conduct in normal operation. Dec 14, 2022 at 10:12