Ectognathus, do-it-yourself micro-server hexapod, part two

Good afternoon, dear Khabrovites. This is the second part of an article about the development of a hexapod robot. You can find the first part here .
In this article I will talk directly about the production of the robot itself, the transition from models in SolidWorks to a real device.

Production start

The first thing I would like to note is between the moment “well, I have a model, the project is almost ready” and “I have a finished device on my desk”, in fact, there are a lot, a lot of things. The faster you make this transition, the less likely it is that the project will be abandoned. At this stage, a friend managed to lose enthusiasm, so I continued the project alone.
After the model was completed, it was necessary to start, in fact, production, and the first thing to do was to purchase the necessary parts. If there were no problems with servos and batteries, and by that time they were already on my desk, then finding everything else turned out to be much less easy. I started with bearings on the very screw acting as an axis. Since I chose the M3 screw, the bearings had to be found with the same inner diameter. And the easiest way to do this was to do it in the auto / air model store. Therefore, I recommend that anyone looking for this kind of small parts first study the assortment of shops with models, it turned out to be much easier than contacting stores specializing in bearings.
I got a couple of these sets - 4 bearings with an inner diameter of 3 mm, an outer one - 8 mm, and a height of 4 mm, worth 450 rubles for 4 pieces.
Oddly enough, the bearings were not difficult to find, but to buy screws is much more difficult. The fact is that starting with M3, screws are sold on almost every corner, but there were M2 screws in the design - they mounted the “rocking” of the servos, and it was impossible to use the M3 there - they would just turn the rocker. In ordinary stores there were no such screws, and hardware stores sold them only in thousands. Fortunately i found a store in which you can even buy one screw. Despite the somewhat inconsistent name “Superbolt”, the store turned out to be very good, where I immediately bought all the fasteners - M3 of different lengths with a hidden head, M2, nuts for them and washers.
I purchased racks of various sizes in the VoltMaster store .
In total, all this small things came out cheaper than 500 rubles.
Next, it was necessary to choose where and from which to mash parts, and here trouble was waiting. We milled a lot where, but everywhere we needed our own material, 2 mm thick sheet aluminum was either not there, or "it was once, but it is now over." The new sheets were sold only in the format of 1x3 meters, which was, to put it mildly, a bit too much. I phoned up five firms and were nowhere ready to sell trimmings.
But, fortunately, I remembered that the former classmate has a milling machine. Having contacted him, I discussed the problem, and found out that he also did not have an aluminum sheet, but there was a composite material called ALUCOBOND , which is a "sandwich" of two thin layers of aluminum, between which some polymer is enclosed. The thickness of this sandwich was 3 mm, and the density (and, accordingly, the mass) was two times less than sheet aluminum!
Thus, after adjusting the density in the solid, the mass of the new model became about 650 grams.
By the way, a couple of days ago I found out that you can still buy scraps of aluminum in one of the companies, so if you definitely need a duralumin, then sometimes you can still find it, but you need to look persistently.
After all the necessary was purchased, it was time to move on to the next stage.


