Thanks for the replies.

Of course, after I posted, I realized that Timer2 is an 8-bit timer, not a 16-bit timer.

That means that my TICK_CNT is incorrect.

Now, I'm looking at 255-(16Mhz/1024/62Hz) for roughly 3 as a TICK_CNT preload.

Of course, this means I'm interrupting 62 times per second instead of 4, but 62 was the smallest number that I could work out where the TICK_CNT wasn't negative and it was close to a whole number. Maybe I'm thinking about this the wrong way though because it means I need to multiply the number of counted pulses by Timer1 by 62 in order to get an estimate of the speed.

The maximum speed that I'm looking to capture would be 200 mph. That means 31Hz * 200 = 6200 Hz, which should still be able to be captured even if I'm interrupting 62 times per second. Right?

Updated sketch:

const uint16_t TICK_CNT = 3; // 255-(16MHz/1024/62Hz)

static uint16_t freq = 0;

double sped = 0; //"speed" seems to be a reserved term

void setup() {

pinMode(13, OUTPUT);

digitalWrite(13, HIGH);

Serial.begin(115200);

noInterrupts(); // disable all interrupts while we configure

// init Timer1 - 16-bit timer/counter

TCNT1 = 0; // start count at zero.

TCCR1B |= _BV(CS12) | _BV(CS11) | _BV(CS10); // Increment T1 input on each positive edge

// using an external source. Table 16-5, pg 139.

// init Timer2 - 8-bit timer/counter

TCNT2 = TICK_CNT; // preload Timer2 to interrupt every 250 msec

TIMSK2 = _BV(TOIE2); // enable the Timer2 overflow interrupt

TCCR2B |= _BV(CS22) |_BV(CS21) | _BV(CS20); // init clock prescaler to 1024. Table 18-9, page 164.

interrupts(); // enable all interrupts

Serial.println("Ready...");

}

ISR(TIMER1_OVF_vect) {

// do nothing. this is just a dummy ISR in case it actually overflows.

Serial.println("Inside Timer1 Overflow Interrupt.");

}

ISR(TIMER2_OVF_vect) {

//Serial.print("TCNT1: ");

//Serial.println(TCNT1);

freq = TCNT1;

//Serial.println(freq);

TCNT1 = 0;

TCNT2 = TICK_CNT;

}

void loop() {

if (freq != 0) {

freq = freq * 62; // multiple the frequency * 4 (using leftshift 2 places). 250ms*4 = 1 sec.

sped = freq * .03225; // multiplying freq * 0.03225 will give speed in mph. 31Hz == 1 mph.

// see: http://www.microwave-solutions.com/contents/en-uk/d13_System_Design.html

Serial.print("Freq: ");

Serial.print(freq, DEC);

Serial.print(" Hz, Speed: ");

Serial.print(sped, 0);

Serial.println(" mph");

freq = 0;

}

}

Updated output: Looking better!

Ready...

Freq: 62 Hz, Speed: 2 mph

Freq: 310 Hz, Speed: 10 mph

Freq: 186 Hz, Speed: 6 mph

Freq: 62 Hz, Speed: 2 mph

Freq: 248 Hz, Speed: 8 mph

Freq: 310 Hz, Speed: 10 mph

Freq: 186 Hz, Speed: 6 mph

Freq: 248 Hz, Speed: 8 mph

Freq: 310 Hz, Speed: 10 mph

Freq: 124 Hz, Speed: 4 mph

Freq: 434 Hz, Speed: 14 mph

Freq: 310 Hz, Speed: 10 mph

Freq: 248 Hz, Speed: 8 mph

Freq: 992 Hz, Speed: 32 mph

Freq: 124 Hz, Speed: 4 mph

Freq: 434 Hz, Speed: 14 mph

Freq: 124 Hz, Speed: 4 mph

Freq: 310 Hz, Speed: 10 mph

Freq: 496 Hz, Speed: 16 mph

Freq: 372 Hz, Speed: 12 mph

Freq: 372 Hz, Speed: 12 mph

Freq: 62 Hz, Speed: 2 mph