# What is the purpose of 9th pin in ULN2003

Whenever I need to use relays with Microcontroller, I use ULN2003. I connect the GPIO from MCU to the input pin of ULN. Connect 8th pin of ULN to GND and take output from the ULN. I normally set high(5v) the GPIO, ULN inverts it(0v) and gives it to coil of relay. I connect 2nd coil to 12v so relay works. I have never used 9th pin of ULN. But I have found in few schematics that the designer has connected this pin to 12v via diode, like below:

Now if the main purpose of 9th pin is to connect it to 12v, then why this diode is used in this configuration, as it will block 12v, so 9th pin will not be connected to 12v. Am I misunderstanding something. Please guide.

• Pin #9 will be connected to 12V whenever its voltage goes above 12V (plus Vf of the diode), which can happen when turning off inductive loads. – JimmyB Nov 18 '16 at 12:59

The purpose of the pin is to provide a flyback diode aka catch diode aka freewheeling diode on each output for inductive loads, so that the inductive energy stored in the coil does not break down the output transistor of the ULN2003 and possibly damage it.

When a Darlington driving an inductive load attempts to switch off, the load inductance will cause Vce to increase while the current stays almost the same. The absolute maximum output voltage is 50V for this chip, and it will likely be exceeded with a 12V relay switching off. The result is that the stored energy is mostly dissipated in the transistor, which can damage it.

What happens if you look at it from the relay coil's point of view, referencing to the +12V supply, the other side of the coil goes from -12V to + high voltage, while the current tries to stay the same (maybe -36mA). This effect is why you see a spark when you disconnect a relay coil or a motor by touching wires. If the ULN2003 breaks down at +70V you will have +58V across the coil and 2.5W being (briefly) dissipated by a microscopic transistor.

Common (not best) practice is to connect that pin (the internal diodes) to the relay supply voltage. The current then circulates through the diode which (drops only 0.6V or so) and coil and dies off as the energy is lost in the relay coil resistance. It's a sub-optimal circuit and will likely result in the relays' life being foreshortened below datasheet expectations, but it is simple and protects the driver well.

There is little to be gained in adding the external 1N4004 as you have shown. Possibly the designer did not understand how it works.

As with just about every other component in existence, you could have found the answer by reading the datasheet

It's used when you're switching an inductive load (a motor, for example) and you need flyback (a.k.a. freewheel) diodes to protect the transistors from voltage spikes when the motor stops. It's a common cathode for all of the freewheel diodes. If you're only switching something like LEDs or other non-inductive loads, you can leave it unconnected. Relays are inductive, though, so I would connect it in your case.

simulate this circuit – Schematic created using CircuitLab

This is what you get if you connect relay and pin 9 to +12V source, there is one such diode transistor circuit for each channel in ULN. Imagine now what happens when you switch off transistor, coil produces reverse current because of discharge, this current is consumed by diode. So diode protects transistor from high reverse voltage. Additional diode in your circuit is there just for additional precaution, not strictly necessary.

• A coil does not produce a reverse current. A coil will maintain the same direction of the current (the voltage across the coil will reverse). – efox29 Nov 18 '16 at 13:22