Using Hall Sensor(TLE-4905) with Arduino Mega

Cattledog .... thanks for your comments and recommendations. My aim is/was to get as accurate RPM readings as I can from a fairly small DC motor (pretty-much unloaded, or lightly-loaded via a shaft that attaches to a rotary encoder for RPM measurements), and see if the arduino mega 2560 is able to do some closed-loop control on the dc motor's RPM (basic rpm step response) ---- like a rolling start ... eg 1000 rpm to 2000 rpm. The aim is to just get a rough 'Kv' value --- ie. rough Kv factor to cover linear RPM versus pwm (sure --- there's dead-band to consider), and rough 'first order' time constant. And hopefully will get the system to work roughly like a second order system. My dc motor will only work up to around 4000 rpm max --- usually operating around 1000 to 3500 rpm range.

I was thinking that if I can use the method based on your code, then at least I might be able to fairly conveniently get decent RPM measurements and do some motor control the same time.

Now, with Nick Gammon's frequency counter method --- that uses two timers --- one for counting and the other for controlling gating duration. I haven't yet thought about whether Nick Gammon's frequency counting method will work for my case ----- as his code has a while-loop in the main loop that keeps looping until the counter has finished counting.

But with your method, that makes use of the external counter only --- I think it might be workable for my case. I'll see how it goes! Hopefully the mega 2560 can do it for me, without needing to go for heavier artillery hehehe. Thanks again CD.