I think this fits under Microcontrollers (embedded systems). This is just an idea I had few years ago and now I'm considering developing and testing it again.
Pulse Width Modulation (PWM) is usually generated with a counter and a compare value. When the counter is below the compare value, the output is low and otherwise high. The counter is basically a constant frequency sawtooth signal. And the generated PWM signal has the same frequency.. constant frequency which creates a strong peak in the frequency spectrum. This is a problem. Also a sawtooth counter has a poor performance around its most usual working point.. around 50%. At that point you could increase the frequency.
The main thing about a counter counting up from 0 to 255 over and over again at constan frequency is, that the histogram of the generated numbers over time is flat.. all the numbers appear equally often. Of course, because they are ordered from 0 to 255. My solution is to mix these numbers. Instead of using a counter, why not use a Random Number Generator which produces evenly distributed random numbers between 0 and 255. This spreads the frequency spectrum of the generated PWM and works on higher frequencies around the 50% midpoint.
I know this is not exactly very new idea any more. But I am surprised that modern microcontrollers don't have hardware random number generators with comparators and random-pwm output. Last time when I played with this idea, I used an XMega microcontroller with AES crypto engine to produce random numbers and DMA-channel to move them to a buffer efficiently. The comparator was a constant frequency interrupt routine.. so that had to be done in software. I think i got it working around 150kHz. I was planning to use it to control a switched-mode power supply.
Pulse Width Modulation (PWM) is usually generated with a counter and a compare value. When the counter is below the compare value, the output is low and otherwise high. The counter is basically a constant frequency sawtooth signal. And the generated PWM signal has the same frequency.. constant frequency which creates a strong peak in the frequency spectrum. This is a problem. Also a sawtooth counter has a poor performance around its most usual working point.. around 50%. At that point you could increase the frequency.
The main thing about a counter counting up from 0 to 255 over and over again at constan frequency is, that the histogram of the generated numbers over time is flat.. all the numbers appear equally often. Of course, because they are ordered from 0 to 255. My solution is to mix these numbers. Instead of using a counter, why not use a Random Number Generator which produces evenly distributed random numbers between 0 and 255. This spreads the frequency spectrum of the generated PWM and works on higher frequencies around the 50% midpoint.
I know this is not exactly very new idea any more. But I am surprised that modern microcontrollers don't have hardware random number generators with comparators and random-pwm output. Last time when I played with this idea, I used an XMega microcontroller with AES crypto engine to produce random numbers and DMA-channel to move them to a buffer efficiently. The comparator was a constant frequency interrupt routine.. so that had to be done in software. I think i got it working around 150kHz. I was planning to use it to control a switched-mode power supply.
Last edited: