Skip to content

Vertiam/adc-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

50 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โšก ADC Resolution, Noise & Oversampling โ€” Signal Processing Lab

Quatumn Hackathon ยท Track #4 ยท Problem Statement #19

A complete, browser-based digital laboratory for studying Analog-to-Digital Conversion, quantization noise, and oversampling.
Record real signals, run controlled experiments, visualise the physics, and export a full lab report โ€” no installation required.


๐ŸŒ Live Website

๐Ÿ”— https://vertiam.github.io/adc-simulator/


๐Ÿ“ฝ๏ธ Video Demo

๐Ÿ”— Click This Link to Watch the video demo!!


Page URL Description
๐Ÿ  Landing Page /index.html Project overview, theory cards, experiment guide
๐Ÿ”ฌ Lab Environment /lab.html Full 5-step guided experiment

๐Ÿ“‹ Table of Contents


๐ŸŽฏ Evaluation Criteria Alignment

Criterion How This Project Meets It
Physical / System Correctness Midtread uniform quantization matches the IEEE standard ADC model. SNR formula 6.02n + 1.76 dB is the exact closed-form theoretical result. Oversampling gain 10ยทlogโ‚โ‚€(M) is derived from noise power spectral density. FFT uses Cooley-Tukey radix-2 DIT with Hanning windowing โ€” standard DSP practice. All formulas are textbook-accurate.
Visualization Quality 4 live interactive charts: waveform, error signal, SNR curve, FFT spectrum. Staircase fill shows error area even at high bit depths. Quantization level grid lines visible at โ‰ค7 bits. Zoom, pan, markers, comparison snapshots, and text annotations on every chart. Dark/light mode. PNG export.
Conceptual Clarity Every technical term has a plain-English hover tooltip. Step-by-step guided lab workflow. Pre-filled theory notebook with derivations. Real-world application examples. Designed so a student with zero prior knowledge can complete the full experiment and understand ADC principles end-to-end.

๐ŸŽฏ What This Project Does

This project models every stage of the ADC pipeline:

Real Signal โ†’ Sampling โ†’ Quantization โ†’ Error Measurement โ†’ Oversampling โ†’ SNR & FFT Analysis

Students interact with this pipeline through a guided 5-step lab session, recording readings, writing observations, and generating a complete exportable report.

Core deliverables from the problem statement:

Required Outcome Implementation
Model ADCs with different bit resolutions 2-bit to 16-bit slider, live waveform update
Visualize quantization noise Error chart + orange fill + FFT spectrum
Demonstrate noise reduction via oversampling 1ร— to 64ร— slider, live SNR update
Quantized signal plots Waveform chart with stepped quantized line
SNR vs ADC resolution graphs SNR curve chart with operating point dot

๐Ÿ” Problem Statement

Problem Statement #19:

Analog-to-digital conversion introduces quantization noise. Simulate ADC digitization effects and study how oversampling improves signal quality.

  • โœ… Model ADCs with different bit resolutions (2โ€“16 bit)
  • โœ… Visualize quantization noise (error chart + FFT)
  • โœ… Demonstrate noise reduction using oversampling (1ร— to 64ร—)
  • โœ… Quantization, ADC resolution, oversampling, noise averaging โ€” all implemented and visualized

๐Ÿ›  Technologies Used

Technology Role Why Chosen
HTML5 Page structure No framework overhead, works offline
CSS3 + Variables Shared design system Single style.css; dark/light via class toggle
JavaScript ES6+ All simulation logic In-browser, zero-latency slider response
Web Audio API Microphone recording Native PCM capture, no libraries
MediaRecorder API Audio stream capture Standard across all modern browsers
Chart.js v4.4.1 4 live interactive charts Fastest JS charting library for real-time data
chartjs-plugin-zoom Zoom & pan Built on Hammer.js touch gestures
Custom FFT (JS) Frequency spectrum Cooley-Tukey radix-2 DIT, O(N log N)
localStorage Auto-save student data No backend required
GitHub Pages Free HTTPS hosting getUserMedia requires HTTPS

๐Ÿ”ฌ Lab Workflow โ€” All 5 Steps

Step 1 โ€” Student Setup

