Anda di halaman 1dari 9

Sensors and Actuators A 155 (2009) 7381

Contents lists available at ScienceDirect

Sensors and Actuators A: Physical


journal homepage: www.elsevier.com/locate/sna

The optical mouse sensor as an incremental rotary encoder


M. Tresanchez, T. Pallej, M. Teixid, J. Palacn
Department of Computer Science and Industrial Engineering, Universitat de Lleida, Jaume II, 69, 25001 Lleida, Spain

a r t i c l e

i n f o

Article history:
Received 3 February 2009
Received in revised form 18 May 2009
Accepted 4 August 2009
Available online 8 August 2009
Keywords:
Optical mouse
Mouse sensor
Rotary encoder
Displacement sensor

a b s t r a c t
In this paper, a new application and capabilities of the sensor of the optical mouse are presented. An
inexpensive incremental rotary encoder is built based on a mechanical assembly where the sensor is at a
xed distance from a rotary white surface onto which a reference black line is drawn. The optical mouse
sensor measures changes in position by optically acquiring sequential surface images and mathematically
determining the direction and magnitude of movement. The optical sensor uses the information of the
images acquired and an attached light source in a closed control loop to keep an average illumination
level in the images. In this paper, the registers involved in this control loop are used to detect high
contrast marks without any dedicated image-processing procedure. The detection of this reference mark
in a rotary white surface allows the correction of long term cumulative errors originated in displacement
measurements performed by the optical sensor and enables the use of the rotary encoder in precision
measurements close to 1900 counts per revolution.
2009 Elsevier B.V. All rights reserved.

1. Introduction
The computer mouse, invented in 1964, has evolved from the
initial mechanical conguration based on wheels and a rotating
ball to the actual design based on optical sensors. The inexpensive
optical mouse sensor can be used specically as a displacement
sensor. In [1] the optical sensor is proposed and tested as a twodimensional displacement sensor over opaque objects when the
height offset does not exceed 1.25 mm. In [2] the optical sensor is
characterized as a motion sensor showing that limitations mainly
arise from the sensitivity of the device to the texture of the reference surface and the upper limit of the working speed. In [3],
the optical mouse sensor shows a very good coefcient of determination in a linear displacement over typical ground surfaces,
R2 = 0.9998, but a high dependence on the relative height of the
sensor with an error of 1% for an offset of 0.1 mm, and very bad
measurements in circular trajectories.
Despite these known problems, the optical mouse sensor has
been used in robotics to measure the displacement and trajectory of
a mobile robot [3,4]. In [59], several redundant optical sensors are
used to reduce the positioning error and eliminate measurement
outliers. In [9] an improvement of 26% in the measurement of the
speed is reported using two complementary sensors.
The optical mouse sensor can be used in other applications
where a kind of linear optical ow [10] is needed. In [11], the sensor is used to measure vibrations. In [12], it is used as a tracking

Corresponding author. Tel.: +34 973 702724; fax: +34 973 702702.
E-mail address: palacin@diei.udl.es (J. Palacn).
0924-4247/$ see front matter 2009 Elsevier B.V. All rights reserved.
doi:10.1016/j.sna.2009.08.003

device for surgical instruments in training setups. In [13], it is used


as a tracking device for small animals, in [14], to measure the solid
circulation rate in a circulating uidized bed and in [15] to classify
different types of materials and their surfaces as polished or milled.
Recently, in [16] the effects of illumination and acceleration on
the optical mouse sensor were analyzed using a laser-based sensor
(ADNS-6010). The results showed that acceleration and deceleration require a specic calibration when the sensor was used as
a precision measurement system. The results also showed a poor
correlation of the measurements of both axes and proved that this
correlation can be improved using additional light sources. We
agree with these results because the illumination obtained with a
standard LED is more diffuse and uniform than that obtained with
a laser-based LED (see Fig. 1).
In this paper, the optical mouse sensor is proposed as an inexpensive incremental rotary encoder. This application avoids the
most important problem associated with this optical sensor, its
strong sensitivity to height variations. In the encoder, the optical
sensor will be attached to the inner radial surface of a wheel to measure the displacement during a rotation with a known and xed
height, radius and measurement surface. Only one axis of the optical sensor is needed for the measurements while a reference mark
on the rotating surface will be used to count the number of revolutions, to correct cumulative errors in the displacement measured,
and for automatic internal calibration of the number of counts per
revolution (cpr) of the rotary encoder. The odometry in a low cost
mobile robot is the main design application of this device attached
or embedded in a caster or driving wheel although it could be used
in other inexpensive applications where a rotary measurement is
also needed.

