A simple and fast light barrier

I have developed a circuit of a simple light barrier. It had to be able of switching really fast, so using a relay was not an option for me.

I will not show the sender part of the light barrier as it is nothing more than a LED and its resistor limiting the current that flows through the LED.

Below is the schematic of the receiver part:

Schematics of the receiver part of the light barrier

The circuit consists of the 2 resistors R1 and R2, a comparator and the photo diode and while my test it was supplied with an Uin of 5V.

R1 and the photo diode work as a light dependent voltage divider. When there is no light received on the photo diode, its reverse current (dark current) is typically lower than 5 nano ampere, which equals to a resistance of more than 1 Gigaohm when supplied with 5 Volt. This means that when the photo diode in the above schematic does not receive any light, the voltage level of the positive input of the comparator (labeled „+“) will be equal to zero. This will result in the comparator outputting zero at Uout, indicatic that no object is detected.

When the photo diode receives light, its reverse current will rise linear with the intensity, which results in the photo diode pulling up the positive input of the comparator according to the intensity of the light radiation it receives. Typically the maximum reverse current on light exposure (photo current) is around 30 micro ampere, wich at 5 Volts equals a resistance of 170 Kilo Ohm. If the light intesity is high enough to pull the positive input of the comparator above the reference voltage Vref, the comparator will output the supply voltage at Uout to indicate that it has detected an object.

The value of R1 defines the voltage range that the photo diode can set at the positive input of the comparator and therefore defines the voltage range usable for your reference voltage Vref. At a certain value of R1 you can get the broadest possible voltage range for the Vref. This optimal value can be calculated using following formulas:

R1opt = (Rpmax + Rpmin) / 3

Rpmax = Uin / ID

Rpmin = Uin / IL

R1opt is the optimal resistance value for R1. Rpmax is the resistance of the photo diode when it is not hit by light radiation, while Rpmin is the resistance of the photo diode when it is exposed to the maximum possible light radiation. ID is the reverse current of the photo diode when it is in the dark. IL is the reverse current the photo diode puts out when exposed to maximum light radiation.

You can calculate the usable voltage range for the Vref with the formulas below:

Umax = Uin * R1 / (Rpmin + R1)

Umin = Uin * R1 / (Rpmax + R1)

In the schematics above R1 is 100 Kilo Ohm, so you will get following usable voltage range for the Vref:

Umax = 5 V * 100000 Ohm / (170000 Ohm + 100000 Ohm) = 1,85 V

Umin = 5V * 100000 Ohm / (1000000000 Ohm + 100000 Ohm) = 0,00 V

With the optimal value for R1 of 133 Mega Ohm in the schematics above you would get a usable voltage range from 0,59V to 4,99V.

If you want to swap the detection behaviour, you simply need to swap the connections to the positive and negative input of the comparator: Connect the Vref to the positive input and the anode to the negative input of the comparator. This will result in the comparator outputting the supply voltage when nothing is detected and zero when it has detected an object.