Electronics & Circuits · Study deck

Analog-Digital Boundaries: Signal Contracts

An ADC value is not trustworthy until its bandwidth, filter, rate, and time window are named.

Voltage Vera is your guide for this deck.

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

After studying this chapter

Learning objectives

You will be able to:

  • Specify an analog-to-digital contract with bandwidth, filter, rate, and duration.
  • Diagnose aliasing caused by marginal rates and missing filters.
  • Distinguish amplitude quantization from time sampling in an IoT signal chain.
  • Explain why digitizing near the sensor can make a long cable more robust.
iotclass.org

Major section

Analog-Digital Signal Boundary Contracts

That value is not trustworthy until the signal's bandwidth, the range of frequencies to measure, is known.

  • Sampling rate means how often a signal is measured.
  • Firmware is the code stored on the device.
  • Modulation means changing a signal to carry or control information.
  • These trials do not capture every source of drift or timing error.

Why it matters

Debugging mixed-signal hardware is easier when you always know whether the signal in front of you is analog or digital, because each domain fails differently and responds to different fixes.

Filtering, sample rate, and bit depth are coupled boundary decisions that must preserve the evidence the application needs.
Filtering, sample rate, and bit depth are coupled boundary decisions that must preserve the evidence the application needs.
iotclass.org

Major section

Analog-Digital Signal Boundary Contracts (continued)

Between samples, the digital record simply has no information.

  • Pulse width modulation (PWM) is a timed on-and-off output used to imitate a changing level.
  • The boundary must decide what range, step size, noise margin, and sampling rate are acceptable before firmware treats the value as truth.
  • This gives the rate a sound highest frequency.
iotclass.org

Major section

Analog-Digital Signal Boundary Contracts (continued)

The anti-alias filter limits what can reach the ADC.

  • Here, 50.0 mV means 5.00°C of analog error but uses only 12.5% of a 400 mV digital margin.
  • A microcontroller is digital: it works with a finite set of numbers, updated at discrete instants.
  • The amplitude side is a rounding contract.
iotclass.org

Major section

Analog-Digital Signal Boundary Contracts (continued)

Almost every physical quantity a sensor measures — temperature, pressure, light, sound, acceleration — is analog: continuous in both time and amplitude, taking infinitely many values that change smoothly.

  • Quantization (amplitude)A continuous voltage is snapped to one of a finite set of levels.
  • An N -bit converter has 2^N levels, so the smallest step it can represent is one LSB.
  • Sampling (time)The signal is measured only at discrete instants, fs times per second.
iotclass.org

Major section

Analog-Digital Signal Boundary Contracts (continued)

A digital HIGH/LOW is read with margin, so noise below that margin is rejected.

  • The payoff: regenerationEach digital stage re-decides 0 or 1 and outputs a clean signal, so error does not accumulate.
  • Bit depth sets a separate limit on small changes in level.
  • Digital regeneration is a separate but related contract.
iotclass.org

Major section

Analog-Digital Signal Boundary Contracts (continued)

The units show the Nyquist bound: two samples per cycle times fmaxf_{max}fmax​ cycles per second gives 2fmax2f_{max}2fmax​ samples per second.

  • Rate and bit depth must therefore follow the filter and the proof the app needs to keep.
  • The contract is therefore not "analog bad, digital good." It is a handoff rule.
  • At the ADC, it deliberately chooses what amplitude steps and time points will survive.
  • An analog chain has no such boundary.
iotclass.org

Major section

Analog-Digital Signal Boundary Contracts (continued)

After the ADC, the design must protect codes, timestamps, calibration metadata, and validity flags.

  • A later dashboard can only be as trustworthy as the weakest boundary in that chain.
  • The boundary contract names those failure modes while the design is still reviewable.
  • That agreement, plus margin, is the entire source of noise immunity.
iotclass.org

Major section

Analog-Digital Signal Boundary Contracts (continued)

A "digital" signal is still physically an analog voltage — a 3.3 V logic HIGH is a real 3.3 V.

  • If any one of those is implicit, teams debug symptoms instead of the boundary.
  • If they are explicit, the oscilloscope trace, ADC register value, packet field, and cloud record can be compared against the same contract.
  • That error is acceptable only if it is smaller than the measurement tolerance.
iotclass.org

Major section

Signed Sensor Decoding Contracts

The bytes are not wrong; the decoder forgot signedness, width, byte order, or scale.

  • An analog-to-digital converter means the circuit that turns a measured voltage into a number; it is shortened to ADC.
  • Firmware means the program stored on a device to control its hardware.
Bitwise operations used to inspect, modify, and reposition fields in IoT registers.
Bitwise operations used to inspect, modify, and reposition fields in IoT registers.
iotclass.org

Major section

Signed Sensor Decoding Contracts (continued)

Quantisation still contributes q/12=0.0180°Cq/\sqrt{12}=0.0180°Cq/12​=0.0180°C rms, and a 1 Hz poll can only preserve real temperature content below 0.5 Hz.

  • Binary Number Systems teaches place value, powers of two, ADC count ranges, and the precision limits that show up in IoT data.
  • The mathematical gist: A 12-bit two's-complement field has 4,096 codes.
  • Signed decoding fails when firmware performs the right operation at the wrong stage.
iotclass.org

Major section

Sign bit · Sign extension

