Save big on A03TM50000 PhotoReflector. We offer the lowest prices and highest quality, with free shipping on any orders over $100 1(877)414-2679. Like a photointerrupter and photoreflector which detect an object when it interrupts or reflects light. However, detection errors might occur if fluctuating background light such as room lighting strikes the photosensor. To prevent these detection errors, one typical method uses optical filters by utilizing the. This IR Distance Interrupter features a high-sensitivity RFR-359F photoreflector to perform distance detection function. The photoreflector consists of a GaAs infared light emitting diode and a silicon planar phototransistor. When the infrared light emitted by the emitter gets reflected on.

Reflective photosensor (photoreflector) RPR-220 Applications Outline. Compact disc players. Game machines. Copiers. Office automation equipment Features 1) A plastic lens is used for high sensitivity. 2) A built-in visible light filter minimizes the influence of stray light. 3) Lightweight and compact. Dimensions (Unit: mm).

Robots can employ many types of sensors with very different operating principles and features to acquire data from the environment. In this article we focus on reviewing sensors which operate by detecting infrared radiation in one form or another. Infrared sensors for robots are used for a variety of purposes, there are IR range sensors used for measuring distances to objects, IR proximity sensors which can successfully replace physical contact sensors, passive infrared (PIR) sensors which can be used to detect motion based on detecting heat radiated by a body, IR sensors used for data transmission — either between robots or with a stationary beacon or base — and positioning, and even gas concentration measurements can be performed with certain types of IR sensors.

Sharp GP2Y0A02YK0F IR Range Sensor

GP2Y0A02YK0F is an infrared sensor build by Sharp and is one of the most powerful infrared sensors that can be used to build a robot.

Sharp GP2Y0A02YK0F is a distance sensor composed of three elements:

  • Position sensitive detector;
  • IRED (infrared emitting diode);
  • Signal processing circuit.

The sensor can detect everything that exists in front of it at a distance between 20 to 150 cm (7.87 to 59.05 in). These values are quite real and make from this sensor a standard of IR sensors for distance. The distance between the sensor and the object is directly proportional with analog voltage value. Information from the sensor can be captured by means of the 3-wire interface.


  • Operating supply voltage: 4.5 V to 5.5 V;
  • Operating supply current: 33 to 50 mA;
  • Output terminal voltage: -0.3 V to 5.3 V;
  • Detection range: 20 cm to 150 cm (7.87 to 59.05 in);
  • Typical response time: 39 ms;
  • Typical start-up delay: 44 ms;
  • Output type: analog.

DFRobot adjustable IR Sensor Switch

This adjustable IR sensor switch from DFRobot is one of the most well performing sensors for measuring distance. The distance between sensor and object detected can be between 3 to 80 cm. The sensor from DFRobot is perfect for detecting and avoiding obstacles by the robot. It is easy to use, install, does not occupy much space and comes with full documentation. Analog signal varies in value depending on the distance between the sensor and the object detected.


  • Power supply: 5 V;
  • Current: 100 mA;
  • Range: 3-80 cm adjustable;
  • Red: +5V; Yellow: Signal; Green: GND;
  • Model: SEN0019.

Phidgets 1103 IR Reflective Sensor


The 1103 IR reflective sensor from Phidgets is used to detect objects at a distance of up to 10 cm. The sensor works only for objects that do not emit bright light, for example a light bulb, but works equally well in dim and brightly lit environments.


  • Supply voltage: 4.75 V to 5.25 V;
  • Current consumption: 9 mA;
  • Output impedance: 1 KOhm.

Sharp IS417F IR Proximity Detector

The IS417F proximity detector from Sharp is an IR sensor that can be used as short-range wide-angle proximity detector or for non-contact bump sensing.

It uses a LED as an IR light source to illuminate the objects. Using this LED the sensor makes the detection, insensitive to ambient lighting.

Dagu Compound IR Sensor

This compound IR sensor from Dagu Electronic can be used to track movement within 200 mm. The negative part for this sensor is that it does not function as set in bright light, such as sunlight, bright light produces a blinding effect for the sensor. Operating mode of the sensor is simple, it sends IR light to the object and follows the light reflected.


  • Track movement within 200 mm;
  • Simple range finder function.

Sparkfun SEN-08630 PIR Motion Sensor

The SEN-08630 sensor can detect movement of living beings that emit heat, it is a sensor that can be used to build robots that need to detect motion in social environments. Motion detection is done by comparison between a snapshot of the environment and what is moving after snapshot, if there is movement, the sensor generates an output.


  • Product length: 1.27 inches;
  • Product height: 1 inches;
  • Product width: 0.96 inches;
  • Voltage: 3.3 – 5 V.

