📜 ⬆️ ⬇️

German-Chinese device and a bit of math

Madness of the brave we sing a song


Recently I accidentally found out about the existence of a charming MG238 device - an electronic device tester. I watched a couple of videos, slightly ofigel, I found the author’s site (by the way, the project is open, I think that the Chinese manufacturers do not pay copyright), I looked at the diagram and ofigel completely. That is, the measuring part is represented by 3 controlled dividers and IT measures everything I saw in the video?

The first thought was - it's fake, but there are reviews of people who bought and use this device, and mostly positive ones. Then the second thought came - why didn't I do it? There are many answers to this question, the main of which will be “The elder sister did not allow”. For those who are in the tank - this is from the saying "Laziness was born before you." Well, okay, drove through, but still, how IT works. The source codes are laid out, the scheme is given, you can see, but there was a desire to understand yourself, just did not have time to do it, then at least repeat it (if not in the gland, then in the head).

Let's start with, in my opinion, the simplest - measuring resistance. We will try to understand the logic of the author of the development and its features. In the device diagram href = " www.mikrocontroller.net/wikifiles/f/f0/Schaltplan_transistortester.png " 3 measuring points can be distinguished, each of which contains 2 resistances of 680 Ohms and 470 KΩ, connected to the input of the ADC and to the ports of the MC. Based on the scheme, we can assume the following algorithm for determining the unknown resistance - we connect it between two measuring points, connect the power to one of them through the MK port through a resistor, and to the other - ground through the MK port combined with the ADC. We get the classic voltage divider, for which the expression is true

Ux = Uo * Rx / (Rx + R0), where U0 is the supply voltage, R0 is the known resistance, and Rx is the resistance under study.
Measuring now the voltage Ux at the input of the ADC, we can calculate the value of the investigated resistance by the formula
Rx = R0 * Ux / (U0-Ux).
')
It seems to be simple, but as you know the devil is hiding in the details. Let's try to determine the range of measured values. At first glance, the range of measured resistance extends from 0 to infinity, but in fact, when resistance moves away from known resistance, the measurement accuracy will fall, so it would be good to determine the limit values ​​of resistances measured with some predetermined accuracy at certain conditions.

How can we define this range? The first thing that comes to mind is a computational experiment. We take Excel, draw up a table, enter the formulas and get the results - quite specific numbers, which, due to the linearity of the parameters, can be easily scaled. But this is not our way; we prefer an analytical method of solution (although, of course, we did so at the beginning).

First of all, we assume that the values ​​of U0 and R0 are known to us absolutely precisely (at least with respect to U0 this is really true, because we measure not the real value of Ux, but we scale it by the support voltage, which coincides with the voltage U0, so that we are completely not interested in its absolute value). In relation to the reference resistance, this assumption looks more daring, let us leave it to the calibration. Under such assumptions, the accuracy of the result obtained depends only on the accuracy of measurement of Ux, the study of which we will do.

The accuracy of the output result of the ADC depends on many factors, we sum them all up and turn them into a kind of generalized error indicator dUx. Of course, such an approach greatly simplifies the task, but is quite efficient, and for the first approximation, we can assume that the ADC in the MC gives us 10 exact binary bits. Then the conversion error will be dUx = U0 / 2 ** 10 = U0 / 1024 (or for this scheme 5/1024 ~ 5mV, which is absolutely unimportant). We only need to remember the number 1/1024 - the unit of the lower order and, accordingly, the measurement error.

We study the behavior of the function Rx (Ux) = R0 * Ux / (U0-Ux) with small changes near Uxo, represented as Ux = Ux0 + dUx, in the first approximation we get Rx (Ux) = Rx (Uxo) + dUx * Rx` (Ux0), considering that Rx` (Ux0) = R0 * U0 / (U0-Ux) ** 2, we find that dRx = dUx * R0 * U0 / (U0-Ux0) ** 2, from this we get qRx = dRx / Rx = dUx / Ux0 * U0 / (U0-Ux0) = qU * U0 / Ux0 * U0 / (U0-Ux), or by dividing both parts by U0 * U0
qRx = qU / (K * (1-K)), where K = Ux0 / U0, or qRx / qU = 1 / (K * (1-K)).

Denoting the target value by qM, we get a quadratic equation

K ** 2-K + 1 / qM = 0, the solution of which are the values
K1,2 = (1 + -sqrt ((qM-4) / qM)) / 2.

To begin with, we will see that qM cannot be less than 4, if we do not seriously consider complex resistances, that is, in the best case, with K = 1/2, that is, the resistance of the resistor under study is equal to the standard resistance, the measurement accuracy of the resistance is 4 times worse, than the maximum achievable accuracy of the ADC. Further, we see that as the K value deviates from 1/2, the measurement error increases and in the limit goes to infinity. A little about why this happens. In the left part, with a decrease in the measured value and with a fixed measurement error, the relative error will inevitably increase, so everything is expected here. But on the right side of the case is a bit more cunning - let us pay attention to the denominator U0-Ux. Again, with a constant absolute error, the relative error of the whole denominator as a whole will again increase, which leads to a loss of accuracy.

Now we can calculate it - let's set the required accuracy to 1%, taking into account qU ~ 0.1%, we get qM = 10 and, accordingly, K1 = 0.89 K2 = 0.11. From these values, it is easy to obtain Rmax / R0 = 7.87 and Rmin / R0 = 0.13. That is, if we set the value of the reference resistor to 680 Ohm, we will be able to measure resistors with nominal values ​​of 86 ohms to 5k3 with the above method under given conditions, and for the 470k resistor the corresponding range will be from 59k6 to 3700k, it is obvious that outside these limits accuracy will be lower. Strictly speaking, the dynamic range in this case is 62, that is, we have to put 1000/62 = 16 reference resistors in the resistance range of 1 to 1000. Since we have only 2 reference resistors, we will see what accuracy is achievable when their ranges overlap - if we ask for an accuracy of 3%, then we can measure with such accuracy resistors from 24 ohms to 13 ohms with just two reference resistors, and the range for one resistor is 1 to 782 (fairly close to 680 to 470000). Perhaps such accuracy was accepted as required by the instrument developer. At the same time, outside this range, the accuracy falls and the accuracy of 5% is achievable in the range from 14 Ω to 22 Ω. Given that resistors are usually measured with an accuracy of 5%, the result can be considered satisfactory, although it is also difficult to call it good. On the other hand, the device is not positioned as a measuring device, but as a tester, that is, with an accuracy of 5%, it is quite possible to assess whether the resistor is working.

There is one more idea, you can extend the range by connecting the other end to ground through a reference resistor. In this, the resistance of the standard will double, and the upper limit of the range should also double. However, in this case, we must measure 2 voltage values, which degrades the initial accuracy, it would be necessary to calculate what happens, but it is too late.

Source: https://habr.com/ru/post/273873/


All Articles