You are on page 1of 9

Sensors and Actuators A 155 (2009) 73–81

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. Palacín ∗
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 a b s t r a c t

Article history: In this paper, a new application and capabilities of the sensor of the optical mouse are presented. An
Received 3 February 2009 inexpensive incremental rotary encoder is built based on a mechanical assembly where the sensor is at a
Received in revised form 18 May 2009 fixed distance from a rotary white surface onto which a reference black line is drawn. The optical mouse
Accepted 4 August 2009
sensor measures changes in position by optically acquiring sequential surface images and mathematically
Available online 8 August 2009
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
Keywords:
level in the images. In this paper, the registers involved in this control loop are used to detect high
Optical mouse
Mouse sensor
contrast marks without any dedicated image-processing procedure. The detection of this reference mark
Rotary encoder in a rotary white surface allows the correction of long term cumulative errors originated in displacement
Displacement sensor 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 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
The computer mouse, invented in 1964, has evolved from the circulation rate in a circulating fluidized bed and in [15] to classify
initial mechanical configuration based on wheels and a rotating different types of materials and their surfaces as polished or milled.
ball to the actual design based on optical sensors. The inexpensive Recently, in [16] the effects of illumination and acceleration on
optical mouse sensor can be used specifically as a displacement the optical mouse sensor were analyzed using a laser-based sensor
sensor. In [1] the optical sensor is proposed and tested as a two- (ADNS-6010). The results showed that acceleration and deceler-
dimensional displacement sensor over opaque objects when the ation require a specific calibration when the sensor was used as
height offset does not exceed 1.25 mm. In [2] the optical sensor is a precision measurement system. The results also showed a poor
characterized as a motion sensor showing that limitations mainly correlation of the measurements of both axes and proved that this
arise from the sensitivity of the device to the texture of the ref- correlation can be improved using additional light sources. We
erence surface and the upper limit of the working speed. In [3], agree with these results because the illumination obtained with a
the optical mouse sensor shows a very good coefficient of deter- standard LED is more diffuse and uniform than that obtained with
mination in a linear displacement over typical ground surfaces, a laser-based LED (see Fig. 1).
R2 = 0.9998, but a high dependence on the relative height of the In this paper, the optical mouse sensor is proposed as an inex-
sensor with an error of 1% for an offset of 0.1 mm, and very bad pensive incremental rotary encoder. This application avoids the
measurements in circular trajectories. most important problem associated with this optical sensor, its
Despite these known problems, the optical mouse sensor has strong sensitivity to height variations. In the encoder, the optical
been used in robotics to measure the displacement and trajectory of sensor will be attached to the inner radial surface of a wheel to mea-
a mobile robot [3,4]. In [5–9], several redundant optical sensors are sure the displacement during a rotation with a known and fixed
used to reduce the positioning error and eliminate measurement height, radius and measurement surface. Only one axis of the opti-
outliers. In [9] an improvement of 26% in the measurement of the cal sensor is needed for the measurements while a reference mark
speed is reported using two complementary sensors. on the rotating surface will be used to count the number of revolu-
The optical mouse sensor can be used in other applications tions, to correct cumulative errors in the displacement measured,
where a kind of linear optical flow [10] is needed. In [11], the sen- and for automatic internal calibration of the number of counts per
sor is used to measure vibrations. In [12], it is used as a tracking 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
∗ Corresponding author. Tel.: +34 973 702724; fax: +34 973 702702. in other inexpensive applications where a rotary measurement is
E-mail address: palacin@diei.udl.es (J. Palacín). also needed.

0924-4247/$ – see front matter © 2009 Elsevier B.V. All rights reserved.
doi:10.1016/j.sna.2009.08.003
74 M. Tresanchez et al. / Sensors and Actuators A 155 (2009) 73–81

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 reg-
ister is 1 when any of the DELTA registers is different to zero and
can be used as a motion flag. 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
Fig. 1. Example of images obtained with two optical mouse sensors: LED-based captured by the sensor, and SQUAL, SHUTTER, PIXELSUM that are
ADNS-3088 LED (left), laser-based ADNS-6010 (right). 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

