User:Pryrt/sandbox1

Inspired by ENOB
While trying to determine the derivation of ENOB, since I can never remember where the 6.02 and 1.76 come from, I discovered a significant lack of detail in the ENOB page. However, my derivation isn't ready for prime time.

Derivation
First, assume an ideal A/D or D/A converter: it's only source of noise is Quantization error (QE).

Briefly, QE is the difference between the desired value and the actual quantized [digital] value—if you want 1.7 codes, but you've got a 1-code resolution, you'll get 2 codes, which is a 0.3 code quantization error. The size of a quanta in our converter is 1 LSB (least significant bit), and the most our ideal converter will be off is ±½ LSB. The (RMS) amplitude of the QE will be the root of the average of the squared error, $$E^2$$:



\begin{align} QE_{RMS} & = \sqrt{ \frac{1}{LSB} \cdot \int_{-LSB/2}^{+LSB/2}\,E^2\,dE } \\ & = \sqrt{ \frac{1}{LSB} \cdot \left [ \frac{1}{3} E^3 \right ]_{-LSB/2}^{+LSB/2} } \\ & = \sqrt{ \frac{1}{3 \cdot LSB} \cdot \left [ (LSB/2)^3 - (-LSB/2)^3 \right ] } \\ & = \sqrt{ \frac{1}{3 \cdot LSB} \cdot \left [ \frac{LSB^3}{8} + \frac{LSB^3}{8} \right ] } \\ & = \sqrt{ \frac{1}{3 \cdot LSB} \cdot \left [ \frac{LSB^3}{4} \right ] } \\ & = \sqrt{ \frac{LSB^2}{12} } \\ & = \frac{LSB}{\sqrt{12}} \\ \end{align} $$

Since the converter is ideal, the N of SNR (and the N+D of SINAD) comes completely from QE. First, we'll need the RMS of a full-scale sinusoid in an N-bit device:



\begin{align} V_{RMS} & = \sqrt{ \frac{1}{2 \pi} \cdot \int_{0}^{2 \pi}\,\left ( \left ( \frac{2^N \cdot LSB}{2} \cdot \cos{\theta} \right )^2 d\theta \right ) } \\ & = \sqrt{ \frac{2^{2N} \cdot LSB^2}{8\pi} \cdot \int_{0}^{2 \pi}\,\cos^2{\theta}\,d\theta } \\ & = 2^N \cdot LSB \cdot \sqrt{ \frac{1}{8 \pi} \cdot \left [ \frac{\theta}{2} + \frac{\sin{2\theta}}{4} \right ]_0^{2\pi} } \\ & = 2^N \cdot LSB \cdot \sqrt{ \frac{1}{8 \pi} \cdot \left [ \frac{2\pi}{2} + \frac{\sin{4\pi}}{4} - \frac{0}{2} - \frac{\sin{0}}{4} \right ] } \\ & = 2^N \cdot LSB \cdot \sqrt{ \frac{1}{8 \pi} \cdot \frac{\pi}{1} } \\ & = 2^N \cdot LSB / \sqrt{8} \\ \end{align} $$

Now we can compute the ideal SNR (in V/V) by setting the signal to the RMS sinusoid, and the noise to QE_{RMS}:



\begin{align} SNR_{V/V} & = S / N = V_{RMS} / QE_{RMS} \\ & = \frac{2^N \cdot LSB / \sqrt{8} }{LSB / \sqrt{12}} \\ & = 2^N \cdot \frac{\sqrt{12}}{\sqrt{8}} \\ & = 2^N \cdot \sqrt{\frac{12}{8}} \\ & = 2^N \cdot \sqrt{{3}/{2}} \\ \end{align} $$

To get the famous equation, convert V/V to dB:



\begin{align} SNR_{dB} & = 20 \cdot \log_{10} \left ( 2^N \cdot \sqrt{{3}/{2}} \right ) \\ & = 20 \cdot \log_{10}(2) \cdot N + 20 \cdot \log_{10}(\sqrt{1.5}) \\ & = 20 \cdot \log_{10}(2) \cdot N + 10 \cdot \log_{10}(1.5) \\ & = 6.0206 \cdot N + 1.7609 \\ \end{align} $$

That's the ideal signal-to-noise, which means it's also the best-case SINAD for a converter. If we take the measured SINAD from a real-world converter, and plug it back into the equation, the number of bits we calculate would be the effective number of bits in an ideal converter that would generate that SINAD: i.e., the ENOB: $$ N = ENOB = \frac{SINAD - 1.7609}{6.0206} $$

Error
There was an implicit (and inaccurate) assumption in the above derivation: that the peak-to-peak amplitude of the converter sinusoid was $$2^N LSB$$. For the converter, the codes will range from $$0\mbox{ to }(2^N-1)$$, or from $$-2^{(N-1)}\mbox{ to }(2^{(N-1)}-1)$$, with a span of $$2^N-1$$ LSBs. Thus, we really have


 * $$ SINAD = 20 \cdot \log_{10} \left ( (2^N-1) \cdot \sqrt{{3}/{2}} \right ) $$

However, for anything 5 bits or above, it's less than 1% error.

Also, based on implications in Gerard and Quantization error, the $$QE_{RMS}$$ derivations assumes a reasonably uniform distribution of the error in order for the integral to hold true. (I'm not a mathematician, but I would think that the sum of the squared errors, even if they aren't continuous or uniform, would still come out close to a third of the cube... but I'm probably wrong.)