🔬 Virtual Laboratory: Pulse Code Modulation (PCM)

ECE 426-Digital Communications | Department of  Electrical & Communication Engineering

1. Introduction to Pulse Code Modulation

PCM is a digital representation of an analog signal where the magnitude of the signal is sampled regularly at uniform intervals, then quantized to a series of symbols in a digital (usually binary) code. It is the standard form of digital audio, digital telephony, and other digital applications.

Three Essential Operations in PCM:
  1. Sampling: Converting continuous-time signal to discrete-time
  2. Quantization: Converting continuous-amplitude to discrete-amplitude
  3. Encoding: Converting discrete values to binary code words

2. Sampling Theorem (Nyquist Theorem)

A continuous-time signal can be completely represented in its samples and recovered back if the sampling frequency satisfies:

fs ≥ 2fm

Where fs is the sampling frequency and fm is the maximum frequency component in the analog signal.

🎯 Nyquist Rate

The minimum sampling rate required to reconstruct the original signal without aliasing.

fNyquist = 2fm

⚠️ Aliasing

Occurs when fs < 2fm, causing spectral overlap and distortion. Anti-aliasing filters are used to prevent this.

3. Quantization

Quantization is the process of mapping continuous input values to a finite set of discrete output values.

Uniform Quantization

Step Size: Δ = (Vmax - Vmin) / L
where L = 2n (number of levels, n = bits per sample)

Quantization Error: -Δ/2 ≤ e ≤ Δ/2
Quantization Noise Power: Nq = Δ²/12

4. Signal-to-Quantization-Noise Ratio (SQNR)

For a sinusoidal input with uniform quantization:

SQNR = 6.02n + 1.76 dB

Each additional bit improves the SQNR by approximately 6 dB.

5. PCM Transmission Rate

Bit Rate: Rb = n × fs bits/second
where n = number of bits per sample
fs = sampling frequency

6. Companding (Compression-Expanding)

To improve the SQNR for small amplitude signals, companding is used:

  • μ-law (Mu-law): Used in North America/Japan
  • A-law: Used in Europe and most international systems

Companding effectively makes the quantization steps smaller for small amplitudes and larger for large amplitudes.

🎛️ PCM Parameters

Analog Signal & Sampling (Sample-and-Hold)
Quantized Signal & Binary Encoding
Binary: 10001101 01110010...
Reconstructed Signal (Low-Pass Filter)
Quantization Error (Noise)
Sampling Rate (fs)
8.0 kHz
Nyquist Rate
2.0 kHz
Quantization Levels (L)
256
Bit Rate (Rb)
64 kbps
Step Size (Δ)
7.81 mV
Theoretical SQNR
49.92 dB
Actual SQNR
--
Aliasing?
NO

🧪 Laboratory Experiments

Experiment 1: Sampling Theorem Verification (Nyquist Rate)

Objective: Verify the Nyquist-Shannon sampling theorem and observe aliasing.

  1. Set Message Frequency to 1000 Hz (Sinusoidal)
  2. Set Sampling Rate to 8000 Hz (8 kHz)
  3. Verify that Nyquist Rate shown is 2000 Hz (2×fm)
  4. Start simulation and observe clean reconstruction
  5. Gradually decrease Sampling Rate to 1500 Hz (below Nyquist)
  6. Observe the "Aliasing: YES" warning and distorted output
  7. Note the folding frequency: falias = |fs - fm|
Expected Result: Reconstruction is perfect when fs ≥ 2fm, severely distorted when fs < 2fm.

Experiment 2: Quantization Analysis

Objective: Analyze quantization error and verify the 6n dB rule.

  1. Set Bits per Sample to 2 bits (4 levels)
  2. Observe the "staircase" effect in quantization plot
  3. Note the large error signal amplitude
  4. Increment bits to 4, 6, 8, 10, 12 sequentially
  5. Record SQNR for each case and verify: SQNR ≈ 6.02n + 1.76 dB
  6. Plot SQNR vs n (should be linear with slope ~6 dB/bit)

Experiment 3: Companding Characteristics

Objective: Compare uniform vs. companded quantization.

  1. Set signal amplitude to 0.2V (low level)
  2. Use Uniform quantization (8 bits) and note SQNR
  3. Switch to μ-law companding
  4. Observe improved SQNR for small signals
  5. Increase amplitude to 1.0V and compare again
  6. Analyze why companding improves dynamic range

Experiment 4: Dynamic Range and Bit Rate

