Electronics & Circuits · Study deck

ADC and DAC: Conversion Calculations

An ADC count is useful only when it maps back to the measured voltage.

Voltage Vera is your guide for this deck.

analogdigitalesp32
Voltage Vera, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Calculate ADC Output: Compute digital values from analog voltage inputs using the ADC conversion formula
  • Select Reference Voltages: Evaluate and match Vref to sensor output ranges for maximum resolution
  • Quantify Quantization Error: Derive measurement precision limits across different ADC resolutions
  • Determine Nyquist Sampling Rates: Compute minimum and practical sampling frequencies for specific signal types
iotclass.org

Major section

Start Simple

The test engineer must show how one known input becomes both outputs without hiding a reference value, scale factor, unit change, or rounding choice.

  • Reverse the calculation to see whether the reported value can recover the original within the stated limit.
  • A distant chart may show the result, but it cannot restore resolution lost at conversion.
  • This opening does not cover every converter design.
iotclass.org

Major section

Phoebe's Field Notes: Where the Converter Numbers Come From

The mathematical gist.: A 10-bit, 3.3 V ADC has q=V_{ref}/2^{10}=3.22 mV.

  • At 1.65 V, the chapter's endpoint rule gives \(D=\lfloor(1.65/3.3)1023\rfloor=511\), reconstructing 1.648 V within half an LSB.

Numbers to remember

3.3 V3.3 V ADC has q=V_{ref}/2^{10}=3.22 mV.
1.65 VAt 1.65 V, the chapter's endpoint rule gives \(D=\lfloor(1.65/3.3)1023\rfloor=511\)
iotclass.org

Major section

ADC Conversion Formula

The visual is specifically about aDC conversion showing how continuous analog voltage is sampled and quantized into discrete digital steps.

  • These visible labels explain aDC conversion showing how continuous analog voltage is sampled and quantized into discrete digital steps.
  • They keep adc conversion formula tied to evidence that can be inspected on the schematic, part, or trace.
ADC conversion showing how continuous analog voltage is sampled and quantized into discrete digital steps
ADC conversion showing how continuous analog voltage is sampled and quantized into discrete digital steps
iotclass.org

Major section

Quantization Error Example

Quantization error is the inherent inaccuracy introduced when converting continuous analog signals to discrete digital values.

  • Where LSB (Least Significant Bit) is the smallest voltage change the ADC can detect.
  • Any voltage between 1.650V and 1.653V will round to the same digital value (512).
  • Effective bits increase by log2(N)/2.

Numbers to remember

1.653V1.653V will round to the same digital value (512).
1VIf measuring 0-1V signal, use 1V reference (not 3.3V or 5V).
3.3VIf measuring 0-1V signal, use 1V reference (not 3.3V or 5V).
iotclass.org

Major section

ESP32 Soil Moisture Example

Scenario: A smart irrigation system uses a capacitive soil moisture sensor that outputs 1.2V (dry) to 2.8V (saturated).

  • You need to determine optimal ADC configuration on an ESP32 to detect 1% moisture changes for water-efficient farming.
  • Key Insight: Proper attenuation selection is critical.
  • Using 0 dB attenuation (0-1.1V range) would clip the signal, while 11 dB provides headroom.

Numbers to remember

0 dBUsing 0 dB attenuation (0-1.1V range) would clip the signal
0-1.1VUsing 0 dB attenuation (0-1.1V range) would clip the signal
11 dBwhile 11 dB provides headroom.
iotclass.org

Major section

Ultrasonic Distance Example

Scenario: An autonomous robot uses an HC-SR04 ultrasonic sensor for obstacle detection.

  • The echo pulse width (10us to 25 ms) must be measured accurately.
  • You need to determine if ADC-based measurement or timer-based capture is appropriate.
  • Key Insight: ADCs are for converting analog voltage levels to digital values.

Numbers to remember

10usThe echo pulse width (10us to 25 ms) must be measured accurately.
25 msThe echo pulse width (10us to 25 ms) must be measured accurately.
iotclass.org

Major section

For Kids: Meet the Sensor Squad!

Math helps the Sensor Squad turn real-world measurements into exact numbers!

  • Temperature Terry was measuring the temperature of a fish tank. "It is 25 degrees Celsius!
  • ADC Andy looked at the signal. "Okay, I need to turn that into a number Max can understand.
  • One quarter of 1023 is about 255.