74

M. Tresanchez et al. / Sensors and Actuators A 155 (2009) 7381

Fig. 1. Example of images obtained with two optical mouse sensors: LED-based
ADNS-3088 LED (left), laser-based ADNS-6010 (right).

bits data message. As an example, a low cost microprocessor such


as the PIC18F4550 working at 48 MHz requires 130 s to read one
register.
The ADNS-3088 provides read and write access to 31 internal
registers [17]. The relative displacement measured by the sensor
is obtained reading the MOTION, DELTA X, and DELTA Y registers.
The DELTA registers contain the accumulated relative displacement
since the last sensor reading (from 127 to 128). The MOTION register is 1 when any of the DELTA registers is different to zero and
can be used as a motion ag. The family of the ADNS-308X also
has other interesting registers, such as PIXEL BURST (values from
0 to 63) that allows sequential access (pixel by pixel) to the image
captured by the sensor, and SQUAL, SHUTTER, PIXELSUM that are
internal registers used to control the illumination of the area under
the sensor and will be explained later in the next section.
3. Detecting reference marks

Fig. 2. Sectional view of typical assembly of an optical mouse sensor (courtesy of


Avago).

The paper is structured as follows. Section 2 introduces the


working principle of the optical mouse sensor. Section 3 describes
the method proposed to detect reference marks. Section 4 describes
the implementation of the incremental rotary encoder. Section
5 shows the validation of the rotary encoder. Finally, Section 6
presents the nal conclusions.
2. Sensor description
The optical mouse sensor used in this paper is the ADNS-3088
[17] witch is an updated version of the versatile ADNS-3080 analyzed previously in [9]. The optical sensor includes a digital signal
processor (DSP) and a CMOS camera of 30 30 pixels on the same
chip. The optical mouse sensor is based on a very compact image
acquisition system with the following parts (Fig. 2): the main
sensor, an infrared light source (LED-based) that illuminates the
surface, and a convex lens that collects the reected light. All the
parts are mounted clipped in a base plane to keep the device very
close to the surface at a nominal distance of 2.4 mm.
The optical mouse sensor measures changes in position by
optically acquiring sequential surface images (frames) and mathematically determining the direction and magnitude of movement
at a very high rate (up to 6400 frames/s); the DSP detects small
variations in the roughness of the surface by means of the shadows created by the source light (see Fig. 1) that is also controlled
in a closed loop to maintain a constant illumination range in
the images acquired. According to the manufacturer specications, the maximum measurable speed is 40 in. per second (ips)
(1.016 m/s), the maximum acceleration during measurements is
15 g (147.15 m/s2 ) and the selectable resolutions are 400 and 800
counts per in. (cpi). The communication with the optical sensor is
performed by the standard SPI bus using an 8 bit address and 8

The optical sensor generates cumulative error in the measurements [1,4] even in the case of a placement at a xed height
and displacements parallel to its internal axis. This error can be
reduced by averaging a high number of sensors (10 or more) [3]
although this solution is not valid for a small and inexpensive rotary
encoder so, in this paper, we propose the inclusion of reference
marks on the rotary white surface screened by the optical sensor.
The detection of reference marks will enable the correction of the
displacement/rotation measured by the sensor although they will
require an initial calibration to establish the reference value of the
existing counts from mark to mark. In the case of a rotary encoder
the simplest mark is a radial black line (from the center to the outer
radius of the rotary surface). Once detected, the relative cumulated
value of the internal counters can be corrected with the reference
value corresponding to one revolution. The detection of the reference black line can be performed using two alternative methods:
reading the image acquired by the sensor and applying some imageprocessing algorithms or exploiting the information provided by
some additional internal registers involved in the control loop of
the illumination of the optical sensor.
The image acquired by the sensor can be read by repetitive
access to the PIXEL BURST register although this reading stops any
motion measurement and a long time is required to get the complete image using the SPI bus; 900 readings for a 30 30 image
(26 ms in SPI burst mode). The introduction of an internal image
buffer to allow complete image reading without stopping the sensor will enhance the development of unexpected new applications
of the optical mouse sensor [10]. As an alternative, some additional
internal registers as SQUAL, SHUTTER, and PIXELSUM offers average information of the internal status of the illumination control
loop and the image acquired by the sensor. These registers can be
read at any moment without disturbing the sensor and are candidates for indirect black-mark detection without reading the image
acquired by the sensor.
3.1. Detecting marks using SQUAL
The SQUAL register gives information about the changes (also
called features) detected in the image currently being analyzed.
This register is an indication of the roughness of the surface mea-

