Interrupt the Interrupt

I want to measure the time between the rising edge of a pulse from a spinning wheel using the mills() function. Using an interrupt makes, but how do I exit the interrupt if the wheel never makes a full revolution?

You should not wait for anything in the interrupt service routine. It should just take a time stamp and set a flag for the main program to read.

Using an interrupt makes, but how do I exit the interrupt if the wheel never makes a full revolution?

Under what condition is the interrupt triggered? ALL that you need to do, when that happens, is record the time and return. It matters not that the wheel makes a full revolution, a partial revolution, or just barely moves.

@lexical43, how slow an RPM do you want to measure? Really, there is no limit to how slow a wheel can turn. The RPM can not be calculated without two timestamps. So there is no logical way to "exit" during a measurement, except by imposing a maximum bound on the time interval. But then you would have to wait for the next pulse anyway, to begin the next two measurements. Pointless. But the last valid RPM is always calculated from the last two timestamps.

Anyway, my first post addresses my suspicion that you intended to wait around inside the ISR until you collect both time stamps. That is a terrible approach.

If you implement this correctly (which is in the main program), RPM is undefined or invalid while there are zero or one timestamps recorded, and valid if there are two. Those two can then be subjected to a maximum difference that results in a minimum RPM, if that is important to your application.

Using the time stamp approach will work great. ...and yes, I want to measure RPM that exceeds a minimum set point to eliminate the indefinite delay while waiting for an infinitely slow RPM.

...and yes, I want to measure RPM that exceeds a minimum set point to eliminate the indefinite delay while waiting for an infinitely slow RPM.

Quantum phisycs show that, for the same reason that if you leave time enough to pass a crashed glass cup will glue itself and return to it's previous state, a motor can not have "0" speed.

Regards

lexical43:
Using the time stamp approach will work great. ...and yes, I want to measure RPM that exceeds a minimum set point to eliminate the indefinite delay while waiting for an infinitely slow RPM.

There are three things you need to check:

  1. There are at least two time stamps recorded
  2. The difference between time stamps is less than the minimum that you wish to record
  3. The last recorded time stamp is recent