Where can you use microcontrollers from mice? Mouse-based displacement controller

The ADNS-3060 optical sensor, compared to its “ancestors”, has a truly impressive set of characteristics.
The use of this chip, packaged in a 20-pin package, provides optical mice with unprecedented capabilities.
Acceptable maximum speed the movement of the manipulator increased to 40 inches/s (that is, almost 3 times!), i.e. reached a “signature” speed of 1 m/s.

This is already very good - it is unlikely that at least one user moves the mouse at a speed exceeding this limit so often that he constantly feels discomfort from using the optical manipulator, including gaming applications.
The permissible acceleration has increased, scary to say, a hundred times (!), and reached a value of 15 g (almost 150 m/s²).

Now the user is given 7 hundredths of a second to accelerate the mouse from 0 to the maximum 1 m/s - I think that very few people will now be able to exceed this limitation, and even then, probably only in their dreams.
The programmable speed of taking pictures of a surface with an optical sensor in the new chip model exceeds 6400 frames/s, i.e. "beats" the previous "record" almost three times.

Moreover, the ADNS-3060 chip can itself adjust the frequency of snapshots to achieve the most optimal operating parameters, depending on the surface over which the mouse moves.
The “resolution” of the optical sensor can still be 400 or 800 cpi.
Let's look at the ADNS-3060 chip as an example. general principles the operation of optical sensor chips.

The general scheme for analyzing mouse movements has not changed compared to earlier models - micrographs of the surface under the mouse obtained by the IAS sensor block are then processed by a DSP (processor) integrated in the same chip, which determines the direction and distance of movement of the manipulator.
The DSP calculates the relative amounts of displacement in the X and Y coordinates relative to the mouse's original position.

Then the external mouse controller chip (what it is needed for, we said earlier) reads information about the movement of the manipulator from the serial port of the optical sensor chip.
Then this external controller translates the received data about the direction and speed of mouse movement into signals transmitted via standard PS/2 or USB interfaces, which are then sent to the computer.

But let’s delve a little deeper into the features of the sensor.
The block diagram of the ADNS-3060 chip is shown above.
As we can see, its structure has not changed fundamentally, compared to its distant “ancestors”.
3.3 Power is supplied to the sensor through the Voltage Regulator And Power Control block; the same block is charged with voltage filtering functions, for which a connection to an external capacitor is used.

The signal coming from an external quartz resonator to the Oscillator block (the nominal frequency of which is 24 MHz; lower-frequency master oscillators were used for previous models of microcircuits) serves to synchronize all computational processes occurring inside the optical sensor chip.
For example, the frequency of images of an optical sensor is tied to the frequency of this external generator (by the way, the latter is not subject to very strict restrictions on permissible deviations from the nominal frequency - up to ± 1 MHz).

Depending on the value entered at a specific address (register) of the chip’s memory, the following operating frequencies for taking pictures with the ADNS-3060 sensor are possible.

As you might guess, based on the data in the table, the frequency of sensor shots is determined using a simple formula:
Frame rate = (Generator setting frequency (24 MHz)/Value of the register responsible for the frame rate).

Surface images (frames) taken by the ADNS-3060 sensor have a resolution of 30x30 and represent the same matrix of pixels, the color of each of which is encoded with 8 bits, i.e. one byte (corresponding to 256 shades of gray for each pixel).
Thus, each frame (frame) arriving at the DSP processor is a sequence of 900 bytes of data.

But the “cunning” processor does not process these 900 bytes of the frame immediately upon arrival; it waits until 1536 bytes of information about pixels are accumulated in the corresponding buffer (memory) (that is, information about another 2/3 of the subsequent frame is added).
And only after this the chip begins to analyze information about the movement of the manipulator, by comparing changes in successive images of the surface.

With a resolution of 400 or 800 pixels per inch, their implementation is indicated in the RES bit of the microcontroller memory registers.
A zero value of this bit corresponds to 400 cpi, and a logical one in RES sets the sensor to 800 cpi mode.