Pololu IR Beacon Transceiver

The IR beacon transceiver from Pololu is a compact board that is used in pairs to allow robots to locate each other, the idea behind this product is communication between robots. Suppose that two robots want to communicate with each other and know the distance and the direction where is heading one of them. In this case, for both robots such a plate is used which has integrated up to 4 IR sensors. The beacons work by transmitting and detecting infrared light, much like a television remote control.


  • PCB size: 1.35″ circle;
  • IR modulation frequency: 56 kHz;
  • Output refresh rate: 20 Hz;
  • Detection range: 6 inches to 20 feet;
  • Supply voltage: 6-16 V;
  • Data voltage: 5 V;
  • Number of IR detectors: 4.

Fairchild QRB1134 IR Photoreflector

The QRB1134 is an IR photoreflector sensor that works simply by emitting an infrared light and detect it. Objects that are in front of sensor reflect the light, depending on the distance between sensor and object. Analog output of the sensor is proportional to the amount of light received.


Can be used for line following robots, the optimal working distance of the sensor is 0.5 cm (0.2 inches).

SenseAir CO2 Engine BLG

The CO2 Engine BLG from SenseAir is a non-dispersive infrared (NDIR) sensor for measuring CO2 concentration in the environment. It can be used for robots that work especially in areas with high degree of danger for humans.

The sensor also measures relative humidity (RH) and temperature and can also store logs of its measurements. It is designed to be battery operated. It is equipped with alarm function which is activated if CO2 emissions exceed a certain amount. Measurement ranges are available from 400 ppm up to 30% vol CO2 and it can be configured as flow-through or diffusion sensor.

SRS Home Front Page Monthly Issue Index
Author:Dafydd Walters < [email protected] >
Date:September 30, 2000

1. Abstract

This article describes how to implement a simple, but robust, optical wheel encoder system on a robot that uses hobby servos for two-wheel differential drive. In my case I am using the TJ-PROTM robot platform from MekatronixTM, and some aspects of this article are specific to that platform. However, it should be easy to adapt the hardware and software for virtually any robot with an HC11 controller board.

This article details the hardware you will need (and where you can buy it), construction methods, and software techniques for implementing navigation by dead reckoning. The software examples are written in Newton Labs' Interactive C ('IC') version 3.2. To make use of the code samples, I am assuming you know how to load C and binary modules in IC, and that you know how to use the start_process( ) function.

Rather than being heavy in theory, this is written more as a 'how to' article. If you are interested in the theory, I would refer you to the Rossum Project article in the Links section at the end.

2. Hardware

At the heart of this design is a pair of Hamamatsu P5587 photoreflectors (figure 1), one mounted on each side of the robot behind the wheels. Each wheel has a cardboard disc fixed to it with 48 alternating black and white segments.

2.1 Principle of Operation

The tiny 5-legged Hamamatsu photoreflector package contains an infrared ('IR') LED and a matching IR phototransistor, both mounted on the top of the device in such a way that the phototransistor will detect reflected IR light emitted from the LED when a bright surface (such as white card) is positioned within a few millimeters of the device.

Figure 1. Hamamatsu P5587 Photoreflector

As the wheel turns, and the photoreflector 'sees' the white segments between the black segments, the phototransistor outputs a digital pulse train. By counting the pulses, and knowing the number of segments and diameter of the wheel, the robot can compute its position based on the distance traveled by the wheels.

2.2 Parts List

Table 1 lists the complete bill of materials for this project.

