I have built a controller of sorts for my car that does many things. The latest being control the automatic gearbox.

The problem I'm having is reading the speedo sensor. The sensor gives one pulse per tailshaft revolution, and with 33" tyres and a 4.3:1 ratio diff, that gives me roughly 61cm of travel per tailshaft revolution. (I think haha)

According to my calculations, sampling every 100ms will not give me either 0 or 1 pulse under 21kph.
I need to measure slower speeds than this.

What is the best way to measure this? I currently use pulsein to read the tacho input also, but this obviously takes less time and higher RPM, so I'm looking at changing that also.

The problem I have is the pic has to act quickly, the engine revs very quickly, and if it spends 1 second counting pulses, it will probably be over-revving by then.

I assume the best way to handle this is with interrupts, but have not used them yet, so would love to be pointed in the right direction. Any help would be appreciated.



The unit is based on a 16F877a running at 4mhz (I can run it faster if I have to) It also controls the air-conditioning & thermo fans in a climate control kind of way, aswell as having a 20x4 display that gives me info on engine stats and temperatures.

Thanks in advance.

Dave