After the integrated DSP processor processes the image data, it calculates the relative displacement values ​​of the manipulator along the X and Y axes, entering specific data about this into the memory of the ADNS-3060 chip.
In turn, the external controller (mouse) chip, via Serial Port, can “draw” this information from the memory of the optical sensor approximately once every millisecond.

Note that only an external microcontroller can initiate the transfer of such data; the optical sensor itself never initiates such a transfer.
Therefore, the issue of efficiency (frequency) of tracking mouse movement largely lies on the “shoulders” of the external controller chip.
Data from the optical sensor is transmitted in 56-bit packets.

Well, the Led Control block with which the sensor is equipped is responsible for controlling the backlight diode - by changing the value of bit 6 (LED_MODE) at address 0x0a, the microprocessor of the optosensor can switch the LED to two operating modes: logical “0” corresponds to the “diode is always on” state, logical “1” puts the diode into the “on only when necessary” mode.
This is important, say, when operating wireless mice, as it allows you to save the power of their autonomous power supplies.
In addition, the diode itself can have several brightness modes.

This, in fact, is all about the basic principles of operation of an optical sensor.
What else can you add?
Recommended working temperature ADNS-3060 chips, as well as all other chips of this kind, - from 0 °C to +40 °C.
Although Agilent Technologies guarantees the preservation of the operating properties of its chips in the temperature range from -40 °C to +85 °C.

Driver AMD Radeon Software Adrenalin Edition 19.9.2 Optional

A new version AMD drivers Radeon Software Adrenalin Edition 19.9.2 Optional improves performance in Borderlands 3 and adds support for Radeon Image Sharpening technology.

There are two such devices - for positioning the mouse horizontally and vertically. When the mouse is controlled diagonally, both position coordinators are involved. Pulses from two IR receivers (three-terminal IR transistor housings) are sent to a microcircuit (located on the back side of the printed circuit board) filled with compound. Its type is designated SS-1HBA-1. From the output of this microcircuit, through pulsation-smoothing chokes, the control signal is sent to the connector designated J1 and then to the PC via wire.

The wiring of connector J1 is as follows:

Pins 1 and 4 (black and yellow conductors of the connecting cable with the PC) – common wire;

5 – “+ 5 V” (red);

2 and 3 (green and white)

responsibly) is a high-frequency sequence of pulses with an amplitude of 4.5 V. The last two conductors transmit information about a change in the mouse position to the PC. However, these signals are difficult to use without a special decoding device. Therefore, there is an easier way to receive simple control signals from the mouse (as it moves). Thus, the IR transistor Q1 (opposite it is the IR LED IR1) is “responsible” for the transverse movement of the mouse (left, right), and Q2 and, accordingly, IR2 are responsible for the longitudinal movement (straight, forward, backward). Experimentally, it was possible to establish that in the absence of an obstacle between the IR transmitter and the receiver, there is high level voltage, and it changes to low as soon as the IR receiver stops receiving the transmitter signal.

Rice. 3.22. Mechanical computer mouse with the case removed, view of the printed circuit board and coordinate positioning mechanism

That is, when the mouse moves, the ball acts on the gear, the teeth of which are located between the transmitter and receiver of the IR signal. The same control signal (from high to low level) can be “taken” from the jumper contacts indicated on printed circuit board JPD2 and JPD3 (highlighted in Fig. 1). Knowing where on the board computer mouse connect an actuator (for example, a signaling device about the displacement of an object), all that remains is to take care of an electronic adapter that converts a change in the logical level into sound signal. In Fig. Figure 3.23 shows a mouse fixed between the crowns of a village house and a stable attached to it. When the house settles, or the distance between the logs changes by a millimeter, the “mouse” immediately gives a signal, and the signaling device “raises the alarm.”

