How to Build an Infrared Proximity Switch Circuit with a Voltage Comparator Chip
In this project, we will build an infrared proximity switch circuit with a voltage comparator chip.
An infrared proximity switch sensor is a switch which will activate when the sensor detects an object, meaning it will activate if an object or anything at all goes in front of the sensor.
The infrared proximity switch sensor is a reflection-type photoelectric sensor which sends and receives infrared beams. Infrared proximity switches work by sending out beams of invisible infrared light. A photodetector on the proximity switch detects any reflections of this light. These reflections allow infrared proximity switches to determine whether there is an object nearby. When the infrared is able to read back the infrared beams that it sends out, then this means the path of the infrared is impeded, which means there is an object nearby. When the infrared sensor cannot read back the infrared beams it sends out, this means that the path is unimpeded and there is no object in front of the sensor, which is why it cannot read back the infrared beams it is sending out.
Normally, when the sensor is unblocked (no object in front of it), the sensor will output a HIGH signal (about 3.5V) on its signal line. When an object blocks the sensor so that the sensor can read back the infrared beams, then the sensor will output a LOW signal (0V) on its signal line.
This drastic change in voltage makes it very easy for a voltage comparator chip to read these voltages. How it does so is explained in detail below under the circuit schematic.
In this circuit, we will make it so that an LED lights up whenever an object is in front of the sensor and be off whenever no object is in front of it.
An infrared proximity switch such as the one we are using in this circuit has great application for real life.
The sensor can detect
any type of moving objects, so it can act as a motion detector circuit.
Components Needed
- Infrared Proximity Sensor Switch
- LM393 Voltage Comparator IC
- 330Ω resistor
- LED
The infrared proximity sensor switch can be obtained from ebay for about $5 normally.
It operates on 5V of power.
The distance the sensor can detect an object is between 3cm-80cm, and this distance is adjustable, so that if you want the sensor to only be triggered when within 10cm of the sensor, you can do so.
The infrared sensor is a 3-terminal device.
There is a red, green, and yellow wire.
The red wire is the +5V line. It connects to the +5V of power.
The green wire is the GND line. It connects to the GND terminal of the power supply.
The yellow wire is the signal line. It connects to the input of the LM393 voltage comparator. Being that it only outputs 2 values, LOW or HIGH, it is a digital input. The arduino will either read it as LOW or HIGH. Know that the signal on this sensor is active low. When the sensor does not detect any object, it outputs a HIGH signal. When it detects an object, it outputs a LOW signal (0v).
The LM393 is dual voltage comparator that can be obtained from cheaply from a number of online retailers. You can find it at Tayda Electronics at the following link: Tayda Electronics- LM393 Dual Voltage Comparator.
Before we actually build our comparator circuit, we first must go over in detail the pinout of an LM393 comparator IC, so that you know what each pin is and what each pin does.
An LM393 is a 8-pin chip.
The pinout is shown below:
The LM393 has 2 power inputs. These are labeled Vcc and GND. Vcc is where the positive terminal of the voltage supply gets inserted into. This supply voltage can be as high as 36V. GND is where the ground wire of the voltage source gets connected to. These 2 terminals complete the power path for the LM393 chip and gives it the power it needs to function.
Apart from power, we now deal with the 2 operational amplifiers that are internally within the chip. Each op amp has 2 inputs and one output. These op amps are independent of each other, meaning each one acts independently to give its own output value (based on their 2 input values). In1 (-) and In2 (-) are the inputs for the op amp 1. Output 1 is the output of this op amp. In2 (-) and In2 (+) are the inputs for op amp 2. Output 2 is the output of this op amp.
The other components we need are the LED and the 330Ω resistor in series to limit current to the LED so that it
doesn't burn out.
Infrared Proximity Switch Sensor Circuit Using a LM393 Voltage Comparator Chip
The schematic diagram of the infrared proximity switch circuit using a LM393 voltage comparator is shown below.
First, we must connect power to the sensor and to the voltage comparator chip.
Next, we connect the signal line of the sensor to the noninverting terminal of the comparator.
We wire up a voltage divider circuit between 2 100KΩ resistors. A voltage divider between 2 resistors have the same value will yield half the voltage powering the divider circuit, so the 5V powering it will be divided into 2.5V. 2.5V is then fed into the inverting terminal of the chip.
How an op amp works is whenever the voltage at the inverting terminal is greater than at the noninverting terminal, the output will be drawn up to VCC and the load at the output of the comparator, which is an LED in this circuit, will be turned on. When the voltage at the inverting terminal is less than at the noninverting terminal, the output will be drawn down to GND and the load, the LED, will not be powered on.
When the sensor does not detect any object, it normally outputs a HIGH signal of about 3.5V on its signal line. This means that the voltage at the noninverting terminal is 3.5V, while the voltage at the inverting terminal is 2.5V. Since the voltage is greater at the noninverting terminal, the output will be drawn down to ground and the LED will not be powered on. This is the case when the sensor does not detect any object.
When the sensor does detect an object, it outputs a LOW signal of about 0.07V. This means that the voltage at the noninverting terminal is 0.07V, while the voltage at the inverting terminal is 2.5V. Since the voltage is now greater at the inverting terminal, the output will be drawn up to VCC and the load, the LED, will be powered on.
And this is how an infrared proximity switch can work with a voltage comparator.
To see how this circuit works in real life, see the following video below.
Related Resources
How to Build an Infrared Proximity Switch Circuit with a NAND Gate