And now I will tell you about the most important. About a rake that can be stepped on during production. Rakes that result in additional costs.
Well, firstly, if this is your first project ... Yes, even if not the first one, I still recommend cutting / milling to be ordered not at large companies, but at small private owners, if the design has not yet been debugged. Because it is very unlikely that you will be allowed to sit next to a large company and, having seen that the first part does not fit with your drives, shout “stop the milling cutter !!!”.
Since I milled with a classmate, I had such an opportunity. We agreed to cut out a few test parts first, check them, and then, if everything goes well, cut out everything else. Of course, the test parts did not dock, so I had to edit them on the go and re-cut them again.
So what is worth paying attention to?

  1. Laser cut or mill? The answer depends on your design requirements. Laser cutting is faster. For the price, in principle, is not very different. But if you need to countersink holes, that is, forming holes for screws with hidden heads, for example, as in this figure,
    the laser will not help you. However, I found that such openings are simply obtained at home using a dremel and the corresponding conical nozzle, something like this:
  2. Bilateral details. This refers to parts that cannot be obtained without turning the milled sheet — for example, having countersink on both sides, or through-through grooves. Once again, the laser disappears here. But with milling, not everything is so smooth. I don’t know how in large firms, and where I milled, it would have resulted in untold hemorrhoids, increased costs in time, and, accordingly, in money. I believe that in large firms this will also not be free. Therefore, try to avoid such situations. You can countersink with a dremel, it will be quick and free.

  3. The cutter has a nonzero radius. It is obvious. Therefore, it should be remembered that the internal cuts cannot be smaller than the radius of this cutter. That is, the internal corners will be rounded, which means that your parts inserted into such grooves will no longer fit. Let me explain with an example:
    This is a part of a servo mount, a node from the base of the leg, where two servos are mounted. The technological border is surrounded by a red frame. If it is not made in the model, the milling cutter will cut it through anyway - as physically cannot make a right angle. But just to extend your groove, it certainly will not, therefore its real length (that is, the length of the part with a constant width) will be less by the radius of the cutter. If you do not want to file the details with a file, then it is better to immediately foresee this moment.

  4. Sizes. You have to measure everything. You hear? That’s all . First of all, you need to purchase an electronic vernier caliper (you can also use an ordinary caliper, but with an electronic one), such as this
    and measure all the purchased parts included in your design with an accuracy of 0.1 mm. Firstly, the sizes given on the Internet are often very inaccurate. And secondly, for the Chinese, it seems, such a thing as a normal drawing does not exist in principle - for example, what they give to their servo drives: image

    More than half of the required sizes are missing; the remaining ones are not true. But with this I pinned very hard. No, I measured everything that was necessary. But when I drew the detail already mentioned above, measuring the cylindrical protrusions on the drive (as you can see from the part, there are two of them, one large, a shaft sticks out of it, the second is smaller, sticks to the first), without thinking, I decided that the small one lies on side of the big. After the test piece was cut out, the drive did not get into it. Upon closer examination, it turned out that the small cylinder does not lie on the side of the large one, but is shifted by 0.3 (!) Mm. This 0.3 mm was enough to prevent the drive from cramping where it should.
    Of course, not everywhere the dimensions are so critical - you need to look at the design, where the error will not greatly affect. But most importantly, do not forget about it and measure everything.

After I corrected the construction several times, the jambs finally disappeared, and I received a package of my parts, from which I began to collect Ectognatus.


There were no special rakes at the assembly stage. I note only two things.

  1. The nuts are loosened. Mercilessly. Unfortunately, there were no lock washers to prevent self-loosening for the M2 screws, and where the M3 was, they locked the bearing, so they had to be abandoned. And then, in the process of work, I had the opportunity to see the nuts falling out on the go. Therefore, after the design is assembled and tested, the nuts can be planted on enamel or paint, which I did. Self-unscrewing stopped, everyone is happy.

  2. Painting a robot. Since this same Alyukobond was not a very pleasant color - blue on the one hand, green on the other, I decided to paint it. Black matte auto enamel came up very, very well for this. It lays well, dries instantly. True, I painted with a brush, and spray, as I was later told, the result is better. Not tested, but very possible.

This is what the newly milled part looked like.

Leg assembly, construction check.

Model and real body of the robot
Model and real node of the servo-
mount Ektognatus assembly


So, after the whole structure has been assembled, it's time to test it in action.
Before designing custom electronics, I wanted to check how it behaves in the real world, current consumption, etc. For verification, it was decided to use the Mini-STM32 board, which I already talked about in the corresponding article .
Since it is impossible to power electronics and drives from batteries without a converter, the batteries have been left out of work, in design, but not connected.
For verification, I chose the following path: a circuit board is made from a breadboard, to which all drives are connected - power and ground are connected to 18 drives, and their signal inputs are grouped in three pieces (one leg). Mini-STM32 is connected ).
Since there were a lot of channels (18 pieces!) And the frequencies there are about 50 hertz, there was no point in chasing a hardware PWM, only looking for hemorrhoids. Therefore, the signal inputs from the drives I hung on the usual free GPIO. A radio module with a Nordic chip was connected to the controller's SPI, which I can’t help but admire: 261072511055
Since at one time I wrote for him a driver for FreeRTOS working on interrapts and DMA rather than simple polling, I rolled this FreeRTOS onto the board.
In fact, this turned out to be a radio-controlled 18-channel PWM generator. From the point of view of software, there are no special tricks there, except for the driver for the radio module. PWM is generated using a single timer, using the same method as in this article from Dihalt
There is an array of 18 structures

