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).
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).
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.
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.
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...
The transistor 2n2222 is used to inverse the signal from high to low.