Sub topic 7
Weighted sums and a binary-weighted DAC
This chapter assumes you know the inverting summing amplifier, the virtual ground at its summing node, and the output equation Vout = -Rf × Σ(Vi / Ri). Here you pick different input resistors on purpose and use the result to build a digital-to-analog converter (DAC).
Weights come from the resistor ratio
Each input of the summer contributes a current Vi / Ri into the virtual ground. The feedback resistor turns the total current into a voltage. So the weight of input i is Rf / Ri, and a smaller Ri gives that input more influence.
For two inputs with R1 = 10 kΩ, R2 = 20 kΩ and Rf = 10 kΩ:
Vout = -(1 × V1 + 0.5 × V2)
The inputs do not interact, because each one sees the same virtual ground. That is why you can change one weight without disturbing the others.
Binary weights make a DAC
A DAC converts a binary number into a voltage. Suppose each bit is a logic signal that is either 0 V or a reference voltage Vref. If the resistors double from one bit to the next, the weights halve, and the bit weights follow binary place value.
| Bit | Weight | Input resistor |
|---|---|---|
| b3 (MSB) | 1 | 10 kΩ |
| b2 | 1/2 | 20 kΩ |
| b1 | 1/4 | 40 kΩ |
| b0 (LSB) | 1/8 | 80 kΩ |
With Rf = 5 kΩ and Vref = 5 V, the gain is Rf / R = 0.5. The output is:
Vout = -2.5 × (b3 + b2/2 + b1/4 + b0/8)
Check it numerically
The script below computes the output for any bit pattern.
def dac_output(bits, vref, r_msb, rf):
"""bits is a list of 0/1 values, MSB first.
Resistor for bit k (counting from the MSB) is r_msb * 2**k."""
current = sum(b * vref / (r_msb * 2**k) for k, b in enumerate(bits))
return -rf * current
for code in ([1, 0, 1, 0], [1, 1, 1, 1], [0, 0, 0, 1]):
print(code, round(dac_output(code, 5.0, 10e3, 5e3), 4))
# [1, 0, 1, 0] -3.125
# [1, 1, 1, 1] -4.6875
# [0, 0, 0, 1] -0.3125The last line shows the step size. One least significant bit (LSB) changes the output by 0.3125 V, which is 2.5 V / 8.
Limits and common errors
- Inverted output. The summer inverts, so the DAC output is negative. Add an inverting stage or accept the sign.
- Resistor accuracy. An error in the 10 kΩ MSB resistor shifts the output by more than a whole LSB, so the MSB resistor needs the tightest tolerance. For an n-bit DAC, the MSB resistor must be accurate to better than about 1 part in 2^n.
- Resistor spread. An 8-bit version needs values from 10 kΩ to 1.28 MΩ. Parts that different are hard to match. The R-2R ladder avoids this by using only two resistor values.
- Logic levels. A real logic output is not exactly Vref, and its output resistance adds to the input resistor. Use a buffered reference switch.
Exercise
Keep Vref = 5 V, R = 10 kΩ for the MSB, and the 10k/20k/40k/80k binary-weighted inputs. You change Rf to 8 kΩ. What is Vout for the code 1100, and what is the LSB step?
Show answer
The gain is Rf / R = 0.8, so Vout = -(5 × 0.8) × (b3 + b2/2 + b1/4 + b0/8) = -4 × (...). For 1100, the sum is 1 + 0.5 = 1.5, so Vout = -6 V. The LSB step is 4 / 8 = 0.5 V.