Analog and Digital Signals
Embedded systems live between the physical world and software. Sensors produce voltages and currents that vary continuously, while microcontrollers process numbers and logic states. Data conversion is the discipline that connects those two worlds without losing the meaning of the measurement or control signal.
Learning Objectives
By the end of this lesson, you should be able to:
- distinguish analog, digital, discrete-time, and quantized signals;
- explain logic thresholds and noise margin;
- describe bandwidth, noise, offset, gain error, and dynamic range;
- identify where ADCs, DACs, comparators, and PWM fit;
- choose practical checks before connecting a signal to an MCU pin.
Analog Signals
An analog signal can vary continuously over a range. A thermistor divider, microphone, strain gauge bridge, photodiode amplifier, battery voltage, and motor current shunt are all analog examples.
Important properties include:
| Property | Meaning |
|---|---|
| amplitude | signal size in volts, amps, pascals, newtons, or another unit |
| offset | DC level added to the varying part |
| bandwidth | frequency range containing useful information |
| noise | unwanted random or coupled variation |
| source impedance | how easily the source drives the next circuit |
A sensor output of 0.5 V to 2.5 V may represent pressure, position, temperature, or acceleration. The voltage is only useful when the system also knows the scaling and limits.
Digital Signals
A digital signal uses defined states. In common MCU logic, a pin below the input-low threshold is read as 0, and a pin above the input-high threshold is read as 1. The undefined region between thresholds should not be used as a stable logic level.
Digital does not mean noise-free. It means the receiver interprets a voltage range as a state. Noise margin is the safety gap between valid output levels and input thresholds.
For a logic output connected to a logic input:
$$
NM_H = V_{OH(min)} - V_{IH(min)}
$$
$$
NM_L = V_{IL(max)} - V_{OL(max)}
$$
where NMH and NML are high-level and low-level noise margins in volts. A negative margin means the interface is not guaranteed to work across process, voltage, temperature, loading, and noise.
Continuous, Sampled, and Quantized
An analog signal can be continuous in time and amplitude. An ADC makes it sampled in time and quantized in amplitude.
title "Continuous signal and digital samples"
time start=0 end=10 unit=ms divisions=5
A: sine label="analog input" amplitude=1 cycles=1 unit=norm color=#2563eb
S: pulse label="sample instants" low=0 high=1 at=1 width=0.15 unit=mark color=#dc2626
The waveform is illustrative. Real ADC samples occur at repeated intervals, and the numeric output depends on reference voltage, resolution, input circuit, and ADC architecture.
An N-bit unipolar ADC produces 2^N possible codes. The ideal voltage step, often called one LSB, is approximately:
$$
V_{LSB}=\frac{V_{REF}}{2^N}
$$
For a 12-bit ADC using VREF = 3.3 V:
$$
V_{LSB}=\frac{3.3}{4096}=0.000805\ \text{V}=0.805\ \text{mV}
$$
This does not mean the measurement is automatically accurate to 0.805 mV. Reference tolerance, input noise, offset, gain error, source impedance, layout, and calibration all matter.
Dynamic Range and Noise
Dynamic range is the span between the largest useful signal and the smallest distinguishable signal. In an ideal ADC, signal-to-quantization-noise ratio is often estimated as:
$$
SNR_{ideal}=6.02N+1.76\ \text{dB}
$$
For a 12-bit converter, the ideal value is about 74 dB. Real systems may deliver fewer effective bits because analog noise, reference noise, clock jitter, sensor error, and PCB coupling reduce performance.
The effective number of bits relates measured SNR to resolution:
$$
ENOB=\frac{SNR_{measured}-1.76}{6.02}
$$
Interfaces Between Worlds
| Function | Device or method | Typical purpose |
|---|---|---|
| analog to digital | ADC | measure sensors and voltages |
| digital to analog | DAC | generate references, audio, control voltages |
| threshold detection | comparator | convert analog crossing into logic event |
| digital average control | PWM plus filter | approximate analog output |
| isolation or level adaptation | optocoupler, isolator, level shifter | protect and translate domains |
Practical Input Checks
Before connecting a signal to an embedded input, check:
- voltage range never exceeds pin absolute maximum ratings;
- source impedance is low enough for the ADC sample capacitor;
- signal bandwidth fits the sampling rate and anti-alias filter;
- ground reference is valid and not carrying large load currents;
- protection components do not corrupt normal measurements;
- noise and resolution are compatible with the required accuracy.
Worked Example: Battery Divider
A 12 V battery must be measured by a 3.3 V ADC. Choose a divider ratio so the maximum battery voltage, for example 15 V, maps below the ADC reference.
For R1 = 47 kOhm from battery to ADC and R2 = 10 kOhm from ADC to ground:
$$
V_\text{ADC}=V_\text{BAT}\frac{R_2}{R_1+R_2}
$$
$$
V_\text{ADC}=15\frac{10}{47+10}=2.63\ \text{V}
$$
This is inside a 3.3 V range, but the effective source resistance is about 8.25 kOhm, so the ADC acquisition time must be checked.
The divider current at 15 V is:
$$
I=\frac{15}{47,000+10,000}=263\ \mu\text{A}
$$
The parallel source resistance seen by the ADC is:
$$
R_{TH}=R_1||R_2=\frac{47k\times10k}{47k+10k}=8.25\ k\Omega
$$
If the ADC datasheet recommends source impedance below 5 kOhm at the chosen sample time, either lower the divider values, increase acquisition time, or buffer the divider.
Common Mistakes
- Treating any voltage between
0 VandVDDas a valid digital level. - Feeding an ADC from a source impedance too high for its sample time.
- Ignoring sensor offset and calibration.
- Sampling a changing signal without anti-alias filtering.
- Connecting grounds without considering high current return paths.
- Comparing ADC counts from different boards without checking reference voltage.
- Letting protection diodes conduct during normal operation.
Summary
Analog signals vary continuously and carry physical meaning through amplitude, timing, and noise. Digital systems represent states and numbers using thresholds, sampling, and quantization. Reliable embedded data conversion starts by checking voltage range, impedance, bandwidth, reference, noise, and protection before trusting firmware readings.
Further Reading
- Analog Devices: Data Conversion Handbook
- Texas Instruments: Analog Engineer's Pocket Reference
- Microchip: ADC Basics