I will say a word about the engineering approach

    Hi, Habr.

    On this relaxed Sunday evening, I would like to talk on two topics, partly interrelated - about what and how the engineering approach in the development of electronics looks, and how and why to write articles on this electronics on Habr so that they are pleasant and understandable to everyone.

    The phrase in today's article led me to this idea : “Under the cut is multi-beetle, but it will be engineering”; Unfortunately, not only was there no engineering under the cut, but in general in a very large percentage of articles on the topic “How I made the device” published recently on Habré, there is nothing engineering.

    Why?

    Because any engineer - like a programmer, doctor, lawyer, and any professional in general - has a basic methodology of work, without which activity from a professional turns into unsystematic throwing. More precisely, it’s not even a methodology — we can attribute adzhayl, TRIZ to the methodology, and that’s all, each has its own - but a crude strategy that can be written down in a few steps.

    So what does this apply to electronics?

    1) Formation of the task - or, formally speaking, statement of the technical task.

    At the first stage, we formulate what and why we want to get at all, as well as the boundary conditions that we want to observe.

    I won’t even touch the GPS trackers, the operation of the GPS module, the time it takes to enter the coordinate capture mode, etc. - things are quite complex and depend on a lot (I note only that any minimally modern GPS module has at least four operating modes, with a consumption of 20-30 mA, 2-3 mA, 200-300 μA and <10 μA, not counting the full shutdowns).

    Let's take a simpler thing - an accelerometer. For example, here are three completely real tasks that were solved on the cheap ST LIS3DH MEMS accelerometer:

    • tilt angle sensor - tracking the angle of the tilt of the lighting column
    • physical activity and fall sensor - tracking the facts of free fall, as well as assessing the physical activity of the carrier
    • vibration sensor - tracking vibration spectrum 0.1 ... 100 Hz

    In all three cases - battery powered devices that we want to optimize for energy consumption.

    We look at the accelerometer datasheet :

    • sleep - 0.5 μA
    • 1 Hz - 2 μA
    • 25 Hz - 6 μA
    • 1344 Hz - 185 μA

    Obviously, our three tasks will require three different operating modes - in the first one, even 1 Hz is extremely redundant for a column, the column is usually not in a hurry, and the repair team is not in a hurry, especially. In the second, the mode with a speed of the order of 25 Hz is quite adequate, and in the third, it would obviously be nice to have a 10-fold excess of the sampling frequency over the frequency of the measured signal.

    Moreover, in the case of a column, 1 Hz is so excessive that the manual interrogation of the accelerometer is generally the most effective option. Suppose our microcontroller wakes up for such a survey once every 15 minutes (we agreed with the customer, he is satisfied with such a delay in the information about the column about to fall - the team will arrive there in no time before two hours later), the whole procedure takes 100 ms, and the controller at the same time, it consumes 5 mA - the average energy consumption of the active mode of the controller turns out to be 5 * 0.1 / 15/60 = 0.55 μA, which in combination with 0.5 μA of the sleeping accelerometer is approximately twice as profitable as the accelerometer threshing itself by 1 Hz and waking controller only if the threshold is exceeded.

    In fact, what I am describing now is essentially the third stage in the methodology of the development approach; now it is intended to illustrate how important it is to set the task in advance.

    Do you make a GPS tracker? Excellent. Are you doing it for whom? For a pedestrian, in whom he should be lying in his pocket, weigh 50 g and live on the battery for a day? For a railway carriage, where should he live for five years, but at least five kilograms? For a free-grazing cow, on which he has been living on a battery for the same five years (because the cow no longer lives), but should he weigh a maximum of 35 g, because it is attached to her ear?

    These are all completely different tasks.

    And clearly state exactly what you are doing and what are the boundary conditions, if you fall into which the task can be considered solved, it is necessary in advance.

    Actually, already at this stage, most DIY projects have a black hole: the author does something completely unclear why. Sometimes he honestly writes “in order to practice soldering”, but most often various abstract ones - without TK they will always be abstract - things like “to achieve minimum processor power consumption while scoring everything else for power consumption” turn out to be an end in themselves.

    Take the same article mentioned above - the author of the device is chasing units of microampsconsumption, switching the accelerometer power (less than 2 μA in hibernation) and GPS (7-8 μA in battery backup mode) by separate transistors. Is it really necessary? Here in front of me right now lies the electronics module for the “smart helmet” (it also has a GPS tracker), it has the required operating time on a single charge with a margin obtained with an average hospital consumption of 5 mA ( milli amperes), do you really think that plus or minus a dozen microamps here does it matter? And if not, then why shove extra details on an already quite tight board?

    2) Selection of components

    After you have decided on the boundary conditions, the second stage begins, in which you choose what you will make your device from.

    The task, in fact, is not very simple, because Each component has a bunch of parameters, such as:

    • electrical parameters
    • board space
    • complexity and cost of installation
    • component cost
    • availability on sale

    We even take the same tasks with the accelerometer - well, ok, in a smart helmet you will definitely be satisfied with LIS3DH for half a dollar, the coils in Kompel. And on the measurement of the deviation of the column? And with what accuracy does the client want to measure this deviation? Still cheaper 12-bit LIS3DH, slightly more expensive 16-bit LIS2HH or already top-end ADXL355 costing fifty dollars and with delivery for two weeks? Here we return to the boundary conditions of paragraph 1 and begin to count, count, count.

    And it was just an accelerometer. And imagine what kind of variety is happening on the market, for example, screens. It is clear that everyone loves WH1602 (although I personally love WEH001602 more), but right away you will answer what to put in some water meter that has 6-8 years old working on one battery, while continuously showing cubic meters?

    Actually, each component in the circuit should be justified - the developer must either have an understanding of why the component is exactly the same, or an understanding that in this case it doesn’t matter which one (well, for example, resistors are usually more or less anyway installed, although there are nuances).

    And all this is interconnected. For example, the same choice of battery - LiMnO 2 with a voltage of 2.0 ... 3.0 V, LiSOCl 2 with a voltage of 2.4 ... 3.6 V or a generally rechargeable battery with its 3.0 ... 4 , 2 V? And components from what can work from you? And from what they will work more efficiently or more economically? And the peak currents of the load will the selected element pull? And if it is LiSOCl 2, then taking into account passivation still pull? Do you want to put DC / DC boost, and when not, turn it off? Does the selected load disconnect chip know how, or does it turn off - does it stop the PWM, but does the input turn out at the output? Is there a danger of overheating, otherwise maybe you should go to 1.5-volt LiFeS 2 in general , which have no thermal self -acceleration ?

    And so in a circle several times - the change of one component pulls others, others…

    Do you think the same GPS modules - are they all the same? In my “smart helmet”, within the framework of the dimensions agreed with the customer and within the framework of the commercially available and satisfying battery requirements, the components will have to be placed on the side of the board adjacent to the case, and therefore there is something about the height limit for these components 1.5 mm. Now pick up the nearest GPS module and measure how much it has the height of the body.

    Yeah. Exactly. Well, you can reconcile the dimensions and make the case 1 mm thicker, or you can change the usual Quectel L76 to the brand new EVA M8M with its 7 × 7 × 1.1 mm.

    What do we see in the above article? The author does not know why he is making the GPS tracker, therefore he puts the first GPS module into it, about which he does not know the operating modes and does not particularly want to find out, and therefore, for the sake of energy saving (it’s also not very clear why) it’s just cuts him all the food.

    That is - failure in the formation of the task leads to failure in the choice of components.

    3) Production of the prototype of the product

    Well, there is probably nothing to dwell on here - after choosing the components, the final circuit is made, the board, prototypes are assembled. With this, DIY is usually more or less good, and the fact that the blue electrical tape and multi-colored wires are gradually replaced by custom boards is welcome.

    4) Optimization of component operating modes

    Despite all your efforts, the previous steps will leave separate white spots - in many cases you will always have room for fine-tuning the operation of components (GPS is, by the way, a good example here - you can play with them for a long time to set inactivity modes in order to minimize power consumption while ensuring specified accuracy of coordinates). It’s either difficult or impossible to find out many nuances by datasheets - manufacturers often don’t specify too detailed data or relationships between different parameters.

    Therefore, after the manufacture of the prototype, which, according to your preliminary estimates, should fall into the requirements of TK, the stage of its optimization begins .

    There is, for example, a classic example - processor power consumption as a function of its speed. Yes, the more megahertz - the more milliamps. But the faster the processor will complete the task and again go to sleep! But at the same time, the task may partially depend on the speed of external interfaces that work the same on either 1 MHz or 64 MHz. In this case, the output of the processor at 64 MHz may take longer than its output at 4 MHz (starting and stabilizing the quartz resonator, starting and stabilizing the PLL, reconfiguring the clock modes), and as a result, from on to off, the same task in the first case eat more microamps-seconds than in the second!

    Here, of course, one often does not need to get too carried away - if you with a good margin fall into the boundary conditions of TK, then it makes little sense to spend time on optimization; well, as in that aforementioned “smart helmet”, which with an average consumption of 5 mA saves units and even dozens of microamps, it simply does not make sense, this is an error, not a saving.

    At the same stage, various assumptions can be checked - for example, the author of an article about a GPS tracker suggested that devices with high consumption will be more economical if they are supplied with lower voltage. In practice, this is not always the case - if the module includes a pulse converter, then in any case it consumes constant power, which means that when the voltage decreases, it will increase the current consumption.

    As a result, the total consumption of the circuit, in which one more step-down converter is added, and also the level matching circuit, will only increase.

    5) Experimental proof of the optimal solution to the problem

    The last stage (which, however, can partially be performed at the penultimate one) is experimental proof that the device is made correctly and optimally.

    Firstly, it’s worth taking a look again - if any unnecessary details were discovered during the prototyping and debugging process. Over-engineering, in which the device gets a lot of unnecessary, is generally quite typical for DIY projects - take, for example, a recent article about a touch switch, the author of which, having the most powerful microcontroller at hand, made touch sensors on separate chips, and then still could not keep the energy consumption of the resulting in any way acceptable. Well, or the belief among arduinists , that for "protection from interference" the output of the microcontroller and the gate of the transistor that controls the relay must be separated by an optocoupler.

    However, in these cases, a critical examination of their projects would not help the authors in any way - they obviously have an acute lack of basic knowledge that allows them to solve the problem in an optimal way, rather than screwing up additional components with functionality that is not very clear to them. Nevertheless, to take a look at the circuit and think if something turned out to be not very necessary in the end — the signals, tracks, components — are worth it.

    Secondly, it is necessary to understand whether the device really meets the boundary conditions of the technical requirements, and if not, or even if its parameters simply do not fit into your ideas about what they should be, then why (yes, I specially highlighted in bold: worthless to a developer who, having received an energy consumption of 40 μA instead of the calculated 5-10 μA, cannot explain why).

    There are no cases “well, everyone understands that 10 microA is written in the datasheet, but in reality it will not work out below 100 microA” in nature. Either a completely specific error in the datasheet, for example, the toe was not printed, or you don’t understand something. To be honest, the likelihood that you will encounter such an error is rather small in professional activity and practically equal to zero in DIY projects, this is one case for many thousands of components and, as a rule, in some exotic modes of their work - therefore, if the parameters of your device strongly and objectively do not coincide with what you counted on a napkin on a datasheet, which means that you do not understand something.

    I saw a lot of examples of this in the same issue of energy consumption - digital inputs left in the air, unplugged processor peripherals, forgotten power-ups ... But I don’t remember a single case when, in the end, it turned out that “in reality, it really won’t work out ", And consumption would not have been possible either to lead to a calculated one, or to correct the calculations taking into account explicitly indicated in the datasheets, but by mistake not taken into account previously factors.

    The study of such issues is usually quite nontrivial, but it is necessary. If your calculations do not coincide with your measurements, it means that you were mistaken in either one or the other, and the errors must be corrected.

    So what are articles to write about?


    Well, in conclusion - about what to write on Habr so that you have no complaints from professionals, whom we consider a significant part of the audience.

    In fact, those articles on electronics design that I regularly see fall into one of the groups:

    • information garbage duplicating the first page of Google
    • biography "how I spent the weekend"
    • a guide on how to make yourself some kind of device
    • analysis of subtleties that are not obvious to most

    A good example of the latter is, for example, the latest article Hardware bit banding CortexM3 / M4 . The content of such articles is not necessarily a scientific discovery, but in any case, a sufficiently detailed analysis of information unknown to most people for practical use. Such articles are of varying complexity and varying specificity, but they are all united by the fact that you would have dug up information from them yourself, of course, sooner or later, but spent the time that greatly exceeded the reading time of the article.

    The diametrical opposite to them is the articles “how to blink an LED using a multivibrator”. It’s not that they contained incorrect or unnecessary information, but if all the same information can be obtained from almost any link from the first page of Google’s search for the corresponding request, then the value of such an article is generally zero. This is garbage, article for the sake of article.

    However, articles are possible that are useful, but do not contain fundamentally new information - these are guidelines on how to make yourself some kind of device based on the personal experience of the author. As a rule, these are relatively uncomplicated things (complex, going through the entire design path described above, appear in the form of “how we did” articles and, as a matter of fact, quickly fall into a list of subtleties that arose during the process and fall into the corresponding category), and information that given in articles is necessary and sufficient for independent repetition and further development by readers of the device. These are schemes, firmware, explanations of why the device is made just like that and how it can be made at all.

    Finally, a biography article - and the touch button and the GPS tracker fall into this category of those mentioned above - the most mysterious genre for me. Their authors write a lot - sometimes very many - letters, abundantly accompanied by pictures, but an outsider can not extract anything useful from them . The authors do not justify the decisions they choose, often do not indicate why they are doing this, often do not present the conceptual schemes or source codes of the firmware, not only in their entirety, but at least in significant parts, and do not indicate any specific problems, arising in the process and which may be interesting to others (“at first I did not know how to solder SMD components, but I learned over time” is not a problem that is interesting for others).

    Although such an article looks superficially a deep technical work, in reality it is a school essay “How I Spent the Summer", uninteresting to anyone except the author himself.

    Avoid this if possible.

    PS Since there must necessarily be some illustrations in the article, I will give an example for which people do not like claiming that the picture from Fritzing is a full-fledged electrical circuit:

    image

    Try to understand what is going on in this figure.

    Also popular now: