0
0
Power-electronicsConceptBeginner · 3 min read

ADC Resolution 8-bit, 10-bit, 12-bit Explained in Embedded C

In embedded C, ADC resolution refers to how many bits the analog-to-digital converter uses to represent an analog input as a digital number. An 8-bit ADC outputs values from 0 to 255, a 10-bit ADC from 0 to 1023, and a 12-bit ADC from 0 to 4095, affecting the precision of the measurement.
⚙️

How It Works

Think of an ADC like a ruler that measures voltage instead of length. The resolution is how many tiny steps the ruler can divide the voltage into. For example, an 8-bit ADC divides the voltage range into 256 steps (from 0 to 255), while a 12-bit ADC divides it into 4096 steps (from 0 to 4095). The more steps, the finer the measurement.

When the ADC reads an analog voltage, it converts it into a digital number based on these steps. So, higher resolution means you get a more precise digital value that better represents the original voltage. This is important in embedded systems where accurate sensor readings are needed.

💻

Example

This example shows how to read an ADC value and print it for different resolutions in embedded C. It simulates reading an ADC value and prints the digital result.

c
#include <stdio.h>

// Simulated ADC read function for different resolutions
unsigned int read_adc(int resolution_bits, float analog_voltage, float vref) {
    unsigned int max_value = (1U << resolution_bits) - 1; // max ADC value
    unsigned int digital_value = (unsigned int)((analog_voltage / vref) * max_value);
    if (digital_value > max_value) digital_value = max_value; // clamp
    return digital_value;
}

int main() {
    float vref = 3.3f; // Reference voltage
    float analog_voltage = 1.65f; // Example input voltage

    unsigned int adc_8bit = read_adc(8, analog_voltage, vref);
    unsigned int adc_10bit = read_adc(10, analog_voltage, vref);
    unsigned int adc_12bit = read_adc(12, analog_voltage, vref);

    printf("8-bit ADC value: %u\n", adc_8bit);
    printf("10-bit ADC value: %u\n", adc_10bit);
    printf("12-bit ADC value: %u\n", adc_12bit);

    return 0;
}
Output
8-bit ADC value: 128 10-bit ADC value: 512 12-bit ADC value: 2048
🎯

When to Use

Use lower resolution ADCs (like 8-bit) when you need simple, fast measurements and precision is not critical, such as reading buttons or simple sensors. Higher resolution ADCs (10-bit or 12-bit) are better for applications needing more accurate readings, like temperature sensors, light sensors, or audio signals.

Choosing the right resolution balances precision, speed, and memory. Higher resolution means more precise data but can be slower and use more memory to store values.

Key Points

  • ADC resolution defines how finely an analog signal is converted to digital.
  • 8-bit ADCs have 256 steps, 10-bit have 1024, and 12-bit have 4096 steps.
  • Higher resolution means more precise measurements but may require more processing.
  • Choose resolution based on the accuracy needed and system constraints.

Key Takeaways

ADC resolution determines the number of digital steps representing an analog input.
8-bit ADC outputs range from 0 to 255, 10-bit from 0 to 1023, and 12-bit from 0 to 4095.
Higher resolution improves measurement precision but may increase processing time.
Select ADC resolution based on the accuracy requirements and hardware limits.