In this article I will talk about how we collected the glove to determine the position of the hand for the competition. Of course, there are difficulties in its manufacture, but even a schoolboy can collect it. Such a glove can be used both for controlling electronics and as a manipulator for various games.
Those who read the
article about the scanner will probably remember that I promised to continue. But because of the contests, I still have no time for this. But now I sit after the competition and write an article about a part of our project. At the exhibition I was asked to tell about the principle of operation of this device, then they asked for contacts, and then I just decided that I would better write an article and solve the problem for more than two people. Initially, with the help of this glove we controlled the electronics (we included teapots on the Internet using gestures), and now we use it for tracking the position of the hand. That's all the introduction.
Principle of operation
Hand gloves can be divided into several types (I can miss something):
')
1) On strain gages
Well, this is the easiest. A strain gauge is a strip from which two contacts extend. When stretching / compressing this strip, its resistance changes. We put on each movable joint on such a sensor and get a profit. But these strain gauges are quite expensive, it is impossible to determine the direction of the bend and the tape itself has a decent length (about the length of a finger).
2) On the "LED tubes"
Already more interesting. The bottom line is this: a silicone or rubber tube is taken, an LED is installed at one end of the tube, and a photoresistor / transistor at the other end. The more we bend such a sensor, the less light falls on the photo sensor, and accordingly its resistance increases. Such a sensor is cheaper than a strain gauge in order. But it has the same disadvantages: it is inconvenient to bend and it is impossible to determine the direction of the bend.
3) orientation sensors
By this I mean various accelerometers, gyroscopes, magnetometers, and various combinations of them. The cost of such sensors varies greatly, and the main problems arise when programming them. It is these sensors that I applied in a glove.
I stopped the choice on LIS331 sensors. This is an eight-bit, three-axis accelerometer. Just because they then cost 30 rubles apiece retail. This was generally my first experience in using such sensors, so I decided: “if I drown this sensor, it will not be a pity”.
From the accelerometer we get the decomposition of the acceleration vector of the sensor in its three axes. Where is the acceleration? Well, as from space - the acceleration of free fall on the Earth acts on us. Here it is necessary to say about the minus of this sensor: this very vector fluctuates from any hand-shake, so we have high-frequency noise at the output. But to determine the gesture, when the hand almost does not move, you can apply them.
Actually, this is the whole task: take the sensor on each moving bone, connect it to the microcontroller, find the position of the sensor, determine the gesture. But it was not there…
Sensor board
Let's start with the fact that this sensor is still necessary to solder. Do you think you are good at soldering? Meet (grid pitch on photo 0.5 mm):
LGA16. He is also pleased to meet you. It was because of him that I had to buy a soldering station. I really love SMD. The details are small and the handkerchiefs are correspondingly small too. But this is ... In general, now, after soldering the MPU-9250, I say that it is a freebie, but then it was a look. Well, at least it's not a pity to kill. Armed with a program for tracing boards draw a board. First, the area under the microcircuit. Our best friend in soldering is surface tension. When we solder exactly this power will cause the microcircuit to fall into place. Therefore, the site must be done quite long, otherwise the microcircuit will pull the same surface tension to the side. All sizes are taken from datasheet. I could not do it in one layer without jumpers, so there will be one after all. On the layout, it is shown in red. Large sites in order to solder the cable there. Since the pitch between these pads is 2.54 mm and these pads are located both above and below the microcircuit, the loop with a pitch of 1.27 mm is ideal for us. The result will be such a fee:
And such a sensor after soldering:
The photo clearly shows the
mess on the table for which I apologize what I had in mind when I spoke about the step of conclusions. The width of the cable is almost equal to the width of the board, and therefore does not look very bad. But the board still needs to be done and corroded. The fee is easily done by LUT, and I’m being bullied in hydrogen peroxide. To achieve a better result, I roll the board in solution with an electric motor. You can at once make an array of boards on one piece of fiberglass. This will greatly speed up the manufacturing process. After etching we puddle the board and at this stage the problems begin ...
Soldering
This process is absolutely useless to describe. Better to see the video once. I can only say that I jammed 8 sensors before I sealed the 6 sensors I needed. Well, the first time is soldering, you can forgive. I will not attach a video about the soldering of the LGA case, since they are easy to find in a search engine, and I don’t want to litter the Internet with another one.
Another useful life hack: blow-dry in some tray / baking tray / plate / basin in general in anything that has sides. The microcircuits are blown away by a hairdryer, and it is almost useless to look for them.
After sealing the sensor, solder the cable, remember that you forgot to solder the jumper, solder the cable, solder the jumper, return the cable to its place.
Microcontroller board
This is your business, which MK to use. Here I will talk about a little trick, which for some reason is forgotten. And it allows saving the legs of the microcontroller, which are already few on some boards. And this trick is called logic. Not the one that feminine happens, but the one that starts at 74HC. Specifically, we are interested in 74HC164. This is a shift register. It works quite simply. He has legs Data, Clock, Reset and conclusions. Through Data and Clock, we successively transmit 8 bits, which the register simultaneously outputs to the outputs. And with the help of Reset, you can set all the pins to 0. Actually we connect the legs of the Enable accelerometers to this microcircuit and with the help of one microcircuit we control eight accelerometers. But we need only five, so that the remaining two can be occupied by LEDs. There will be a beautiful highlight. Only here there is a bug: when we reset the chip, the “bits of LEDs” will be written to 0. And since we write the data pretty quickly, this blinking will look like a decrease in brightness, which can make the engineer nervous. Actually the general block diagram of the glove will look like this:
When programming, you must also remember that the microcircuit will be selected when there is a logical zero on the Enable leg (also known as CS). So in order to select the second accelerometer, you will need to write 10111111 instead of 01000000 in the register.
Programming
Data exchange with the accelerometer is as follows:
0 bit - R / W bit. If 1, then we read the data, if 0, then we write to the sensor.
1-7 bit - Address of the register with which we are going to work.
8-15 bit - The data we write to the register. If we read, then the accelerometer will simply ignore them.
If everything is clear with this, then for the beginning we read the WHO_AM_I register. This register can only be read and its default value can be found in the datasheet. For our accelerometer, this register is located at the address 0x0F, and the default value is 0x3B. That is, we send 0x8F to the accelerometer first, then any 8 bits, and must read 0x3B. If you read something else, then somewhere cant. Either in soldering, or send the wrong data, or overheated microchip during soldering. Maybe the speed is too big. And do not forget to tighten the leg CS to the ground and return back. If you received the correct data, then you can be congratulated - it remains to solder only 4 sensors. It turns out this picture:
After sealing all five sensors (one for each finger), we attach them to the glove. I used hot glue for this. It turned out this:
In order for us to begin to receive any data from the chip, it must be turned on. To do this, set the BOOT bit of the CTRL_REG2 register to one and write the value 0xC7 to the CTRL_REG1 register. The first is to reset the accelerometer, and the second is to take the sensor out of power saving mode, set the sampling frequency to 400Hz, and turn on all three axes.
All data from the x, y and z axes is written to registers with addresses 0x29, 0x2B, and 0x2D, ​​respectively. In order to get the data, we just read them and that's it (don't forget that if we read, then 0bit of the first parcel is 1). Here is another “if” with a trick: if you read the data, and there are solid zeros, and the code is exactly working and correct, then look carefully at the name of your accelerometers. There may not be LIS331DL, but LIS331DLH. What does this letter give? And the sensor is now 16-bit, so also with a large number of settings. Because of this, the addresses of the registers change. I on search of this jamb killed hours 4, not less. It was a shame. But suppose you did everything right. Then you will get this kind of trash in the terminal:
I doubt that such accelerations act on the accelerometer lying peacefully on the table. Probably all a matter of interference. No, well, what did we want for 30 rubles? We'll have to somehow get rid of them. For this we need a filter. The easiest way to implement it is software (it seems that there is a filter inside the sensor, but for some reason it did not work for me). It looks ugly simply: the new value = old value + measured value * coefficient. It is clear that the cut-off frequency depends on the coefficient that you need to choose for your own tasks.
Gesture definition
In the simplest case, you can simply look at the sign of the number that we accepted. Get the array on five fingers, and send this array to the computer. Like, if the finger is bent, then 1, and if straightened, then 0. For example, 11011. This is exactly what was realized in the first glove, for more was not needed. But it is also realistic to determine the angle of inclination. To do this, we simply take the arctangent of the ratio of accelerations along two axes and obtain the angle of inclination along the plane in which these axes lie. Having done this for three pairs of axes, we can find the tilt angles along the three axes and restore the position of the sensor in three-dimensional space. But I think no one will need it. Even not due to the fact that the task will not require it, but due to the fact that for such tasks it is necessary to use a six-axis sensor (accelerometer + gyroscope) or even better nine-axis (accelerometer + gyroscope + magnetometer). But they are much more expensive and work with them is somewhat more difficult.
Conclusion
I hope that those who wanted to collect something like this article will help. I would have helped at that time. Now we have already won one competition with this glove, and even made a new glove on nine-axis sensors, with which we won on the other. Truth be told in secret, the magnetometer did not work for me, but nobody knows about it. The glove works well without it, so I'd rather have bought cheaper six-axis sensors. Now there are no contests in the near future, so I will try to write a second article about 3d scanner, as I promised.
PS I forgot to attach the sensor board layout itself:
SprintLayout Fee