The optical sensor generates cumulative error in the measure-


ments [1,4] even in the case of a placement at a fixed 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
Fig. 2. Sectional view of typical assembly of an optical mouse sensor (courtesy of encoder so, in this paper, we propose the inclusion of reference
Avago). marks on the rotary white surface screened by the optical sensor.
The detection of reference marks will enable the correction of the
The paper is structured as follows. Section 2 introduces the displacement/rotation measured by the sensor although they will
working principle of the optical mouse sensor. Section 3 describes require an initial calibration to establish the reference value of the
the method proposed to detect reference marks. Section 4 describes existing counts from mark to mark. In the case of a rotary encoder
the implementation of the incremental rotary encoder. Section the simplest mark is a radial black line (from the center to the outer
5 shows the validation of the rotary encoder. Finally, Section 6 radius of the rotary surface). Once detected, the relative cumulated
presents the final conclusions. value of the internal counters can be corrected with the reference
value corresponding to one revolution. The detection of the refer-
2. Sensor description ence black line can be performed using two alternative methods:
reading the image acquired by the sensor and applying some image-
The optical mouse sensor used in this paper is the ADNS-3088 processing algorithms or exploiting the information provided by
[17] witch is an updated version of the versatile ADNS-3080 ana- some additional internal registers involved in the control loop of
lyzed previously in [9]. The optical sensor includes a digital signal the illumination of the optical sensor.
processor (DSP) and a CMOS camera of 30 × 30 pixels on the same The image acquired by the sensor can be read by repetitive
chip. The optical mouse sensor is based on a very compact image access to the PIXEL BURST register although this reading stops any
acquisition system with the following parts (Fig. 2): the main motion measurement and a long time is required to get the com-
sensor, an infrared light source (LED-based) that illuminates the plete image using the SPI bus; 900 readings for a 30 × 30 image
surface, and a convex lens that collects the reflected light. All the (26 ms in SPI burst mode). The introduction of an internal image
parts are mounted clipped in a base plane to keep the device very buffer to allow complete image reading without stopping the sen-
close to the surface at a nominal distance of 2.4 mm. sor will enhance the development of unexpected new applications
The optical mouse sensor measures changes in position by of the optical mouse sensor [10]. As an alternative, some additional
optically acquiring sequential surface images (frames) and mathe- internal registers as SQUAL, SHUTTER, and PIXELSUM offers aver-
matically determining the direction and magnitude of movement age information of the internal status of the illumination control
at a very high rate (up to 6400 frames/s); the DSP detects small loop and the image acquired by the sensor. These registers can be
variations in the roughness of the surface by means of the shad- read at any moment without disturbing the sensor and are candi-
ows created by the source light (see Fig. 1) that is also controlled dates for indirect black-mark detection without reading the image
in a closed loop to maintain a constant illumination range in acquired by the sensor.
the images acquired. According to the manufacturer specifica-
tions, the maximum measurable speed is 40 in. per second (ips) 3.1. Detecting marks using SQUAL
(1.016 m/s), the maximum acceleration during measurements is
15 × g (147.15 m/s2 ) and the selectable resolutions are 400 and 800 The SQUAL register gives information about the changes (also
counts per in. (cpi). The communication with the optical sensor is called features) detected in the image currently being analyzed.
performed by the standard SPI bus using an 8 bit address and 8 This register is an indication of the roughness of the surface mea-

Table 1
Paper types analyzed.

Type Size Color Manufacturer Reference Weight SQUAL Displacement

Normal A4 White International Paper 70476 80 g/m2 14 ± 5 Bad (0)


