A **Digital-to-Analog Converter (DAC)** converts a digital signal (usually binary) into an analog voltage or current. The output is typically a stepped approximation of a continuous waveform.
The formula for a **basic DAC** depends on its type, but the most common is the **binary-weighted DAC** or the **R-2R ladder DAC**.
### Formula for Binary-Weighted DAC:
For a binary-weighted DAC, the output voltage \( V_{out} \) is calculated as the weighted sum of the digital input bits. The general formula is:
\[
V_{out} = V_{ref} \times \left( \frac{D_N}{2^N} + \frac{D_{N-1}}{2^{N-1}} + \cdots + \frac{D_1}{2^1} + \frac{D_0}{2^0} \right)
\]
Where:
- \( V_{ref} \) is the reference voltage (the maximum output voltage corresponding to the full-scale digital input).
- \( D_N, D_{N-1}, \dots, D_0 \) are the digital input bits, where each \( D_i \) is either 0 or 1.
- \( N \) is the number of bits in the DAC (e.g., 8-bit DAC, 12-bit DAC).
### Example:
For a 4-bit DAC, the output voltage can be represented as:
\[
V_{out} = V_{ref} \times \left( \frac{D_3}{8} + \frac{D_2}{4} + \frac{D_1}{2} + D_0 \right)
\]
If the input is \( D_3 = 1, D_2 = 0, D_1 = 1, D_0 = 1 \) and \( V_{ref} = 5 \text{V} \), the output voltage would be:
\[
V_{out} = 5 \times \left( \frac{1}{8} + \frac{0}{4} + \frac{1}{2} + \frac{1}{1} \right) = 5 \times \left( 0.125 + 0 + 0.5 + 1 \right) = 5 \times 1.625 = 8.125 \text{V}
\]
### R-2R Ladder DAC:
An **R-2R ladder DAC** works on the same principle but uses a simple resistor network, which is easier to implement than the binary-weighted DAC, especially for higher resolutions.
The output voltage of an R-2R ladder DAC is also determined by the digital input, with the output voltage being proportional to the binary value represented by the digital input.
### General Features:
- The DAC resolution (number of bits) determines the precision of the output voltage.
- A higher number of bits provides finer control over the output voltage, but requires more components.