Using Hall Sensor(TLE-4905) with Arduino Mega

Hi again Cattledog!!

I noticed a line in your code that says : byte number_of_sensors = 1;

If the number of sensors were instead '2', instead of 1, then will that mean 1 channel, but expecting 2 pulses per revolution?

Or can that mean 2 channels (A and B) and feeding channel A to one external timer, and feeding channel B to a different external timer ----- and then combining the counts from both timers?

Just asking only! At the moment, I have a rotary incremental encoder that has 2 channels. Your code works excellently with 1 channel feeding timer 5 of the MEGA2560. I was then thinking about whether the other output channel of the encoder can be used as well ------ which is where I'm coming from with the question about byte number_of_sensors = 1;
.

Thanks CD!

unsigned long count_period = 1000;  // units of MICROsec
unsigned int count_to_rpm = 60000UL / count_period; //convert counts to RPM
byte number_of_sensors = 1;
unsigned long final_counts;
unsigned long start_time = micros();
unsigned long measured_time;
unsigned long current_time = micros();

void setup()
{
  Serial.begin(115200);
  TCCR5A = 0; //initialize Timer5
  TCCR5B = 0;
  TCNT5 = 0;
  pinMode( 47, INPUT_PULLUP); //external source pin for timer 5 of MEGA 2560
  //set external clock source pin T5 (digital pin 47) to clock on a rising edge
  TCCR5B =  bit (CS50) | bit (CS51) | bit (CS52);

  //Test pulses to confirm circuit 50 pps =  3000
  pinMode(11, OUTPUT);
  tone(11, 50000);//test pulse jumper pin 11 to pin 47 of MEGA 2560
}

void loop()
{
  current_time = micros();
  
  if (current_time - start_time >= count_period)
  {
    TCCR5B = 0; //stop counter
    final_counts = TCNT5; //frequency limited by unsigned int TCNT5 without rollover counts
    TCNT5 = 0;
    measured_time = current_time - start_time;
    unsigned int rpm = (final_counts * count_to_rpm) / number_of_sensors;

    Serial.print(measured_time);
    Serial.print("\t\t");
    Serial.print(final_counts);
    Serial.print("\t\t");
    Serial.println(rpm);
    
    current_time = micros();
    start_time = micros();  
    
    TCCR5B =  bit (CS50) | bit (CS51) | bit (CS52); //restart external clock source
  }
}