Recycled A4 White Evercopy Plus 50048 80 g/m2 168 ± 11 OK
Adhesive A4 White Impega 00123 100 g/m2 64 ± 9 OK
M. Tresanchez et al. / Sensors and Actuators A 155 (2009) 73–81 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.

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
sured indirectly through the shadows enhanced by the lateral 5.2 mm, elapsed 25.4 mm.
illumination applied. The SQUAL register has values from 0 to 169;
a high value means that the image-processing algorithm used to 3.2. Detecting marks using SHUTTER
detect motion will have more points to compare and the motion
will be measured more accurately. As a reference, Table 1 shows The SHUTTER register is an indication of the intensity applied to
the value of the SQUAL register when placing the optical mouse the LED, and then of the emitted light. When the image becomes
sensor over some standard paper for office use. The optical sen- dark, an internal control loop increases the intensity applied to the
sor does not work properly in the case of fine and reflecting white LED to keep an average illumination on the image. The SHUTTER has
paper and, in general, SQUAL values greater than 30 ensure good 16 bits of resolution and a high and a low register value; in each
detection of the displacement. step, the intensity applied to the LED changes 1/16. Fig. 5 shows
Fig. 4 shows the dynamic evolution of the SQUAL register in a the dynamic evolution of the SHUTTER register when repeating the
forward displacement of the optical sensor (parallel to the y-axis) displacement over the same surface and lines as in the previous
over an adhesive white surface (see Table 1) with three transver- paragraph. Fig. 5 shows that the SHUTTER register has values from
sal black lines, 1.2, 3.2 and 5.2 mm wide respectively, and elapsed 20 to 25 for the white paper but increases to 40 for a width of
25.4 mm (1 in.) (Fig. 3); the lines where printed on a standard laser 1.2 mm, 100 for a width of 3.2 mm and up to 270 for a width of
printer. Fig. 4 shows that the SQUAL register has values from 50 to 5.2 mm (see Fig. 3).
68 for the white paper but has two positive peaks when the sensor The results shown in Fig. 5 were obtained with a linear move-
reaches the beginning and end of the lines and one or two negative ment at a fixed speed and the height of the peak is proportional
peaks depending on the width of the line. The number of features to the line width. Fig. 6 shows the minimum and maximum value
detected varies very little in the white paper, increases suddenly in (peak) of the SHUTTER for a set of experiments with black lines of
the border of the lines, decreases suddenly when the line is com- different widths. The linear speed of the displacement was fixed and
pletely under the sensor (the image becomes almost black and no constant and lines were isolated with at least 20 mm of unmarked
features are detected). 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. 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 Fig. 6. Maximum and minimum value of the SHUTTER register for different line
5.2 mm, elapsed 25.4 mm. widths.
76 M. Tresanchez et al. / Sensors and Actuators A 155 (2009) 73–81

Fig. 7. Dynamic evolution of the PIXELSUM register when moving the optical mouse Fig. 8. Maximum, average and minimum value of the PIXELSUM register for differ-
sensor over white paper with three transversal black lines of width: 1.2, 3.2 and ent line widths.
5.2 mm, elapsed 25.4 mm.

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


saturates for widths greater than 7.6 mm. Therefore, an isolated line range, from 130 to 140. The maximum values correspond to the
wider than 2 mm can be easily detected by reading the SHUTTER height of the positive peak that saturates in its maximum allow-
register and applying a threshold detection value of 60. able value (220) for lines wider than 5 mm. The minimum values
correspond to the height of the negative peak that saturates for
3.3. Detecting marks using PIXELSUM lines wider than 2 mm. Therefore, a threshold value of 120 applied
to the instantaneous value of PIXELSUM permits the detection of
The PIXELSUM register is the cumulative value of all the pixels of lines up to 0.2 mm.
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 4. The incremental rotary encoder
cumulative addition of the 900 pixels in the image; its maximum
value is 221 (all pixels white). Fig. 7 shows the dynamic evolution The rotary encoder is based on a mechanical assembly (Fig. 9)
of the PIXELSUM register when repeating the displacement over where the sensor is at a fixed distance from a rotary surface covered
the same surface and lines as in the two previous paragraphs. Fig. 7 with an adhesive paper (see Table 1) onto which a reference black
shows that the PIXELSUM register values range from 130 to 150 for line is drawn. In this implementation the y-axis of the optical sensor
the white paper but decrease to 60 for a width of 1.2 mm, to 42 for is tangential to the center of the rotating surface.
a width of 3.2 mm and 35 for a width of 5.2 mm (see Fig. 3). After The most important problem associated with the use of opti-
this initial negative peak, a positive peak up to 220 appears for the cal mouse sensors are the sensitivity to changes in the height and
width of 5.2 mm. This positive peak is originated by the internal the cumulative errors generated when measuring arbitrary motion
control loop of the camera that suddenly increases the intensity (displacements not parallel to any axis) [4]. The mechanical con-
of the LED to force the black line to appear almost white in the figuration of the rotary encoder solves the first problem problems
image. Obviously, as the black line disappears from the image, the because the optical sensor is placed at a fixed height from the rotary
PIXELSUM value also increases because the image is then too white. surface and minimizes the second because the orientation of the
Fig. 8 shows the maximum, average and minimum value of the y-axis is fixed and tangential to the rotation of the surface.
PIXELSUM register for a set of experiments with black lines of dif- A radial line printed on the white measurement surface ana-
ferent widths. The linear speed of the displacement was fixed and lyzed by the optical sensor will be used as a reference to count
constant (100 mm/s) and lines were isolated with at least 20 mm 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) 73–81 77

