Effective routine to measure speed using phototransistor or reed switch

Thread Starter

Xavier Pacheco Paulino

Joined Oct 21, 2015

I've been searching around the web for a effective way to measure the speed using a phototransitor or a reed switch, but still can't manage to create an algorithm for this. A phototransistor offers higher resolution as they are many pulses per revolution compared to a reed which provides only a pulse per rev. Which method is effective to accomplish this? Interrupts? I wouldn't like a time consuming routine. I'm using a STM32 nucleo. If you know other references that I could read, let me know.

Thank you.


Joined Jul 18, 2013
There are many applications and App notes for the Picmicro, which is what I am using, I generally use a slot opto, but have also used a retro-reflective sensor.
If it is mainly high rpm application, you only need one or two pulses/rev, if slow speed then 10 or 10+ may be needed.
Interrupts or input to timer roll-overs can reduce the demand on processing time.
The above can also be used to monitor and correct speed if needed.