# Help understanding this schematic : Why is the diode there (AT89C2051 Programmer)?

I am having trouble understanding the following portion of schematic from AT89C2051 programmer circuit. Please help me comprehend what is going on here.

Here is what I understand:

• A1 directly controls the 12V going to AT89_RST pin
• When A1 is low,

• If A0 is high, AT89_RST pin sees high.
• if A0 is low, AT89_RST pin sees low.

So why is the 5V added there with the diode? I suspect it might be one of the following two reasons, but I really don't understand why.

• To pull up AT89_RST to 5V. But A0 can be driven both high and low. Why pull it up?
• As some form of protection to prevent A0 from getting roasted with 12V? I think it might be the case, but I don't understand how it works to prevent that.

Notes:

• AT89C2051 Programmer's Github.
• A0 and A1 are being driven by arduino (5V logic).

As some form of protection to prevent A0 from getting roasted with 12V? I think it might be the case, but I don't understand how it works to prevent that.

This is the answer. Here's how it works:

When A1 is high, 12V is supplied to the reset pin via the optocoupler. The reset pin is now at +12V, which would presumably damage whatever is connected to A0 without some sort of protection.

The diode is configured such that it will conduct when its anode (the pin connected between the two resistors) is greater than 5V. So when A1 is high, and reset is at 12V, that diode will begin to conduct, and clamps the voltage at its anode to 5V plus the forward voltage of the diode--call it 0.7V, so the anode is at 5.7V. R2 limits the amount of current that can flow through the diode, which prevents overloading the 12V supply and blowing up the diode. since it's 1k, and it will have 12-5.7=6.3V across it, it will have about 6.3 mA flowing through the diode and the resistor.

From the schematic at the github project you linked, A0 is connected to an arduino, and microcontrollers, like most ICs, are not rated to have any of their IOs at a higher voltage than that of their supply. Usually there are diodes from each pin to the positive and negative rails built into the IC for the suppression of ESD. If an IO pin is brought above the supply voltage, these diodes will conduct, and with sufficient, sustained current, the IC may be damaged. That's why it's important that the Arduino is not directly exposed to the 12V on the reset pin. Since D1 clamps to something like 5.7V, this could be enough that an ESD diode in the Arduino would begin to conduct, so R3 limits the amount of current that can be driven through the diode, and ensures that D1 does all of the clamping.

• Thanks a lot for the answer. If I'm not comfortable with exposing 5.7V to the Arduino pin, can I put a diode between R3 and A0 with the anode facing A0? Will it drop additional 0.7V? Sep 18, 2018 at 4:50
• Doing as you described would mean that the Arduino can pull the reset pin low, but cannot drive it high, so you could do that, but you would have to add a pullup resistor in addition to the diode. As long as D1, R2, and R3 are there the Arduino will be plenty safe.
– ajb
Sep 18, 2018 at 5:00