Refer to the voltage divider circuit to get formula 1
Formula 1: Vo = Vin + i2 * R2
Formula 2: i2 = (Vcc-Vin) / (R1 + R2) {Condition: the current flowing to Vo ≈0}
Substituting R1=R2 into formula 2 gives formula 3
Formula 3: i2 = (Vcc-Vin) / 2R2
Substituting formula 3 into formula 1 gives formula 4
Formula 4: Vo = (Vcc + Vin) / 2
According to formula 4, the above circuit can be regarded as an addition circuit.
In the analog-to-digital conversion measurement of the microcontroller, the measured voltage is required to be greater
than 0 and less than VCC. If the measured voltage is less than 0V, an addition circuit can be used to increase the
measured voltage to above 0V. At this time, there are certain requirements for the variation range of the measured
voltage:
Substituting the above conditions into formula 4, the following formula 2 can be obtained
(Vcc + Vin) / 2> 0 means Vin> -Vcc
(Vcc + Vin) / 2 <Vcc means Vin <Vcc
The above 2 formulas can be combined: -Vcc <Vin <Vcc