# PWM samplerate to equal PCM accuracy

How fast samplerate 1 bit PWM needs to equal 16 bit 48khz PCM?

1 second signal = 48000 samples,each sample can be anywhere from -32767 to +32768,therefore 1 second of 16bit 48khz PCM contains 65536^48000 possible combinations,thats very big number!

I was thinking about this,correct me if I am wrong,for 1 bit PWM signal to equal acuracy of 16bit 48khz PCM,it would need to run at 3145728000hz samplerate,that is 3 GHZ.

Now I would like to mention music format known as DSD,its 1 bit,running at 64x sampling rate of RedBook,that is 44100 x 64 = 2822400hz... thats 3 MHZ not GHZ,that is orders of magnitude bellow what I calculated to be minimum for 1bit signal to equal acuracy of PCM.

DSD is using noiseshaping,it helps to push the noisefloor down in the audible range,but that doesnt make up for fact that the samplerate is far too low to be able to reproduce all the possible combinations of sound in given lenght of signal equal to PCM ( right? )

PWM in audio is widely used in Class D amplifiers,doing a research I found out that they run even slower,some of them bellow the MHZ range,250khz for example,I am thinking,PWM freqency that slow must have much lower accuracy than PCM

It must be throwing away information because the 1bit PWM even when running at high speeds just doesn't equal the data bandwidth of PCM if it's not in the gigahertz range. Is what I have written true or false?

• does it have to be real PWM (like a square wave with a reasonably constant duty cycle) or does it just need to be a toggling bit, like the +1 and -1 you get with DSD (Direct Stream Digital)? if the latter, supposedly there is this Gerzon-Craven limit or look at Lipshitz. that means 16x oversampling is the minimum you need to ever hope to match 16-bit words at 1x. but the noise-shaping filters are a bitch. in reality, i think you will need 64x or 128x oversampling (and good error feedback) to get 96 dB S/N. – robert bristow-johnson Nov 14 '16 at 4:34
• your understanding is pretty good. 64x DSD is less efficient and more wasteful with the data than 1x 16-bit PCM. and they will likely have about the same dynamic range (which is dB S/N + dB headroom) in the spectrum below 24 kHz. but the 1-bit 64x DSD requires 4 times the number of bits as does the 16-bit 1x PCM – robert bristow-johnson Nov 14 '16 at 4:38
• robert bristow-johnson I request for you to IMMEDIATELY reverse the edit you applied to my question.You completly changed the most important part,the question as it is after you changed it is completly useless for me.Put back my numbers " 3145728000hz",yes thats 3 GIGA hertz.No,I didnt meant 64x48khz,I meant 65536x48khz! – Sweeper Nov 14 '16 at 7:22
• well, the premise to the questions is quite flawed. it can't really be answered because of the flawed premise. but i'll roll it back. – robert bristow-johnson Nov 15 '16 at 1:49
• robert bristow-johnson I gained better knowledge and I see what is problem,we were thinking about different things.You was thinking Delta Sigma modulation with noiseshaping like DSD,yes it needs only 64x oversample to equal 16bit PCM,but I was thinking about pure Delta modulation,no sigma,no noise shaping,in that case I am right that it needs to be going at 3 giga hertz to match 16 bit PCM – Sweeper Nov 17 '16 at 0:00

Short answer: For a direct implementation of PWM in discrete-time, yes, for 48 kHz, 16-bit audio, a clock of 3.2 GHz is required.

Direct Stream Digital (DSD) format uses 1-bit $\Delta$-$\Sigma$ modulation (DSM), which is somewhat different than pulse-width modulation (PWM), although both generate an on-off switched sequence as the output.

Regular PWM uses a comparator (the sign function), where the input is a modulating (the desired signal) and a high-frequency carrier signal. The harmonic and intermodulation distortion between the desired signal and the carrier signal are what is going to determine the unwanted signal output limiting the signal-to-noise-and-distortion (SINAD) ratio. With a triangle-wave carrier with frequency $\omega_c$, the output for a single sinusoid with frequency $\omega_v$ and amplitude $M$ between 0 and 1 is: $$PWM(\omega) = \frac{1}{2} M \cos{\omega_v t} \\ + 2 \sum_{m=1}^{\infty} \frac{J_{0}\left(\frac{1}{2} m \pi M \right)}{\pi m} \sin\left(\frac{1}{2} \pi m \right) \cos\left(m \omega_c t \right) \\ + 2 \sum_{m=1}^{\infty} \sum_{n=\pm 1}^{\pm \infty} \frac{J_{n}\left(\frac{1}{2} \pi m M \right)}{\pi m} \sin\left(\frac{1}{2} \pi (m+n) \right) \cos\left((m \omega_c + n \omega_{v} ) t\right)$$ $J_n$ denotes the n-th order Bessel function. The first line has your desired sinusoidal signal, the second and third line are harmonic and intermodulation distortion. This is entirely deterministic and similar spectra can be computed for any input signals that can be described by Fourier-series. Sample rate does not play a role in the ideal, continuous-time case. The distortion products can typically be moved to higher frequencies and filtered out by a low-pass filter by choosing a higher carrier frequency $\omega_c$, but there is no guarantee that intermodulation products will not appear in the baseband. The third line contains what is called foldback distortion, and as you can see, there will always be distortion in the baseband, and there is no way to guarantee that some input signal will not cause some combination of superpositions that cause severe foldback distortion. The best you can hope for is that the foldback distortion is small for most signals (which it usually is, and it is dominated by other noise sources).

