eRCaGuy_Timer2_Counter (downloadable Arduino library)
Recommended donation: $5 for home use; $50~$100+ for business use under the included copy-left, open-source GNU GPLV3 or later license (contact me for other license options).
Enter a donation amount, or $0, above. Donations are greatly appreciated.
License: open-source, copy-left GNU GPLV3 or later license. Commercial (closed-source, proprietary) licenses sold at request. Contact me if desired.
Have you ever noticed that when you call the Arduino micros() function, it only returns values in multiples of 4 microseconds? Have you ever wished you could get higher-resolution time-stamps, to decrease error and jitter when reading pulse widths or frequencies? If so, this library is for you! It will give you a substitute for the micros() function with up to 8x better resolution.
"Dude, your lib is really very useful and precise." ~André Frazatto
"Thanks for posting this code, it saved me from a couple more hours of debugging" ~Adam Krasuski
Your donations brighten my day, help support my family, and keep me doing and sharing my projects! :)
This Arduino library allows you to call a method like timer2.get_micros() in place of just micros(), in order to get a time stamp with a resolution of 0.5us instead of 4us. This is very useful when you need to determine periods and frequencies very precisely. Check out the examples. You may find the "read_PWM_pulses_on_ANY_pin_via_pin_change_interrupt" example especially useful, as it will measure the period of a PWM pulse, fast or slow, on *any* pin, and print the result to the serial monitor. This can be used to read an RC PWM pulse as well.
Library webpage: http://www.electricrcaircraftguy.com/2014/02/Timer2Counter-more-precise-Arduino-micros-function.html.
You'll get one downloadable zip file.