Analyzing Quantization Error and Signal Noise
In this lesson, you will learn how to evaluate the inherent errors introduced when your microcontroller rounds a continuous analog voltage into a discrete digital value.
The Quantization Gap
When an Analog-to-Digital Converter (ADC) samples a voltage, it maps an infinite range of analog values onto a finite set of digital codes. Imagine your ADC has a range of 0V to 3.3V and a resolution of 10 bits. It divides the 3.3V range into 1,024 discrete "buckets" (or steps). If your input voltage falls between two buckets, the ADC must round it to the nearest digital integer. This rounding creates quantization error.
This error is essentially the difference between the true analog value and the rounded digital representation. Because the ADC always rounds to the nearest step, the maximum error is always half of one Least Significant Bit (LSB).
Visualizing the Error
If your ADC step size is , then any input signal will have an uncertainty of .
Consider a simple check in code to see how a digital value represents an input:
// Step size calculation for 3.3V reference and 10-bit ADC
float v_ref = 3.3;
float v_step = v_ref / 1024.0;
// If ADC reads a raw value, the 'noise' is inherent to the resolution
uint16_t adc_raw = get_adc_value();
float measured_voltage = adc_raw * v_step;
// The uncertainty (quantization noise) is:
float error_margin = v_step / 2.0;
Signal Noise vs. Quantization
While quantization error is a mathematical consequence of turning analog signals into numbers, signal noise refers to external electrical interference (like electromagnetic noise from motors or power lines).
When you look at your adc_raw value, you aren't just seeing the quantization error; you are seeing the original signal plus "floor noise." If your noise level exceeds the v_step size, your ADC readings will "flicker" between two adjacent digital codes even if the input voltage is perfectly stable. This is why high-precision systems often require physical filtering (like a capacitor on the input pin) before the signal reaches the ADC, as software cannot distinguish between the signal, true quantization error, and external environmental noise once the conversion is complete.
Key Takeaway: Quantization error is an unavoidable rounding uncertainty of LSB, whereas signal noise introduces additional fluctuations that can be mitigated through external hardware filtering.