AddThis

Bookmark and Share

Wednesday, 4 February 2009

Optical Mouse Hack

Fig 1. Optical Mouse for positional feedback


The ability to know where we are is vital skill we often use in decision making and often taken for granted. When dealing with robots this capability can be a complex expensive task but at the same time a powerful and sometimes essential capability.

Some of techniques that could be applied are

  1. Dead Reckoning Using Incremental Optical encoders at the wheel
  2. Radio Beacons and GPS
  3. Optical Mouse !!!!!

Dead Reckoning Using Incremental Optical Encoders at the wheel

This has been the most common method for estimating the position of the robot. This method relies on the feedback from the optical incremental encoder attached to the wheels as shown in Fig 1. The arrangement consists of two pairs of photo emitter and detector which are placed in such a way that the pulse train generated by the detector when the motor or the wheels rotate is 90 degree phase shifted to each other as shown in Fig 3. By counting the pulse train the robot can estimate how far it has moved from the reference position. The quadruple encoding also gives information about the direction of rotation.

One of the major problem associated with this type of feedback is the systems tolerance against slipping between the wheels and the floor when the robot is cruising at very high speeds. Due to this slippage the wheel rotates while the robot does not actually move that distance. This results in a false position information.

Radio Beacons and GPS

Navigating using active beacons has been with us for centuries. Using the stars for navigation is one of the oldest example of global referenced navigation; technology has brought forward many other systems, such as light houses and more recently radio navigation systems.

The two important technologies that are employed today are

  1. Ground Based Beacons
  2. Global Positioning System GPS

The simple idea of the beacon system is to provide the user with position information relative to that of the beacon system, if this point is known as global location then the position of the user with respect to this global location can be found.

Major disadvantage of beacon systems is there unsuitability for indoor use due to a combination of attenuation of signals due to obstacles, and the multipath fading introduced due to multiple reflection of RF by walls and other surfaces.

Motorola Microcontroller
Motorola Mini-Ranger Falcon and Harris Infogeometric System are some of the commercially available ground based beacon system. The Global Positioning System (GPS) is provided by the US military through a constellation of 24 satellites which are placed 55 degrees to the equator at a distance of 28,000 Kms. The Differential GPS (DGPS) is very accurate providing a resolution of 1-5 meter for civilian purpose but this technology is not applicable for any sort of indoor use.

Optical Mouse

When I built ADAM-1 the most important problem that I faced was estimating the position of my robot. The cheap dc motor that I used has no optical encoder attached to it neither the gear system that I got from a Tamiya toy allowed any possibility of attaching an optical encoder to it.

Though I have been using Optical mouse even before I started building ADAM-1 the idea of using optical mouse for determining the position never struck me. But when I was faced with the same problem in ADAM-2 I got the idea of using optical mouse.

Using optical mouse for position detection has several advantages. First the sensor detects the actual distance the robot has moved in 2-dimension hence even if the robot wheel slips at high speeds the robot was still able to accurately determine its position. Second since no mechanical parts are involved they are very reliable.

Theory of Operation

Optical mouse uses a tiny camera to take approximately 1,500 pictures every second. The pictures are taken by bouncing light from a small, red light emitting diode (LED) off the surface under the mouse, onto a Complimentary Metal Oxide Semiconductor (CMOS) camera. The CMOS camera sends each image to a Digital Signal Processor (DSP) for analysis. The DSP, operating at 18 MIPS, is able to detect the changing pattern in the images between movements. Based on these patterns, the DSP determines how far the mouse has moved and sends the corresponding coordinates to the external microcontroller.

Agilent technologies makes this optical sensor modules called HDNS-2000. HDNS-2000 consists of an Image Acquisition System (IAS), Digital Signal Processor, two channel quadrature output and 2 wire serial port.

The optical mouse modules that I used were taken from the IBM optical mouse that I bought from Wall Mart for 29$. I removed the plastic outter casing and also removed the strip wire attachment to the mouse buttons. The figure 5 shows the HDNS-2000 chip from Agilent in the IBM Optical mouse PCB.

Pin Name PS/2 Mode Quadrature Mode
1 PS2_C PS/2 Interface Clock PS/2 Interface Clock
2 MODE/XA Select PS/2 Mode XA output
3 RB/XB Right Button Input XB output
4 MB/YB Middle Button Input YB output
5 LB/YA Left Button Input YA output
6 XY_LED LED control output LED control output
7 Vdd3 3.3 VDC input 3.3 VDC input
8 REFB Internal Reference Internal Reference
9 OSC1 Oscillator Input Oscillator Input
10 GND Ground Ground
11 OSC2 Oscillator Output Oscillator Output
12 GND Ground Ground
13 Vdd5 5 VDC input 5 VDC input
14 Vdd5 % VDC input 5 VDC input
15 NRESET NRESET NRESET
16 PS2_D PS/2 Interface Data PS/2 Interface Data

Table 1. Pin Description for HDNS-2000

The PCB also contains the MC68HC908JB8 HCMOS Microcontroller Unit from Motorola. Fig 8 gives a more closer view of the Motorola microcontroller while fig 9. gives the pin out of this chip. Though HDNS-2000 has the capability to provide a PS/2 interface the Motorola microcontroller helps to provide a dual interface (PS/2 or USB). At power up, the firmware in the Motorola microcontroller tests the CLK (green wire) and Data (white wire) for a non-zero value for 50 ms if the condition is satisfied then the firmware identifies the input as PS/2 else it identifies as USB. Since my 8051 microcontroller did not have the capability to provide an USB interface I went for PS/2. The source code for reading the coordinates from an optical mouse can be found here.


Fig 2. The Incremental Optical Encoder attached to a motor


Fig 3. Incremental Optical Encoder

Fig 4. Quadruple Encoding

LED
HDNS-2000

Fig 5. Optical Mouse (Top View)

Fig 6. HDNS-2000 Optical Sensor Module

Fig 7. HDNS-2000 Pin Layout

Fig 8. CMOS Camera

Fig 9. Motorola Chip MC68HC908JB8 to control HDNS-2000

Fig 10. Pin Layout of MC68HC908JB8

1 comment:

  1. wow...
    it's awesome..

    can i ask u question about this project?

    ReplyDelete

There was an error in this gadget