Key terms

So 0.250 volts
So 0.250 volts is one quarter of the way.
iotclass.org

Major section

For Kids: Meet the Sensor Squad! (continued)

the microcontroller was curious. "How do you figure out which step number matches 0.250 volts?".

  • So 0.250 volts is one quarter of the way.
  • So I tell Max: the reading is 255!".
  • the LED wanted to know more. "And how does Max turn 255 back into a temperature?".
iotclass.org

Major section

For Kids: Meet the Sensor Squad! (continued)

That gives me about 25 degrees -- exactly what Sammy measured!".

  • the battery chimed in. "But what if you only had 256 steps instead of 1024?".
  • Andy nodded. "Then each step would be a bigger jump -- about 0.4 degrees instead of 0.1 degrees.
  • I would be less precise.
iotclass.org

Major section

ADC Input Impedance Pitfall

The circuit works in simulation but reads incorrectly in hardware.

  • The ESP32 ADC has an internal sample-and-hold capacitor that draws charging current during conversion.
  • High-impedance sources (like voltage dividers with large resistors) cannot supply enough current fast enough, causing the ADC to read lower voltages than expected.
  • Result: readings are 5-10% low.

Key terms

If readings
If readings are consistently low, source impedance is likely the culprit.

Numbers to remember

5-10%Result: readings are 5-10% low.
iotclass.org

Deck summary

Key takeaways

The test engineer must show how one known input becomes both outputs without hiding a reference value, scale factor, unit change, or rounding choice.

  • The mathematical gist.: A 10-bit, 3.3 V ADC has q=V_{ref}/2^{10}=3.22 mV.
  • The visual is specifically about aDC conversion showing how continuous analog voltage is sampled and quantized into discrete digital steps.
  • Quantization error is the inherent inaccuracy introduced when converting continuous analog signals to discrete digital values.
  • Scenario: A smart irrigation system uses a capacitive soil moisture sensor that outputs 1.2V (dry) to 2.8V (saturated).
iotclass.org

Retrieval practice

Recall check 1 of 2

Voltage Vera says: answer from memory, then check your reasoning.

Q1A 10-bit ADC has a 5V reference voltage. What is the voltage resolution (step size)?

A0.5 mV
B4.88 mV
C10 mV
D50 mV
Show answer

Answer: B Step Size = V_ref / 2^bits = 5V / 1024 = 0.00488V = 4.88mV. This is the smallest voltage change the ADC can detect. Arduino Uno uses this exact configuration with its 10-bit ADC.

Q2A 12-bit ADC with Vref = 3.3V measures 2.0V. What is the digital output?

A2000
B2481
C1241
D606
Show answer

Answer: B Output = floor((2.0V / 3.3V) x (2^12 - 1)) = floor((2.0 / 3.3) x 4095) = floor(2481.8) = 2481. The 12-bit ADC divides the 0-3.3V range into 4096 steps (0-4095).

iotclass.org

Retrieval practice

Recall check 2 of 2

Voltage Vera says: answer from memory, then check your reasoning.

Q3An 8-bit DAC with Vref = 3.3V receives digital input 192. What is the output voltage?

A1.65 V
B2.48 V
C3.10 V
D2.95 V
Show answer

Answer: B V_out = V_ref x (Digital_Input / (2^bits - 1)) = 3.3V x (192 / 255) = 3.3V x 0.753 = 2.48V. The 8-bit DAC can output 256 discrete voltage levels (0-255), and we scale the digital value proportionally.

iotclass.org

Print reference

Answers 1 of 2

Answer key.

  1. B · Step Size = V_ref / 2^bits = 5V / 1024 = 0.00488V = 4.88mV. This is the smallest voltage change the ADC can detect. Arduino Uno uses this exact configuration with its 10-bit ADC.
  2. B · Output = floor((2.0V / 3.3V) x (2^12 - 1)) = floor((2.0 / 3.3) x 4095) = floor(2481.8) = 2481. The 12-bit ADC divides the 0-3.3V range into 4096 steps (0-4095).
iotclass.org

Print reference

Answers 2 of 2

Answer key.

  1. B · V_out = V_ref x (Digital_Input / (2^bits - 1)) = 3.3V x (192 / 255) = 3.3V x 0.753 = 2.48V. The 8-bit DAC can output 256 discrete voltage levels (0-255), and we scale the digital value proportionally.
iotclass.org