I'm reading a schematic (done by a former employee) with a microcontroller, and I came across this circuit:

Sample circuit

What is the function of D1?

Also, I think that R2 isn't necessary, because the control input come from another GPIO that always has 1 or 0 as its output.

Besides this one, there is another block of this same circuit but connected to the RESET pin of the microcontroller. This part of the circuit is used to flash the microcontroller via ISP.

R1 = 47k
R2,R3 = 10k
D1 = 1N4148
  • 3
    \$\begingroup\$ You do realize that the GPIO does not actually have a "1" or a "0" but that it has voltages that represent these symbols? \$\endgroup\$ – placeholder Nov 18 '14 at 14:12
  • \$\begingroup\$ What microcontroller are you using? \$\endgroup\$ – Peter Mortensen Nov 19 '14 at 17:15
  • \$\begingroup\$ @PeterMortensen: LPC1759 \$\endgroup\$ – Ricardo Crudo Nov 20 '14 at 13:38

It's there to protect the B-E junction of Q1 from reverse breakdown.

For positive input voltages, the B-E junction of Q1 will conduct, and the voltage at the base will be limited to about +0.65V. As long as R1 is sized appropriately to limit the current, fairly arbitrary positive voltages can be applied to the input.

D1 provides a similar path for negative input currents, guaranteeing that the base voltage never goes below -0.65V for the same range of negative voltages.

  • \$\begingroup\$ hmm, I got it. So, in this case it isn't necessary. I guess I know what happened. Originally this control pin was receiving signal from a DTR pin, of the old RS232 serial port, now, that I have GPIO to GPIO control, I believe I don't need it anymore. \$\endgroup\$ – Ricardo Crudo Nov 18 '14 at 15:23
  • 6
    \$\begingroup\$ Clamping diodes like that are rarely "needed" as a required part of the design. Instead, they are for just-in-case situations that you don't plan for. Are you 100% certain that the power supply will never have a hiccup? That some load dump condition will never occur for a few milliseconds? That some other component on the board won't fail and cause an unexpected negative voltage? The diode certainly isn't hurting anything, so I wouldn't think removing its potential benefit is a good idea. \$\endgroup\$ – Dan Laks Nov 18 '14 at 16:41
  • \$\begingroup\$ @DanLaks - nonetheless, such protections are not normally used between microcontrollers (if on the same board / supply). What we are looking at here is a discrete RS232 level shifter (complete with inverter). Probably the entire circuit is now superfluous - even if there is a difference between IO voltages, there are simpler solutions and the inversion can usually be done in software. \$\endgroup\$ – Chris Stratton Nov 19 '14 at 16:20
  • \$\begingroup\$ Just to add to this: reverse breakdown in bipolar transistors happens in the 3-6V range, so you don't need that much voltage to go outside the specs of the part + at that point the device can be damaged. \$\endgroup\$ – Jason S Nov 19 '14 at 16:41

That is called an "input clamping" diode. It's often done with two diodes, not just one (one to Vcc as well as one to GND), and is used to "clamp" the incoming voltage to ground minus the forward voltage of the diode (or Vcc plus the forward voltage for the upper diode).

enter image description here

In your circuit it is specifically to remove any negative voltages from the input.


Question poster mentioned the critical info in his comment "Originally this control pin was receiving signal from a DTR pin, of the old RS232 serial port" - that's the real answer to "why"; RS232 uses negative voltages for signalling (as low as -15v), hence the (fairly large) current limiting resistor R1 and diode D1 to stop the transistor getting fried by being reverse-biased across the base-emitter junction. You don't normally see (or need) this kind of diode if it's being driven by a CPU; typically just a current limiting resistor will do.


As others have suggested, but not explicitly stated, the diode is basic input protection for an externally accessible input. I.e. the pin is likely on a connector which the user of this device drives.

On the other hand, if this control input is not external, the diode is likely not required unless it's being driven from a circuit that provides a negative voltage under normal operation (i.e. maybe its a negative going pulse like +/-5V square wave, or being driven by an AC coupled waveform). Protecting a transistor like this if negative voltages are not expected is probably pointless since something far worse has happened if your circuit is driving a negative voltage unexpectedly, and in which case the base resistor R1 likely provides enough protection anyway.


Just noticed you mentioned that a microcontroller drives the CONTROL input, so I'd say the diode is pointless, since you've got a much bigger problem if the microcontroller is driving a negative voltage.

Also just as you alluded, if the microcontroller is always driving the output then R2 is also pointless. However, in reset state many microcontrollers will tristate their outputs, and possibly enable pull-ups. The enabled pull-ups could cause a small current to flow in the base, multiply that by a couple hundred and that's the current that would flow through the transistor. This depends on the strength of the internal pull-ups (~50 - 100kOhm is typical).


Your Answer

