Quantization & Coding Simulator
PCM Analog-to-Digital Conversion Pipeline
Parameters
Analysis
Analog Input
Quantized Levels
Binary Representation (PCM Words)
Transmitted Waveform (NRZ-L)
Quantization Error Explorer
Hover over the analog signal graph to see instantaneous quantization error (e).
Pulse Code Modulation (PCM)
The fundamental process of converting analog signals into digital bitstreams.
1. Sampling
The first step in PCM is converting the continuous-time analog signal into a discrete-time signal. According to the Nyquist-Shannon Sampling Theorem, to accurately reconstruct a signal, it must be sampled at a rate ($f_s$) more than twice the maximum frequency ($f_{max}$) present in the signal.
2. Quantization
Sampling discretizes time; quantization discretizes amplitude. The amplitude of each sample is rounded off to the nearest value from a finite set of levels. The difference between the original value and the quantized value is called Quantization Error or Quantization Noise.
- Uniform Quantization: Equal spacing between levels. Best for uniformly distributed signals.
- Non-Uniform Quantization: Uses companding (Compressing-Expanding) like $\mu$-law or A-law to improve SNR for small signals.
3. Encoding
Each quantized level is assigned a unique binary code. If we use $n$ bits, we can represent $L = 2^n$ levels. The resulting bit rate ($R_b$) is:
After encoding, the bits are often transformed via Line Coding (e.g., Manchester, NRZ) to ensure synchronization and DC balance during transmission.
Signal-to-Quantization Noise Ratio (SQNR)
SQNR measures the quality of the quantization. For a full-load sinusoidal input, the theoretical maximum SQNR is approximately:
Each additional bit improves the SNR by roughly 6dB.
Laboratory Procedure
Setup the Environment
Open the Virtual Lab tab. Familiarize yourself with the control panel on the left and the visualization graphs on the right.
Observe Sampling & Quantization
Set the input signal to Sine Wave, Amplitude 1V, Frequency 1kHz.
- Set Bits (n) to 2. Observe the severe "staircase" effect and large error.
- Gradually increase n to 4, then 8. Note how the quantized signal approaches the analog signal.
Analyze Quantization Error
Use the "Quantization Error Explorer" at the bottom. Hover over the peaks and zero-crossings of the analog wave.
- Record the maximum error observed.
- Compare the theoretical SQNR value displayed with your qualitative observation of the error.
Study Line Coding Schemes
Keep Bits = 3. Change the "Line Coding" dropdown.
- Observe NRZ-L: High for 1, Low for 0.
- Observe Manchester: Transition in the middle of every bit period.
- Observe AMI: Alternating polarity for 1s, zero for 0.
Companding Investigation
Set Bits to 3. Enable "μ-Law Companding". Observe how the quantization steps are finer near zero amplitude and coarser at high amplitudes. This reduces error for small signals.
Report Writing Guidelines
Required Sections
1. Objective
State the purpose: To study PCM, quantization error, and line coding schemes.
2. Theory
Briefly explain Sampling, Quantization, Encoding, and specific line codes. Include the SQNR formula.
3. Simulation Setup
Document the parameters used (Frequency, Amplitude, Bits).
4. Observations & Graphs
Include screenshots of the simulator for:
- Quantized Signal vs Analog Signal.
- Line Coded output for NRZ-L and Manchester.
- Table of Bits vs Theoretical SQNR.
5. Conclusion
Discuss the trade-off between Bit Rate (Bandwidth) and Signal Quality (SQNR).
Use the "Print to PDF" function of your browser to save the simulator results for your appendix.