Required fields (name, reg number, dept, date) with shake-animation validation and live green/red border feedback. Auto-saves to localStorage every 10 seconds. All fields populate the final report.

Step 2 โ€” Signal Source

๐ŸŽค Microphone โ€” getUserMedia() โ†’ MediaRecorder โ†’ WebM blob โ†’ decodeAudioData() โ†’ Float32Array PCM โ†’ normalized to [-1, +1]. Live waveform via AnalyserNode.

โšก Generator โ€” Sine, Square, Sawtooth, Chirp. Configurable frequency and amplitude.

๐Ÿ“‚ CSV Upload โ€” Drag-and-drop, single-column or time,value format, linear interpolation resample to 250 points.

Step 3 โ€” Run Experiments

Four live charts, all interactive:

  1. Waveform โ€” Original vs Quantized with staircase fill and level grid lines
  2. Quantization Error โ€” The noise signal; RMS error shown live
  3. SNR vs Bit Depth โ€” Theoretical curve + orange dot at current settings
  4. FFT Spectrum โ€” Cooley-Tukey FFT of the error signal; shows noise spectral distribution

Controls: Bit Depth (2โ€“16 bit) ยท Oversampling (1ร—โ€“64ร—) ยท Noise Floor (0โ€“30%).

Record This Reading logs current settings (bits, OS rate, SNR, ENOB, RMS) to a data table.

Step 4 โ€” Lab Notebook

Aim, Apparatus, Theory, Observations, Analysis, Conclusion โ€” all editable, auto-saved.

Step 5 โ€” Report

Auto-assembled from all previous steps. Print with @media print CSS, or export full CSV.


๐Ÿ“š Core Concepts

1. Analog vs Digital

Real-world signals are continuous. Computers store only discrete numbers. The ADC bridges this gap.

2. Bit Depth & Quantization Levels

Levels = 2โฟ          Step = 2 / 2โฟ    (in [-1, +1] range)
Bits Levels Typical Use
4 16 Illustration
8 256 Telephony
12 4,096 Sensors, IoT
16 65,536 CD audio
24 16,777,216 Studio recording

3. Quantization Noise

Q[i]    = round(x[i] / step) ร— step
error   = Q[i] - x[i]   โˆˆ [-step/2, +step/2]
RMS     = step / โˆš12

4. Signal-to-Noise Ratio

SNR = 6.02n + 1.76 + 10ยทlogโ‚โ‚€(osRate)   dB

Every bit adds ~6 dB. Every 4ร— oversampling adds another ~6 dB.

5. Oversampling

Sample M times faster, average groups of M. Noise variance drops by M, amplitude by โˆšM.

Golden Rule:  4ร— oversampling = +1 bit = +6 dB SNR
ENOB = n + logโ‚‚(M) / 2

6. FFT Spectral Analysis

Quantization noise is ideally white (flat spectrum). The FFT chart shows this. Oversampling lowers the noise floor uniformly across all frequency bins.


๐Ÿงฎ The Algorithm

Midtread Uniform Quantization

step  = 2 / Math.pow(2, bits)          // one level's width
Q[i]  = Math.round(x[i] / step) * step // snap to nearest level

This is the IEEE-standard ADC model. Rounding error is uniformly distributed in [-step/2, +step/2].

Oversampling + Decimation

// Generate N ร— osRate super-samples โ†’ quantize each โ†’ average groups
for (let i = 0; i < N; i++) {
  let sum = 0;
  for (let j = 0; j < osRate; j++) sum += Q_super[i * osRate + j];
  output[i] = sum / osRate;
}

Statistical independence of rounding errors means averaging M values reduces noise variance by M.

Cooley-Tukey FFT

Algorithm:   Radix-2 DIT with bit-reversal permutation
Complexity:  O(N log N) vs O(Nยฒ) naive DFT
Window:      Hanning  w[i] = 0.5 ร— (1 - cos(2ฯ€i/N))
Input:       Quantization error signal
Output:      Power spectrum, first N/2 bins

๐Ÿ“Š Visualization Features

Chart What It Shows Evaluation Criterion Met
Waveform Smooth blue original vs stepped orange quantized + fill + level grid Physical correctness + Visualization quality
Error Signal Raw quantization noise at each sample point Visualization quality + Conceptual clarity
SNR Curve Theoretical 6.02n + 1.76 dB plotted against current operating point Physical correctness
FFT Spectrum Noise power distribution across frequency bins (Hanning-windowed) Physical correctness + Visualization quality