typedef struct
	u32 __O *PinAddress;
	u16 DutyCycle;

Where * PinAddress - bitband address of control of the selected leg. The array is sorted in ascending order by DutyCycle , the DutyCycle of the first element is entered into the Capture-Compare register, and in the interrap by coincidence of the timer, the corresponding pin level is set through PinAdress . Then the DutyCycle is entered in the SS register next. When the timer reaches the maximum, all pins are set to 1, the array is re-sorted (in case new values ​​come), and everything repeats again. So that the received values ​​do not knock down the generation, they are entered into the new Work array, and at the time of the timer overflow, the Work and Sorted arrays are swapped - thus, we get double buffering.

To communicate with the computer, the same board is used, with the same radio module, connected via USB. In it, I implemented a HID device, so the data is sent to it elementarily, without additional drivers, from any convenient programming language. My control program, for example, in C #. The transmitter is controlled, of course, also FreeRTOS, so that you do not have to rewrite the module driver. Information is transmitted to the robot in one task, data exchange with USB - in others. Even if nothing new came over USB, the transmitter constantly pings the robot, sending it a packet with the corresponding header. Since the radio modules have hardware connection, you can immediately find out if there is a connection with the robot or not, and set yourself the corresponding byte in status. USB task as a report sends this status.
If new data arrives (angle values ​​for 18 drives, raw, without frills), then the USB task puts them in the queue for transmitting, and the transmitter task in the same raw form sends them to the robot, which, upon receipt, enters them into the already mentioned array Work.
Thus, all the logic can be implemented on a computer - only the duty cycle of the drives will be transmitted to the robot.
Of course, in the future this will be implemented in a different way, but it is perfectly suited for verification - it is not necessary to alter the glands a hundred times.

The program, written in half a day, cannot boast of an interface, of course, but it performs its functions, in principle. So far, no IR, only forward kinematics for drawing models and corny sequences written down in the forehead for movements.
After everything described above was done, I recorded several sequences to Ectognatus, which he reproduced on this video:

The wires connected to it are powered by the LBP, for the reason for the lack of a converter already described above.
So, it's time to talk about the most important thing. That’s all . граблям грабли, всем косякам косяк.

Praise to Chinese Servos

Do you know what the test showed? The robot was barely standing. He could somehow keep his weight on six legs, but it was enough to lift two, and he tumbled to this side. What I saw very, very upset. Hands dropped straight. I sat and thought, "Could it really be that my calculations were so erroneous that the robot cannot hold on?" I took off his "floor" with batteries - instead of 650-700 grams, Ektognatus began to weigh 500-550. After that, he reluctantly portrayed a willingness to work - the video above was filmed in these conditions. But how so? And then I thought - “maybe something is wrong with the drives?” and decided to measure the moment declared by the manufacturer. Here the rake opened, which so painfully tapped my forehead.
Like all rakes, they consisted of two parts - the one you are stepping on, small, metal, and the one that hits hard on the forehead.
The metal part of the rake was the fact that manufacturers produce two types of drives, MG90 and MG90S. They are slightly different in parameters and design.
Here is the MG90S, the ones I bought:
Weight: 13.4g
Dimension: 22.8 * 12.2 * 28.5mm
Stall torque: 1.8kg / cm (4.8V) - 2.2kg / cm (6.0V)
Operating speed: 0.10sec / 60degree (4.8v ) - 0.08sec / 60degree (6.0V)
Operating voltage: 4.8-6.0V
But MG90:
Pay attention to the protrusion at the bottom of the drive (which I called "asshole", because in this situation he was her, without getting into the structure). It is clearly visible in the drawing:
But its parameters:
Weight: 14g
Dimension: 23.1 * 12.2 * 29.0mm
Stall torque: 2.2kg / cm (4.8V) - 2.5kg / cm (6.0V)
Operating speed: 0.11sec / 60degree ( 4.8v) - 0.10sec / 60degree (6.0V)
Operating voltage: 4.8-6.0V

