Electronic – Improving PWM by using comparison to LFSR instead of counter

dacpwm

PWM is a very powerful technique to simulate an analog output from a microcontroller, programmable logic or any other digital environment. This can be used to drive LEDs, motors and speakers, etc… without the need of an external DAC component (in some cases a low-pass filter is necessary).

A PWM is typically made by using a counter and a comparator. The counter constantly counts and rolls up, and when it is above a threshold value (the desired % of output voltage), then a '1' logic is send, when below a '0' logic is send.

The main problem of PWM is that there is a tradeoff between precision and frequency: If one more bit is needed for precision, it means that the counter will take twice as long before it rolls again, and as such the parasite frequencies that will have to be filtered off are lower in the spectrum, thus closer to the signal and harder to filter.

For these reasons, PWM is inapplicable for signals that should either

  1. Have high analogue frequencies
  2. Needs too many bits in the DAC

My idea is simple, instead of using a N bit counter, I use a random number generator, made by taking the high (or low ?) N bits of a M bit LFSR (for example, use the lowest 8 bits of a 16 bit LFSR). That way, instead of outputting a square wave with a variable pulse width, we output a steam of random pulses.

The probability that a pulse is '1' is equal to the ratio between the desired output voltage, and the maximum output voltage. As such, the result is exactly the same as PWM, exept that the parasite frequencies are now random, and such are much easier to filter. It is now possible to add as many bits as necessary for the ADC, and this won't cause any problems.

For example, it becomes possible and actually very simple to have 16-bit Audio output with a 1MHz clock. With traditional PWM this would never has been possible: Only a 5-bit audio signal would have been possible without either a hearable audio fuzz.

Will this work? Since this idea is so simple and improves the PWM technique so much, why is it not mentioned in anywhere?

Best Answer

I thought I'd sum up my comments in an answer - maybe it'll be of some use to somebody.

  1. Using white noise will make it harder to remove the modulation signal rather than easier. In the case of a normal PWM signal, you need a low pass and you are done. When using white noise to do the modulation you will cause noise in the same frequency range as the signal you are trying to create. This cannot easily be removed.
  2. The noise left in your generated signal will be about 14dB below the level of the white noise that you used as a modulator signal. Assuming true white noise up to 1MHz as in your example, then the amount of noise left is a simple proportion. 44100Hz/1MHz gives 4.41 percent or about -14dB.
  3. I verified my estimate above by generating a white noise signal with a 1MHz sampling rate then filtering and resampling down to 44100Hz. The resulting signal was indeed 14dB below the original white noise signal.
  4. Interestingly enough, 14dB is also about the dynamic range of the 5Bit sampling at 1MHz mentioned in the question. So, you don't really gain anything in the signal to noise department. You trade scratchy 5Bit quantized audio that is at least quiet when there's no signal to get a signal that is quantized at a much higher bit depth but has a constant white noise at -14dB - even when there's no actual signal present.

So, the idea does and doesn't work.

As you expected, you can use noise modulation to get a better bit depth and have less quantization error by spreading the modulation signal over the entire bandwidth.

That comes at the cost of not being able to remove the modulation noise from the generated output signal so that you end up with the same signal to noise ratio.

All you've done is to change the cause of the poor signal to noise ratio.