Table 1
Paper types analyzed.
Type

Size

Color

Manufacturer

Reference

Normal
Recycled
Adhesive

A4
A4
A4

White
White
White

International Paper
Evercopy Plus
Impega

70476
50048
00123

Weight
80 g/m2
80 g/m2
100 g/m2

SQUAL

Displacement

14 5
168 11
64 9

Bad (0)
OK
OK

M. Tresanchez et al. / Sensors and Actuators A 155 (2009) 7381

75

Fig. 3. Image of the experiment performed to evaluate the effect of one transversal
black line in some internal registers of the optical mouse sensor.

sured indirectly through the shadows enhanced by the lateral


illumination applied. The SQUAL register has values from 0 to 169;
a high value means that the image-processing algorithm used to
detect motion will have more points to compare and the motion
will be measured more accurately. As a reference, Table 1 shows
the value of the SQUAL register when placing the optical mouse
sensor over some standard paper for ofce use. The optical sensor does not work properly in the case of ne and reecting white
paper and, in general, SQUAL values greater than 30 ensure good
detection of the displacement.
Fig. 4 shows the dynamic evolution of the SQUAL register in a
forward displacement of the optical sensor (parallel to the y-axis)
over an adhesive white surface (see Table 1) with three transversal black lines, 1.2, 3.2 and 5.2 mm wide respectively, and elapsed
25.4 mm (1 in.) (Fig. 3); the lines where printed on a standard laser
printer. Fig. 4 shows that the SQUAL register has values from 50 to
68 for the white paper but has two positive peaks when the sensor
reaches the beginning and end of the lines and one or two negative
peaks depending on the width of the line. The number of features
detected varies very little in the white paper, increases suddenly in
the border of the lines, decreases suddenly when the line is completely under the sensor (the image becomes almost black and no
features are detected).

Fig. 4. Dynamic evolution of the SQUAL register when moving the optical mouse
sensor over white paper with three transversal black lines of width: 1.2, 3.2 and
5.2 mm, elapsed 25.4 mm.

Fig. 5. Dynamic evolution of the SHUTTER register when moving the optical mouse
sensor over white paper with three transversal black lines of width: 1.2, 3.2 and
5.2 mm, elapsed 25.4 mm.

3.2. Detecting marks using SHUTTER


The SHUTTER register is an indication of the intensity applied to
the LED, and then of the emitted light. When the image becomes
dark, an internal control loop increases the intensity applied to the
LED to keep an average illumination on the image. The SHUTTER has
16 bits of resolution and a high and a low register value; in each
step, the intensity applied to the LED changes 1/16. Fig. 5 shows
the dynamic evolution of the SHUTTER register when repeating the
displacement over the same surface and lines as in the previous
paragraph. Fig. 5 shows that the SHUTTER register has values from
20 to 25 for the white paper but increases to 40 for a width of
1.2 mm, 100 for a width of 3.2 mm and up to 270 for a width of
5.2 mm (see Fig. 3).
The results shown in Fig. 5 were obtained with a linear movement at a xed speed and the height of the peak is proportional
to the line width. Fig. 6 shows the minimum and maximum value
(peak) of the SHUTTER for a set of experiments with black lines of
different widths. The linear speed of the displacement was xed and
constant and lines were isolated with at least 20 mm of unmarked
white surface. The most interesting result is that the minimum
value is always the same (surface dependent) whereas the height
of the peak increases as the width of the line increases, although it

Fig. 6. Maximum and minimum value of the SHUTTER register for different line
widths.

76

M. Tresanchez et al. / Sensors and Actuators A 155 (2009) 7381

Fig. 7. Dynamic evolution of the PIXELSUM register when moving the optical mouse
sensor over white paper with three transversal black lines of width: 1.2, 3.2 and
5.2 mm, elapsed 25.4 mm.

