Signal
A signal is any physical quantity that varies over time, space, or any other independent variable and
carries information. In electronics, this is typically a time-varying voltage or current. The smooth blue
line represents a continuous sound wave or voltage.
Sampling
Sampling is the process of converting a continuous-time signal into a discrete-time signal.
Instead of measuring the signal constantly, you take "snapshots" at uniform time intervals ( T s ).
The speed of these snapshots is the sampling frequency ( f s=1 / T s). The vertical red lines and
dots captured every 0.1 seconds ( 10 Hz ) .
What is Quantization?
Quantization is the process of mapping a continuous, infinite set of values to a smaller,
discrete, and finite set of values. In the context of electronics, digital signal processing (DSP),
and computer science, it is the crucial step that takes an analog sample (which can have an
infinite number of decimal places) and rounds it to the nearest value that digital hardware can
actually store and process.
To put it simply: Sampling breaks a signal down in time (creating snapshots), while quantization
breaks a signal down in amplitude (rounding those snapshots to fixed steps).
Bit Depth
The number of binary bits assigned to represent each sample.
Low bit depth (e.g., 4-bit = 16 levels) results in a rough, blocky representation of a signal.
High bit depth (e.g., 16-bit CD quality = 65,536 levels; 24-bit studio quality = 16.7 million levels)
creates steps so tiny that the reconstructed signal sounds completely smooth to the human ear.
Quantization Error (or Quantization Noise)
Because quantization involves rounding, there is always a slight difference between the true
analog value and the quantized digital value. This difference is called the quantization error:
Error=Quantized Value−True Sampled Value
In audio systems, this error manifests as a faint background hiss known as quantization noise.
Clipping / Saturation
If an analog signal's voltage goes beyond the maximum or minimum limits that the quantizer
can handle, the system cannot round it properly. Instead, it flatlines (clips) at the absolute
highest or lowest available code, which causes severe acoustic or visual distortion.
Types of Quantizers
Uniform Quantization: The step sizes are perfectly equal throughout the entire range.
This is the most common type and is what you see in standard linear PCM audio.
Non-Uniform Quantization: The step sizes vary. Steps are made much smaller and
tightly packed near zero (where human hearing or vision is most sensitive to detail) and
much larger at high amplitudes. Algorithms like µ−law and A-law use this to optimize
telephone audio networks.
Example on signal, sampling and quantization
Analog a signal: x (t )=2 sin ( 2 πt )
where: Amplitude A = 2 , Frequency f =1Hz
Sampled: fs=10Hz
1
Therefore, T s= =0.1 s
fs
Take one complete cycle: t=n T s, for n=0,1,2,3,…,9
Replace t in the analog signal ( x (t ) ¿ by t=n T s
x ( n )=2 sin ( 2 π ( 0.1 n ) ) , hence, the obtained sampled values are then gotten from;
x [ n ] =2 sin (2 πn / 10 )
For instance, at n = 3, x [ n ] =2 sin¿ = 1.9021
[note that the angle there is in radians, i.e π(rad) = 1800]
n 0 1 2 3 4 5 6 7 8 9
t(s) 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
Sampled
0.0 1.1756 1.9021 1.9021 1.1756 0.0000 -1.1756 -1.9021 -1.9021 -1.1756
Value
4-Bit Quantization Mapping Table
Level Quantized Value Binary Code
0 -2.00 0000
1 -1.75 0001
2 -1.50 0010
3 -1.25 0011
4 -1.00 0100
5 -0.75 0101
6 -0.50 0110
7 -0.25 0111
8 0.00 1000
9 0.25 1001
10 0.50 1010
11 0.75 1011
12 1.00 1100
13 1.25 1101
14 1.50 1110
15 1.75 1111
n 0 1 2 3 4 5 6 7 8 9
t(s) 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
Sampled - - -
0.000 1.1756 1.9021 1.9021 1.1756 0.0000 -1.1756
Value 1.1756 1.9021 1.9021
Quantized
0.125 1.125 1.875 1.875 1.125 0.125 -1.125 -1.875 -1.875 -1.125
Value
Binary
1000 1100 1111 1111 1100 1000 0011 0000 0000 0011
Encoding
Example:
Actual sample: x [ 1 ]=1.1756
Nearby levels (quantized values): 1.00 and 1.25
Distance to 1.00: ∣1.1756−1.00∣ = 0.1756
Distance to 1.25: ∣1.1756−1.25∣= 0.0744
Since 0.0744 < 0.1756, we choose 1.25, and its Binary equivalent is 1101 (from the mapping
table)
Quantization Error = difference between sampled value and quantized value = ∣1.1756−1.25∣ =
0.0744
Quantization Error is calculated using the formula e q=Quantized Value−Sampled Value
The above plots perfectly visualize the complete Analog-to-Digital Conversion (ADC) process for
the signal x(t) we've been working with. It breaks down the transformation of a continuous
wave into discrete digital steps.
The plot breaks the ADC process into three distinct components, as shown in the legend:
The Analog Signal (Smooth Blue Line): This represents the original continuous real-world signal.
As we calculated earlier, this is a 1 Hz sine wave with a peak amplitude of 2 V
( x ( t ) =2sin ( 2 πt ) ) .
The Discrete Samples (Red Dots + Vertical Red Lines) represents the Sampling stage. The
system looks at the analog wave exactly 10 times per ¿ sampling rate, or every 0.1 seconds)
The red vertical lines (impulses) show the exact instantaneous voltage captured at that specific
moment (e.g., 1.18 V at 0.1 s, 1.90 V at 0.2 s).
The left axis shows how the 4-bit system divides the voltage range from
−2.00 V ¿+ 1.75 V into 16 discrete intervals with a step size of Δ=0.25 V .
The Quantized Signal (Staircase Green Line): This represents the Quantization stage.
Because a computer cannot store infinite decimal values, it must round each red sample
dot to the nearest allowable "step" or "level." This rounding creates the characteristic
digital staircase effect.
Ultimately, this graph is a visual proof of why higher bit-depths, are used in modern
tech. With more bits, the grid lines on the Y-axis become incredibly tight, the green
staircase closely hugs the blue line, and the quantization error shrinks until it's
practically invisible to the human ear or eye!
Example 1 (Unipolar)
An 8-bit successive approximation ADC has a reference voltage range from 0V to 5V. If the
analog input voltage is 3.2V, calculate its decimal equivalent and the digital output code.
(Assume rounding to the nearest integer).
SOLUTION
Given Data:
8 -bit ADC ¿),
N=8 bits
V min =0 V
V F=5 V
V i=3.2 V
Step1 : Resolution
N 8
Res=V F S / 2 =5 / 2 =5 /256=0.01953125 V / step
Step2 : Decimal Code
D=round ¿
D ¿ round ( (3.2−0 ) / 0.01953 )
D=round ( 163.84 ) =164
Step3 : Binary Code
7 5 2
164=128+32+ 4=2 + 2 + 2
BinaryCode=101001002
Verification:
V o =D× Res+V min =164 × 0.01953125=3.203125 V
Final Answer :
Decimal Code=164
8−bitBinaryOutput=10100100 2
The number 164 tells you which step on the ADC's staircase the input voltage falls on. An 8-bit
ADC cannot output the decimal number "164" because it only outputs 1s and 0s (voltage highs
and lows). The number 164 is just the middle-man that we use to figure out what those 1s and
0s should be. The code is the binary equivalent of the decimal 164
Example 2 (Bipolar)
A 4-bit successive-approximation ADC has a reference voltage range from -2V to +2V. If the
analog input voltage is 1.1756V, calculate its decimal equivalent and the digital output code.
(Assume rounding to the nearest integer).
SOLUTION
Given: 4 -bit ADC ( N=4 ) ,
( V min =−2 , V F =+2 ) .
Input Voltage (Vin ¿ :1.1756 V (from the previous plot data)
4 4
Resolution ( Δ )= = =0.25 V / step
2 16
4
Code D=round ( 1.1756−
0.25
(−2 )
)=round (
0.25 )
3.1756
=round (12.702 )=13
Binary Equivalent: 1101 (This exactly matches level 13 / 1.25V from your 4-bit staircase plot!
Combined Signal Sampling & Quantization (4bit) Table
n 0 1 2 3 4 5 6 7 8 9
Sampled - - - -
0.0000 1.1756 1.9021 1.9021 1.1756 0.0000
Value 1.1756 1.9021 1.9021 1.1756
Quantized
0.00 1.25 1.75 1.75 1.25 0.00 -1.25 -2.00 -2.00 -1.25
Value
Binary Code 1000 1101 1111 1111 1101 1000 0011 0000 0000 0011
Quantization - - - - - -
0.0000 0.0744 0.0744 0.0000
Error 0.1521 0.1521 0.0744 0.0979 0.0979 0.0744
Comparison of 3bit vs 4bit Combined Signal Sampling & Quantization (4bit) Table
Sampled 3-Bit 3-Bit 3-Bit 4-Bit 4-Bit 4-Bit
n t (s)
Value Quantized Code Error Quantized Code Error
0 0.0 0.0000 0.0 100 0.0000 0.00 1000 0.0000
1 0.1 1.1756 1.0 110 -0.1756 1.25 1101 0.0744
2 0.2 1.9021 1.5 111 -0.4021 1.75 1111 -0.1521
3 0.3 1.9021 1.5 111 -0.4021 1.75 1111 -0.1521
4 0.4 1.1756 1.0 110 -0.1756 1.25 1101 0.0744
5 0.5 0.0000 0.0 100 0.0000 0.00 1000 0.0000
6 0.6 -1.1756 -1.0 010 0.1756 -1.25 0011 -0.0744
7 0.7 -1.9021 -2.0 000 -0.0979 -2.00 0000 -0.0979
8 0.8 -1.9021 -2.0 000 -0.0979 -2.00 0000 -0.0979
9 0.9 -1.1756 -1.0 010 0.1756 -1.25 0011 -0.0744
Instantaneous error at n = 2
Sampled Value: 1.9021 V
Quantized Value: 1.75 V
Quantization error (e q ¿=1.75−1.9021=−0.1521 V . The negative sign indicates that the
quantization process underestimated the true signal voltage (the step level is slightly lower than
the actual wave peak).
Instantaneous error at n = 4
Sampled Value: 1.1756 V
Quantized Value: 1.25 V
Quantization error( e q ¿=1.25−1.1756=+0.0744 V . The positive sign indicates that the
quantization process overestimated the true signal voltage.
Problem 1: Sampling Rate & Sampling Interval
Question
A continuous-time electrocardiogram (ECG) signal contains frequency components ranging from
5 Hz ¿ 150 Hz .
a. What is the minimum sampling rate ¿) required to completely capture the signal without
losing information?
b. What is the maximum allowable sampling interval (Ts) corresponding to this minimum
sampling rate?
Solution
a. Find the Minimum Sampling Rate (fs):
According to the Nyquist-Shannon Sampling Theorem, a signal must be sampled at a rate
greater than twice its highest frequency component (fmax) to avoid aliasing: f s ≥2 ⋅ f max
Given f max=150 Hz :
f s=2 ⋅150 Hz=300 Hz
b. Find the Maximum Sampling Interval (Ts):
The sampling interval is the reciprocal of the sampling frequency:
1
T s=
fs
1
T s= ≈ 0.00333 seconds(or 3.33 ms)
300 Hz
Problem 2: ADC Resolution & Step Size
Question
A data acquisition board features a 12-bit bipolar Analog-to-Digital Converter (ADC) configured for an
input voltage range of −5 V ¿+5 V .
a. Calculate the voltage resolution (step size Δ ) of this ADC.
b. If the ADC outputs a digital code of 2048 (in decimal), what is the corresponding quantized
analog voltage?
Solution
a. Calculate the Resolution:
First, determine the Full-Scale Range ( V FSR ) :
V FSR =V max −V min =5 V −(−5 V ) =10 V
The total number of quantization levels for an N−bit ADC is2 N .
12
For a12−bit ADC , 2 =4096 levels.
V FSR 10 V
Δ= N
= ≈ 0.00244 V(o 2.44 mV / step)
2 4096
b. Calculate the Quantized Voltage for Code 2048:
Using the linear mapping formula:
V out =V min + ( D ⋅ Δ )
V out =−5 V + ( 2048 ⋅0.0024414 V )=−5 V +5 V=0.0 V
(Note: Because 2048 is exactly halfway through the 4096 digital steps, it maps perfectly to the midpoint
of the voltage range).
Problem 3: Audio Bit Rate & File Size
Question
A studio recording engineer tracks a musical performance in stereo (2 channels) using a high-fidelity
sampling rate of 96kHz and a bit depth of 24bits.
a. What is the raw bit rate of this uncompressed audio stream in Megabits per second (Mbps)?
b. If the song lasts exactly 4 minutes and 30 seconds, how much storage space will the
uncompressed file take up in Megabytes (MB)?
Solution
a. Calculate the Bit Rate:
The bit rate equation for multi-channel digital audio is:
Bit Rate=Sampling Rate ( f s ) × Bit Depth ( N ) ×Number of Channels
Bit Rate=96,000 Hz× 24 bits ×2 channels=4,608,000 bits / second
Convert to Megabits per second (Mbps) by dividing by 1,000,000:
4,608,000
Bit Rate= =4.608 M b p s
1,000,000
b. Calculate the File Size:
First, convert the duration into total seconds:
Time=( 4 ×60 )+ 30=270 seconds
Multiply total seconds by the raw bit rate to find total bits:
Total Bits=4,608,000 bits / s × 270 s=1,244,160,000 bits
Convert bits to Bytes (divide by 8):
1,244,160,000
Total Bytes= =155,520,000 Bytes
8
Convert Bytes to Megabytes (MB). Using standard decimal system notation ( 1 MB=1,000,000 Bytes ) :
155,520,000
File Size= =155.52 M B
1,000,000
Problem 4: Combining Everything (Sensor Monitoring)
Question
An industrial factory sensor monitors pipe vibrations. The system samples a 2 kHz analog vibration
signal at a rate 2.5 times its Nyquist rate. The samples are passed to a 16-bit ADC. The system stores
data continuously for 1 hour.
1. Find the sampling frequency ( f S )
2. Find the bit rate of the data stream.
3. Find the total data accumulated in Megabytes (MB) after 1 hour.
Solution
1. Find the Sampling Frequency ¿):
First, locate the Nyquist rate (which is double the signal frequency):
Nyquist Rate=2 ×2 kHz=4 kHz
The problem states it samples at the Nyquist rate
the Nyquist rate:
f s=2.5 × 4 kHz=10 kz
2. Find the Bit Rate:
Bit Rate=f s × Bit Depth=10,000 samples / s ×16 bits / sample=160,000 bits / second=160 kp
3. Find the Total Accumulated File Size:
Convert 1 hour into seconds:
Time=1 hour × 60 minutes ×60 seconds=3600 seconds
Calculate total bits:
Total Bits=160,000 bits / s ×3600 s=576,000,000 bits
Convert ¿ Bytes:
576,000,000
Total Bytes= =72,000,000 Bytes
8
Convert to Megabytes (MB):
72,000,000
File Size= =72 M B
1,000,000
Problem 5:
Let’s consider a Digital Thermostat control system for an industrial chemical reactor, where the
temperature must be kept within a tight, safe range to avoid an explosion.
The Scenario
Operating Range: 0°C to 100°C (VFSR = 100).
Critical Threshold: If the temperature hits 50.5°C, the reaction becomes unstable and
catastrophic.
Input: The sensor reads exactly 50.5°C
Comparison of Bit Depths
Parameter 4-bit ADC (Low Precision) 10-bit ADC (High Precision)
4 10
Total Levels 2 =16 2 =1024
∘ ∘
Resolution 100 /16=6.25 C 100 /1024 ≈ 0.0977 C
Calculation 50.5 / 6.25=8.08 50.5 / 0.0977 ≈ 516.89
Stored Value 8 ( 8 × 6.25=50.0∘ C ) 517 ( 517 × 0.0977=50.51∘ C )
The Danger: Quantization Error as a Catastrophic Failure
1. With a 4-bit ADC (The Dangerous Choice):
The system rounds 50.5∘ C down to 50.0°C. The computer reads "50°C" and thinks, "Everything is
perfectly safe, no need to trigger the cooling system." Because the quantization step is so large ( 6.25∘ C )
, the system is blind to the dangerous temperature rise occurring at 50.5 °C . The catastrophic reaction
proceeds unchecked because the digital representation provided a false sense of security.
2. With a 10-bit ADC (The Safe Choice):
The system registers the value as roughly 50.51∘ C. It detects that the temperature has exceeded the
critical 50.5 °C threshold and immediately triggers the emergency cooling system. The high resolution
allows the system to distinguish between a safe state and a catastrophic state.
Interpretation
In engineering, this is often called "Loss of Observability." If your ADC resolution is coarser than the
tolerance required for safety, your system effectively acts as if it is blind. In high-stakes environments like
medical ventilators, autonomous braking systems, or aerospace flight controls choosing an insufficient
bit depth doesn't just mean "less data"; it means the software cannot "see" dangerous conditions until it
is too late to prevent a catastrophe.