Discretization (quantization and sampling) effects cause additional distortion, and several PWM methods try to take this into account. As you have discovered, you need very high time-resolution in order to represent large word-widths where there is discretization in time. This does not mean that the (average) switching frequency has to be high, only that the time-resolution is high. That is, you need to represent your output sequence as a non-uniformly sampled signal. Hence you don't need a high sampling rate, only a mechanism on the output that can cause non-uniform switching with that accuracy. This does makes it difficult to accurately simulate PWM. There are several PWM-like methods that seek to solve these distortion problems.

DSM (noise-shaping using 1-bit) also uses the comparator, but there is no carrier signal. Instead there is feedback from the error between the input and output of the comparator. By virtue of Bode's sensitivity integral, it is then possible to spectrally shape the error, dependent on the feedback filter used. As the comparator is a discontinuous non-linearity (no Lipshitz constant), there does currently not exist any theory with regards to the stability of DSM, and the successful design is entirely dependent on simulations. It works most of the time because in most cases you have an actuating signal to the comparator that causes some sort of averaging, causing the discontinuity to become effectively continuous. The DSM does go unstable and produce weird results in some pathological cases. So in general, it does not work, it just works most of the time. In DSM the distortion is also entirely deterministic, although it can be chaotic. It is impossible to de-correlate the distortion in DSM from the input.

I do not know of any methodology other than (Monte-Carlo) simulation for reliably determining an approximate SINAD in either case.

I've added a couple of figures comparing PWM and DSM with 1-bit truncation.

Time-series after reconstruction:

Power Spectral Densities (up to 2 kHz):

For DSM a 5th order feedback-filter was used, oversampling rate of 128, and sample rate of 1 MHz. With this it is possible to achieve an ENOB in excess of 17 bit with a 2-kHz baseband. For audio this would have to be 20 kHz, hence a sampling rate of 10 MHz. The PWM carrier was at 4 kHz. Most of the distortion (the noise-floor) stem from time discretization, not having introduced proper pre-distortion needed for discrete-time PWM, and will not represent ideal (natural) PWM very well. I will see if I can update this later. Using proper pre-distortion you should see a SINAD in excess of 100 dBc (ENOB > 16 bit). A 1-bit truncated signal can have an ENOB less than one since the ENOB is based on the uniform quantization error distribution assumption with is only approximately valid for 7-bit quantization or higher.

Why not just use a 1-bit DSM re-quantization (e.g. DSD) which is much more linear than a PCM-PWM conversion? The answer to this is switching losses. With high OSR and high and irregular switching activity, the DSM bit-stream in its basic form is not very suitable to drive high power Class-D amplifiers. Likewise, PWM due to its two-level representation and high jitter susceptibility (the need for good switching time resolution) is not very suitable for high resolution small signal DACs.

It might also be noted, that it is quite common for Class-D amplifiers to re-quantize to e.g. 8-bit using DSM before producing the PWM signal, instead of using complicated pre-distortion and non-uniform switching techniques, as a low word length reduces the required timing-accuracy significantly.

Some literature to check out:

Direct Digital Pulse Width Modulation for Class D Amplifiers

Signal processing for high resolution pulse width modulation based digital-to-analogue conversion

Digital-to-Analog Conversion in High Resolution Audio

Understanding Delta-Sigma Data Converters

Oversampling Delta-Sigma Data Converters

Lee's rule extended (on DSM stability and design)

• 1. "The harmonic and intermodulation distortion between the desired signal and the carrier signal are what is going to determine the unwanted signal output limiting the signal-to-noise-and-distortion ratio" I have no idea what you meant,can you explain it in detail? 2. What is quasi-stationary signal? "Sample rate does not play a role in the ideal case, but discretization effects can cause additional distortion." 3.What is the ideal case? 4. I though higher PWM samplerate is always better 5. discretization = quantizazion? 6. why not guaranteed IMD will not baseband? – Sweeper Nov 16 '16 at 23:28
• 7. what is "discontinuous non-linearity"? non-linearity = distortion,discontinuos = not costant,is it like distortion that pops here and there but it isnt always present? 8. How is it possible for DSM stability simulation to exist if there is no theory? 9. "Time series" is just another word for time domain? 10. Can you explain these two pictures? I dont understand anything. 11. What is "PSD up to 2khz" 12. How can any signal have less than 1 ENOB? 13. 5th order feedback filter = 5th order noise shaper,correct? 14.What do you mean PWM carrier was at 4 khz" 15. What is REQ? – Sweeper Nov 16 '16 at 23:56
• @Sweeper: I've tried to update the answer... – Arnfinn Nov 17 '16 at 23:08
• @Sweeper: With regards to the filters and OSR in DSM, if the linear model holds, then things will improve with higher order filters and higher OSR. But due to the non-linearity, the improvements are hard to predict. A lot of hard simulation work goes into making a well functioning DSM. Also, in general, both for DACs and Class D amplifiers, you want to keep the switching rate low, as you tend to produce a lot of additional distortion energy due to non-ideal effects in transistors if switching rapidly. So high switching rate (OSR) is not necessarily better in practice. – Arnfinn Nov 18 '16 at 4:33
• @Sweeper: There will always be foldback distortion when using PWM, due to the carrier signal needed. DSM will not have this type of distortion. If you have a perfect clock and perfect switch, DSM at 3 GHz likely be better than PWM... – Arnfinn Nov 18 '16 at 13:30