Analog vs Digital

Every sensor, speaker and wire in an electronic system carries information as a changing voltage. That voltage can be treated in two very different ways. An analog system works with the exact value of the voltage. A digital system only cares whether the voltage is high or low. This one choice is the reason computers, phones and nearly all modern electronics are built from digital logic, and it is the starting point for everything in this course.

Learning objectives

By the end of this lesson you will be able to:

  • Explain the difference between analog and digital signals.
  • Describe why digital circuits tolerate noise better than analog circuits.
  • Classify a voltage as logic 0, logic 1 or undefined using threshold levels.
  • Calculate the resolution of an analog-to-digital converter (ADC).
  • Estimate how much data a sampled signal produces.

Analog signals

An analog signal can take any value in a continuous range. A microphone produces a voltage that rises and falls smoothly with the sound pressure. The temperature of a room, the position of a volume knob and the brightness of light are all naturally analog quantities.

The strength of analog is that it can represent a quantity exactly, in theory. The weakness is that any disturbance changes the value. Noise picked up on a wire becomes part of the signal and cannot be told apart from it. Copying an analog signal many times makes the noise add up.

Digital signals

A digital signal can take only a small number of distinct values. In binary logic there are two, written 0 and 1 and often called LOW and HIGH. A circuit does not need to know whether the voltage is 4.8 V or 5.0 V. It only needs to know that it is clearly in the HIGH range.

Because a digital value is defined by a range, small disturbances do not change it. A signal that drifts a little is still read as the same bit. This makes digital data easy to store, copy and send without loss. It also lets us use Boolean algebra, which is the mathematics of two-valued variables.

Property Analog Digital
Values Continuous range Limited set, usually two
Effect of noise Changes the information Ignored if small
Copying Quality degrades Exact copies
Processing Amplifiers, filters Logic gates, processors
Example Microphone voltage Computer bus

Logic levels and noise margins

Real digital circuits define voltage ranges for each logic value. For the classic 5 V TTL logic family, the guaranteed values are:

Quantity Meaning Value
VOL (max) Highest voltage an output gives for logic 0 0.4 V
VOH (min) Lowest voltage an output gives for logic 1 2.4 V
VIL (max) Highest voltage an input accepts as logic 0 0.8 V
VIH (min) Lowest voltage an input accepts as logic 1 2.0 V

Voltages between VIL and VIH are in the undefined region. A gate may read them as either value, so a well-designed circuit never leaves a signal there except while it switches.

The gap between what an output guarantees and what the next input needs is the noise margin:

  • High-level noise margin = VOH - VIH = 2.4 - 2.0 = 0.4 V
  • Low-level noise margin = VIL - VOL = 0.8 - 0.4 = 0.4 V

Noise smaller than 0.4 V on a wire cannot flip a bit. Other logic families use different numbers, so always check the data sheet.

From analog to digital: sampling and quantization

To process a real-world signal digitally, an ADC does two things:

  1. Sampling: it measures the voltage at regular time intervals. The Nyquist rule says the sampling rate must be more than twice the highest frequency in the signal.
  2. Quantization: it rounds each measurement to the nearest of 2^n levels, where n is the number of bits.

The step between two neighbouring levels is the resolution:

Resolution = full-scale voltage / 2^n

More bits give finer steps. The rounding difference between the real value and the stored value is called quantization error.

Worked example 1: ADC resolution

An 8-bit ADC measures voltages from 0 V to 5 V. What is its resolution?

  • Number of levels = 2^8 = 256.
  • Step size = 5 V / 256 = 0.01953 V, which is about 19.5 mV.

Any input is therefore stored with an error of at most about half a step, roughly 9.8 mV. A 12-bit ADC on a 3.3 V range has 4,096 levels and a step of 3.3 / 4,096 = 0.806 mV. Its step is about 24 times smaller than the 8-bit example (19.53 / 0.806 is roughly 24.2).

Worked example 2: Classifying voltages in a TTL system

Using the TTL input thresholds above (VIL max 0.8 V, VIH min 2.0 V), classify each input voltage:

Input voltage Region Logic value
0.5 V Below 0.8 V 0
1.4 V Between 0.8 V and 2.0 V Undefined
2.4 V Above 2.0 V 1
3.3 V Above 2.0 V 1

The 1.4 V input could be read either way, so a designer must avoid it. Compare this with an analog system, where 1.4 V would simply be a valid value.

Worked example 3: How much data does a sampled signal produce?

A speech signal is limited to 4 kHz. How much data does 10 seconds of it need?

  • Nyquist: the sampling rate must exceed 2 x 4 kHz = 8 kHz, so use 8,000 samples per second.
  • Samples in 10 seconds: 8,000 x 10 = 80,000.
  • Using 8 bits per sample: 80,000 x 8 = 640,000 bits.
  • In bytes: 640,000 / 8 = 80,000 bytes, about 80 KB.

This is why digital audio needs storage and bandwidth, and why numbers in binary and hexadecimal matter. You can practise converting such values with the number converter.

Why digital wins for computing

  • Noise immunity. Small errors are ignored, so signals can pass through many stages.
  • Exact storage and copying. Bits do not degrade.
  • Flexibility. The same hardware can run any program.
  • Design tools. Boolean algebra, truth tables and Karnaugh maps give exact methods for designing circuits, which you will use in the next lessons.

Analog is still needed at the edges of a system: sensors, amplifiers, radio and power circuits are analog, and converters connect them to the digital core.

Common mistakes

  • Thinking digital means binary only. Digital means a limited set of values. Binary is the most common case.
  • Assuming a digital signal is a perfect square wave. Real edges take time, and the voltage passes through the undefined region.
  • Confusing resolution with accuracy. More bits give finer steps, but errors in the reference voltage still limit accuracy.
  • Sampling too slowly. Below twice the highest frequency, the signal is misrepresented, which is called aliasing.
  • Mixing up VOH and VIH. Output values are the guarantees, and input values are the requirements.

Practice problems

Problem 1. How many levels does a 10-bit ADC have?

Answer: 2^10 = 1,024 levels.

Problem 2. What is the resolution of a 12-bit ADC with a 3.3 V full-scale range?

Answer: 3.3 / 4,096 = 0.000806 V, about 0.81 mV.

Problem 3. How many bits are needed to distinguish 1,000 different levels?

Answer: 10 bits, because 2^9 = 512 is too small and 2^10 = 1,024 is enough.

Problem 4. How many bits does 1 second of stereo audio need at 44,100 samples per second and 16 bits per sample?

Answer: 44,100 x 16 x 2 channels = 1,411,200 bits.

Frequently asked questions

Is digital always better than analog? No. Digital is better for storing, copying and computing. Analog is still essential for sensing and for radio and power circuits, and digital systems depend on it at the input and output.

What does a logic 1 mean in volts? It depends on the logic family. In 5 V TTL, an input at or above 2.0 V counts as 1. Modern 3.3 V and lower-voltage families use different thresholds.

Why do computers use binary and not decimal? Two states are the easiest to build reliably, since a transistor is either on or off. A ten-level signal would have tiny noise margins and would be much harder to make dependable.

Next lesson: continue with Number Systems: Binary and Hexadecimal to learn how digital values are written and converted.