In an N -bit two's-complement value, bit N−1 set means negative; the range is −2^(N−1) to +2^(N−1)−1.

  • Widening a signed value must copy the sign bit into the new high bits — or a negative reading turns into a huge positive one.
  • The expected signed outputs are 0, 1, 2047, -2048, and -1.
  • Both results came from the same twelve bits.
iotclass.org

Major section

Anti-Alias Filters for Signals · Sampling Rate vs Duration

A 1 Hz temperature signal sampled at 10 Hz is contaminated by 50 Hz mains hum folded to 0 Hz DC offset if no anti-aliasing filter is present.

  • Sampling rate (samples per second) and sample acquisition time (how long each sample takes) are different concepts.
  • The ESP32 ADC has a maximum sampling rate of approximately 100 kSps, but each conversion takes approximately 10 us.
  • Triggering conversions faster than the ADC can complete them causes invalid readings.
iotclass.org

Deck summary

Key takeaways

That value is not trustworthy until the signal's bandwidth, the range of frequencies to measure, is known.

  • Between samples, the digital record simply has no information.
  • The anti-alias filter limits what can reach the ADC.
  • Almost every physical quantity a sensor measures — temperature, pressure, light, sound, acceleration — is analog: continuous in both time and amplitude, taking infinitely many values that change smoothly.
  • A digital HIGH/LOW is read with margin, so noise below that margin is rejected.
iotclass.org

Retrieval practice

Recall check 1 of 6

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

Q1A vibration trace looks plausible, but its sampling plan is undocumented. Which record makes the ADC result reviewable?

ARecord sample rate and smooth plot alone, omitting filter and time window.
BRecord bandwidth, analog filter, sample rate and capture time window.
CRecord sensor model and packet format alone as the ADC sampling contract.
DRecord ADC bit count and dashboard plot alone as frequency evidence.
Show answer

Answer: B These fields tie the physical signal to the digital record.

iotclass.org

Retrieval practice

Recall check 2 of 6

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

Q2An analog sensor's raw output travels a long cable to the MCU and picks up hum. An ADC next to the sensor sends the digital value over that cable, where measured interference stays below the receiver's logic noise margin. Why does this avoid the false analog reading?

ADigital signals do not induce or receive any electrical interference on a cable.
BThe digital value only decodes wrong if noise exceeds the logic noise margin.
CThe ADC removes all noise from the environment around the cable.
DAnalog signals cannot travel more than a few centimetres.
Show answer

Answer: B Digitizing at the source means the long, noisy run now carries a signal read with margin, so sub-margin interference is rejected instead of being read as false analog wander.

iotclass.org

Retrieval practice

Recall check 3 of 6

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

Q3The 8-bit pattern 1111 1111 is read two ways. What are its unsigned and two's-complement signed values?

A255 unsigned, and -255 signed.
B-1 unsigned, and 255 signed.
C127 unsigned, and -128 signed.
D255 unsigned; -1 signed.
Show answer

Answer: D All-ones is the maximum 255 when unsigned, and -1 in two's complement (the pattern just below zero, since adding 1 wraps to 0).

iotclass.org

Retrieval practice

Recall check 4 of 6

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

Q4A register read gives a 12-bit two's-complement code as an unsigned value 'raw' (0 to 4095). Which expression correctly converts it to a signed integer?

Avalue = (raw >= 2048) ? raw - 2048 : raw
Bvalue = (raw >= 0) ? raw - 4095 : raw
Cvalue = (raw >= 0) ? (~raw + 1) : raw
Dvalue = (raw >= 2048) ? raw - 4096 : raw
Show answer

Answer: D If bit 11 is set (raw >= 2048 = 2^11), the value is negative, recovered by subtracting 2^12 = 4096; otherwise it is already the positive value.

iotclass.org

Retrieval practice

Recall check 5 of 6

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

Q5An audio IoT device samples a microphone signal at 8 kHz (telephone quality). A nearby machine emits a 6 kHz tone that appears in the recorded audio as a 2 kHz tone. What phenomenon is this?

AAliasing of the 6 kHz tone across the 4 kHz Nyquist boundary
BHarmonic distortion creating a lower 2 kHz tone from 6 kHz input
CQuantization noise caused by inadequate ADC amplitude resolution
DAnalog intermodulation between the machine tone and sample clock
Show answer

Answer: A This is classic aliasing.

iotclass.org

Retrieval practice

Recall check 6 of 6

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

Q6For a fixed sensor signal band with credible out-of-band interference, and suitable averaging or decimation after conversion, which purpose of oversampling best supports a practical ADC design?

ATo increase the maximum frequency the ADC can digitize
BTo eliminate the need for any analog filtering
CTo reduce the ADC's power consumption per sample
DTo give anti-alias filter margin and improve effective SNR
Show answer

Answer: D Oversampling provides margin for analog anti-alias filter roll-off.

iotclass.org

Print reference

Answers 1 of 2

Answer key.

  1. B · These fields tie the physical signal to the digital record.
  2. B · Digitizing at the source means the long, noisy run now carries a signal read with margin, so sub-margin interference is rejected instead of being read as false analog wander.
  3. D · All-ones is the maximum 255 when unsigned, and -1 in two's complement (the pattern just below zero, since adding 1 wraps to 0).
iotclass.org

Print reference

Answers 2 of 2

Answer key.

  1. D · If bit 11 is set (raw >= 2048 = 2^11), the value is negative, recovered by subtracting 2^12 = 4096; otherwise it is already the positive value.
  2. A · This is classic aliasing.
  3. D · Oversampling provides margin for analog anti-alias filter roll-off.
iotclass.org