saturates for widths greater than 7.6 mm. Therefore, an isolated line
wider than 2 mm can be easily detected by reading the SHUTTER
register and applying a threshold detection value of 60.
3.3. Detecting marks using PIXELSUM
The PIXELSUM register is the cumulative value of all the pixels of
the image currently analyzed by the sensor. The register has 8 bits
and its value must be multiplied by 256 to get the real value of the
cumulative addition of the 900 pixels in the image; its maximum
value is 221 (all pixels white). Fig. 7 shows the dynamic evolution
of the PIXELSUM register when repeating the displacement over
the same surface and lines as in the two previous paragraphs. Fig. 7
shows that the PIXELSUM register values range from 130 to 150 for
the white paper but decrease to 60 for a width of 1.2 mm, to 42 for
a width of 3.2 mm and 35 for a width of 5.2 mm (see Fig. 3). After
this initial negative peak, a positive peak up to 220 appears for the
width of 5.2 mm. This positive peak is originated by the internal
control loop of the camera that suddenly increases the intensity
of the LED to force the black line to appear almost white in the
image. Obviously, as the black line disappears from the image, the
PIXELSUM value also increases because the image is then too white.
Fig. 8 shows the maximum, average and minimum value of the
PIXELSUM register for a set of experiments with black lines of different widths. The linear speed of the displacement was xed and
constant (100 mm/s) and lines were isolated with at least 20 mm

Fig. 8. Maximum, average and minimum value of the PIXELSUM register for different line widths.

of unmarked white surface. Fig. 8 shows average values in a short


range, from 130 to 140. The maximum values correspond to the
height of the positive peak that saturates in its maximum allowable value (220) for lines wider than 5 mm. The minimum values
correspond to the height of the negative peak that saturates for
lines wider than 2 mm. Therefore, a threshold value of 120 applied
to the instantaneous value of PIXELSUM permits the detection of
lines up to 0.2 mm.
4. The incremental rotary encoder
The rotary encoder is based on a mechanical assembly (Fig. 9)
where the sensor is at a xed distance from a rotary surface covered
with an adhesive paper (see Table 1) onto which a reference black
line is drawn. In this implementation the y-axis of the optical sensor
is tangential to the center of the rotating surface.
The most important problem associated with the use of optical mouse sensors are the sensitivity to changes in the height and
the cumulative errors generated when measuring arbitrary motion
(displacements not parallel to any axis) [4]. The mechanical conguration of the rotary encoder solves the rst problem problems
because the optical sensor is placed at a xed height from the rotary
surface and minimizes the second because the orientation of the
y-axis is xed and tangential to the rotation of the surface.
A radial line printed on the white measurement surface analyzed by the optical sensor will be used as a reference to count
the number of turns and to correct cumulative error in the dis-

Fig. 9. Image (right) and drawing (left) of the parameters and parts of the rotary encoder.

M. Tresanchez et al. / Sensors and Actuators A 155 (2009) 7381

Fig. 10. Dynamic evolution of the SHUTTER, PIXELSUM and SQUAL registers when
moving the optical sensor linearly over white paper with three black lines of width:
1.2, 3.2 and 5.2 mm, elapsed 25.4 mm.

placement measured. From the design point of view, the design of


the rotary encoder has three different parameters that can be optimized (Fig. 9): the width of the reference line, w, the radius of the
placement of the sensor, r, and its relative height, h. However, other
parameters, such as the sensitivity to the orientation of the optical
sensor, , and the rotating speed, , need to be analyzed.
One of the most important parts of the proposed rotary encoder
is the procedure to detect the reference line. Fig. 10 compares the
evolution of the SHUTTER, PIXELSUM and SQUAL registers when
moving the optical sensor linearly over a white paper with three
black lines of width: 1.2, 3.3 and 5.2 mm (see Fig. 3). As can be
expected, the results in Fig. 10 indicate that PIXELSUM is an inputsensing variable in the internal camera control loop and SHUTTER is
an output reactive variable. The peak obtained with the SHUTTER
register is very clean but the peaks obtained with the PIXELSUM
register enable the detection of smaller lines and indicate more
clearly their beginning and ending location. Therefore, the PIXELSUM register will be used to detect the radial reference line on the
rotary white surface of the optical encoder.
The rst parameter analyzed is the radius of placement of the
sensor, r. The radius was measured with a precision of 0.05 mm
from the center of rotation of the wheel, established manually
with the images from the optical sensor (Fig. 11). Fig. 12 shows
the average counts per revolution (cpr) measured by the optical
sensor in 20 complete rotations (detected using the reference line
and the PIXELSUM register) in the y-axis (tangential to the rotation) and the x-axis (perpendicular) for both allowed resolutions of
the optical sensor, 400 and 800 cpi. The sensor was placed at the
recommended height (2.4 mm) and the angle of orientation of the
sensor, , was carefully adjusted to 0 (tangential to the rotation).
The angular speed was 15 revolutions per minute (rpm) throughout
the experiment.
Fig. 13 shows the standard deviation of the counts measured
in 20 turns over the y-axis for the different radii analyzed. The
standard deviation is slightly higher when doubling the resolution
of the optical sensor and is almost constant in a range from 8 to

