Difficult development of simple devices

 3r3181. 3r3-31. Greetings reader! Today I will tell you a funny story that made me think about the problems that arise when choosing the right components for the implementation of an electronic product that is not (optimally). And also about the seeming simplicity on the example of the “one day” device.
 3r3181.
 3r3181.
Difficult development of simple devices 3r33177.
3r3334.
 3r3181. We agree that the story is fictional, any coincidences are random or not random.
 3r3181. Once Seryozha, a programmer, approached me with a request to make a device for him in the car that emulates the sequential pressing of 2 virtual buttons when pressing one physical in the cruise control car control circuit (Ford Focus 2). The scheme of the standard control unit is as follows:
 3r3181.
 3r3181.  3r3181.
 3r3181. From the side of the control unit, this is a classic push-button input using an ADC. So, the device’s task when pressing the hardware button is to successively press the ON and SET + button for a time of ~ 0.2s. For ease of integration of the device, it was decided to power it from the upper resistor divider. Voltage at the terminals of connection 4.6 V without the connected circuit of buttons. Since the device was planned to be made in the evening, I made a scheme without preliminary calculations from what was on the mounting table. Head-on: r3r3159.  3r3181.
 3r3181.  3r3181.
 3r3181. Seryozha wrote the firmware, and the device worked fine on the car. At the moment when the board already wanted to pack in the body of the steering column switch someone from the depths of the office shouted: “Why is it so difficult? Half of the details can be thrown out, and in general STM8 for such a task is the most ". And so it began The author of the idea volunteered to solder the layout “out of 3 parts” (apparently anticipating an easy victory). I (guided by my own article about 3r3333. Professional jealousy 3r-3334.) Decided not to interfere with the flight of a young specialist, but only connected at a stage when everyone understood that a miracle did not happen.
 3r3181.
 3r3181. The scheme proposed by my colleague was really simpler, but it worked only on the table:
 3r3181.
 3r3181.  3r3181.
 3r3181. Errors were visible even at first glance, nevertheless I decided to make the circuit work on MK STM8S001J3.
 3r3181.
 3r3181. In order to understand how to remake the scheme, we will conduct several measurements. The resistance of the upper resistor in the ADC divider is ~ 130 Ohms, and the voltage without load is 4.6 V.
 3r3181.
 3r3181. Then the layout of the button node is:
 3r3181.
 3r3181.  3r3181.
 3r3181. 3r3365.  3r3181. 3r3r1616. when the buttons are released, the current in the circuit is 2 mA, the voltage at the input of the ADC is ??? V; 3r3167.  3r3181. 3r3r1616. when the button is pressed ON 3.7 mA, the voltage at the input of the ADC is ??? V; 3r3167.  3r3181. 3r3r1616. when the SET button is pressed + 18.4 mA, the voltage at the input of the ADC is 2.2 V. 3r3-3167.  3r3181. 3r376.
 3r3181. In this case, the operating voltage range of the MK STM8S001J3 is ???-5.5 V. It turns out that an attempt to press the SET + button leads to a voltage drop below the minimum and the MC is reset.
 3r3181.
 3r3181. At this point, I propose to distract and discuss what an ideal MK is for this task and why it was not chosen. Usually for such crafts use what the developer knows how to work and what is at hand. For example, the microchip has PIC10F200 or ATtiny10 controllers in the SOT23-6 package with a supply voltage range of 2 (1.8) - 5.5 V. These chips do not require a voltage regulator (like STM32L031), but they will not restart when you press the SET + button (as STM8S001J3). In the strapping will be only 2 resistors and a capacitor. Beauty, but in the nomenclature of STMicro controllers with this power range is not. An attentive reader will rightly note that within the framework of such a task almost any controller can be mastered, but the lack of a familiar programming environment and debugging tools determine the choice.
 3r3181. Let's return to the scheme. To solve the problem of resetting the controller, we need energy to power the controller while pressing the SET + button. To estimate the amount of this energy, it is necessary to measure the current consumption (or see the documentation): 3r3159.  3r3181.
 3r3181.  3r3181.
 3r3181. Almost 500 uA at best. This is a lot, but to make it clear I will give the calculation. For the accumulation of energy, we need a diode (VD1) and a capacitor (C1):
 3r3181.
 3r3181.  3r3181.
 3r3181. The fall on VD1 of 0.2 V, respectively, with the released buttons C1 will be charged up to ??? - 0.2 = ??? V. When the "press" button SET + is pressed, the voltage at the point Vin drops to 2.2 V, VD1 closes and MK powered by discharging C1.
 3r3181.
 3r3181.  3r3181.
 3r3181. In this expression, the energy stored in the capacitor is on the left (when it is discharged from ??? to 3.1 V), on the right is the energy spent by the controller during the time t = 0.2 s. Then the capacitance of the capacitor:
 3r3181.
 3r3181. 3r3r166.
 3r3181.
 3r3181. 660 uF for this task very much. Let's try to put the controller to sleep while pressing the button.
 3r3181.
 3r3181. For this, the STM8 has Active Halt Mode:
 3r3181.
 3r3181.  3r3181.
 3r3181. By turning off MVR and Flash, we managed to get a current consumption of ~ 40 μA (this is significantly higher than the stated current, but this current is suitable for this task), and thanks to the AWU (auto wake up unit), you can easily set an awakening after 256 ms after going to sleep. In this case, to ensure the operation of the controller, a capacitor with a capacity of only 47 microfarads is needed.
 3r3181.
 3r3181. It seems that all problems are solved, but there is one more BUT. The current when the SET button is pressed + 18.4 mA is less than the current limit for the output, but the logic zero voltage will be around 0.7 V. This will lead to a drop in current through the resistor and will require either recalculating the resistance or using an external transistor according to the scheme with open drain. I chose the second option as more predictable in behavior. The final scheme took the form:
 3r3181.
 3r3181. 3r3142.
 3r3181.
 3r3181. In this form, it has successfully earned and operated to this day.
 3r3181.
 3r3181. 3r3151. Instead of the conclusion 3r3152.
 3r3181.
 3r3181. In this article I want to draw attention to the problem of how the developer is punished for an unnecessarily superficial or frivolous approach to the development of a simple (at first glance) device. On the other hand, I wanted to show how a non-optimal choice of the basic element base (in this case, MK) complicates the development process and the product itself for two main reasons: 3r3159.  3r3181.
 3r3181. 3r3161.  3r3181. 3r3r1616. The need to adjust the choice of technical solutions to the skills of the programmer. 3r3167.  3r3181. 3r3r1616. Impossibility to embrace the whole range of possible components, suitable for the task, to choose from them the “most”. These factors, most often, explain the fact that many devices (household, commercial, special) work fine, but they are not made the way you would have done it. 3r3167.  3r3181.
3r33177. 3r3181. 3r3181. 3r3181. 3r3174. ! function (e) {function t (t, n) {if (! (n in e)) {for (var r, a = e.document, i = a.scripts, o = i.length; o-- ;) if (-1! == i[o].src.indexOf (t)) {r = i[o]; break} if (! r) {r = a.createElement ("script"), r.type = "text /jаvascript", r.async =! ? r.defer =! ? r.src = t, r.charset = "UTF-8"; var d = function () {var e = a.getElementsByTagName ("script")[0]; e. ): d ()}}} t ("//mediator.mail.ru/script/2820404/"""_mediator") () (); 3r? 3175. 3r3181. 3r33177. 3r3181. 3r3181. 3r3181. 3r3181.
+ 0 -

Add comment