I've done some simple PCB's but am not a real electronics designer so forgive stupid mistakes or stupid questions.

I'm trying to detect a voltage range between 1-50 volts (VIN) as digital 'on' and when it is on, it also needs to switch of the battery connection/power to the circuit by applying the 3.3 voltage to the PNP.

I have buck converter giving the power to the PCB, but only if VIN is connected. When it is not connected, the battery needs to turn 'on' and supply the board. At the same time, i'm trying to detect the VIN digitally (and analog but that already works) on an atmega1284P.

here is the circuit. Is it allowed to have a voltage of 1-50 V on the base? Or would this be damaging the Atmega/transistor? How should I do it if this is not correct? enter image description here And here is the circuit of the PNP "switching" the battery to be always on, untill VIN is connected. Or at least that's what I'm trying to accomplish. enter image description here

Pin 1 of the battery(B1) is the +, pin 2 the -. I need the minus of the battery to be always connected to ground, because when I detect a voltage on VIN, a charging circuit will be turned on. I used a PNP because the battery should alwasy deliver the power, untill VIN is connected, the power should then come from the buck converter connected to VCC. Im in doubt because the voltage applied to the base of the PNP would be ~3.3V. lower than the 3.5 coming out the battery after the shottkey.


1 Answer 1


One can protect the base of a BJT from high voltages simply by having a sufficiently large base resistor. One drawback of such an approach is that the base current is roughly proportional to the input voltage. To get a sharp turn on, the resistor should be small. To get low current when the input voltage is high, the resistor should be large.

The following circuit turns "on" when the input voltage rises above somewhere around 0.7 V. It turns on sharply, but the current drawn by the base is limited by the low threshold voltage N-channel MOSFET M1. When Q1 conducts, it can only pull it's collector voltage down to near the threshold voltage of M1 plus the Vbe of Q1. Somewhere around 2V. When Q1 shunts it's collector down to 2V, the low threshold voltage P-channel MOSFET M2 conducts.


simulate this circuit – Schematic created using CircuitLab

Here are the characteristics of this circuit at various levels of input voltage.

enter image description here

enter image description here

As mentioned, the turn on is fairly sharp. The input current is never excessive. The total power consumption is fairly small.

I chose the MOSFETs because they were available on CircuitLab and they had low threshold voltages. You can use other MOSFETs provided the threshold voltages are small.

I made no attempt to use 1.0 V as the threshold voltage for the circuit, as I am guessing, it is not critical.

  • \$\begingroup\$ Super clear answer man. Thank you very much. And a good idea to use the MOSFETS. Didn't think of it, but a good idea! \$\endgroup\$
    – Oscar K
    Jan 14 at 21:04

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.