77

Fig. 12. Average counts of both measurement axes in the allowed resolutions
depending on the placement radius of the sensor.

Fig. 13. Standard deviation of the counts measured in one complete turn over the
y-axis depending on the placement radius of the sensor.

12 mm, although the upper limit depends largely on the quality of


the mechanical device that holds the sensor over the surface of the
wheel, and which is more critical as size increases. Fig. 14 shows
the average relative error in the counts measured in one complete
turn compared with the analytical value obtained for both resolutions; 400 and 800 cpi. The relative error decreases as the radius of
curvature increases (the motion is focused on the y-axis) and can be
measured more easily by the optical sensor. According to the results
in Figs. 13 and 14, the placement radius of the optical mouse sensor must be in a range between 8 and 12 mm, with a coefcient of
determination in the counts measured, R2 , of 0.99991. These limits in the radius guarantee the development of small and compact
rotary encoders based on the optical mouse sensor.
Fig. 15 shows the histogram of the absolute error obtained in the
counts measured in one turn after 400 revolutions compared with

Fig. 11. Images from the ADNS-3088 used to locate the center of rotation of the wheel of the rotary encoder; the line has a width of 0.2 mm.

78

M. Tresanchez et al. / Sensors and Actuators A 155 (2009) 7381

Fig. 14. Relative error of the counts measured in one complete turn over the y-axis
depending on the placement radius of the sensor.

Fig. 15. Histograms of the absolute error obtained in the counts measured in one
turn at a xed angular speed of 15 rpm and the optical sensor placed at a radius of
10 mm for resolutions of 400 and 800 cpi.

the analytical value expected; the sensor was placed at a radius of


10 mm and the angular speed was 15 rpm. The standard deviation of
the measurements was 1.04 counts for 400 cpi and 1.70 counts for
800 cpi, that is the resolution nally chosen for the optical mouse
sensor of the rotary encoder because the resolution was improved
100% and the standard deviation of the measurements is only 62%
worse.
The second parameter analyzed is the sensitivity to the angular
speed, . Fig. 16 shows the counts measured in the y-axis for angu-

Fig. 16. Maximum, average and minimum counts measured in one complete turn
with the optical sensor placed at a radius of 10 mm.

Fig. 17. Standard deviation of the counts measured in one complete turn with the
optical sensor placed at a radius of 10 mm.

lar speeds from 5 to 100 rpm with the sensor placed at a radius of
10 mm, an angular orientation of 0 , and height of 2.4 mm. Fig. 16
shows that the average value measured decreases linearly with
speed, and the standard deviation of the measurements increases
linearly with speed (Fig. 17), although the average relative error in
the counts measured is always lower than 1.5%, which can be an
acceptable value in the context of inexpensive sensors.
There are no problems detecting the reference line in this speed
range. Fig. 18 shows the maximum, average and minimum values
of the register PIXELSUM, which are almost constant when using
a 0.2 mm wide line in a range of angular speed up to 100 rpm.
The results in Fig. 18 agree with the results also shown in Fig. 8,
therefore the detection of the reference line can be done at very
different angular speeds with a simple threshold in the values of
the PIXELSUM register. In theory, considering only the measurement limitations of the optical sensor, and the time spent reading
the PIXELSUM, DELTA X, and DELTA Y registers sequentially, the
maximum allowable speed when the sensor is placed at a radius
of 10 mm is 490 rpm, although the mechanical design of the rotary
encoder used in this paper did not allow this limit to be veried.
Fig. 19 repeats the previous experiment for line widths of 0.2,
1.2, and 2 mm (see Fig. 20) with the sensor placed at a radius of