Similarly, you can control the settlement of the foundation, the tilt of doors, door frames and any structures (not just wooden ones) where the tilting, movement or displacement of parts is undesirable or dangerous. As a sound signaling device, you can use the circuit shown in Fig. 3.24.

A sound capsule with a built-in generator is used as HA1 audio frequency, it must be connected strictly in accordance with the polarity. Transistor VT1 p-p-p conductivity opens when the voltage at point A is close to zero, that is, at the moment the mouse is displaced.

Rice. 3.23. Method for installing a computer mouse as a house subsidence sensor

Do not try to apply a voltage of more than 6 V to the “electronic filling” of the mouse; it will fail.

Rice. 3 24. Option of a sound alarm circuit for connecting to an object displacement sensor in the form of a computer mouse

Almost no one uses mechanical mice today (everyone has switched to optical ones), so its “second life” seems to me very interesting and useful as part of the considered device for signaling the displacement of load-bearing structures of a village house. Of course, this development can be applied in other cases - when a highly accurate object displacement sensor is required. A computer mouse fully meets these requirements, if only because any movement of it, even half a millimeter, will generate a change in level from high to low. Having disassembled the body of the mechanical mouse, I recommend blowing with compressed air the places where the plastic gears and the positioning ball are attached, and also placing a drop of household oil on the fastening of the gears to reduce friction from the rotation of their axes.

Optical mice have no moving mechanical parts, they are more durable, and the operating principle based on the reflection of a signal from the surface of the table allows you to create an original non-contact backlit light switch based on an optical mouse. Using the Defender Optical 1330 computer optical mouse (400 dpi resolution) as an example, we will consider the lighting control device below.

Literature: Kashkarov A.P. Electronic devices for coziness and comfort.

If your computer mouse is broken, do not rush to buy a new one. It is quite possible that you will be able to repair the breakdown yourself and the device will serve you for many more years.

The mouse sensor is acting up

Often there is also a situation when we cannot accurately move the cursor to a certain point. It constantly trembles and moves on its own. This situation clearly indicates that the optical group of the mouse is clogged.

Clogging is most often external. Dust or hair gets into the compartment where the diode light is reflected from the table. To get rid of such a blockage, you don’t even need to disassemble the mouse. Just turn it over and blow it out. As a last resort, use a small brush to remove stuck debris.

If, after such manipulations, the mouse cursor trembles, then, most likely, either the sensor is clogged inside or has completely failed. In any case, you can try to disassemble the mouse and clean the sensor using a toothpick with a cotton swab soaked in alcohol wrapped around it:

Before cleaning the sensor with a cotton swab, you can also try blowing it to remove any fine dust that may stick after it gets wet. After this, carefully, without pressing, insert the toothpick with rotational movements into the sensor hole. After making a couple of turns and without stopping rotating, we take out the toothpick, wait for the alcohol to dry and try to connect the mouse.

If, after all attempts at cleaning, the sensor does not work normally, then if you have another mouse, a soldering iron and straight hands, you can unsolder the non-working microcircuit and replace it with a sensor from another mouse. However, this already requires a certain skill, so not everyone will be able to pull it off...

Mouse wheel scrolls

It happens that the mouse works fine, but when we try to use its wheel, the page we are scrolling begins to jump up and down, or does not want to scroll at all. Alas, failure of the mouse wheel is a fairly common failure and it was this that prompted me to write this article.

First you need to carefully consider how evenly the wheel rotates in the groove. The groove itself and the wheel axle have a hexagonal cross-section, but sometimes one or more sides of this hexagon can become deformed, resulting in the axle slipping in the problem area.

If you have just such a problem, then it can be solved by sealing the edge of the wheel axle with adhesive tape or electrical tape in small quantities. If everything is normal with the movement of the wheel, then the breakdown has occurred inside the encoder (scroll sensor). From long-term use it could have become loose and should be tightened a little:

To do this, take small pliers and press them one by one on the four metal brackets that secure the encoder to the plastic parts of the scroll mechanism. The main thing here is not to overdo it and not break the fragile plastic, but at the same time press harder. Try connecting the mouse and checking whether the negative effect when scrolling decreases after each click.

