Existing library for reading PWM signals


I just bought an Arduino Zero and realized that the pulsein() function isn't what I needed to read in PWM outputs from an encoder that I have.

The encoder outputs a continuous PWM output at 1kHz so using looping the pulsein() function to read the PWM values would hog up the processor all the time.

I am moving from a Pololu Orangutan MCU to the Arduino platform and Pololu wrote a very nice library for reading PWMs based on pin change interrupts: https://www.pololu.com/docs/0J18/8

Is there a library similar in the Arduino world? I haven't found anything yet and don't want to reinvent the wheel if such a library already existed.


There have got to be libraries like that for Arduino. I'm sure there are for AVR-based boards. You may be out of luck with the Zero though, as it's new, and since it's a different architecture, it may be that nobody has written that for it yet...

I'm thinking that even though the Zero is ARM based, as long as I can get an existing library for the AVR based ones, it's easier to modify the library than having to start from scratch.