Objective: Analyze the trade-off between quality and bandwidth.

  1. Set fs = 8000 Hz, n = 8 bits (Telephone quality standard)
  2. Calculate and verify Bit Rate = 64 kbps
  3. Increase fs to 16000 Hz (n=8) - observe bit rate doubles
  4. Calculate storage required for 1 minute of audio at these rates
  5. Determine minimum bit rate for "CD Quality" (fs=44.1kHz, n=16)
Important Safety Note: When testing with square waves, note that they contain infinite harmonics. The sampling theorem applies to the bandwidth-limited version. Observe Gibbs phenomenon in reconstruction.

📈 Performance Analysis

Theoretical SQNR vs Bits

Shows linear relationship between bits per sample and SQNR (6 dB per bit rule).

Quantization Levels vs Dynamic Range

Bits (n) Levels (L) Theoretical SQNR Resolution (12V range)
2413.8 dB3.00 V
41625.8 dB0.80 V
825649.9 dB46.9 mV
12409674.0 dB2.93 mV
166553698.1 dB0.18 mV

Companding Advantage Analysis

Without Companding (Uniform): SQNR ∝ Signal Power (small signals have poor SQNR)
With μ-law Companding: SQNR ≈ constant over wide dynamic range (~40 dB improvement for small signals)
μ-law Formula: y = sgn(x) × ln(1 + μ|x|) / ln(1 + μ), where μ = 255

Bandwidth Requirements

🎙️ Telephone Quality

fs = 8 kHz, n = 8 bits

Rb = 64 kbps
BW (NRZ) = 64 kHz

🎵 CD Quality (PCM)

fs = 44.1 kHz, n = 16 bits, Stereo

Rb = 1.411 Mbps
BW (NRZ) = 1.411 MHz

Error Analysis

Granular Noise: Occurs when signal varies slowly within a quantization step. Dominant in fine quantization.

Slope Overload: Occurs in delta modulation (derivative of PCM) when signal changes too rapidly. Not applicable to standard PCM but important in differential schemes.

📋 Laboratory Report Guidelines

Required Report Structure

1. Title Page

  • Title: Pulse Code Modulation (PCM) Analysis
  • Course: Digital Communications (Course Code)
  • Student Name, ID, Section
  • Submission Date

2. Abstract (Summary)

Brief overview (150-200 words) covering objectives, methodology, key results (SQNR values, sampling rate verification), and conclusions.

3. Theory and Objectives

  • State Nyquist Sampling Theorem with mathematical proof sketch
  • Explain uniform quantization and quantization noise power (Δ²/12)
  • Derive SQNR formula: 6.02n + 1.76 dB for sinusoidal input
  • Explain need for companding in telephony

4. Experimental Results

Required Tables and Plots:

  • Table 1: Sampling Rate vs Reconstruction Quality (include screenshots at fs = 2fm, 5fm, 0.5fm)
  • Table 2: Bits per Sample (n) vs Measured SQNR vs Theoretical SQNR
  • Graph 1: Plot SQNR (dB) vs n (show 6 dB/bit slope)
  • Graph 2: Companding curve (input vs output)
  • Screenshots of quantization levels for n=2, 4, 8

5. Analysis Questions

  1. Calculate the minimum sampling rate for a signal with maximum frequency 4 kHz. What happens if you sample at 6 kHz?
  2. Verify the 6.02n + 1.76 dB formula using your measured data. Calculate percentage error.
  3. Why does telephone PCM use 8 kHz sampling and 8-bit quantization? Calculate the resulting bit rate.
  4. Explain the trade-off between quantization levels and bit rate. Why can't we simply use n=16 for all applications?
  5. Compare uniform quantization with μ-law companding for a 0.1V signal in a ±1V system.

6. Conclusion

Summarize key findings, discuss sources of error (numerical precision in simulation, finite sampling), and state practical implications for digital audio/telephony system design.

7. References

List textbooks (e.g., Proakis, Sklar), IEEE papers on PCM, and ITU-T standards (G.711 for μ-law/A-law).

Grading Rubric:
Theory & Objectives (20%) | Simulation Data Quality (25%) | Analysis & Calculations (30%) | Presentation & Formatting (15%) | Conclusions (10%)

Penalty: -10% for missing screenshots, -5% for calculation errors.
Submission Checklist:
☐ PDF format (no Word docs)
☐ File named: PCM_Lab_RollNumber.pdf
☐ All 4 experiment sections completed
☐ Minimum 5 screenshots included
☐ Calculations shown step-by-step
☐ Turnitin similarity < 20%