Photoelectric Sensor Interface Circuit Design

A photoelectric sensor detects an object by the change it makes to a beam of light. The optical part decides what can be seen; the circuit decides whether the change can be separated from sunlight, from a dirty lens and from the drift of its own components. Most installed sensors that fail do so for the second reason.

The Three Optical Arrangements

A through beam sensor puts the emitter and the receiver in separate housings facing each other. It gives the longest range and the most reliable detection, and it costs two housings and two cables. A break in the beam is unambiguous, which is why it is used where the object must be detected with certainty.

A retro reflective sensor puts both in one housing and uses a reflector on the far side. It is easier to install and roughly half as sensitive to a dirty lens, because the light passes the same dust twice. A polarising filter in front of the receiver allows it to ignore the reflection from a shiny object.

A diffuse sensor relies on the light scattered back from the object itself. It needs only one housing and no reflector, and its range depends on the colour and finish of the target. A white paper target may be detected at ten times the distance of a black one, which has to be allowed for in the installation.

Why modulated light Is Used

Modulated light solves the problem of the ambient. The emitter is switched at a few kilohertz, and the receiver amplifies only what arrives at that frequency. Sunlight and filament lamps are effectively constant over one cycle, so a narrow band amplifier rejects them even when they are far brighter than the emitter.

The modulation frequency is chosen well away from the mains frequency and its harmonics, and away from the chopping frequency of any switching regulator on the board. A frequency of a few kilohertz with a duty cycle near fifty percent gives the best rejection with a simple synchronous detector.

A synchronous demodulator multiplies the received signal by the transmitted waveform and integrates the result. Anything not at the modulation frequency averages to zero, and the integration time sets the bandwidth. A longer integration time improves the ambient light rejection at the cost of a slower response.

The photodiode front end

The photodiode is operated in photoconductive mode with a reverse bias, or in photovoltaic mode with no bias. The reverse biased connection is faster and has a lower junction capacitance, while the unbiased connection has less dark current and less noise.

A transimpedance amplifier is the standard front end. The feedback resistor sets the gain, and the capacitor across it sets the bandwidth together with the junction capacitance of the photodiode. Too little capacitance in the feedback path and the amplifier oscillates, so the value is calculated from the diode capacitance and the gain bandwidth product.

The feedback resistor is the largest noise source in the circuit at these levels. A resistor of a few megohms generates enough thermal noise to be visible, and the cure is either a larger signal, a narrower bandwidth, or a photodiode with a larger active area to collect more light.

Photoelectric sensor pair mounted on a detection board

Setting the Threshold and hysteresis

Hysteresis is the difference between the level at which the output turns on and the level at which it turns off. Without it, a signal that hovers at the threshold produces a burst of edges at the output, and the counter or the controller downstream sees hundreds of objects instead of one.

The threshold is set from two measurements: the signal with the beam clear and the signal with the object present. The midpoint is the natural setting, and the hysteresis is then made a fraction of the difference. For a clean beam the difference is large and the setting is uncritical; for a diffuse sensor on a dark target the difference may be small.

Where the contrast varies between installations, an automatic threshold that adapts to the beam level is worth the complexity. It stores the clear beam level at start up, or on a command, and sets a threshold relative to it. That removes the need for a screwdriver adjustment at each machine.

Alignment, Range and Optical Margin

Optical margin is the ratio of the received light to the light needed to switch. A sensor installed with a margin of ten to one works through dust, misalignment and aging, while one that just operates at the target distance will fail within weeks.

Alignment of a through beam sensor is the most common installation error. The emitter and receiver must be square to each other and centred, and the tolerance falls with distance. An alignment aid, either a visible indicator on the receiver or a meter on the received level, saves hours of trial and error.

The lens has to be kept clean. A small aperture reduces the amount of scattered light that reaches the detector, and it also reduces the dust that reaches the optical surface. Many industrial sensors add an air purge for the same reason.

Photodiode amplifier and comparator threshold layout on a sensor PCB

The Output Stage

The output is usually a transistor, either a PNP or an NPN type, capable of switching a few hundred milliamps. The output device should be protected against the inductive kick of a relay coil or a solenoid, and a flyback diode across the load is standard practice.

Short circuit protection is worth having on an output that is wired by an installer. A current limit that survives a short to the supply for an indefinite time costs a few parts and prevents a callout. Thermal shutdown of the output stage is a common feature in industrial sensors.

Where the sensor drives a logic input rather than a load, a series resistor and a clamp protect the input from the higher voltage of the sensor supply. The interface rules for that stage are the same as for any industrial input and are described in our guide to mixed signal board design.

Verification and Field Problems

Verify the sensor on a bench with a target at the extremes of the intended range and finish. Measure the received signal with an oscilloscope at the amplifier output, not at the digital output, because the digital output hides how much margin is left.

Record the clear beam level and the blocked level for each unit. A unit whose clear level is much lower than the others has an alignment or a lens problem, and finding it at the bench is cheaper than finding it at the machine.

A sensor that works in the morning and fails at noon is usually suffering from ambient light. Check for a window or a skylight that puts a patch of sunlight on the receiver, and confirm the modulation frequency is far from any fluorescent lamp ballast frequency. The assembly and release practices that keep these units consistent are collected in our PCB design release checklist and judging PCB quality.

FAQ

Why does my photoelectric sensor trigger without an object? Ambient light or a reflection reaching the receiver is the usual cause. Check the optical margin and confirm the modulation frequency is far from any lamp ballast.

What is a good optical margin? A received level about ten times the switching level gives a sensor that survives dust, ageing and a small misalignment.

Should I use a through beam or a diffuse sensor? Use through beam where detection must be certain, and diffuse where mounting on one side only is worth a wider variation in range.

Leave A Comment