So following on from this thread where I actually solved my initial query...
https://forum.arduino.cc/index.php?topic=549221.0
I have now moved on (somehow!) to making a more streamlined way of counting pulses without blocking things too much.
I am using an Arduino Mega.
So, I will have this process happening on two pins, with different frequency of pulses.
One will be for engine RPM.
One will be for speed.
RPM will be connected to the ignition coil via a conditioning circuit to give a ground every pulse.
Speed will be through a hall sensor, using the original eddie current speedo reading the rotating magnet.
//The arduino will also be looking at various other parameters at the same time (oil temp, oil pressure, fuel level, turbo pressure, lambda, and a few others). The other parameters are mostly a read analogue signal, do a little maths, crank out a PWM signal proportional to the input based on the response curve of that particular sensor. these are mostly done and working. I plan to have these all as functions to call in a particular order.
So... On to the pulses.
I need to count them, accurately.
Maximum pulses on RPM input will be about 250 Hz (2 pulses per crank revolution, max revs a little over 7000)
Maximum pulses on speed input will be significantly lower, exact frequency not yet calculated but I do have the maths somewhere. But circumference of the wheel, max speed of about 90mph (this car is terrifying at low speeds!), wheel is a 15" rim with a 120/60 tyre, so nothing at all crazy).
So, I can see two ways of doing this:
Set a timer going in loop counting pulses. After an elapsed time, call the function for calculating RPM using pulses per interval.
or
Measure the time between two rising edges, and then call the function for calculating RPM using interval between pulses.
Both methods will mean I have to block to count pulses.
What I would like to do is have something counting time between two falling edges, so that I can call that last recorded value and do some calculations, or have it give me the number of pulses since I last checked, and the time since last check, and then I can do calculations with that.
Alternatively, does there exist a nice little piece of hardware that will count away that I can poll then reset at certain time intervals?
Something like this?
or is there something on board the Arduino Mega that already supports this?
Can anyone give me a little more info about how this works:
http://interface.khm.de/index.php/lab/interfaces-advanced/arduino-frequency-counter-library/
Finally, a HUGE thank you to GoForSmoke for all the help so far given! It is very much appreciated!!
His responses can be seen on the second page of the other thread I linked at the top there^^^