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
- Have high analogue frequencies
- 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?