user8552: I am working on comparing autopilots like Ardupilot, CC3D, KK2.1.5. The comparision is about system reactions/behaviors that it gives during flight. For this purpose, I need to read the PWM duty cycle (like osilascopes - the PWM frequency can be vary from 50 to 430 Hz) values from autopilot card. There are 4 command input PWMs and 4 esc control PWMs for a typical quadrotor. I have to read 8 duty cycle values with digital/analog input pins. How do I measure duty cycle of 8 PWM signals?  Also, is digital or analogue measurement precise and faster?
Note about attachInterrupt command: According to arduino.cc AtMega328 series have 2 interrupts, Arduino ATmega 2560 series have 7 interrupts. 

user3917: The code shown in my answer to question 18183, “Read RC receiver channels using Interrupt instead of PulseIn”. That answer has code to read four channels of RC PWM.  It can easily be adapted to work with eight channels.  It has an ISR that runs when selected pins change.  It sorts out which channel(s) changed, and stores the value of micros() at each change.
Also see my answer to question 19106, “Can external interrupts be OR'd together on the '328 (Uno)?”  That answer includes a sketch for generating appropriate ISR code.  My answer to question 32572, “How to detect the direction of a rotary encoder?”, shows another instance.
Digital input, as used in the code mentioned above, takes under  a microsecond ten microseconds in the ISR.  As noted in dannyf's comment, unrolling the for loop and (where possible) using constants instead of variables can reduce the in-ISR time to 3.4 μs.  Note, ISR entry and exit still add several microseconds.
10-bit analog input, on the other hand, will take around 104 microseconds per reading, a time comparable to some of the pulse widths you'll be measuring.  So it isn't fast enough.  If degraded ADC accuracy is acceptable, decreasing the ADC-clock scale factor as explained in a webpage at microsmart.co.za can get AD conversion time down to 20 μs.  This is around three times as long as digital input takes, so rather slow.

8552: <p>I am working on comparing autopilots like <a href="http://ardupilot.org/" rel="nofollow noreferrer">Ardupilot</a>, <a href="http://www.dronetrest.com/t/cc3d-flight-controller-guide/830" rel="nofollow noreferrer">CC3D</a>, <a href="https://www.google.com.tr/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;uact=8&amp;ved=0ahUKEwjN7ubm7dfRAhVnIpoKHfF9DDQQFggZMAA&amp;url=https%3A%2F%2Fwww.rcgroups.com%2Fforums%2Fshowatt.php%3Fattachmentid%3D6646802%26d%3D1396466493&amp;usg=AFQjCNG_tmyH1Ppv2sy7WixUytnVCPFHDA&amp;sig2=pgugQ4brDIwro2KgWw1ziQ&amp;bvm=bv.144224172,d.bGs" rel="nofollow noreferrer">KK2.1.5</a>. The comparision is about system reactions/behaviors that it gives during flight. For this purpose, I need to read the PWM duty cycle (like osilascopes - the PWM frequency can be vary from 50 to 430 Hz) values from autopilot card. There are 4 command input PWMs and 4 esc control PWMs for a typical quadrotor. <strong>I have to read 8 duty cycle values with digital/analog input pins.</strong> How do I measure duty cycle of 8 PWM signals?  Also, is digital or analogue measurement precise and faster?</p>

<p><em>Note about <strong>attachInterrupt</strong> command: According to <a href="https://www.arduino.cc/en/Reference/attachInterrupt" rel="nofollow noreferrer">arduino.cc</a> AtMega328 series have <strong>2</strong> interrupts, Arduino ATmega 2560 series have <strong>7</strong> interrupts.</em> </p>
 3917: <p>The code shown in <a href="https://arduino.stackexchange.com/a/18221/3917">my answer to question 18183</a>, “Read RC receiver channels using Interrupt instead of PulseIn”. That answer has code to read four channels of RC PWM.  It can easily be adapted to work with eight channels.  It has an ISR that runs when selected pins change.  It sorts out which channel(s) changed, and stores the value of <code>micros()</code> at each change.</p>

<p>Also see <a href="https://arduino.stackexchange.com/a/19109/3917">my answer to question 19106</a>, “Can external interrupts be OR'd together on the '328 (Uno)?”  That answer includes a sketch for generating appropriate ISR code.  <a href="https://arduino.stackexchange.com/a/32582/3917">My answer to question 32572</a>, “How to detect the direction of a rotary encoder?”, shows another instance.</p>

<p>Digital input, as used in the code mentioned above, takes under  <strike>a microsecond</strike> ten microseconds in the ISR.  As noted in dannyf's comment, unrolling the <code>for</code> loop and (where possible) using constants instead of variables can reduce the in-ISR time to 3.4 μs.  Note, ISR entry and exit still add several microseconds.</p>

<p>10-bit analog input, on the other hand, will take around 104 microseconds per reading, a time comparable to some of the pulse widths you'll be measuring.  So it isn't fast enough.  If degraded ADC accuracy is acceptable, decreasing the ADC-clock scale factor as explained in <a href="http://www.microsmart.co.za/technical/2014/03/01/advanced-arduino-adc/" rel="nofollow noreferrer">a webpage at microsmart.co.za</a> can get AD conversion time down to 20 μs.  This is around three times as long as digital input takes, so rather slow.</p>
