In conventional mice, a highly sensitive optical sensor hides. There hides its own small "camera" and processor processing, which tracks the movement of the smallest points on the surface. In top mice resolution is only 3 microns!
With what podmyshinymi stones we encountered, plus the technical part, we will tell further!
The following TK was given by the customer: to make it as soon as possible, with any mouse (possibly wireless), output to a 7 segment indicator, reset by a button, the computer does not fit, resolution 0.01 mm, maximum distance 1000 mm.
For Began as it was done:
Reading the xy coordinates from the mouse:
You can implement data reading in several ways:
A) directly from the optical sensor chip
+ You can do with a simple controller
– about universality can be forgotten completely
B) connect the mouse via USB to simple controllers (for example to arduino)
+ Simplicity and deshivizna
– it is necessary to solder
– at hand was only arduino, and you can connect to it compatible mice with
PS / 2, and they are usually very inaccurate. It was possible on stm32, but debug boards
Greatly risen in price, itself did not have time to solder. (But if interested, then
A few years ago there was such a similar project on stm32f4discovery)
C) Take some kind of simple one paid computer. At hand was just
+ Suitable for any USB mouse
+ Good performance
-more expensive, but the excess power may be required later
As a result, Malin pi was placed under the surgeon's knife. Four 64-bit A-53 cores at 1GHz, 512MB of RAM and many other space-based digitizers for this task.
Problem: The indication should be on the 7-segment indicators issued. It turns out that we need 6 digits per coordinate, total 12 indicators. Each indicator has 7 feet per digits + leg on the LED point (dp), the common wire is not considered. Total after simple calculations we get that we need to control 96 conductors plus we need a button. 96 resistors did not really want to spend.
Listen to this!
After all, if the LED is lit – it means – does it need a single resistor?
It is not possible to control such an array of legs at once. There is an exit! And even a few!
1) Use additional microcircuits of the type max7219, or shift registers, multiplexers, etc.
+ You can almost infinitely increase the number of indicators
– max7219 was found to have an operating voltage of 5 V
– was not at hand anything suitable.
2) You can make a dynamic display. At one time, only one LED light is lit. If the indicators switch very quickly, the human eye will not notice the frames.
+ Need only 8 wires and resistors per indicator and 12 for switching indicators. Plus do not forget the button. Total: only 21 legs against 96. We take!
-how we try to control the whole indicator through one pin, then the maximum current is limited to 50 mA. We always take a stock, and take 35 mA for all 8 LEDs (which is not very hot). In addition to this, we add a quick switch of indicators. As a result, each of us shines 12 times less than the prescribed one. You can complete 12 transistors, but I left it for later, because Brightness finally sufficed.
Now the software begins:
You need to install linux on the server. I put the minimal distribution
RASPBIAN JESSIE LITE
Further through the program putty connected to the IP malinki, and further all through the command line.
To make it easier to work with GPIO (input and output ports) there is a wonderful library of WiringPi
How to install it and manage the ports, you can find a lot of information on the network, so I will not elaborate on this in detail.
Next, we need to create our project's daddy
cd / home / Pi Sudo mkdir mouse Cd / home / pi / mouse
Next, open the editor and paste the code from the gita. IMPORTANT! The code was written very quickly!
To exit the editor, you have to press Alt + x and save the file with the name blinker.c
Further it is necessary to compile necessarily with instructions wiring pi
gcc -o mouse mouse.c -l wiringPi
Everything! Now connect the mouse, insert the wires and start!
// pin number declarations. We're using the Broadcom chip pin numbers.
const int p21pin = 2;
Const int p22pin = 3;
Const int p23pin = 4;
Const int p24pin = 17;
Const int p25pin = 27;
Const int p26pin = 22;
Const int p11pin = 10;
Const int p12pin = 9;
Const int p13pin = 11;
Const int p14pin = 5;
Const int p15pin = 6;
Const int p16pin = 13;
Const int papin = 8;
Const int pbpin = 23;
Const int pcpin = 12;
Const int pdpin = 20;
Const int pepin = 21;
Const int pfpin = 24;
Const int pgpin = 18;
Const int pdppin = 16;
const int butpin = 26;
Automatic launch At boot:
sudo nano /etc/init.d/autostart.sh
Work with this program really easy. By clicking the mouse button or just a button on the board is zeroing. When the button is pressed for a long time, go to the DPI adjustment mode. This is an important parameter that is set by the mouse and shows how many counts we get when moving one inch. Accordingly, the digger on the board and on the mouse adds and decreases DPI. Long press, our value is recorded in a file and reliably stored until the next system boot. For the purity of the experiment in the program, the indication, receiving information from the mouse and the button are processed in parallel processes.
Then the most interesting! Testing and results!
What are the nuances of working with the mouse:
1. The X and Y axes on my mouse were not parallel to the side faces, I had to use "Pythagorean pants" to calculate the real distance.
2. The resolving power is not equal to the error!
In simple language, the resolution really shows the minimum displacement that the mouse will see (the counts in the computer must be discrete with minimum resolution). But that the mouse will not miss anything, nothing is guaranteed. You can reduce this value using good surfaces (so that the optical sensor can track movements), use small speeds. But omissions will always be! For the user, this means a constant zero departure and an unpredictable measurement error.
3. The USB HID on which the mouse works does not guarantee the delivery of information to the computer! That is, it is unknown whether the computer missed any information from the mouse or not. The probability of loss of information is small, but still there is.
4. The sensitivity settings (resolution) are sometimes stored not in the mouse, but in the program for the mouse.
5. Here I am very angry! The fact is that I took the mouse from the coolest assortment of Logitech, this is the most advanced model for that day of logitech performance mx. But what was my surprise when the mouse gave different errors in moving forward and backward. WHAT IS IT LIKE? I will explain for the user. If you constantly move the mouse back and forth, then the cursor is noticeable so everything decreases and decreases. It's on any platforms. You have to raise your mouse periodically and place it in a new place. After I noticed this, my life turned into a nightmare! #Logitech logitech explain the essential difference in measurement errors forward and backward!
Video of the demonstration of the work-
https://youtu.be / ZVuP0h4cddM
As a result: the disadvantages outweighed all the advantages of the mouse as a measuring device. Therefore, the project was closed and spread for dear readers of GeekTimes.