Can someone explain to me how this circuit works?
I know D3 is a flyback diode, and BSS138 is a FET which means a low voltage can drive the relay on or off.
What is the purpose of D2. Why use two LEDs D1a and D1b?
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It only takes a minute to sign up.Sign up to join this community
D2 speeds up the turn off of the relay.
When the MOSFET is turned off, the current in the relay coil needs somewhere to go. As you already understand, the current goes through D3, the flyback diode. Now, if that were all there was, it could take some time for the current to decay, as the energy stored in the coil is dissipated in heat in the resistance of the coil itself.
This is where D2 comes into play. Instead of ~1 V across the coil, D2 allows the current to form ~13 V across the coil (~12 V from the Zener D2 plus ~1 across D3). That results in a faster decay of the relay current, as the energy stored in the coil is wasted into heat also in D2.
The current decays more rapidly because (di/dt) = V / L, meaning that the rate of change of current in a given inductor is proportional to the voltage across it. At 13 V (with both diodes), the current drops more than 10 times faster that at 1 V (with a single diode).
why use two LEDs D1a and D1b?
Depending on your eye's position, the body of the relay could hide one of the LEDs. One LED on each side of the board, so you can see one no matter which way the board is installed.
To be exact, D3 by itself is not the flyback diode, because it is not directly over the coil.
However, both D3 and D2 together are over the coil, so they both are the flyback diodes.
Using a Zener and a regular diode is very common if the relay needs to have a fast release time by dissipating the energy with higher voltage compared to a simple diode.
With a normal diode, the coil energy is dissipated with only 0.7V voltage drop. With 12V Zener and normal diode in series, the coil energy is dissipated with 12.7V voltage drop.
And really, why there are two LEDs we can't guess. Maybe for double the visibility, visibility from different angles, or for redundancy, if for some reason the other LED gets damaged and does not work.