Notice the difference? A little bit slower and a little stronger. Well, I myself stepped on this part of the rake - I had to take, of course, the MG90s, which are stronger. However, they did not get into the design only if they tried to install both in the servo mount (in truth, not because of the “asshole”, but because they were a little bit higher in height than in length, and the mount was designed for square drives). But along with the MG90S, he stood up to the mount like a glove, without any problems. This suited me quite well, since the weak MG90S remained only as a rotary servo, on which there was almost no load. And the servos, which accounted for all the weight, were easily replaced with the MG90.
Now let's turn to the rake handle. Big and heavy. So, how do normal people perceive the Stall Torque parameter? Obviously, like this: “If X * Y is specified by Stall Torque, then when we suspend a weight of less than Y at a distance X from the axis of the servo, the server will be able to lift this weight. If the mass is around Y, then the serva will be able to hold it, but it will not be able to lift it. ”
For expensive and good drives, this is indeed the case - however, it still does not bother to check. But the Chinese comrades take this parameter differently. It is practically not connected with the real moment. I do not exaggerate, this means that for one MG90S the moment may be three times less than stated, for another - three and a half. For MG90 - in two. Etc. That is, there is not even a linear relationship, you can’t just “divide by three”, for example.
But let's take a closer look. I decided to measure the moment of my drives. To do this, you can use a simple device - a container in which we will pour water, with something that serves as a shoulder and a measuring cup. As a shoulder, I took the horizontal part of the foot of the robot, 6 cm long. Thus, I expected that the serva would be able to raise the capacity with 300 ml of water when feeding a sweat of 5V source. The moment in this case would be equal to 0.3 * 6 = 1.8 kg * cm. The capacity was a liter package from under the juice, from which I cut off the top and through which I passed a strong wire instead of a handle. If you repeat this at home, make sure that both the bag and the handle hold tight, otherwise you can fill in all the equipment. The shoulder is screwed to the servo drive, the package is hung on the second end of the shoulder, a small program gives the minimum value of the angle of rotation, which changes to the maximum when the button is pressed. In this case, the server tries to lift the load from the lowest to the highest position. By the amount of water we determine the weight of the cargo, and therefore the moment acting on the servo. The moment at which the server will no longer be able to lift the load, but will lift with a slight decrease and there will be a Stall Torque.
What I finally saw: 300 ml (moment 1.8) - the serva does not move. Well, the moment is overestimated, this is expected. But according to estimates, I had a large supply, how much did they overestimate it? We continue to measure.
250 ml (moment 1.5) - almost does not move.
150 ml (moment 0.9) - slightly rises, does not even reach the middle
100 ml (moment 0.6) - almost reaches the middle
~ 90 ml (moment 0.54) - lifts the load.
Honestly, I could not believe my eyes - I understand that it is possible to overestimate the performance, but more than three times ... Maybe this is a server I got? But no, I measured all 20 pieces that I ordered.
As a result, two-thirds behaved as described above, a third were even weaker (as far as - did not find out). In addition, there was a strong spread in PWM, that is, for one servo the maximum rotation was at duty cycle, say 0x200 (value of the timer register), for the other - 0x1E5, etc.
But it is not all that bad. I ordered 20 MG90 drives, those with an "ass" and stronger. The measurement results were more rosy - with the declared moment 2.2 they gave out about 1.2.
That is, the characteristics were not overestimated already not three, but only twice. Well, there were still those who turned out to be weaker than the others, but still it was not so critical.
I recall that according to the parameters stated on the site, the MG90 is only 1.2 times stronger than the MG90S, in reality, the MG90 is more than twice as powerful as the MG90S. In addition, they turned out to be significantly quieter and less susceptible to oscillations in the setting region - hello to the MG90S PID controller.
The conclusion from this is this: never believe the information received from Chinese manufacturers, if you do not want to later discover that the parameters on the site are connected with the real only through the phase of the moon and the astral vortex. Before development, do not spare money for 1-2 drives, calculate its real moment, consumption, speed. This will be cheaper than reordering the entire batch later. Well, if you buy Chinese drives - be sure to take with a margin. The point is not only that a third turned out to be even weaker, but also that one was generally beaten (trembled terribly, apparently there was something wrong with his regulator), the pair burned out from the strain and another one pulled the gear off motor shaft.
However, with those that I purchased for the second time, the MG90, I am quite satisfied. As a result, the robot quite calmly rose along with the batteries, absolutely calmly able to raise its legs, not being afraid to fall, and even was able to rise from the “unfolded” position (as in the video) in one motion, purely due to the strength of the servos, without backing up, with the tips of the legs.

