title: Using 4 16bit timers for 400hz PWM
body: <p>I'm dealing with arduino mega based quadcopter and trying to make PWM frequency for 4 motors - 400hz each.<br> I've found an interesting solution where 4 ATmega2560 16bit timers are used to control 4 ESCs with PWM so it could reach 400hz frequency. 700 to 2000µs are normal pulse widths ESC are dealing with. 
  <br>
  1sec/REFRESH_INTERVAL = 1/0.0025 = 400hz.</p>
  
  <pre><code>this is servo.h lib:
  #define MIN_PULSE_WIDTH       700     // the shortest pulse sent to a servo  
  #define MAX_PULSE_WIDTH      2000     // the longest pulse sent to a servo 
  #define DEFAULT_PULSE_WIDTH  1000     // default pulse width when servo is attached
  #define REFRESH_INTERVAL     2500     // minimum time to refresh servos in microseconds 
  
  #define SERVOS_PER_TIMER       1     // the maximum number of servos controlled by one timer 
  #define MAX_SERVOS   (_Nbr_16timers  * SERVOS_PER_TIMER)
  </code></pre>
  
  <p>The problem is to make it work each PWM should be controlled with 1 16bit timer. Otherwize, say, 2 escs on 1 timer would give 200hz. So all of 16bit timers are busy controlling 4 ESC but I still need to read input PPM from receiver. To do so I need at least one more 16bit timer which I don't have anymore.<br> It's still one 8bit timer free bit it can only read 0..255 numbers while normal number escs operate with are 1000..2000 and stuff.</p>
  
  <p>So what would happen if I'll use same 16bit timer for both pwm and ppm reading? Would it work? Would it decrease speed drastically?<br> I have arduino working in pair with Raspberry Pi which controls data filtering, debugging, and stuff, is it better to move ppm reading to Raspberry?</p>