Analog and Digital Worked Example Calculation Audit

Analog and Digital Worked Example Calculation Audit

Ada re-derives this chapter’s own numbers step by step, at full precision

foundations
math-foundations
calculation-audit
electronics
beginner
Ada ADA · CALCULATION AUDIT

Analog and Digital Worked Example Calculation Audit

A 12-bit ADC on a 3.3 V reference measures 2.0 V, and the firmware stores the floor of 2481.818 as code 2481; elsewhere the same chapter sizes a 159 Hz RC filter, a 5.09 mA duty-cycled battery draw, and a 0.25 W resistor. Each figure is a single line of arithmetic that quietly fixes a physical limit. This audit re-derives every scale factor and rounding step and asks whether those numbers are physically plausible or just values the firmware happens to carry.

Companion to the chapter ADC/DAC Worked Examples — every number here comes from that chapter.

A worked example is an audit trail: every scale factor, rounding choice, and physical limit should be visible before firmware turns the value into a decision.

See the relationship before changing it

The figure reads from left to right. The blue card is adc input voltage. The middle card applies this page's rule. The green card is floored adc code. Walk the arrows once: set the input, apply the rule, then read the result with its unit.

The retained audit below checks several chapter fixtures. This model keeps those stated values fixed and changes only adc input voltage, so the numeric fixture does not switch without explanation.

ADC input voltage changes floored adc code An input card leads through the rule code = floor(input / 3.3 V x (2^12 - 1)) to the floored adc code result. INPUT PAGE INPUT APPLY THE RULE predict calculate check units OUTPUT RESULT
Walk the arrows. Firmware flooring follows the voltage ratio; calibration and reference error remain outside this ideal model.

Derive the baseline in four named moves

  1. 1

    Name the input. The chapter baseline is 2 V.

  2. 2

    Name the relationship. code = floor(input / 3.3 V x (2^12 - 1))

  3. 3

    Substitute with units. floor(2.0 / 3.3 x 4,095) = 2,481

  4. 4

    Read the result. Keep the unit beside the value. Use it only inside the technical boundary on this page.

Predict, then change adc input voltage

Try Predict the direction of code = floor(input / 3.3 V x (2^12 - 1)). Test another adc input voltage, then compare floored adc code.

2 V
Chapter baseline
Floored ADC code

Observe Firmware flooring follows the voltage ratio; calibration and reference error remain outside this ideal model. Reset adc input voltage to 2 and compare floored adc code.

Explain Firmware flooring follows the voltage ratio; calibration and reference error remain outside this ideal model.

Check yourself

What should you do before trusting a moved-control result?
Answer: Predict its direction, apply the shown relationship, keep the units, and reset to the worked baseline.
What does this small model leave out?
Answer: Only adc input voltage moves here. Field effects named in the technical boundary stay fixed.
Try

Select Calculate for the 2.0 V, 12-bit ADC case plus the 10 kohm and 100 nF RC example.

Observe

The rows produce code 2481 by flooring 2481.818 and a 159.15 Hz filter cutoff without mixing their units.

Explain

ADC scaling maps voltage into an integer code while the RC product sets analogue bandwidth; each result is plausible only within its own physical constraint.

Technical boundaries

For the worked examples, excluded from this fixed arithmetic are sensor calibration error, analogue noise, component tolerances, heat transfer, or battery ageing beyond the stated arithmetic.

1. ADC codes are ratios, not magic numbers. The chapter's 12-bit, 3.3 V example measures 2.0 V by scaling the input against the endpoint code 4095:

D = floor((2.0 / 3.3) × (212 − 1)) = floor(0.6060606 × 4095) = floor(2481.818) = 2481

2. The examples also expose the physical limit behind the formula. Quantization, filter bandwidth, and resistor power become design constraints only after the units are carried through.

Audit check Arithmetic shown Design consequence
10-bit ADC at 5 V 5 V / 1024 = 0.0048828 V = 4.88 mV A single count cannot prove a change smaller than about one step.
12-bit ADC reading 2.0 V (2.0 / 3.3) × 4095 = 2481.818, then floor = 2481 The rounded-down code is expected, not an off-by-one bug.
10 kohm and 100 nF RC filter 1 / (2 × pi × 10000 × 100e-9) = 159.15 Hz Signals well below 159 Hz pass; faster noise is attenuated.
Duty-cycled battery current 50 mA × 0.10 + 0.1 mA × 0.90 = 5.09 mA 1000 mAh / 5.09 mA = 196.46 h, so "10% active" is still current-hungry.
Power in a 100 ohm resistor at 50 mA (0.050 A)2 × 100 ohm = 0.25 W A 0.25 W part is at its limit; selecting at least 0.5 W adds margin.
Red LED current limit from 3.3 V (3.3 V − 2.0 V) / 0.010 A = 130 ohm Rounding up to 150 ohm reduces current and protects the GPIO path.

What the audit buys you: the same arithmetic that produces a firmware value also explains whether the sensor range, analog bandwidth, energy budget, and heat limit are physically plausible.

Every number above is taken from the chapter’s own material and re-derived step by step.