Upcoming improvements

And at this moment I paused. Well, more precisely, I didn’t quite stop, but I slowed down the pace of development, since my vacation was over and a lot of work fell on. I am now in the process of designing custom electronics for the robot, about which I will say a few words in the article.
First of all, it is necessary to design a fairly serious converter that can deliver 30W to the drives. I found a very interesting chip, which, according to International Rectifier, is able to provide DC-DC conversion from 11.1V to 6V x 10A without a radiator, despite the fact that it does not need external mosfets - only a power inductor.
Here it is, darling:
10A drives, of course, will not pull - the maximum that I saw when all the drives are locked, and the robot is trying hard to rise - about 6A. So mikruhi should be enough. But this is in theory, in practice, I never used it - if anyone worked with her, share your impressions.
With the calculator, I will leave the STMku approximately the same as on the debugging one, and, in the long run, I will push inverse kinematics into it.
Initially, it was planned to leave communication on these radio modules - they are convenient, firewood has already been written for them by me, there is a version fully compatible with pins, but with an hellish amp, striking for half a kilometer. And I planned to put a camera on the roof of the robot. Of course, in order not to do the useless work of receiving a “raw” signal from the camera, and sending it using this module (which does not have enough speed to send a normal video), I planned to take the camera with an integrated transmitter, for example, such .
A rather dimensional receiver is placed on the other side, and since the output from it is analog, a usb device is added here, which allows you to connect analog video sources to your computer. And, in principle, I have already come to terms with this, but then I saw him .
Router TL-MR3020. The miracle of Chinese technology for 800 rubles. Outwardly very similar to the Apple device.
Internally - a full-fledged Linux computer, which OpenWRT has long been ported to.
The board inside it is only 5.7x5.7 cm in size. And it has a USB host!
Its consumption, even with the harshest transmission, does not exceed 180 mA, and the average is about 100.
As it turned out, this router (and its full analogue, just intended for the domestic Chinese market, TL-WR703N, about which the majority of articles have been written, if you search, search by this name) has long been used by electronic engineers as a single-board computer that can be used in their crafts. Normal video streaming rises easily and naturally on it, and you can easily connect a regular webcam to it.
You can read more about the TL-MR3020 and its twin brother TL-WR703N on the OpenWRT website.
I’m picking it now at work, so I had the pleasure of working with him live.
In general, now my plan is as follows - on my board there is a converter that provides power to all nodes of the circuit, CTMka, acting as a controller of all mechanics (legs and a rotary servo on the roof, turning the camera), and, possibly, a couple of sensors - say, an accelerometer, to keep track of your tilt. On top of this board is a board from TL-MR3020, with OpenWRT on board, which provides video streaming and Wi-Fi connection between the robot and a computer. Previously, of course, extra connectors are soldered from it - there is nothing to take up space. It will also be connected to my board via USB, the board with the foot controller will appear to be a HID device. Thus, we get rid of the bulky analog video receiver, the converter that comes with it, a separate transceiver module to the computer, and we get the opportunity to steer a robot from any device with Wi-Fi, параллельно наблюдая через его камеру, например – с iPad.
That's all for now, as soon as there is time and I will finalize the boards and get the results, wait for the next article.
Thanks for your attention!