5.5.4 · D3 · Coding › Embedded Systems & Real-Time Software › ADC - DAC — resolution, sampling rate, Nyquist
Yeh page parent topic ka drill-ground hai. Hum har tarah ki situation lete hain jo resolution , sampling rate , aur Nyquist ke ideas produce kar sakte hain — aur har ek ko zero se, bol-bol ke work out karte hain. Yahan koi bhi symbol use nahi hota jo parent note ne build nahi kiya, aur jahan koi naya aata hai hum use wapas earn karte hain.
Intuition Is page ko kaise padhen
Pehle tumhara saamna ek scenario matrix se hota hai: ek table jo har alag tarah ki problem ko naam deti hai jo yeh topic tumhare saath kar sakta hai. Phir har worked example us matrix cell ke saath stamp hota hai jo usne cover ki, taaki end mein koi cell blank na rahe. "Forecast:" line ka jawab padhne se pehle dene ki koshish karo — pehle guess karna hi isko dimag mein chipkaata hai.
Is topic ki har problem asal mein thodi si shapes mein se ek hoti hai. Yeh rahe.
#
Cell (case ka type)
Kya cheez tricky banati hai
Covered by
A
Resolution — normal
seedha LSB / code arithmetic
Ex 1
B
Resolution — boundary / full-scale
top code par "2 N vs 2 N − 1 " ka trap
Ex 2
C
Resolution — degenerate (1 bit, chhota signal)
signal 1 LSB se bhi chhota → dead code
Ex 3
D
Sampling — below Nyquist (aliasing)
frequency fold back ho jaati hai
Ex 4
E
Sampling — above Nyquist (safe)
verify karo koi folding nahi, margin nikalo
Ex 5
F
Sampling — exactly at 2 f (limiting value)
boundary SAFE nahi hai
Ex 6
G
Multiple tones / f s choose karna
sabse zyada frequency ko clear karna hoga
Ex 7
H
Real-world word problem
words → numbers → filter choice mein translate karo
Ex 8
I
Exam twist (SNR ↔ bits, backwards)
6.02N formula ko ulta solve karo
Ex 9
J
DAC reconstruction — staircase
zero-order hold, f s /2 ke upar images
Ex 10
Hum A → J order mein jayenge. Pehle, do axes ki ek shared picture jinpar har problem jeeti hai.
Recall Teen formulas jo hum baar baar use karenge (sab parent se hain)
Full-scale range V r e f ko 2 N codes mein split karo 2 N − 1 gaps ke saath ::: LSB = 2 N − 1 V r e f ≈ 2 N V r e f
Ek voltage se code ::: code = round ( V r e f V in × ( 2 N − 1 ) )
Nyquist rule ::: f s > 2 f ma x ; Nyquist frequency f N = f s /2
Alias frequency ::: f a l ia s = f − f s ⋅ round ( f s f )
SNR ceiling ::: SNR m a x = 6.02 N + 1.76 dB
Yahan N number of bits hai (yes/no switches ki count), V r e f reference voltage hai (input range ka top), f hertz mein ek signal frequency hai, aur f s sampling rate hai samples per second mein. Aur kuch assume nahi kiya gaya.
Worked example Ex 1 — 10-bit ADC ka step size aur code
Ek 10-bit ADC ka V r e f = 5 V hai. (a) Ek code step kitna voltage represent karta hai? (b) 3 V input ke liye kaunsa code niklega?
Forecast: guess karo — kya ek step 5 mV ke kareeb hai ya 5 μ V ke? Kya 3 V ka code 600 ke paas hoga ya 6000 ke?
Step 1. Codes gino: 2 10 = 1024 .
Yeh step kyun? N = 10 independent binary switches 0 se 2 10 − 1 tak count karte hain, toh 1024 distinct levels hain.
Step 2. LSB dhundho (paas wale levels ke beech ka step):
LSB = 2 N − 1 V r e f = 1023 5 ≈ 4.888 mV .
2 N − 1 kyun aur 2 N kyun nahi? 1024 fence-posts hain lekin unke beech sirf 1023 gaps hain — step size ek gap hai.
Step 3. 3 V ko code mein convert karo:
code = round ( 5 3 × 1023 ) = round ( 613.8 ) = 614.
Round kyun? ADC ek mid-tread quantizer hai — yeh input ko floor ki jagah nearest level par snap karta hai.
Verify: code 614 represent karta hai 614 × 4.888 mV ≈ 3.001 V — wapas 3 V par half an LSB ke andar (≈ 2.4 mV ). ✓ Units: volts in, volts out. ✓
Worked example Ex 2 — Sabse bada code kya hai, aur woh kaunsa voltage hai?
Wahi 10-bit, 5 V ADC. Sabse bada code kya hai, aur kaunsa input voltage use produce karta hai? Dikhao ki 2 N − 1 ki jagah 2 N use karne se full scale galat kahan jayega.
Forecast: top code 1024 hai ya 1023 ? Kya yeh exactly 5 V par baithta hai ya thoda neeche?
Step 1. Highest code = 2 N − 1 = 1023 .
Yeh step kyun? Codes 0 , 1 , … , 1023 chalte hain. Zero ek valid code hai, toh count 1024 mein woh shamil hai; maximum index ek kam hai.
Step 2. Exact LSB se code 1023 ka voltage:
1023 × 1023 5 = 5.000 V .
Yeh kyun important hai: exact LSB = V r e f / ( 2 N − 1 ) ke saath, top code bilkul full scale par land karta hai — clean.
Step 3. Ab trap — approximation LSB ≈ V r e f / 2 N = 5/1024 ≈ 4.883 mV use karo:
1023 × 4.883 mV ≈ 4.995 V .
Yeh kyun dikhate hain? Approximate LSB top code ko 5 V se ≈ 5 mV neeche rakhta hai — pura ek step kam. Bade N ke liye woh error invisible hai; full scale ke paas yeh exactly ek LSB bias hai.
Verify: difference 5.000 − 4.995 = 0.005 V = 1 LSB . Dono conventions ke beech gap exactly ek step hai, jaisa claim kiya. ✓
Worked example Ex 3 — 1-bit converter aur ek tiny signal
Extreme edge. V r e f = 3.3 V . (a) 1-bit ADC ka LSB kya hai? (b) Ek sensor 0 ke around sirf 0.5 V ka swing produce karta hai. Kaunse codes aate hain?
Forecast: 1 bit kitne levels deta hai? Kya 0.5 V ki wiggle dikhti bhi hai?
Step 1. N = 1 ke liye codes: 2 1 = 2 (sirf 0 aur 1 ). Gaps = 2 1 − 1 = 1 .
LSB = 2 1 − 1 3.3 = 3.3 V .
Yeh step kyun? Ek switch = do states = ek bada step jo poora range span karta hai. Yeh sabse coarse possible converter hai.
Step 2. 0.5 V feed karo:
code = round ( 3.3 0.5 × 1 ) = round ( 0.1515 ) = 0.
Yeh result kyun? 0.5 V ke sabse kareeb level code 0 hai (jo 0 V represent karta hai). 0.5 V signal ± 2 1 LSB = ± 1.65 V ke decision band se chhota hai, toh yeh bit kabhi flip nahi karta.
Step 3. Pura 0.5 V waveform code 0 par rehta hai — yeh invisible hai.
Yeh degenerate case kyun hai: koi bhi input change jo 2 1 LSB se chhoti ho woh same code mein land karti hai. Yeh "dead code" limit hai jiske baare mein parent ne warn kiya tha ("~0.8 mV se chhota koi bhi change nahi dekha ja sakta"), extreme tak push kiya gaya.
Verify: 2 1 LSB = 1.65 V > 0.5 V , toh koi threshold cross nahi hoti → code 0 rehta hai. ✓ (Real life mein fix: pehle sensor amplify karo, ya zyada bits use karo — dekho Sensor Interfacing on Microcontrollers .)
Worked example Ex 4 — Ek tone jo apni frequency ke baare mein jhooth bolta hai
Ek 7 kHz pure tone ko f s = 10 kHz par sample kiya gaya hai. Playback par tumhe kaunsi frequency sunai degi?
Forecast: 7 kHz Nyquist se upar hai — compute karne se pehle fake frequency guess karo. 5 kHz se zyada hogi ya kam?
Step 1. Nyquist frequency f N = f s /2 = 5 kHz . Kyunki 7 > 5 , rule f s > 2 f ma x toot gaya → aliasing hoti hai.
Yeh step kyun? Sirf f N se strictly neeche wala content safe hai. Uske upar kuch bhi fold ho jaata hai.
Step 2. Alias formula apply karo:
f a l ia s = 7 − 10 ⋅ round ( 10 7 ) = ∣ 7 − 10 ⋅ 1 ∣ = 3 kHz .
round(7/10)=1 kyun? 0.7 nearest whole number of full sampling-rate hops tak round hota hai, jo 1 hai. Tone f s ki doosri side par 3 kHz hai.
Step 3. Interpretation: ek 7 kHz input ek false 3 kHz tone ke roop mein record hoti hai.
Yeh disguise kyun karta hai: cos ( 2 π ⋅ 7000 t ) aur cos ( 2 π ⋅ 3000 t ) har sample instant t = n /10000 par identical values hit karte hain.
Verify: 3 kHz < f N = 5 kHz ✓ (ek valid, representable frequency). Aur 7000 aur 3000 exactly 10000 = f s se differ karte hain — ek folding partner. ✓ Neeche folding picture dekho.
Worked example Ex 5 — Kya yeh design safe hai, aur kitna?
Ek signal mein 4 kHz se upar kuch nahi hai. Isse f s = 44.1 kHz par sample kiya gaya hai. Kya yeh alias ho gaya? Safety margin ratio f s / ( 2 f ma x ) kya hai?
Forecast: obviously safe — lekin guess karo: kya margin 2 × , 5 × , ya bahut bada hai?
Step 1. Nyquist frequency f N = 44100/2 = 22050 Hz . Highest content = 4000 Hz .
Yeh step kyun? Hum highest real frequency ko f N se compare karte hain.
Step 2. 4000 < 22050 , toh f s > 2 f ma x hold karta hai → koi aliasing nahi .
Kyun: kuch bhi fold line se upar nahi jaata, toh kuch fold wapas nahi aata.
Step 3. Margin ratio:
2 f ma x f s = 2 × 4000 44100 = 8000 44100 ≈ 5.51.
Yeh kyun compute karte hain? Parent ≥ 2.5 × recommend karta hai filter roll-off room ke liye; yahan hum ∼ 5.5 × oversample kar rahe hain, bahut comfortable.
Verify: alias formula sanity check ke roop mein apply karo — round ( 4000/44100 ) = round ( 0.0907 ) = 0 , toh f a l ia s = ∣4000 − 0∣ = 4000 Hz : unchanged, koi fold nahi. ✓
f s = 2 f " ek trap kyun hai
Ek 500 Hz sine ko exactly f s = 1000 Hz = 2 f par sample kiya gaya hai. Dikhao ki reconstruction fail ho sakta hai even though arithmetic 2 f "just satisfy" karta hai.
Forecast: parent kehta hai Nyquist condition strict hai (> , ≥ nahi). Guess karo exact boundary par kya galat hota hai.
Step 1. Sample instants: t = n /1000 seconds. Sine hai sin ( 2 π ⋅ 500 t ) .
Yahan sine kyun? Hum deliberately ek aisa phase choose karte hain jahan danger dikhta hai: sine choose karne ka matlab hai samples zero crossings par hit kar sakte hain.
Step 2. Har sample par evaluate karo:
sin ( 2 π ⋅ 500 ⋅ 1000 n ) = sin ( π n ) = 0 for every integer n .
Yeh step kyun? 500/1000 = 2 1 , toh har step angle ko exactly π advance karta hai — hamesha ek zero crossing par land karta hai.
Step 3. Har sample 0 hai. Recorded signal silence hai — amplitude kho jaata hai.
Yeh boundary lesson kyun hai: f s = 2 f par ek period ke do samples dono zeros par baith sakte hain, toh amplitude (aur isliye tone) guarantee se survive nahi karta. Isliye exactly yeh condition f s > 2 f ma x , strict hai.
Verify: sin ( π n ) = 0 for n = 0 , 1 , 2 , 3 → sampled sequence sab zeros hai, failure confirm karta hai. ✓
Worked example Ex 7 — Teen tones, ek sampling rate
Ek signal 300 Hz , 2.5 kHz , aur 9 kHz tones ka sum hai. Teeno ko bina aliasing ke capture karne ke liye minimum sampling rate kya hai?
Forecast: kaunsa tone rule set karta hai? Minimum f s guess karo.
Step 1. f ma x dhundho = sabse zyada frequency present = 9 kHz .
Yeh step kyun? Nyquist sirf top frequency ki parwah karta hai — fold ke upar ek bhi tone sab kuch kharab kar deta hai.
Step 2. Strict rule apply karo:
f s > 2 f ma x = 2 × 9000 = 18000 Hz .
Strict kyun? Ex 6 se, exactly 18 kHz zero-crossing failure ka risk rakhta hai; isse kuch bhi upar pick karo.
Step 3. Parent ka recommend kiya practical margin add karo (≥ 2.5 × filter roll-off ke liye):
f s ≈ 2.5 × 9000 = 22500 Hz ⇒ pick a standard f s ≥ 22.5 kHz (e.g. 44.1 kHz).
Standard rate tak round up kyun? Real hardware clocks standard values mein aate hain; overshoot free safety hai.
Verify: f s = 18000 par, lower tones alias-check: round ( 300/18000 ) = 0 aur round ( 2500/18000 ) = 0 , toh dono unchanged pass hote hain (f a l ia s = 300 aur 2500 ). Sirf 9 kHz tone boundary par baithta hai, confirm karta hai ki wahi binding constraint hai. ✓
Worked example Ex 8 — Temperature logger design
Tum ek room temperature log karte ho jo ek sensor se 0 –3.3 V range karta hai. Tumhe 1 mV ya usse fine ke steps resolve karne hain. (a) Minimum number of bits? (b) Signal ki fastest meaningful variation 2 Hz hai — minimum f s kya, aur kya tumhe anti-alias filter chahiye?
Forecast: bit count guess karo — 8, 10, ya 12? Aur kya 2 Hz ek demanding sampling problem hai?
Step 1. Resolution requirement se bits. Humein LSB ≤ 1 mV chahiye:
2 N − 1 3.3 ≤ 0.001 ⇒ 2 N − 1 ≥ 3300 ⇒ 2 N ≥ 3301.
Yeh inequality kyun? Chhota LSB zyada levels maangta hai; zyada levels zyada bits maangti hain.
Step 2. Solve karo: 2 11 = 2048 (bahut kam), 2 12 = 4096 ≥ 3301 (kaafi). Toh N = 12 bits.
Round up kyun? Tum fractional bit nahi khareed sakte; tum next whole bit lete ho jo requirement clear kare.
Step 3. Achieved LSB check karo: LSB = 3.3/4095 ≈ 0.806 mV ≤ 1 mV ✓.
Re-check kyun? Confirm karta hai ki chosen bit count actually 1 mV spec meet karta hai.
Step 4. Sampling: f ma x = 2 Hz , toh f s > 4 Hz . 10 Hz bhi generous hai.
Anti-alias filter? Temperature physically kilohertz rates par change nahi ho sakta, toh fold karne ke liye bahut kam high-frequency energy hai — ek simple RC low-pass (cutoff kuch Hz) kaafi hai. Dekho Anti-Aliasing Filters .
Verify: 2 12 = 4096 > 3301 ✓ aur LSB = 3.3/4095 = 0.806 mV < 1 mV ✓; f s = 10 > 4 ✓.
Worked example Ex 9 — 80 dB SNR ke liye kitne bits chahiye?
Ek audio ADC ko kam se kam 80 dB signal-to-noise ratio tak pahunchna hai. Ideal ceiling SNR m a x = 6.02 N + 1.76 dB use karke, minimum N nikalo.
Forecast: roughly 6 dB per bit, toh guess karo — 12 bits? 14? 16?
Step 1. Ceiling ko spec meet karne ke liye set karo aur N ke liye solve karo:
6.02 N + 1.76 ≥ 80 ⇒ 6.02 N ≥ 78.24 ⇒ N ≥ 12.997.
Is tarah solve kyun? SNR N mein linearly badhta hai; hum line ko invert karte hain bit count paane ke liye.
Step 2. Next whole bit tak upar round karo: N = 13 .
Up kyun, nearest nahi? N = 12.997 thoda 80 dB se kam hai; N = 13 sabse chhota integer hai jo spec clear karta hai.
Step 3. Confirm karo ki 13 bits kya deliver karta hai:
SNR m a x = 6.02 × 13 + 1.76 = 80.02 dB ≥ 80 dB .
Check kyun? Ensure karta hai ki hum ne under-round nahi kiya.
Verify: N = 12 deta hai 6.02 × 12 + 1.76 = 74.0 dB < 80 (fail), N = 13 deta hai 80.02 dB ≥ 80 (pass) — toh 13 genuinely minimum hai. ✓ (Iske baare mein aur Quantization Noise & SNR mein.)
Worked example Ex 10 — Zero-order hold staircase aur uske images
Ek DAC f s = 8 kHz par codes output karta hai, har sample ko ek period ke liye constant hold karta hai (zero-order hold). Wanted signal ek 1 kHz tone hai. (a) Har held step kitna lamba hai? (b) Pehle spectral "image" copies kahan land karte hain, aur reconstruction filter ka cutoff kya hona chahiye?
Forecast: step duration guess karo, aur guess karo ki junk images 1 kHz ke paas hain ya 8 kHz ke paas.
Step 1. Step (hold) duration:
T s = f s 1 = 8000 1 = 125 μ s .
Yeh step kyun? Har sample exactly ek sampling period ke liye hold kiya jaata hai, staircase ke flat treads produce karta hai.
Step 2. Zero-order hold f s ke har multiple ke around signal spectrum ki copies (images) create karta hai. 1 kHz tone ki nearest images yahan appear karti hain:
f s − 1 kHz = 7 kHz and f s + 1 kHz = 9 kHz .
Yahan kyun? Staircase ke sharp steps high-frequency content se bane hain — mathematically, baseband tone ki mirror copies ∣ k f s ± f ∣ par baithti hain.
Step 3. Reconstruction filter cutoff Nyquist frequency par:
f c ≈ f N = 2 f s = 4 kHz .
f s /2 kyun? Yeh wanted 1 kHz tone pass karta hai (4 kHz se neeche) jabki 7 kHz aur 9 kHz images block karta hai — staircase ko wapas ek clean sine mein smooth karta hai. Dekho Zero-Order Hold & Reconstruction .
Verify: wanted 1 kHz < 4 kHz (passes) ✓; first image 7 kHz > 4 kHz (blocked) ✓; step time 125 μ s × 8000 = 1 full second of samples per 8000 steps — f s = 8 kHz ke saath consistent. ✓
Mnemonic Main kaunse cell mein hoon?
Do sawaal poochho. "Kya yeh ek amplitude question hai ya time question?" Amplitude → bits/LSB/SNR (cells A–C, I). Time → Nyquist/aliasing/DAC (cells D–H, J). Phir: "Kya main ek boundary par hoon?" Boundaries (2 N − 1 , exactly 2 f , top code) wahin hain jahan traps rehte hain.
ADC - DAC — resolution, sampling rate, Nyquist (index 5.5.4) — parent topic
Quantization Noise & SNR — Ex 9 mein use kiya gaya 6.02 N + 1.76 ceiling
Anti-Aliasing Filters — cells D aur H ka fix
Zero-Order Hold & Reconstruction — Ex 10 ka staircase
Fourier Transform & Frequency Domain — images aur folding exist kyun karte hain
Successive Approximation vs Sigma-Delta ADC — yeh numbers hardware kaise bante hain
Sensor Interfacing on Microcontrollers — Ex 3 se dead-code fix