user32290: How to obtain four PWM outputs at 100 kHz using an arduino uno board? The requirement is that all four PWM outputs should have controllable duty ratios individually.

user13327: You can't squeeze 100kHz out of an Arduino without a major software rewrite (at which point you will be using an AtMega chip rather than Arduino). analogWrite defaults to ~500Hz and can be boosted to 62.5kHz on some Arduino models, and only for 2 pins. Other PWM pins are capped at 31.4kHz.
You can achieve 100kHz PWM by toggling pins manually and busy-waiting, but you won't be able to do anything else during this. Or you can make use of interrupts, which is a big leap from Arduino ecosystem as I already said.

user7508: In a comment to Dmitry Grigoryev’s answer you wrote:
void setup()
{
    TCCR2A = 0x23;
    TCCR2B = 0x09;
    OCR2A = 159;
    pinMode(3, OUTPUT);
}

void loop()
{
    OCR2B = 80;
}

It seems you already have the solution to your problem: that's exactly
the way to do it!
Well, there is a catch: since you are using OCR2A to define the period
of your timer, this means you are left with a single PWM channel, where
the duty cycle is controlled by OCR2B. Given that the Arduino Uno has
only three timers, it would seem you can only have up to three PWM
channels at 100 kHz.
But there is a solution. Timer 1 has a feature the other timers
don't have: you can define its period using using the input capture
register ICR1 instead of OCR1A. This leaves you both output compare
registers available for PWM. For this you have to set the timer into
waveform generation mode 14, i.e. fast PWM with TOP = ICR1.
Now you can have your four channels, with Timer 0 driving
pin 5, Timer 2 driving pin 3, and Timer 1 driving
pins 9 and 10.
Some caveats:

As already pointed out by Dmitry Grigoryev, your PWM resolution is
slightly reduced.
By reconfiguring Timer 0, you loose the Arduino Timekeeping function
millis(), micros() and, delay(). You could write your own ISR to
count the overflows of some other timer, but it would be called every
10 µs: even if it is very short it would eat a non-trivial
fraction of your CPU power.


32290: <p>How to obtain four PWM outputs at 100 kHz using an arduino uno board? The requirement is that all four PWM outputs should have controllable duty ratios individually.</p>
 13327: <p>You can't squeeze 100kHz out of an Arduino without a major software rewrite (at which point you will be using an AtMega chip rather than Arduino). <code>analogWrite</code> defaults to ~500Hz and can be boosted to <a href="http://playground.arduino.cc/Main/TimerPWMCheatsheet" rel="nofollow noreferrer">62.5kHz</a> on some Arduino models, and only for 2 pins. Other PWM pins are capped at 31.4kHz.</p>

<p>You can achieve 100kHz PWM by toggling pins manually and busy-waiting, but you won't be able to do anything else during this. Or you can make use of interrupts, which is a big leap from Arduino ecosystem as I already said.</p>
 7508: <p>In a comment to Dmitry Grigoryev’s answer you wrote:</p>

<pre class="lang-c++ prettyprint-override"><code>void setup()
{
    TCCR2A = 0x23;
    TCCR2B = 0x09;
    OCR2A = 159;
    pinMode(3, OUTPUT);
}

void loop()
{
    OCR2B = 80;
}
</code></pre>

<p>It seems you already have the solution to your problem: that's exactly
the way to do it!</p>

<p>Well, there is a catch: since you are using <code>OCR2A</code> to define the period
of your timer, this means you are left with a single PWM channel, where
the duty cycle is controlled by <code>OCR2B</code>. Given that the Arduino Uno has
only three timers, it would seem you can only have up to three PWM
channels at 100&nbsp;kHz.</p>

<p>But there is a solution. Timer&nbsp;1 has a feature the other timers
don't have: you can define its period using using the input capture
register <code>ICR1</code> instead of <code>OCR1A</code>. This leaves you both output compare
registers available for PWM. For this you have to set the timer into
waveform generation mode&nbsp;14, i.e. fast PWM with TOP =&nbsp;ICR1.
Now you can have your four channels, with Timer&nbsp;0 driving
pin&nbsp;5, Timer&nbsp;2 driving pin&nbsp;3, and Timer&nbsp;1 driving
pins&nbsp;9 and 10.</p>

<p>Some caveats:</p>

<ul>
<li><p>As already pointed out by Dmitry Grigoryev, your PWM resolution is
slightly reduced.</p></li>
<li><p>By reconfiguring Timer 0, you loose the Arduino Timekeeping function
<code>millis()</code>, <code>micros()</code> and, <code>delay()</code>. You could write your own ISR to
count the overflows of some other timer, but it would be called every
10&nbsp;µs: even if it is very short it would eat a non-trivial
fraction of your CPU power.</p></li>
</ul>