Alas, in my case it was not possible to completely get rid of jerks. Yes, the frequency and spread of page jumps have decreased, but the jumps themselves have not completely disappeared. Then I decided to approach the issue of sealing radically and in a truly Russian way :) I cut out a piece of thin but dense polyethylene from an old battery pack and stuck it inside the mechanism:

What’s most interesting is that this manipulation helped! All I have to do is cut off the excess length of the strip and assemble the mouse :)

Mouse buttons don't work

The last, and most annoying, breakdown is the non-working button. Whether it's left, right or the one under the wheel doesn't matter - they're all usually the same. The important thing is that a non-working button cannot be repaired in any way. You can only replace its microswitch by removing the non-working one with a soldering iron and replacing it with a new one or one borrowed from another mouse.

The microswitch has three “legs”, the first of which is a regular clamp, and the other two are contacts that need to be soldered. There is no need to solder the fastener. It only serves as a “fool proof” to prevent you from inserting the microswitch in the wrong direction by mistake.

Sometimes the button still works, but it doesn’t work every time you press it. This symptom may indicate that the edge of the button pusher, which presses the microswitch, has worn away due to frequent use.

We disassemble the mouse and carefully examine the problematic button and its pusher. If we see a small dent, then that may be the problem. It is enough to fill the dented area with a drop of epoxy resin or melted plastic.

The last problem you may encounter is that the mouse button double-clicks when you click on it. This issue can be solved by re-soldering the microswitch or... programmatically! In any case, before you take up the soldering iron, check that the mouse settings are correct in the Windows Control Panel:

By default, the double-click speed slider should be in the center, and the sticky mouse buttons option should be disabled. Try setting these parameters and check if the problem is resolved. If not, another radical one programmatic method Double-click "cure" - remove the mouse driver. How to properly remove a driver is written.

conclusions

Mice are one of the most actively used computer devices. Therefore, it is not surprising that they often fail. However, due to the simplicity of their design, in most cases anyone can fix a mouse!

To do this, you don’t need to know how to solder or understand electronics. The main thing is to clearly diagnose the cause of the breakdown. Here, as in medicine, a correct diagnosis is the path to successful repair.

I hope our article will allow you to determine what exactly is broken in your mouse, and therefore, to fix it. Good luck with your renovation!

P.S. Permission granted to freely copy and quote this article provided that an open active link to the source is indicated and the authorship of Ruslan Tertyshny is preserved.

Anatoly Besplemennov

In this circuit, a sensor chip from a computer mouse is used to measure the rotation of a disk, which can be mechanically coupled to any type of hardware or instrument. One of the features of the circuit is the ability to adjust the ratio of the number of pulses per revolution by changing the position of the sensor along the radius of the disk.

The optical mouse sensor is a CMOS chip designed for building optical-electronic tracking systems. Inside the chip, images are captured, digitized, and digitally processed.

For example, consider a simple and cheap OM2 sensor. This device measures the position based on the received frames of the surface image, and through mathematical processing determines the direction of movement and its magnitude. Designed for use with high-brightness LEDs, the sensor is housed in a polystyrene optical housing. The sensor has no moving parts, does not require precise optical adjustment and allows you to create a complete, compact tracking system. OM02 produces a quadrature output signal for both directions of movement (X and Y). The resolution is approximately 0.06 mm, and the movement speed can reach 0.4 m/s.

The sensor chip generates a quadrature signal in the X direction, emulating the output of a conventional encoder. For a 2D system, both X and Y coordinates can be used. X1 and X2 are generated at a maximum frequency of about 25 kHz. The diagrams in Figure 1 illustrate the timing characteristics for the X coordinate axis (direction of movement is to the right). If necessary, the quadrature output signal can be used to directly control a stepper motor.

