ADC Binary Code Calculator
Calculate the ideal binary output code of an ADC from analog input voltage, reference voltage and ADC resolution. View the resulting binary code together with its decimal and hexadecimal representation.
ADC Code = floor[(Vin / Vref) × 2^N]
Result is limited to 0 through (2^N – 1)
-
What Is an ADC Binary Code Calculator?
An ADC Binary Code Calculator determines the digital output code produced by an ideal analog-to-digital converter for a specified analog input voltage. An ADC converts a continuous voltage into one of a finite number of digital codes determined by its bit resolution.
The result is especially useful when working with microcontrollers, data acquisition systems, embedded electronics, sensors, industrial electronics and digital signal processing systems where an analog measurement must be represented as a binary number.
How an ADC Converts Voltage to Binary
An N-bit ADC can represent 2 raised to N different digital code states. For example, an 8-bit ADC has 256 possible codes, while a 12-bit ADC has 4096 possible codes.
Maximum digital code = 2^N – 1
Therefore an 8-bit ADC produces codes from decimal 0 through 255, corresponding to binary 00000000 through 11111111.
ADC Binary Code Formula
For the ideal unipolar model used on this page, the input range begins at 0 V and extends to the reference voltage.
The calculated code is constrained so it cannot exceed the maximum available digital value:
This means an input exactly equal to Vref produces the maximum available code rather than an impossible code equal to 2 raised to N.
8-Bit ADC Binary Code Example
Consider an ideal 8-bit ADC with a 5 V reference and an input voltage of 2.5 V.
Vref = 5 V
N = 8
Levels = 2^8 = 256
Code = floor[(2.5 / 5) × 256]
Code = floor(128) = 128
Decimal 128 represented as an 8-bit binary number is:
ADC Binary Code Ranges by Resolution
| ADC Resolution | Number of Levels | Decimal Code Range | Maximum Binary Code |
|---|---|---|---|
| 4-bit | 16 | 0–15 | 1111 |
| 8-bit | 256 | 0–255 | 11111111 |
| 10-bit | 1,024 | 0–1,023 | 1111111111 |
| 12-bit | 4,096 | 0–4,095 | 111111111111 |
| 16-bit | 65,536 | 0–65,535 | 1111111111111111 |
What Is ADC Resolution?
ADC resolution specifies how many binary bits are available to represent the analog input. Increasing the number of bits increases the number of available digital levels and allows smaller voltage changes to be represented.
10-bit ADC → 1,024 levels
12-bit ADC → 4,096 levels
16-bit ADC → 65,536 levels
This calculator uses the bit resolution to determine the code range. The separate ADC Resolution Calculator is intended for calculations specifically focused on resolution and voltage-per-step analysis.
What Is ADC LSB Size?
The least significant bit, or LSB, represents one ideal ADC code step in this calculator’s model.
For an 8-bit ADC using a 5 V reference:
≈ 19.53125 mV
This means each ideal code step corresponds to approximately 19.53 mV.
ADC Code at Zero Volts
For the unipolar model used here, an input of zero volts produces the minimum digital code.
Decimal Code = 0
8-bit Binary = 00000000
ADC Code at Full Scale
The highest possible N-bit code is one less than the total number of code levels.
12-bit: 2^12 – 1 = 4095
16-bit: 2^16 – 1 = 65535
Therefore an input at the upper supported endpoint is limited to the maximum available code.
ADC Decimal, Binary and Hexadecimal Codes
The same ADC output can be represented using different number systems without changing the underlying digital value.
| Representation | Example Value |
|---|---|
| Decimal | 128 |
| Binary | 10000000 |
| Hexadecimal | 0x80 |
Binary representation is particularly useful when examining ADC registers, individual bits or digital hardware interfaces, while hexadecimal is often more compact for firmware and register documentation.
ADC Quantized Voltage
The digital output represents a discrete quantization level rather than every possible continuous voltage. This calculator also reports the voltage represented by the calculated code using the same ideal step-size convention.
The difference between the actual analog input and its represented level is associated with quantization.
ADC Binary Codes in Microcontrollers
Microcontrollers commonly include ADC peripherals that convert analog signals from sensors, potentiometers, batteries and other voltage sources into digital register values.
For example, firmware may read a 12-bit ADC register containing a value from 0 through 4095. Understanding the corresponding binary code can help when debugging registers, masks, communication packets and embedded measurement logic.
ADC Binary Codes for Sensors
Many sensors ultimately produce an analog voltage that is sampled by an ADC. Temperature sensors, pressure sensors, light sensors, current sensors and position sensors are common examples.
The ADC code is only the digital representation of the measured voltage. Converting that code into a physical quantity such as temperature or pressure requires the sensor’s transfer function or scaling equation, which is outside the purpose of this calculator.
ADC Code vs ADC Resolution
These concepts are related but represent different calculations.
| Calculation | Main Question |
|---|---|
| ADC Binary Code | What digital code corresponds to this input voltage? |
| ADC Resolution | What voltage step can this ADC represent? |
Keeping these calculations separate avoids creating two pages that perform essentially the same task.
Ideal ADC vs Real ADC
The calculator models an ideal ADC. Real analog-to-digital converters can be affected by offset error, gain error, integral nonlinearity, differential nonlinearity, electrical noise, reference-voltage tolerance, temperature drift and other hardware characteristics.
Actual converter transfer functions can also define code transition boundaries differently. For engineering work involving a specific ADC, its datasheet should be treated as the authoritative source.
Unipolar ADC Input Range
This calculator assumes a simple unipolar input range:
It does not model bipolar ADC ranges such as -5 V to +5 V, differential ADC input coding, offset-binary coding, signed two’s-complement ADC output or custom minimum and maximum input ranges.
Keeping those modes out of this page ensures the calculator performs exactly the task described by its title.
Important ADC Binary Code Notes
The supported analog input range is 0 V through Vref.
The number of ADC levels is 2^N.
The maximum code is 2^N – 1.
The calculator uses floor[(Vin / Vref) × 2^N] and limits the result to the valid N-bit code range.
The reported LSB size is Vref / 2^N.
Binary output is padded with leading zeros to match the selected ADC resolution.
An input exactly equal to Vref is limited to the maximum available N-bit code.
This calculator does not model ADC noise, INL, DNL, gain error, offset error, signed bipolar ranges or manufacturer-specific transfer functions.
For a real ADC device, always verify the exact code transition convention and electrical specifications in the manufacturer’s datasheet.