Fig. 10. Dynamic evolution of the SHUTTER, PIXELSUM and SQUAL registers when Fig. 12. Average counts of both measurement axes in the allowed resolutions
moving the optical sensor linearly over white paper with three black lines of width: depending on the placement radius of the sensor.
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 opti-
mized (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 input-
sensing 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 PIXEL-
SUM register will be used to detect the radial reference line on the
Fig. 13. Standard deviation of the counts measured in one complete turn over the
rotary white surface of the optical encoder. y-axis depending on the placement radius of the sensor.
The first 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 12 mm, although the upper limit depends largely on the quality of
with the images from the optical sensor (Fig. 11). Fig. 12 shows the mechanical device that holds the sensor over the surface of the
the average counts per revolution (cpr) measured by the optical wheel, and which is more critical as size increases. Fig. 14 shows
sensor in 20 complete rotations (detected using the reference line the average relative error in the counts measured in one complete
and the PIXELSUM register) in the y-axis (tangential to the rota- turn compared with the analytical value obtained for both resolu-
tion) and the x-axis (perpendicular) for both allowed resolutions of tions; 400 and 800 cpi. The relative error decreases as the radius of
the optical sensor, 400 and 800 cpi. The sensor was placed at the curvature increases (the motion is focused on the y-axis) and can be
recommended height (2.4 mm) and the angle of orientation of the measured more easily by the optical sensor. According to the results
sensor, ˛, was carefully adjusted to 0◦ (tangential to the rotation). in Figs. 13 and 14, the placement radius of the optical mouse sen-
The angular speed was 15 revolutions per minute (rpm) throughout sor must be in a range between 8 and 12 mm, with a coefficient of
the experiment. determination in the counts measured, R2 , of 0.99991. These lim-
Fig. 13 shows the standard deviation of the counts measured its in the radius guarantee the development of small and compact
in 20 turns over the y-axis for the different radii analyzed. The rotary encoders based on the optical mouse sensor.
standard deviation is slightly higher when doubling the resolution Fig. 15 shows the histogram of the absolute error obtained in the
of the optical sensor and is almost constant in a range from 8 to 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) 73–81

