This is a tachometer for a diesel engine in which there is no tach pulse available because there is no spark ignition system. Instead, a pulse is taken off the "tach" output of the alternator (simply a wire connected into one of the three stator windings.)
This is an example of using the CCP (Capture-Compare-Pwm) module within a PIC. This module is set to capture mode in which the value of Timer1 is captured on every rising edge of the 16F628 CCP1 input (pin 9.) Because Timer1 is increments once per microsecond (4MHz crystal,) pulse period in microseconds is simply the number of counts that is captured each time. Simple math then converts pulse period into RPMs. Using the CCP module to measure period is much better than counting pulses for some fraction of a second and then multiplying by some factor to get RPM's, which would mean that RPM's would jump by some rather coarse increment.
After examining the various ways to pick off an RPM signal from my diesel engine, I rejected the more difficult options of installing a magnetic or optical sensor on the crankshaft, and opted instead to pull the alternator apart and connect a wire into the three-phase delta-connected stator to bring out an AC signal.
The pulley ratio is "crank pulley diameter / alternator pulley diameter".
The number of "poles" in the alternator is the count of separate poles on the rotor. Each of the two halves of the rotor in my particular alternator has three fingers
Alternatively, one may buy a diesel alternator, such as the BS-29 at "The Battery Shack" in Florida. It's alternator terminal exhibits the following frequency/RPM response.
The single screen is illustrated above. If pulses become too slow, such as when the engine is off, "0 RPM" is displayed.
CORRECTIONS / UPDATES