Phototransistor Edge Detection


This Circuit Module is aimed at helping our MiniSumo 'Bot stay in the dohyo. Our control system needs an indication that some action is required, this method of detecting the dohyo's white edge uses the reflection and detection of infrared light. In this Application Sheet we consider circuit operation rather than the strategy of detector location or action to be taken.

We have selected a combined IR LED/Prototransistor package based on its simplicity, cost, compact size and apparent tolerance to back ground light sources. This application note is based on the OPB608B , described as a "Reflective Object Sensor" from Optek Technology Inc. but there are a number of manufacturers, and sources, for similar components.

The circuit can be broken down into two sections, the LED driving circuit which produces the IR light and the Phototransistor circuit for IR detection and our signal output.

Driving LEDs.

Figure 1 LED Circuit LEDs must be connected to the power supply through a resistor to restrict current flow, Figure 1, this helps to protect the LED from premature failure and degradation.

The LEDs forward voltage (Vf) can be read from the component Data Sheet, in our case 1.7V. Using a supply voltage of 5V (Vcc) you can see we must drop 3.3v over the resistor (R1). While the Data Sheet shows a maximum Forward Current (If) is 50mA, we can also see the data sheet uses a figure of 20mA for test conditions. This is typical for LEDs giving us an operational Factor of Safety and reducing the degradation effects and should be used for our application.

From these figures we can calculate the limiting Resistor :-

    R1 = (Vcc-Vf)/If

Please note your own supply voltage when applying this formula to calculate your own limiting resistor.

When we round this figure to the nearest convenient resistor value, or we expect a voltage drop, we can check the expected LED current :-


    R1 = (5-1.7) / (20x10-3) = 165Ω, leading to 150Ω or 180Ω as nearest.

  this leads to

    If = (5-1.7) / 150 = 22.0 mA or
    If = (5-1.7) / 180 = 18.3 mA

Note: When using multiple LEDs it's permissable to connect several in series with a single limiting resistor, but LEDs in Parallel must have their own limiting resistors to ensure that they are properly protected.

The power dissipated (Pd) in the limiting resistor can be calculated

    Pd = If x (Vcc - Vf)
        = (22.0 x 10-3) x (5 - 1.7) = 72.6 mW

so a 1/8 Watt resistor, or larger, is adequate for our application.

While we are unable to see the IR LED output there are quick tests we can do to check operation. The firstly we could view the LED through a digital camera, or webcam, which will generally show the IR light as bright white, alternatively test with a multimeter. With the power applied the voltage at the Test Point should be Vf as predicted (1.7V). If it's at the supply voltage level (5V) the LED is open, connected backwards or there is a wiring problem.


Now that we have the IR source we can use the Phototransistor to detect the reflected light. The phototransistor works like a transistor but the base current comes from an integral photodiode so that we need only connect the collector and emitter of the transistor.

The phototransistor can be configured as either a Common-Emitter or Common-collector Amplifier. The Common-Emitter, Figure 2, would give a transition in the output from Low to High Voltage on detection of IR light, while the Common-Collector, Figure 3, would give a High to Low transition.

Figure 2 Common-Emitter Circuit Figure 3 Common-Collector Circuit

Both of these circuits can be used in "active" or "switch" modes. "Active" mode means that output voltage will vary in proportion to the light received by the component, up to a maximum level. "Switch" mode operation gives an "On" or "Off" responce to the light detected. These modes are selected by adjusting the load resistor in the amplifier circuit.

    For Active Mode Vcc > R2 x Icc

    For Switch Mode Vcc < R2 x Icc

Where R2 is the Resistor Load and Icc is the Collector Current of the Phototransistor in the On state, found in the Data Sheet. While Switch mode can be useful, and will readily interface with a microcontrollers digital Input, Active Mode can be read through a Microcontrollers A/D Input allowing thresholds for switching to be set in the controlling software.

For our application we can calculate the Resistor for Active Mode as

    R2 = Vcc / Icc = 5 / 4 mA = 1250Ω

Based on supply voltage of 5V, obviously a drop in Vcc would keep R2 on the right side of the calculation.

Now with power applied to both the LED and Phototransistor, through our calculated resistors, we can measure the responce of the circuit to white and black surfaces with a multimetre or an A/D input of our controller.

Circuit Application and Conclusions

It should be noted that this circuit will tend towards a black responce as the phototransistor is moved away from the detectable surface. Ideally the phototransistor should be mounted rigidly at the optimum distance from the surface, as per the data sheet - 2.79mm in this case.

We can see the circuit offers a simple 3 component construction with a variety of output options which are fixed at construction. In our application it's seen to give a reasonable responce to the change from black to white surfaces. The pictures below show the sensor set up as "Active Common-Collector" with a 1.5K resistor and 4.5V battery pack on a printed Test Sheet. On the left 0V on the black surface and to the right 2.09V on the white surface.

Edge Sensor on Black Edge Sensor on White

While the component construction doesn't lend itself to Bread Board development simple component to component soldering, as shown below, allows ready connection to breadboard circuits. We colour coded for positive and negative battery connections and sensor output, and used Heat Shrink to protect against short circuit. For simplicity it could be modified to give a three wire connection to our circuit board.

Edge Sensor

The 2004 guide price for this assembly is £2.50 but a similar construction using separate IR LED and Phototransistor could take this below £1.00 but would require consideration to shielding the phototransistor from direct IR Transmission as well as possible background interference. Modulation could be used when filtering out background interference when using separate components but this technique is beyond the scope of this application sheet.

Comments and discussion on this application are welcome, there is a topic set up on the MiniSumo Forum.


Product Bulletin OPB608, Reflective Object Sensors

Application Bulletin 213, Basic Design Ideas for Emitters and Sensors

Thanks to Optek Technology Inc for their kind permission to reproduce their data sheets for the purpose of this application sheet. We recommended checking the latest relevant documentation for components used in your application.

    (01 June 2010) - Thanks to Jie Chen.
    Corrected relationship between Vcc, R2 & Icc for the mode of phototransisitor operation.

Terms of Use ©, 2005 - 2011. Web Master Contact.