Fig. 14. Relative error of the counts measured in one complete turn over the y-axis
Fig. 17. Standard deviation of the counts measured in one complete turn with the
depending on the placement radius of the sensor.
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
Fig. 15. Histograms of the absolute error obtained in the counts measured in one of the register PIXELSUM, which are almost constant when using
turn at a fixed angular speed of 15 rpm and the optical sensor placed at a radius of a 0.2 mm wide line in a range of angular speed up to 100 rpm.
10 mm for resolutions of 400 and 800 cpi. 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 analytical value expected; the sensor was placed at a radius of
the PIXELSUM register. In theory, considering only the measure-
10 mm and the angular speed was 15 rpm. The standard deviation of
ment limitations of the optical sensor, and the time spent reading
the measurements was 1.04 counts for 400 cpi and 1.70 counts for
the PIXELSUM, DELTA X, and DELTA Y registers sequentially, the
800 cpi, that is the resolution finally chosen for the optical mouse
maximum allowable speed when the sensor is placed at a radius
sensor of the rotary encoder because the resolution was improved
of 10 mm is 490 rpm, although the mechanical design of the rotary
100% and the standard deviation of the measurements is only 62%
encoder used in this paper did not allow this limit to be verified.
worse.
Fig. 19 repeats the previous experiment for line widths of 0.2,
The second parameter analyzed is the sensitivity to the angular
1.2, and 2 mm (see Fig. 20) with the sensor placed at a radius of
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 Fig. 18. Maximum, average and minimum value of the PIXELSUM register for dif-
with the optical sensor placed at a radius of 10 mm. ferent angular speeds with the optical sensor placed at a radius of 10 mm.
M. Tresanchez et al. / Sensors and Actuators A 155 (2009) 73–81 79

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. 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.

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 sen-
sor (0◦ corresponds to a perfect tangential orientation) obtained
with a 0.2 mm line, a radius of 10 mm and a fixed 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 opti-
cal flow algorithm implemented in the optical sensor averages the
Fig. 22. Average relative error in the counts measured in one complete turn for
displacement detected in the image. Fortunately, this error in the
different relative height offsets with the optical sensor placed at a radius of 10 mm.
orientation originates large displacement measurements in the x-
axis and so can be automatically detected and corrected in an initial
mechanical calibration operation. cal sensor in the case of the recommended height and for an offset
The last experiment of this section is used to confirm the sensi- of 1.2 mm where the sensor fails in the measurements.
tivity of the optical mouse sensor to changes in its relative height.
Starting at the height recommended by the manufacturer (2.4 mm), 5. Use and validation of the rotary encoder
Fig. 22 shows the average relative error in the counts measured in
one complete revolution depending on relative changes of height. The definitive design of the rotary encoder has a 100 mm-radius
The experiment was performed with the optical sensor placed at a wheel and the sensor placed at its recommended height at a radius
radius of 10 mm and an angular speed of 15 rpm. of 10 mm from the center of the wheel. The use of the rotary encoder
Fig. 22 shows that an offset of 0.3 mm in the height originates a requires an initial calibration prior to any measurement operation.
relative error in the measurements of −5.4%. Additionally, Fig. 23 As happens in the conventional mouse, it is supposed that the opti-
shows the image of the reference line (0.2 mm) viewed by the opti- cal 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) 73–81

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
Fig. 24. Cumulative relative error in the counts measured by the rotary encoder
computer and measurement equipment. This microprocessor can when compared with the expected value.
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 first deals with the cor- the adhesive surface used to detect the displacement, for example
rection of the orientation of the sensor. This operation requires 8 lines instead of only one as used in this work.
the rotation of the wheel and is based on the distance measured Finally the last experiment was an extreme manual manipu-
by the x-axis (or the axis radial to the center of the wheel). If the lation of the rotation of the rotary encoder; the orientation and
orientation is correct then the values measured will have small pos- acceleration of the rotations were changed randomly and suddenly
itive and negative values and its cumulative value will be very low to simulate the worst operational conditions (that do not corre-
in a complete turn (<100). Any sensor misalignment will produce spond to a typical measurement application). The worst relative
larger cumulative values as an indication that manual correction of error measured during one arbitrary partial rotation was below 1%
the orientation of the sensor is required. In normal operation, the and this cumulative error was corrected after detecting the refer-
displacement measured along the x-axis can be checked to guar- ence line.
antee normal operation of the sensor and to remove measurement
outliers (none detected with the proposed measurement surface). 6. Conclusions
The second calibration deals with the automatic selection of the
counts per revolution of the sensor, which depends on its place- In this paper, a new application for the optical mouse sen-
ment radius. This operation requires several rotations of the wheel sor as an incremental rotary encoder was presented. The main
at a fixed speed to obtain the average value of the counts per revo- sensitivity problems of these kind of inexpensive optical sensors
lution. The average values obtained when the sensor is placed at a are: sensitivity to changes in height and cumulative error in the
radius of 10 mm are above 1900 cpr. This value is very large for an motion measured in arbitrary trajectories. The use as part of a
encoder and, if desired, the microprocessor can be programmed to rotary encoder minimizes these problems because the optical sen-
offer always a fixed proportional resolution, such as 100 cpr, with sor is always at the same height, pointing to the same surface with
a great reduction in the standard deviation of the counts offered the same relative orientation (the measurement axis is always the
by the rotary encoder. In a mobile robot application where the same). In such conditions, the coefficient of determination of the
radius of the wheel is known, the internal microprocessor can be displacement measured is very good, R2 = 0.99991.
programmed to convert the counts measured in relative or cumu- The use of such additional available internal registers as SHUT-
lative distance. Once calibrated, the rotary encoder will be ready TER, SQUAL, and PIXELSUM permits the detection of reference
for normal operation. Then, the reference line can be used specif- marks in the rotating surface and then the correction of cumulative
ically as an index to count the rotations, but a more interesting errors in the displacement measured by the optical mouse sensor. A
application is the correction of the cumulative counts measured by radial line of 0.2 mm is detected at angular speeds up to 100 rpm by
the rotary encoder, that is, if an internal cumulative register says applying a threshold values to the PIXELSUM register of the optical
that the counts measured in the last turn are 1932 but the calibra- sensor.
tion register is 1930; the cumulative displacement registers can be The sensitivity of the mechanical placement of the optical sensor
corrected by subtracting 2 counts after detecting the reference line. inside the rotary encoder was analyzed: the acceptable values for
Fig. 24 shows the cumulative relative error in the counts mea- an error of orientation of the sensor were from −2.5◦ to 1◦ , and
sured by the rotary encoder in 200 revolutions at a fixed angular 0.3 mm for the error in height of the sensor. The counts measured
speed of 15 rpm. In this ideal case with fixed speed, the relative by the rotary encoder were tested for different angular speeds with
cumulative error computed by comparing the optical sensor raw an error lower than 1% in one revolution; this cumulative error is
data with the corrected values (obtained by multiplying the num- reset to zero when detecting the radial line labelled in the rotating
ber of turns by the number of counts obtained in the calibration) surface.
rises very slowly (0.3% in 200 revolutions) and can be enough A rotary encoder built using a rotary surface covered with a
in most inexpensive applications. This cumulative deviation will granulated white adhesive paper and an optical mouse sensor
be zero if the raw data are corrected with the calibration counts (ADNS-3088 at 800 cpi) placed at a fixed radius of 10 mm and a
every time the reference line is detected. Then, the error will only fixed height of 2.4 mm enables the measurement of the angular
appear in the raw data offered between two detections of the ref- displacement with a resolution close to 1900 counts per revolu-
erence line. Additionally, the precision of the rotary encoder can be tion and the implementation of a procedure to correct cumulative
improved significantly just by adding more radial reference lines to measurement errors originated by the optical sensor. This inexpen-
M. Tresanchez et al. / Sensors and Actuators A 155 (2009) 73–81 81