Fig. 18. Maximum, average and minimum value of the PIXELSUM register for different angular speeds with the optical sensor placed at a radius of 10 mm.

M. Tresanchez et al. / Sensors and Actuators A 155 (2009) 7381

Fig. 19. Maximum, average and minimum counts measured in one complete turn
for different angular speeds with the optical sensor placed at a radius of 10 mm.

9.8, 10 and 10.2 mm. In all cases, the behavior is very similar; the
counts measured in one revolution slightly decreases as the speed
increases. The sensitivity to speed combined with the deviation of
the measurements precludes direct use of this rotary encoder in
applications where precision measurements are needed. However,
the reference line combined with an initial calibration of the rotary
encoder can be used to improve the precision of the measurements,
as stated in the validation section.
Another important factor in the design of the rotary encoder
is the sensitivity to errors in its angle of orientation, . Fig. 21
shows the average of the relative error in the counts measured in
one revolution depending on the angle of orientation of the sensor (0 corresponds to a perfect tangential orientation) obtained
with a 0.2 mm line, a radius of 10 mm and a xed angular speed
of 15 rpm. In general, the average relative error is below 1% for an
orientation in a range from 2.5 (to the center) to +1 . In his case,
this asymmetry is probably originated by the way that the optical ow algorithm implemented in the optical sensor averages the
displacement detected in the image. Fortunately, this error in the
orientation originates large displacement measurements in the xaxis and so can be automatically detected and corrected in an initial
mechanical calibration operation.
The last experiment of this section is used to conrm the sensitivity of the optical mouse sensor to changes in its relative height.
Starting at the height recommended by the manufacturer (2.4 mm),
Fig. 22 shows the average relative error in the counts measured in
one complete revolution depending on relative changes of height.
The experiment was performed with the optical sensor placed at a
radius of 10 mm and an angular speed of 15 rpm.
Fig. 22 shows that an offset of 0.3 mm in the height originates a
relative error in the measurements of 5.4%. Additionally, Fig. 23
shows the image of the reference line (0.2 mm) viewed by the opti-

79

Fig. 21. Average relative error in the counts measured in one complete turn for
different angles of orientation with the optical sensor placed at a radius of 10 mm.

Fig. 22. Average relative error in the counts measured in one complete turn for
different relative height offsets with the optical sensor placed at a radius of 10 mm.

cal sensor in the case of the recommended height and for an offset
of 1.2 mm where the sensor fails in the measurements.
5. Use and validation of the rotary encoder
The denitive design of the rotary encoder has a 100 mm-radius
wheel and the sensor placed at its recommended height at a radius
of 10 mm from the center of the wheel. The use of the rotary encoder
requires an initial calibration prior to any measurement operation.
As happens in the conventional mouse, it is supposed that the optical sensor will work with a dedicated microprocessor as a bridge to

Fig. 20. Lines of 0.2 (left), 1.2 (center) and 2 mm (right) viewed by the ADNS-3088.

80

M. Tresanchez et al. / Sensors and Actuators A 155 (2009) 7381

Fig. 23. Lines of 0.2 mm viewed by the ADNS-3088 at the nominal height (left) and
with a relative offset of 1.2 mm (right).

offer access to the internal registers and measurements provided


