Accurately Measure Resistor Value Using ADC

Now many microcontrollers have ADC function, 10-bit or 12-bit, it is very convenient to use ADC to measure the voltage, to measure the resistance value of the resistance, you can use Ohm's law to divide the voltage and then measure the voltage after the divided voltage to calculate the resistance resistance The simplest resistance measurement circuit is as shown in the figure below:
write picture description here
At this time, the voltage calculation formula of the measurement point is: Vo=R2 / (R1 + R2) * Uref.
This is the simplest measurement calculation method. But because it is simple, it will lead to many small problems. For example, if the value of R1 is 2K, Uref is 5V, and the resistance value of R2 is about 5 to 10 ohms, then the voltage Vo=0.01247 to 0.02488 divided by R2, the voltage changes The range is too small. If the ADC is 12-bit, the reference voltage of the ADC is 3.3V. At this time, the acquisition value of the ADC ranges from 15 to 30, that is, the variation range of the AD value is 30-15=15, and the resistance The variation range of 10-5=5 ohms, that is, the variation range of 5 ohms is calculated by the change of 15 AD values, then the accuracy of AD measurement is: 5 ohms / 15 = 0.33 ohms, that is, the AD value plus 1 , the calculated resistance value needs to add 0.33 ohms, which is really unacceptable.
Another example is that the values ​​of R1 and Uref remain unchanged, and the resistance value of R2 ranges from 1K to 2K. The same calculation method obtains the voltage division value of R2 Vo=1.1 to 1.65 volts, and the AD value ranges from 1365 to 2048. AD The measurement accuracy is: 1K/(2048-1365)=1.46. The strange thing is why the range of AD values ​​is so large, but the accuracy is even worse? Because of the wide range of resistor values, the accuracy is reduced.
How to do? I want to measure the resistance R2 of a relatively precise resistor, what should I do? The following method is the method of measuring resistance by a bridge on the Internet. I have modified it for the convenience of measurement. The resistor network circuit is shown in the figure below:
write picture description here
The resistance value of R2 is about 100 to 200 ohms. We take a reference resistor R3 as 100 ohms, and the resistances of R1 and R3 are the same as 2K. In this way, two voltage division values ​​of U1 and U2 are obtained, and U2 is a fixed voltage U2=100 / (100+2000) * Uref. The value of U1 changes according to the change of R2: U1=R2 / (R2+2000) * ref. After obtaining U1 and U2, the pressure difference can be calculated:
△U=U1-U2, input these two voltages into the operational amplifier for reasonable amplification, so that the obtained output voltage range is as wide as possible within the ADC reference voltage range, In this way, the ADC can be used to measure the voltage value more accurately. The circuit that uses the op amp to amplify is as shown in the figure below:
write picture description here
In the case of R5=R6, R7=R8, the magnification factor of the op amp is m=R7 / R5. The magnification in the circuit is m=20. After being amplified by the operational amplifier, Uo is obtained and sent to the ADC of the microcontroller system for AD sampling. Then we can calculate the relationship between the AD value measured by the ADC and the resistance R2.
Now suppose that the reference voltage of the ADC system is Uadc, the sampling bits of the ADC are 12 bits, and the measurement value of the ADC is A, then the calculation formula of Uo is as follows:
Uo = A / 4096 * Uadc
and Uo is also the output voltage of the op amp, according to the voltage The bridge network and op amp can be calculated to get:
Uo = (U1-U2) * m = ( (R2/(R1+R2) - R4/(R3+R4) ) * Uref * m
That is:
( (R2/ (R1+R2) - R4/(R3+R4) ) * Uref * m = A / 4096 * Uadc —————————-①In
the above formula, R1, R3, R4, m, Uref, Uadc are all is known, then the resistance value of the resistor R2 can be easily calculated according to the value A' measured by the ADC.
The above is the theoretical calculation method, which is true, but the reality is often cruel. Because the resistance has errors and the op amp is not absolutely precise, then the known R1, R3, R4, m, Uref, Uadc Several parameters are slightly different from the actual value. For example, the nominal resistance of resistor R1 is 2K, and the error is 1%. The resistance value measured by the multimeter is 1980 ohms. Obviously, there is an error. Computation is not feasible. then what should we do?
There are always solutions. In the previous formula ①, the resistance value of the resistor R2 is calculated according to the measured value of the ADC and several known parameters. Then we turn it around and use several groups of R2 resistors with known fixed resistance values ​​to connect to the resistor network and measure AD. The value A is used to calculate several parameters of R1, R3, R4, m, Uref, Uadc, but these parameters are a bit too many, and the 6 unknown parameters require 6 sets of formulas to solve, which is very laborious, so let's simplify it. Calculation.
We set R4 to 0 ohms, that is, U2 is connected to GND, U2=0, so the formula ① can be simplified to:
R2/(R1+R2) * Uref * m = A / 4096 * Uadc ————— ————②This
is not much easier! Well, now we ask for the resistance value of R1 and the magnification m in the formula. For the two unknowns, we need two sets of known points (R2, A) to find the parameters R1 and m. In this way, the test resistance of the first point is R21, the AD value is A1, the test resistance of the second point is R22, and the AD value is A2, and put it into the formula ② to get:
R21/(R1+R21) * Uref * m = A1 / 4096 * Uadc
R22/(R1+R22) * Uref * m = A2 / 4096 * Uadc The
above formula is divided by the following formula to get:
(R21/(R1+R21)) / ( R22/(R1+R22)) = A1 / A2
is sorted to get:
R1=(R21 * R22) * (A2 - A1) / (R22*A1 - R21 * A2)
This gives the resistance value of R1.
Then we find the value of m. According to formula ②, the calculation formula of m can be obtained as:
m = (A / 4096 * Uadc) / (R2/(R1+R2) * Uref)
We combine the power supply of the resistor network and the ADC system The reference power supply is connected together, that is to say Uref=Uadc, we want to ensure the stability of the power supply, we can use TL431 or REF3030 and other high-precision voltage regulator chips to produce a stable voltage source to supply power to the resistor network and ADC system. Since Uref=Uadc, the above formula is simplified in this case:
m = (A / 4096) / (R2/(R1+R2))
and we get:
m = A*(R1+R2) / (4096 * R2) —————————-③In
formula ③, R1 has been calculated before, so m is also calculated.
Here we have obtained the values ​​of R1 and m, and then we can calculate the value of the resistance R2 to be measured based on these two parameters and the measured AD value. Since Uref=Uadc, the formula ② becomes:
R2/(R1+R2) * m = A / 4096
, we get:
R2 = A * R1 / (4096*m - A) —————————- ④
Equation 4 is so simple that only A, R1, m can be used to calculate the resistance value of R2, and the R1 and m used are the values ​​calculated by ourselves, instead of directly using the theoretically calculated value, the accuracy is improved. a lot. At the same time, we can find that because Uref=Uadc, the two ends of the above formula ② are reduced, and all calculations have nothing to do with Uref and Uadc. That is to say, no matter how Uref and Uadc change, as long as Uref and Uadc are always equal, All parameters and resistance calculations do not involve Uref and Uadc. But we'd better ensure the stability of Uadc, otherwise the measured AD value will be inaccurate.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325561367&siteId=291194637