sive rotary encoder was primarily designed for odometry in low [11] T.W. Ng, K.T. Ang, The optical mouse for vibratory motion sensing, Sens. Actu-
cost mobile robot applications but can be used in a wide range of ators A SA-116 (2004) 205–208.
[12] M.K. Chmarra, N.H. Bakker, C.A. Grimbergen, J. Dankelman, TrEndo, a device
applications to measure rotation or displacement. for tracking minimally invasive surgical instruments in training setups, Sens.
Actuators A SA–126 (2006) 328–334.
Acknowledgements [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) 55–61.
With the support of the Government of Catalonia (Comissionat [14] S. Matsuda, Measurement of solid circulation rate in a circulating fluidized bed,
per a Universitats i Recerca, Departament d’Innovació, Universitats Powder Technol. PT-187 (2008) 200–204.
[15] N.N.A. Charniya, S.V. Dudul, Sensor for classification of material type and its
i Empresa) and the European Social Fund. surface properties using radial basis networks, IEEE Sens. J. SJ-8 (2008) 1981–
1991.
References [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) 87–92.
[1] T.W. Ng, The optical mouse as a two-dimensional displacement sensor, Sens.
[17] Avago, ADNS-3080 and ADNS-3088 High Performance Optical Mouse Sensor,
Actuators A SA–107 (2003) 21–25.
http://www.avagotech.com (2008).
[2] U. Minoni, A. Signorini, Low-cost optical motion sensor: an experimental char-
acterization, Sens. Actuators A SA–128 (2006) 402–408.
[3] J. Palacin, I. Valganon, R. Pernia, The optical mouse for indoor mobile robot Biographies
odometry measurement, Sens. Actuators A SA–126 (2006) 141–147.
[4] J.A. Cooney, W.L. Xu, G. Bright, Visual dead-reckoning for motion con-
Marcel Tresanchez received the BSc and MSc degrees in engineering from the Uni-
trol of a mecanum-wheeled mobile robot, Mechatronics M–14 (2004) 623–
637. versity of Lleida (UdL), Spain in 2005 and 2007, respectively. He is currently a Ph.D.
[5] S. Lee, Mobile robot localization using optical mice, in: IEEE Int. Conf. Robotics, student in the robotics laboratory of the UdL and his research interests include
Automation and Mechatronics, Singapore, December 1–3, vol. 2, 2004, pp. mobile robots, precision agriculture and the educational application of robotics.
1192–1197.
Tomas Palleja received the BSc and MSc degrees in engineering from the Univer-
[6] D. Sekimori, F. Miyazaki, Self-localization for indoor mobile robots based on
optical mouse sensor values and simple global camera information, in: IEEE sity of Lleida (UdL), Spain in 2004 and 2006, respectively. He is currently a Ph.D.
Int. Conf. Robotics and Biomimetics, Hong Kong and Macau, June 29–July 3, student in the robotics laboratory of the UdL and his research interests include pre-
2005, pp. 605–610. cision agriculture, mobile robots, human system interaction and the educational
[7] A. Bonarini, M. Matteucci, M. Restelli, Automatic error detection and reduction application of robotics.
for an odometric sensor based on two optical mice, in: IEEE Int. Conf. Robotics
and Automation, Barcelona, Spain, April 18–22, 2005, pp. 1675–1680. Merce Teixido received the BSc and MSc degrees in engineering from the University
[8] J. Hu, Y. Chang, Y. Hsu, Calibration and on-line data selection of multiple optical of Lleida (UdL), Spain in 2006 and 2008, respectively. She is currently a Ph.D. stu-
flow sensors for mobile robot localization, in: IEEE Int. Conf. Intelligent Robots dent in the robotics laboratory of the UdL and her research interests include human
and Systems, Nice, France, September 22–26, 2008, pp. 987–992. computer interaction, avatar modeling and the educational application of robotics.
[9] S. Kim, S. Lee, Robust mobile robot velocity estimation using redundant num-
ber of optical mice, in: IEEE Int. Conf. Information and Automation, Zhangjiaje, Jordi Palacin received the BSc and MSc degrees in electronics from the Polytechnic
China, June 20–23, 2008, pp. 107–112. University of Catalonia in 1990 and University of Barcelona (UB), Spain in 1997. He
[10] S. Hengstler, H. Aghajan, MeshEye: a hybrid-resolution smart camera mote for received the Ph.D. degree in electronics from the UB in 2005. In 1992, he joined the
applications in distributed intelligent surveillance, in: 6th Int. Symp. Informa- Department of Computer Science and Industrial Engineering at the University of
tion Processing in Sensor Networks, Cambridge, MA, April 25–27, 2007, pp. Lleida (UdL), Spain leading the robotics group. His research area involves compact
360–369. modeling, data fusion and signal processing applications in robotics.