By connecting outputs X1 and X2 to the input of an exclusive OR gate, you can double output frequency data, while losing information about the direction of movement.

Physical implementation

The disc (or other surface) used must have some texture, pattern, scratches, or rough grinding in order to obtain good OCR results (Figure 3).

The design shown in Figure 4 has been successfully used to provide synchronous motion in production lines, conveyors, labeling equipment and printing on moving objects. More than 100 copies were made, all of them working after several years.

Circuit diagrams for the SPI interface

Other optical sensor chips are also available, differing in the types of light sources used, interfaces, speeds, and so on. For example, the optical CMOS mouse sensor (Figure 5) uses serial interface SPI, and the optical navigation CMOS sensor (Figure 6) has both types of outputs, both SPI and quadrature.

Sensors with SPI interfaces (or USB when using an additional chip) do not allow tracking of each individual pulse, since they transmit data in packets. For hard real-time applications, sensors with quadrature output are preferred.

It would also be interesting to build an encoder based on a wireless computer mouse, and perhaps even more interesting, based on a sensor from a digital caliper, since most of them have an I 2 C interface. But that's another story.

To solve one of the problems, I needed to programmatically obtain and process images of a small area of ​​the paper surface from a very close distance. Not getting decent quality when using regular USB cameras and already halfway to the store for an electron microscope, I remembered one of the lectures in which we were told how various devices, including a computer mouse, work.

Preparation and a little theory

I will not go into details of the operating principle of a modern optical mouse; it has been written about in great detail (I recommend reading it for general development).

After googling information on this topic and disassembling an old PS/2 Logitech mouse, I saw a picture familiar from articles on the Internet.

Not a very complicated design of “first generation mice”, an optical sensor in the center and a PS/2 interface chip slightly higher. The optical sensor I came across is an analogue of the “popular” models ADNS2610/ADNS2620/PAN3101. I think they and their counterparts were mass produced in the same Chinese factory, with different labels on the output. Documentation for it was very easy to find, even along with various code examples.

The documentation says that this sensor receives an image of a surface measuring 18x18 pixels (400cpi resolution) up to 1500 times per second, stores it and, using image comparison algorithms, calculates the offset in X and Y coordinates relative to the previous position.

Implementation

To “communicate with the sensor” I used the popular Arduino computing platform, and decided to solder directly to the legs of the chip.

We connect 5V and GND to the corresponding Arduino outputs, and the sensor legs SDIO and SCLK to digital pins 8 and 9.

To obtain an offset by coordinates, you need to read the value of the chip register at addresses 0x02 (X) and 0x03 (Y), and to dump the picture you need to first write the value 0x2A at address 0x08, and then read it from there 18x18 times. This will be the last “remembered” value of the image brightness matrix from the optical sensor.

You can see how I implemented this on Arduino here: http://pastebin.com/YpRGbzAS (only ~100 lines of code).

And to receive and display the image, a program was written in Processing.

Result

After a little “finishing” of the program for my project, I was able to receive an image directly from the optical sensor and perform all the necessary calculations on it.

You can notice the texture of the surface (paper) and even individual letters on it. It should be noted that such clear picture quality is obtained due to the fact that the developers of this mouse model added a special glass stand to the design with a small lens directly under the sensor.

If you start to lift the mouse above the surface even a couple of millimeters, the clarity immediately disappears.

If you suddenly want to repeat this at home, to find a mouse with a similar sensor, I recommend looking for old devices with a PS/2 interface.

Conclusion

Although the resulting image is not very large, it was quite enough to solve my problem (barcode scanner). It turned out to be very economical and fast (a mouse for ~100 rubles + Arduino + a couple of days to write the code).

I will leave links to materials that were very useful to me for solving this problem. It really wasn’t difficult and was done with great pleasure. Now I'm looking for information about the chips of more expensive models of modern mice to obtain high-quality images with higher resolution. I might even be able to build something like a microscope (the image quality from the current sensor is clearly not suitable for this). Thank you for your attention!