I'm not an engineer at mom
I already lost count of the hours that I spent making a “small box” and suddenly I realized that I really respected engineers - people who can and can design and create new things. My head immediately flooded with memories of the devices that I disassembled in childhood (and not only). These are funny situations when, when unscrewing the last bolt, like a devil from a snuff box, several small springs and parts flew out, which were completely impossible to pack back.
Once I decided to make a small device (“Security Access Tuner” from the game Alien: Isolation) - a controller, a screen, a couple of controls, and pack it all in a small case, which was planned to be printed on a 3d printer. Then I could not even think how long it would take for all these little things to come together ...
I was always attracted by the idea of creating something new - something that doesn’t work out so often in everyday fuss. I don’t know what exactly prompted the creation of this particular device, but one day I thought: “Why not make security access tuner from the game Alien: Isolation”.
The game has a device for “breaking electronic locks”. This device introduces the mechanics of mini-games into the game. Then choose a memes to your liking, but this is something between “We added games to your game so you can play games, playing the game” and “We need to go deeper!”. I will not bore you with the details of the gameplay, because everyone can learn about what kind of “beast” in detail by writing the name in your favorite search engine. We just agree that there is some handheld device with games that I decided to implement.
In the game, the device looks like this (I tried to accurately reproduce the appearance of the device, but this was not the main task, so the final result is slightly different from the original):
Screenshot from the game, the device is in the hands of the character.
So, you need to make a small device with games and these same “mini games" - two. In the first (the one in the picture above), you need to select the characters in the order in which they are displayed on the screen in the allotted time. The game is not difficult, if you get used to it, but at first it makes you think. The second game is to react and you just need to press the button in time (I won’t focus on it because it’s nothing special). In addition to games, there are several status screens, transitions between games and just “Please wait ...”.
By a fortunate coincidence, I was lying idle with a board from Texas Instruments - Tiva C (an analog of Arduino) and a screen for it. And one day, inspiration attacked a person with the presence of free time and for this couple (board and screen) there was an application ...
I immediately decided for myself that the “cherry on the cake” in this idea would not be the software part, but the engineering part. I wanted to make and assemble the device so that everything was compact, functional, logical and convenient (spoiler: everything turned out to be not so simple).
Programming is what I make a living from, and I understood that the program part could not provide serious “challenges”. Therefore, in order to bring the idea to life, I started with what is closest to me - from the software part.
The processing of events from buttons and a rotary encoder is completely commonplace and I see no reason to tell anything about it. Though an interesting part of the software implementation was the display of graphics on the screen. More precisely, not even the conclusion itself, but rather the set of actions that were necessary for what I wanted to appear on the screen. Basically, the “problem” parts were:
- The device’s memory is limited and many pictures (sprites) cannot be added to the device’s memory.
- The screen works with colors in the 565 format (two bytes per color), i.e. for all graphics, you need to do the conversion to the final format, but due to memory limitations, you won’t be able to store all the necessary images in this format in the device’s memory.
- The screen refreshes with a staggering frequency of ~ 1 frame per second, if you need to redraw the entire screen.
The first two problems were solved relatively simply, because the graphics that need to be displayed on the screen are very primitive (as it is in the game and I decided not to go far from the source material). That is why I immediately decided to use two-color images (sprites), which meant that 8 pixels fit in one byte and the colors can simply be changed when outputting.
Based on these very sprites, all the graphics (including text) were implemented, except for a couple of exceptions:
- The logo of a fictitious company of the manufacturer (Seegson), which uses a palette of 16 colors (i.e. 2 pixels in one byte). I wanted a little more beauty when I turned on the device and I added it already at the very end of development, because there was still some memory left.
- Functions were implemented to draw graphic primitives (for example, rectangles, but there are many of them in the interface I tried to repeat).
The problem of the screen refresh rate was not so easy to solve programmatically. Especially for places where you need to update the data on the screen quite often.
Fortunately, the problem was not in the screen itself, but in the slow data bus (SPI bus), so you just had to keep your pants and not go so wide - draw only what is really necessary, i.e. "less is better".
The interface rendering was divided into three parts to solve the problem of the refresh rate:
- Initial drawing (here everything that remains unchanged - the background and static interface elements) is drawn. This stage takes almost a second, but occurs only when changing screens and this second is not so noticeable.
- Animations that are not dependent on user actions (countdown timer status, interference, etc.). Usually these are small changes - not more than 15% of the screen, which even in this case allows you to update the screen at least 6 times per second (in fact, the refresh rate is much higher and the delays are imperceptible). The only exception was the screen with interference - I'll talk about it a little lower.
- Animations that depend on the user's actions (the position of the sliders or the frame around the selected character). These events do not occur so often, because with all desire, the user will not be able to click on the buttons faster than the state is able to redraw the screen.
In simple words, in order to avoid redrawing the entire screen, only what was needed was redrawn. So, for example, if the user selects the next character on the screen, then the previous “selection” (frame) needs to be erased (painted over with the background color) and draw the frame in a new place.
Another example of such optimization (where you need to draw a lot, but in reality it is not enough), is a screen with noise (white noise) - this is the place where the user needs to find the “right frequency” to get into the mini-game. The interference takes up most of the screen and redrawing all the black and white dots would be too long (and stupid). Therefore, the drawing of white noise works as follows: The
screen is divided into two parts (left and right side). Drawing starts on top.
- Randomly selects part of the screen (left or right side).
- Within this section, a strip of random black and white dots is drawn. This screen has two basic operations for working with it (except for the initialization operation) - the operation of writing to the screen buffer and the operation of moving the pointer within this screen buffer itself. Moreover, for an incomprehensible reason to me, the operation of moving the pointer works significantly slower than the write operation. Thus, for this screen, sequential writing to the screen buffer allows you to fill the entire screen in about 0.75 seconds, and when painting each pixel separately, it will take almost twice as much time (1.4 seconds). It is because of this feature that strips of black and white dots are drawn, and not just random pixels.
- Go to the next vertical strip on the screen and repeat the steps described in paragraph 1.
When all vertical lines are drawn, the drawing continues anew from above. As a result of superimposing some black-and-white dots on others, it is completely not noticeable that the screen is essentially “painted over with stripes” like this (first 20 random renderings):
Actually, the interference is not painted over the entire screen, but only those parts where interference is acceptable (i.e., there are several areas on the screen where interference is possible and drawing occurs only within these areas), but this does not change the approach.
The interface needed another rather interesting element - an indicator of the selected radio frequency. In order to make it easier to imagine, we can assume that we have in our hands an analogue of a radio receiver. There is a tuning wheel that can be rotated in a circle to find (select) the desired frequency. An indicator of this frequency is drawn on the screen, which can go around the full circle on the screen and return back to its original position. The indicator in the interface is a triangle (in fact, this is not entirely true, but for simplicity of display, let's agree that it is a triangle), which rotates around one of the vertices located in the center of the screen:
The borders of the screen are marked in gray on the picture.
In fact, this same triangle in the interface should not be completely drawn. Only a fragment located in that part of the screen that is further from the center (at the edges of the screen) should be drawn on the screen. Using an example, I showed it in orange:
The gray translucent rectangle in the center is left for clarity, but is not involved in the drawing.
The task itself is not difficult, just solving it “head on” with redrawing the entire screen is again unacceptable. Therefore, only individual fragments of the indicator were drawn (two beveled borders and a rectangle that connects them), and the previous state of the indicator “erased” (red color in the picture) before drawing:
Those. for this indicator itself, the function of drawing a rectangle was added, which is divided diagonally and filled with two colors (one color on one side relative to the diagonal and another color on the second side). The indicator consisted of two such elements (marked with the number 1 in the picture) and the rectangles connecting them (marked with the number 2):
The width (or height) of this element is determined by the offset relative to the center of the screen. So, when the indicator is in the very center of the screen, only a rectangle (2) is drawn, and when the indicator is moved closer to the edge of the screen, the width of the elements (1) increases. When the indicator is at the edges of the screen, another rectangle is added when drawing:
Perhaps this is where all the “interestingness” of the software part ends, and I can move on to what made me respect the engineers so much ...
Not an engineer
Despite the fact that I have written in a university diploma that I am a “computer science engineer”, in fact I realized that I was “anything computer science”, but not an engineer. I understand that the word “engineer” has a rather broad definition and nowadays it generally very often turns out that someone who is not a manager is an engineer.
By “engineer” I mean people who can and canto plan, design, construct and develop. And in my understanding, I'm not quite an engineer. I’m an amateur in this matter - I like to invent and implement something, but I cannot say that I always succeed. Engineering tasks (we are talking about the case of the device and its main components), which I rated as quite simple for myself, took such an amount of hours that I could not even imagine. I do not know the exact time, but I decided to believe that people did not come up with numbers by which such enormous quantities could be described.
As a child, my father often repeated to me the proverb “Measure seven times, cut once”. Then I did not fully understand why he said this so often, but it was in the process of creating this device that I realized how important it is to measure seven times before deciding in favor of one or the other option. If I listened to dad, I would not have to do so many trials and mistakes.
So, on the left side of the device there should be a scroll wheel that can be rotated up (or forward) to select the next character on the screen or rotated down (back) to select the previous character. I decided that I will not do a full scroll wheel, because for a rotary encoder or something similar, it would require much more space in the case, and for the transition “forward” / “back”, it was the buttons that seemed more logical.
I decided to design a lever in the form of a semicircle that can be moved up or down. This same lever had to press the up button or the down button and be on some axis in order to avoid “extra body movements”:
The idea seemed insanely simple to me, but along with it there were a lot of questions (to which people involved in the design of devices would most likely have ready-made answers) to which I had no answers. And the questions were as follows:
- What and how to attach buttons? In the picture above, they simply “hang in the air” and this cannot be the case in the final device.
- Do I need to think about a mechanism to return the lever to the center? Do you need springs or is there enough elasticity for the buttons ?.
- How to insert a lever into the housing so that the hole in the housing is as invisible as possible? Will the lever be one part or several?
- How will the axis be attached? Will the axis be part of the housing or a separate part?
- How to make sure that what “works on paper” will work after printing on a 3d printer?
And I’m sure that there are a lot of ready-made solutions, and the Chinese most likely can order something like “Woman’s modular button lever module smell of a woman” in a beautiful box. I also know about ready-made tools (editors) for creating such solutions, but for the sake of sports interest, I decided to “reinvent the wheel”, invent everything myself and get by with only basic tools that were “at hand”.
I came up with prototypes of different versions of this lever and tested them in practice. I checked the strength of different sizes of the axis, joints and walls, checked the possibility of creating a lever from several parts (to simplify the placement of the lever in the housing). I thought about how it all falls into the body.
Each time, collecting another prototype, I recalled all of these switches / buttons and levers that surround us in everyday life. I had a feeling that I was a “kitten on a laminate” - while everything around, in every teapot, everything was so elegant and comfortable, and all my prototypes were somehow clumsy and “ill-conceived”. Each of my prototypes was assembled “barely” (if at all), i.e. everything seemed to be perfectly assembled if the dimensions were a little larger, but I had to come up with a solution within the framework of the place that was available in the building. This was the moment that I mentioned at the very beginning:
My head immediately flooded with memories of the devices that I disassembled in childhood (and not only). These are funny situations when, when unscrewing the last bolt, like a devil from a snuffbox, several well-aimed springs and parts flew out, which were absolutely impossible to pack back.
There were moments when it began to seem to me that this task was simply impossible to solve. Those. I understood that this was possible, it just seemed to me that I could not come up with anything sensible. At such moments, I tried to laugh at the situation, distract myself and return to the task later, with renewed vigor. In the end, I came to the following answers to my questions (the answers do not claim to be some kind of global truth, but they worked for me):
- In the case there will be a separate place for the buttons, the buttons below will hold an additional part.
- The lever to the center will return due to the elasticity of the buttons (since the lever has a very small stroke and its displacement relative to the center is not very noticeable). In addition, the lever has a very small weight, which allows you not to worry that the button will be pressed under the weight of the lever.
- The lever will be one part (i.e. it will not be assembled from several parts) and it will be inserted from above. The hole will be of such a size that one of the “legs” of the lever passes freely, after which the lever will move to “push the second leg” in.
- The axis will be part of that extra part that will hold the buttons.
- Prototypes made it possible to verify that it will work in life as well. I actually checked my assumptions as they arrived.
The lever block was assembled as follows (orange - the lever, a translucent wall and a gray part - parts of a large case, and green - an additional part for fixing the buttons and the axis of the lever):
The hole for the lever actually turned out like this and on the final device is not striking:
I guess that this is far from the most elegant engineering solution in the world, but in this solution, everything was “measured out” to me in a millimeter. If the width of the part was slightly smaller and there would not be enough strength, a backlash would appear (and I seriously doubt that it would be convenient to work on an even smaller scale). If you leave a little more space “for maneuvering” or make the walls of the part a little thicker and the screen does not fit into its rightful place.
I understand that reading all this, it may seem that this very lever is a very insignificant part of the device, but in fact, almost half the time that I spent on this entire project, I spent on this lever.
When I tell someone similar stories, people don’t take me seriously. The main response to my statement about my “reduced engineering” was: “Well, what are you telling tales? “After all, everything works, and it looks no worse than factory production!”
So, I already said that I used only the tools that were at hand. For 3d modeling, I used the online editor, which I will not call out loud (so that the post is not considered an advertising post). This editor itself is not very suitable for modeling complex objects, but it completely suited me, because I knew him and could start working right away. If I needed to describe its functionality, then I would say that it is such MS Paint from the world of 3d modeling - only basic operations, only hardcore. In this editor, there is no way to directly work with vertices or normals - only with the whole object.
This is how the model I used for printing looks in this editor:
But the devil is in the details, therefore, let's take a look at all those “scars” that a person with a “non-engineering bone” left on the simple device case:
The image shows the location of the same lever about which I spoke just above.
The edges of the wall did not meet at the recess (the primitives that were used to create the bevels and the central hole differed in width or simply were not aligned with each other), so the editor displays the lines (marked in green). The region marked in red is where, it seems to me (and I'm not sure anymore) there was an old hole for the lever, when I still thought that the lever would consist of several parts.
Of course, this did not affect the final device, because these are offsets / inconsistencies on a scale of less than 0.1mm and the accuracy of 3d printing is not so high as to be noticeable.
Here is another place where the “groove” under the screen was made in the case:
Anyone who understands that in general I would like to show this picture is getting an achievement. The groove is inside the case, so the model’s transparency is turned on and extra lines are visible.
The screen should go into this recess and stay there. This element is needed so that the screen does not hang in the case. Ideally, there should have been a hole (groove) in the form of a precisely measured parallelepiped, but it is clear that something went wrong and the shape of the recess changed several times. In general, it was necessary to listen to dad and measure seven times before drawing a groove and would not have to redo it several times. And I know that it would be possible to put all this in order, but by the means of the editor itself is a pain.
And finally, the case cover ... The cover is attached to the case with four M3 bolts. To do this, in the case, I provided a place for the nuts:
The image shows a bottom view of the body, a rectangular hole - a place for a nut.
Adding these very holes, I proceeded from the thought “as it would be most convenient to make holes in the model”. Knowledgeable people will immediately notice that it was necessary to think about which side it would be more convenient to insert the nut ... As a result, I spent a lot of time in the most unnatural way (and this is not in my strange preferences, but in the stupid arrangement of holes), “insert” the nuts into the holes with tweezers.
And then an artist woke up in me
Day X came, when all the preparatory work came to an end and it was time to print the details, put everything together and paint. The very first step is printing the case and tearing off the supports (supports). As you can see from the photo (and I hope that it can be seen), the print quality is not high enough to just paint the case, so the next step was to “modify the file to the desired shape” so much that I loved: As the case was grinding, I noted “problem areas” Crosses. When the model took its normal form, it was possible to proceed to painting in two stages. The first step in painting is a primer. You can skip this step, but with the primer you can finally align the geometry (remove small scratches) and color. There are unpainted areas in the recesses, but they will be painted over later.
A funny moment was the selection of colors. It seems that I belong to those people who distinguish between 7 and a half colors, so the color can differ significantly from what was in the game. Yes, and looking at screenshots from the Internet, I generally lost faith in my ability to perceive color. It seemed that in each screenshot I saw a new color (shades of gray / blue). I tried to find something similar, and I was just looking for a color in which I would paint a similar device if I were to produce something like that. Then a protective glass for the screen appeared - plexiglass with sharpened edges. In addition to the case itself, it was necessary to print a scattering of small decorative details, which were to complement the final form of the device:
The screen earned a couple of scratches while lying around with the rest of the parts, so it was “packed” in polyethylene until better times.
Some details had to be glued together and painted, which is what I did: Well, in the end, all the parts were glued to the body and the body was repainted to make it appear that the device had been used for many years. Fans of everything new and shiny, before viewing the following pictures, I advise you to take a deep breath and maybe even sit down. I must say right away that the symbols below are completely random and mean nothing. Lovers of conspiracy theories I will ask to relax. Well, a couple of pictures “at work”: Well, it all works something like this:
In general, as usual, what I would like to say with this story is that you should not be afraid to do something with your own hands, you should not be afraid to come up with something new (read as “crutches and bicycles”). And even if you have a “non-engineering bone”, you can learn a lot of new things and just have fun.
Sometimes I ask questions to lovers of electronics and they laugh at how little I understand in electronics. Sometimes I help someone with code writing and smile when I see the source code of people far from programming. Perhaps, reading all this, somewhere one engineer smiled.
Thanks to everyone who read to the end.