๐Ÿ”ง Chart Interaction Tools

Button Function
+ / โˆ’ Zoom in/out (also mouse wheel, pinch)
โŠ™ Reset zoom
๐Ÿ“ Place marker โ€” wave markers sync automatically to error chart
โœ๏ธ Add text annotation โ€” click chart, type label
โŠž Snapshot comparison โ€” freeze current state as purple overlay
โ†“ Download PNG (respects dark/light mode)
Theme toggle Dark โ†” Light mode, saved to localStorage

๐Ÿš€ How to Use

# Hosted: just visit the URL
https://vertiam.github.io/adc-simulator/

# Local (mic needs HTTPS or localhost):
python -m http.server 8000
# open http://localhost:8000

Suggested experiment sequence:

1. Set Bit Depth = 4-bit โ†’ Record
2. Set Bit Depth = 8-bit โ†’ Record
3. Set Bit Depth = 12-bit โ†’ Record  (observe SNR jump)
4. Set Oversampling = 4ร— โ†’ Record   (observe noise floor in FFT)
5. Set Oversampling = 16ร— โ†’ Record
6. Use โŠž to snapshot 4-bit, switch to 12-bit โ†’ direct visual comparison
7. Place marker at a peak โ†’ observe it synced to error chart
8. Export lab report

๐ŸŒ Real-World Applications

Domain ADC Impact
๐ŸŽต Music CD = 16-bit 44.1 kHz ยท Studio = 24-bit 96 kHz
๐Ÿฅ Medical ECG, MRI, pulse oximeters โ€” noisy ADC = wrong diagnosis
๐Ÿ“ฑ Smartphones Every mic, camera sensor, and touchscreen uses an ADC
๐Ÿ›ฐ Telecom 5G radio front-ends โ€” ADC limits channel capacity
๐ŸŒก IoT Temperature, pressure sensors โ€” bit depth = precision
๐Ÿ”ฌ Science Oscilloscopes โ€” limited by ADC resolution

๐Ÿ“ Project File Structure

adc-simulator/
โ”œโ”€โ”€ index.html              โ† Landing page
โ”œโ”€โ”€ lab.html                โ† Full lab (2083 lines)
โ”‚   โ”œโ”€โ”€ 4 chart system      waveform, error, SNR, FFT
โ”‚   โ”œโ”€โ”€ Marker system       waveโ†’error sync
โ”‚   โ”œโ”€โ”€ Comparison mode     snapshot overlay
โ”‚   โ”œโ”€โ”€ Text annotations    click-to-place labels
โ”‚   โ”œโ”€โ”€ FFT engine          Cooley-Tukey + Hanning
โ”‚   โ””โ”€โ”€ Theme toggle        dark/light + localStorage
โ”œโ”€โ”€ style.css               โ† Shared design system
โ”œโ”€โ”€ csv_data_generator.py   โ† Python test data generator
โ””โ”€โ”€ README.md               โ† This file

๐Ÿ”‘ Key Formulas

Levels     = 2โฟ
Step       = 2 / 2โฟ
RMS noise  = step / โˆš12
SNR (ideal)= 6.02n + 1.76  dB
SNR (OS)   = 6.02n + 1.76 + 10ยทlogโ‚โ‚€(M)  dB
ENOB       = n + logโ‚‚(M) / 2
Nyquist    : f_s โ‰ฅ 2 ร— f_max
FFT        : O(N log N),  Hanning window

๐Ÿ‘ฅ Team

Team Name: Qt ฯ€'s ยท Quatumn Hackathon ยท Problem Statement #19 ยท Mechanical Engineering

Role Name Reg. No.
Team Leader Swayam Viral Marfatia RA2511002010080
Member Narayan Murthy RA2511002010124
Member Shirly Oviya RA2511054010030
Member Mithasha P Sishaj RA2511053050040

"The goal is to turn invisible noise into something you can see, drag a slider, and understand." โ€” Qt ฯ€'s

About

Using Oversampling to improve quality of sound passed through an analog to digital controller

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors