 {
   pulse_count[IRQ_1]++;
 }
+

  ring_buffer[IRQ_0][idx] = pulse_count[IRQ_0];
  ring_buffer[IRQ_1][idx] = pulse_count[IRQ_1];

  memset(pulse_count, 0, sizeof(pulse_count));
}

void tach_0_isr()

  int counts[2][BUF_LEN];

  cli();
  for(int i = 0; i < 2; i++)
    for(int j = 0; j < BUF_LEN; j++)
      counts[i][j] = ring_buffer[i][j];
  sei();

  //  qsort(counts[IRQ_0][0], BUF_LEN, sizeof(int), cmp<int>);
  //  qsort(counts[IRQ_1][0], BUF_LEN, sizeof(int), cmp<int>);

  // report the median
  send(counts[IRQ_0][BUF_LEN / 2], counts[IRQ_1][BUF_LEN / 2]);