by the sensors using the RS232 or the USB buses available in most
computer and measurement equipment. This microprocessor can
be used to establish the initial calibration using dedicated selection
buttons (or bus commands) and to offer the results measured.
The initial calibration has two parts. The rst deals with the correction of the orientation of the sensor. This operation requires
the rotation of the wheel and is based on the distance measured
by the x-axis (or the axis radial to the center of the wheel). If the
orientation is correct then the values measured will have small positive and negative values and its cumulative value will be very low
in a complete turn (<100). Any sensor misalignment will produce
larger cumulative values as an indication that manual correction of
the orientation of the sensor is required. In normal operation, the
displacement measured along the x-axis can be checked to guarantee normal operation of the sensor and to remove measurement
outliers (none detected with the proposed measurement surface).
The second calibration deals with the automatic selection of the
counts per revolution of the sensor, which depends on its placement radius. This operation requires several rotations of the wheel
at a xed speed to obtain the average value of the counts per revolution. The average values obtained when the sensor is placed at a
radius of 10 mm are above 1900 cpr. This value is very large for an
encoder and, if desired, the microprocessor can be programmed to
offer always a xed proportional resolution, such as 100 cpr, with
a great reduction in the standard deviation of the counts offered
by the rotary encoder. In a mobile robot application where the
radius of the wheel is known, the internal microprocessor can be
programmed to convert the counts measured in relative or cumulative distance. Once calibrated, the rotary encoder will be ready
for normal operation. Then, the reference line can be used specifically as an index to count the rotations, but a more interesting
application is the correction of the cumulative counts measured by
the rotary encoder, that is, if an internal cumulative register says
that the counts measured in the last turn are 1932 but the calibration register is 1930; the cumulative displacement registers can be
corrected by subtracting 2 counts after detecting the reference line.
Fig. 24 shows the cumulative relative error in the counts measured by the rotary encoder in 200 revolutions at a xed angular
speed of 15 rpm. In this ideal case with xed speed, the relative
cumulative error computed by comparing the optical sensor raw
data with the corrected values (obtained by multiplying the number of turns by the number of counts obtained in the calibration)
rises very slowly (0.3% in 200 revolutions) and can be enough
in most inexpensive applications. This cumulative deviation will
be zero if the raw data are corrected with the calibration counts
every time the reference line is detected. Then, the error will only
appear in the raw data offered between two detections of the reference line. Additionally, the precision of the rotary encoder can be
improved signicantly just by adding more radial reference lines to

Fig. 24. Cumulative relative error in the counts measured by the rotary encoder
when compared with the expected value.

the adhesive surface used to detect the displacement, for example


8 lines instead of only one as used in this work.
Finally the last experiment was an extreme manual manipulation of the rotation of the rotary encoder; the orientation and
acceleration of the rotations were changed randomly and suddenly
to simulate the worst operational conditions (that do not correspond to a typical measurement application). The worst relative
error measured during one arbitrary partial rotation was below 1%
and this cumulative error was corrected after detecting the reference line.
6. Conclusions
In this paper, a new application for the optical mouse sensor as an incremental rotary encoder was presented. The main
sensitivity problems of these kind of inexpensive optical sensors
are: sensitivity to changes in height and cumulative error in the
motion measured in arbitrary trajectories. The use as part of a
rotary encoder minimizes these problems because the optical sensor is always at the same height, pointing to the same surface with
the same relative orientation (the measurement axis is always the
same). In such conditions, the coefcient of determination of the
displacement measured is very good, R2 = 0.99991.
The use of such additional available internal registers as SHUTTER, SQUAL, and PIXELSUM permits the detection of reference
marks in the rotating surface and then the correction of cumulative
errors in the displacement measured by the optical mouse sensor. A
radial line of 0.2 mm is detected at angular speeds up to 100 rpm by
applying a threshold values to the PIXELSUM register of the optical
sensor.
The sensitivity of the mechanical placement of the optical sensor
inside the rotary encoder was analyzed: the acceptable values for
an error of orientation of the sensor were from 2.5 to 1 , and
0.3 mm for the error in height of the sensor. The counts measured
by the rotary encoder were tested for different angular speeds with
an error lower than 1% in one revolution; this cumulative error is
reset to zero when detecting the radial line labelled in the rotating
surface.
A rotary encoder built using a rotary surface covered with a
granulated white adhesive paper and an optical mouse sensor
(ADNS-3088 at 800 cpi) placed at a xed radius of 10 mm and a
xed height of 2.4 mm enables the measurement of the angular
displacement with a resolution close to 1900 counts per revolution and the implementation of a procedure to correct cumulative
measurement errors originated by the optical sensor. This inexpen-

M. Tresanchez et al. / Sensors and Actuators A 155 (2009) 7381

sive rotary encoder was primarily designed for odometry in low


