ADC and DAC circuits: analog to numbers, numbers to analog
Resolution, reference voltage, sampling time, input RC filter. The circuit-side causes to check when an ADC value is not what you expect.
Resolution and reference voltage
A 12-bit ADC divides the reference voltage into 4096 steps. With a 3.3 V reference, one step (1 LSB) is about 0.8 mV.
voltage = ADC value / 4095 × Vref
If the reference is 3.25 V and not 3.30 V, every measurement is off by 1.5%. Precise measurement uses a separate voltage reference IC.
Sampling time and source impedance
Inside the ADC is a small sampling capacitor that charges to the input voltage during the set sampling time. If the resistance on the input side is high, it does not charge fully and the value comes out low.
- Lengthen the sampling time, or
- add a capacitor (a few nF to 100 nF) at the input as a charge reservoir, or
- drive it with an op-amp buffer.
Input RC filter
A resistor and capacitor filter high-frequency noise, and the capacitor also supplies charge at the sampling instant. Set the cut-off above the signal you want to measure and below half the sampling frequency.
DAC
Turns a number into a voltage. Without a built-in DAC, PWM with an RC low-pass filter is sometimes used as a simple DAC. Choose the RC values by weighing output ripple against response speed.