Hamamatsu P5587 photoreflector
(part # R64-P5587)
750 ohm 1/4 watt resistor
6.8 K ohm 1/8 watt resistor
0.1 µF capacitor (ceramic)
Ribbon cable (2 runs of 3 way used)
Header strip (0.1' pitch)
Mr RobotTM
Double sided tape (foam center)
Office supplies store
8eachNylon washer #6Hardware store
2sheetCard stock suitable for feeding through printerOffice supplies store

Table 1. Parts List

2.3 Construction

Cut out two small pieces from the stripboard (figure 2). These will form the circuit boards that will be attached to the servos, upon which the Hamamatsu P5587 photoreflectors will be mounted. The smallest size into which it is practical to cut the boards is 1.4 inch x 0.4 inch. This is the size I used, although in retrospect I could have made the boards wider (perhaps 1.0 inch rather than 0.4 inch) to make it easier to populate the components and wire them up.

Figure 2. Circuit board (front & back) - right wheel

Drill two 3mm diameter holes in the boards, 0.15 inch from one side, 0.2 inch from the bottom, and 0.4 inch apart. IMPORTANT: The two boards are not the same! One is the mirror image of the other, so the holes must be drilled on the correct side as determined by which side of the robot the board will be mounted. Figure 2 shows the board for the RIGHT side wheel. See also figure 8 which shows the assembled board mounted on the right servo.

Cut an 8-inch strip (this length is correct for the TJ-PROTM robot; use whatever length is appropriate for your own robot) of black, white and gray wire from the ribbon cable (this is just for consistency with the wiring color scheme used on MekatronixTM robots; use whichever colors make sense in your own robot's wiring scheme). Cut a 3-connection header from the header strip, and solder one end of the wires to the header pins.

Insert the photoreflector into the board first (figure 3) and solder it in place. The pins of the photoreflector have to be bent apart in order to reach the 0.1' pitch holes in the stripboard. Solder the wires at the free end of the 3-way ribbon to the top of the board (refer to figure 8).

Figure 3. Board with photoreflector fitted.

Referring to the schematic in figure 4, build the circuit on the board. If you buy the P5587 from Acroname, it comes with a datasheet that identifies the pin numbers of the part.

Figure 4. Circuit Schematic

ALWAYS carefully double check all your connections visually after you've finished assembling your boards.

Figure 5. Assembled board

Right-click on the picture of the encoder disk in figure 6 and save it to your computer's hard disk. Print out two copies of the image at 300 dots per inch on card (not paper). Use a laser printer if possible (ink jet 'splatter' could cause problems). Using a hobby knife on a cutting mat, carefully cut around the circles and also cut out the center of the circles so that the card discs fit snugly over the wheel bushes.

Figure 6. Encoder disc

Using small pieces of double-sided foam-centered sticky tape, attach the card discs to the wheels (figure 7).

Astropad for mac. Figure 7. Wheels with discs attached

Mount the boards on the servos (figure 8) using nylon washers to separate the back of the boards from the metal bushes in the servo mounting holes (figure 9) to prevent short circuits.

Figure 8. Finished board mounted in place - right wheel

Figure 9. Metal bushes in servo mounting holes


Plug the header for the right wheel encoder into the PA1 connector (JP10) on the MTJPRO11 board, and the header for the left wheel encoder into the PA2 connector (JP11). The black (GND) wires are closest to the outside of the MTJPRO11 board.

Figure 10. Boards connected to MTJPRO11

2.4 Initial hardware testing

With power applied to the board, watch the output of the photoreflector with a voltmeter flick between high (5V) to low (0V) as you SLOWLY turn the wheels by hand.

3. Software

3.1 Coordinate system

Before we can start writing any meaningful code for navigation, we need to define a coordinate system for the robot's world. We will assume that the robot lives in a two-dimensional world. This means that at any given time its position can be defined in terms of 2-D Cartesian coordinates and the direction it is facing can be defined as an angle measured from one of the axes (see figure 11).

Figure 11. Coordinate System

In keeping with mathematical conventions, we will assume that the angle that defines the orientation of the robot (theta) is measured counterclockwise from the x-axis. This means that in figure 11, for example, theta is positive. If the robot was facing 'south', theta would be negative.

We will assume that the position coordinates, x and y, are in meters, and that the orientation angle, theta, is in radians (PI radians = 180 degrees, where PI = 3.14159 approximately).

Examples (assuming north is straight up the y-axis):

  • 1 meter west of origin facing south = {-1.0, 0.0, -PI/2.0}
  • 1 meter north of origin facing west = {0.0, 1.0, PI}or{0.0, 1.0, -PI}
  • 1 meter south of origin facing east = {0.0, -1.0, 0.0}

3.2 Pulse counting

Working from the lowest level of functionality upwards, the first thing we will need, in order to implement a successful odometry system is accurate pulse counts from the wheel encoders. By counting the pulses from our wheel encoders, we can deduce the distance each wheel has traveled. However, our simple wheel encoders do not tell us the direction a wheel is turning (more sophisticated quadrature encoders do). We will overcome this limitation by using the fact that we know which way the wheels should be turning by adapting the code we use to drive the servo motors (more on this later).

Listing 1 is an IC assembly language source module that counts the pulses output by the photoreflectors as the white and black segments fly past. The variables right_count and left_count increase in value with each passing segment when the wheels are being driven forwards, and decrease when the wheels are being driven backwards. This works by using the input capture function of PORT A bits 1 and 2 (input capture pins IC2 and IC1 respectively) to generate interrupts every time there is a rising or falling edge on these pins. The interrupt handlers increment or decrement the 16-bit counters depending on the values of the variables left_direction and right_direction (which are set by the motor drive code - more on this later).

Right-click here to download odometer.asm. Right-click here to download odometer.icb (the file you must load into IC).

Listing 2 shows the changes required to the motor drive function so that the interrupt handlers in listing 1 know which way the motors are being driven. The bold text shows the code that has been added to the function.

Listing 2.

3.3 Position calculation

Listing 3 contains the code that calculates the position of the robot from the wheel encoder pulse counts. The theory behind the math in this listing may be found in the Rossum Project article by G. W. Lucas referenced at the end of this article in the Links section.

Right-click here to download odometer.c

In your code, (e.g. main( ) function), you need to call initialize_odometry( ), and then start the function odometer_thread( ) in its own thread with start_process(odometer_thread( )); The position of the robot is stored in the global variable current_position, and is continuously updated.

Notice that the function enable_interrupts(0) is called just before 'sampling' the encoder counts and setting them back to zero, and enable_interrupts(1) is called just afterwards. This function, implemented as an assembly language module (listing 4), masks the interrupts when the parameter is 0, and re-enables interrupts when the parameter is 1. The purpose of having interrupts disabled briefly while sampling and resetting the wheel counts is to ensure that no counts are lost in the brief moment between sampling and resetting.

WARNING: Don't attempt to use this function in your own code unless you are certain of what you are doing. Several parts of the system are dependent on interrupts, including the IC multitasking executive, timers, output compare functions (that drive the servos), asynchronous communications with the PC, and more! Only disable interrupts for the briefest possible period. If in doubt, don't do it!

Right-click here to download intr.asm. Right-click here to download intr.icb (the file you must load into IC).

Listing 4.

3.4 Driving the robot

Because our encoder hardware does not allow the robot to know the direction of rotation of the wheels, we are making the assumption that the robot can deduce which way a wheel is rotating from the direction it is being driven.

For this assumption to be correct, we must be careful not to rapidly change the direction of rotation of the wheel at any time. This is because a turning wheel has inertia. If we drive the direction of a wheel from forward to reverse without commanding the wheel to stop in between (and waiting sufficiently long to ensure that the wheel has actually stopped) the wheel may actually turn one or two ticks of the encoder output in the forward direction under its own inertia before it actually changes direction. However, our code would believe that those one or two ticks were in the reverse direction!

The simplest solution to this problem is to command the motor to stop and then pause between each direction change. A wheel that's turning quickly has more inertia that one that's turning slowly, so you can either choose a 'worst case' pause duration, or adjust the duration according to how much power was being driven to the wheel.

The approach I took was to develop a layer of motor drive software above the my_motor_drive_function( ) primitive, that ramps the motor speed gradually up and down, so that there are never any sudden changes of motor speed except when a collision is detected (and in this instance, the simple delay mechanism mentioned earlier is employed). Details of this approach are beyond the scope of this article and are left as an exercise for the reader.

4. Results

I've had very good results with this system on hard floors. The robot can travel for several meters, performing several turns, and still knows its position accurately within a few centimeters. However, on carpeted floors, wheel slippage results in very rapid odometry drift, especially when the robot turns.

At the time of writing this article, I'm working on a system for correcting odometry drift by using sonar readings from a sonar sensor mounted on a pan-and-tilt head. The code is being written in C (ImageCraft's ICC11TM). I hope to document this work in a future article.

5. Links

  • Dead Reckoning article (from the Rossum Project) by G. W. Lucas
  • MekatronixTM, maker of the TJ-PROTM and other robot platforms

Bugs in this article

Please don't hesitate to email me and let me know if you've found any errors or omissions in this article.

Photo Reflector Near Me

Copyright © 2000, Dafydd Walters
[email protected]

Permission to copy all or part of this article, and to use or modify the code samples is freely granted, with the condition that copyright messages must be retained.

Photoreflector Sensor

TJ-PROTM and MekatronixTM are trademarks of Mekatronix, Inc.
ICC11TM is a trademark of ImageCraft Creations, Inc.
Mr. RobotTM is a trademark of NovaSoft, Inc and Mr. Robot
RadioShack® is a registered trademark of RadioShack, Corp.

Photo Reflectors For Portraits