Spurious interrupts using Photointerrupter to measure RPM

Hi All

Been struggling with a simple photo interrupter to measure motor RPM. Using a small 12V DC motor and a cardboard disc. The phot interrupter shows great signal on the scope and no motor noise. Once I attach the line to pin 2 on the Uno the signal gets messy at RPM greater than 50-60. The interrupt then fires spuriously as well resulting in erratic RPM readings.

Any ideas - could the lines be too long between breadboard and Uno?
I've tried making the signal more solid/stronger by running it through a Schotkky NOT gate then a Comparator - no luck there.

Simple code - I attach an interrupt, the interrupt routine just increments PulseCounter, then every second I tally the pulses and clear the PulseCount value again.

On the scope it looks like there is some noise creeping in on the interrupt line.

Any advice is greatly appreciated.



Wow, nice scope pictures.
I like the clear and flawless code.