Loading header...

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.

flowchart LR A["Physical quantity"] --> S["Sensor"] S --> AF["Analog front end"] AF --> ADC["ADC samples"] ADC --> N["Numbers in firmware"] N --> CTRL["Control algorithm"] CTRL --> PWM["PWM or DAC"] PWM --> ACT["Actuator driver"]

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.

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.

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.

Common Mistakes

  • Treating any voltage between 0 V and VDD as 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.

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

Mind Map

mindmap root((Analog and Digital)) Analog Continuous amplitude Sensor voltages Offset and noise Bandwidth Source impedance Digital Logic zero and one Thresholds Noise margin Sampled numbers Quantized codes Conversion ADC measures DAC generates Comparator thresholds PWM plus filter Checks Pin voltage limits ADC reference Sampling rate Ground reference Anti alias filter Common mistakes Undefined logic level Too high source impedance No calibration Ignoring noise