cost mobile robot applications but can be used in a wide range of
applications to measure rotation or displacement.
Acknowledgements
With the support of the Government of Catalonia (Comissionat
per a Universitats i Recerca, Departament dInnovaci, Universitats
i Empresa) and the European Social Fund.
References
[1] T.W. Ng, The optical mouse as a two-dimensional displacement sensor, Sens.
Actuators A SA107 (2003) 2125.
[2] U. Minoni, A. Signorini, Low-cost optical motion sensor: an experimental characterization, Sens. Actuators A SA128 (2006) 402408.
[3] J. Palacin, I. Valganon, R. Pernia, The optical mouse for indoor mobile robot
odometry measurement, Sens. Actuators A SA126 (2006) 141147.
[4] J.A. Cooney, W.L. Xu, G. Bright, Visual dead-reckoning for motion control of a mecanum-wheeled mobile robot, Mechatronics M14 (2004) 623
637.
[5] S. Lee, Mobile robot localization using optical mice, in: IEEE Int. Conf. Robotics,
Automation and Mechatronics, Singapore, December 13, vol. 2, 2004, pp.
11921197.
[6] D. Sekimori, F. Miyazaki, Self-localization for indoor mobile robots based on
optical mouse sensor values and simple global camera information, in: IEEE
Int. Conf. Robotics and Biomimetics, Hong Kong and Macau, June 29July 3,
2005, pp. 605610.
[7] A. Bonarini, M. Matteucci, M. Restelli, Automatic error detection and reduction
for an odometric sensor based on two optical mice, in: IEEE Int. Conf. Robotics
and Automation, Barcelona, Spain, April 1822, 2005, pp. 16751680.
[8] J. Hu, Y. Chang, Y. Hsu, Calibration and on-line data selection of multiple optical
ow sensors for mobile robot localization, in: IEEE Int. Conf. Intelligent Robots
and Systems, Nice, France, September 2226, 2008, pp. 987992.
[9] S. Kim, S. Lee, Robust mobile robot velocity estimation using redundant number of optical mice, in: IEEE Int. Conf. Information and Automation, Zhangjiaje,
China, June 2023, 2008, pp. 107112.
[10] S. Hengstler, H. Aghajan, MeshEye: a hybrid-resolution smart camera mote for
applications in distributed intelligent surveillance, in: 6th Int. Symp. Information Processing in Sensor Networks, Cambridge, MA, April 2527, 2007, pp.
360369.

81

[11] T.W. Ng, K.T. Ang, The optical mouse for vibratory motion sensing, Sens. Actuators A SA-116 (2004) 205208.
[12] M.K. Chmarra, N.H. Bakker, C.A. Grimbergen, J. Dankelman, TrEndo, a device
for tracking minimally invasive surgical instruments in training setups, Sens.
Actuators A SA126 (2006) 328334.
[13] G.K. Lott, M.J. Rosen, R.R. Hoy, An inexpensive sub-millisecond system for
walking measurements of small animals based on optical computer mouse
technology, J. Neurosci. Methods JNM-161 (2007) 5561.
[14] S. Matsuda, Measurement of solid circulation rate in a circulating uidized bed,
Powder Technol. PT-187 (2008) 200204.
[15] N.N.A. Charniya, S.V. Dudul, Sensor for classication of material type and its
surface properties using radial basis networks, IEEE Sens. J. SJ-8 (2008) 1981
1991.
[16] N.N.A. Charniya, S.V. Dudul, Investigations into the effects of illumination and
acceleration on optical mouse sensors as contact-free 2D measurement devices,
Sens. Actuators A SA-149 (2009) 8792.
[17] Avago, ADNS-3080 and ADNS-3088 High Performance Optical Mouse Sensor,
http://www.avagotech.com (2008).

Biographies
Marcel Tresanchez received the BSc and MSc degrees in engineering from the University of Lleida (UdL), Spain in 2005 and 2007, respectively. He is currently a Ph.D.
student in the robotics laboratory of the UdL and his research interests include
mobile robots, precision agriculture and the educational application of robotics.
Tomas Palleja received the BSc and MSc degrees in engineering from the University of Lleida (UdL), Spain in 2004 and 2006, respectively. He is currently a Ph.D.
student in the robotics laboratory of the UdL and his research interests include precision agriculture, mobile robots, human system interaction and the educational
application of robotics.
Merce Teixido received the BSc and MSc degrees in engineering from the University
of Lleida (UdL), Spain in 2006 and 2008, respectively. She is currently a Ph.D. student in the robotics laboratory of the UdL and her research interests include human
computer interaction, avatar modeling and the educational application of robotics.
Jordi Palacin received the BSc and MSc degrees in electronics from the Polytechnic
University of Catalonia in 1990 and University of Barcelona (UB), Spain in 1997. He
received the Ph.D. degree in electronics from the UB in 2005. In 1992, he joined the
Department of Computer Science and Industrial Engineering at the University of
Lleida (UdL), Spain leading the robotics group. His research area involves compact
modeling, data fusion and signal processing applications in robotics.