There are many ways to detect the presence of an object by using, capacitive proximity sensing, inductive, ultrasonic, magnetic, time-of-flight and optical. In this post we will go over using an infrared LED with a detector and how we can use them to detect the presence of an object. At the time, the perfect IR emitter detector sensor did not exist due to the mechanical constraints in the design. So a separate IR LED and detector were needed.
IR does have its limitations and these should be understood to provide the best method based on the applications needs.
Limitations:
Limited range.
Interference from ambient light.
Object material.
Angle of object from the device.
The working principle is that the IR LED emits the infrared light and when it hits an object the light is reflected back to the detector and we are looking to get a distance of a few centimetres only.
The Detector
The detector being used is the Vishay TSSP77038. First, we see from the datasheet that the TSSP77038 requires a carrier frequency of 38kHz. the supply voltage can be from -0.3 - 6V and the output from the detector is roughly the same as the supply voltage.
The datasheet then provides some waveforms. Looking at the "Optical Test Signal" waveform we can see that a modulated waveform is being used. So for 600uS we need to generate a 38kHz carrier frequency for the TSSP77038 to output a logic low.
Modulated Waveform
To modulate the required waveform we can use a 2-input AND gate where a 38kHz carrier frequency is fed to one input and a 600uS pulse/ envelope onto the second input. As the AND gate will only output a logic high when both inputs are high we will see the modulated signal which will be a 600uS burst of 38kHz. We can then use this signal to drive a n-channel MOSFET to turn the infrared LED on.
Timers
Using a microcontroller we will generate the two waveforms using timers to create the modulated waveform.
For the envelope signal we know that the frequency in the datasheet test signal is 100Hz as we are looking to get a 600uS pulse we can calculate the duty cycle of the PWM signal to be:
Setting the duty cycle to 6% should give a 600uS pulse at 100Hz.
We now have our modulated signal as per the specification of the detector datasheet.
Detector
Placing an object in front of the sensor the pulse duration changes in relation to the distance, where the closer the object the longer the pulse duration.
The code example for this post can be found on gitHub at
In the need of some electronics support, check out the services page for what is offered.
Comments