Interrupts and buffer values

I'm building a motor encoder using an IR sensor and a black and white disk attached to the motor shaft. I use attachinterrupt to detect the transitions from black to white and tally this count in a variable. To calculate RPM I need this running count at the beginning and end of a measured time period. I use the millis() function to get time. For both time and count info I am using a variable (for current data) and variable buffer (for previous data) to use in calculating my deltas. The time part is working but the counter is not...both my counter and counterbuffer variables return the same values and cause my RPM equation to equal 0. Anyone have any ideas on how to fix this

// Pin definitions
# define IR 2            // Receive the data from sensor

// Constants definitions
int delaytime = 2000;     // Time between samples (miliseconds)

// Variable definitions       
long Time = 0;          // Time (miliseconds)
long Timebuff = 0;               // Time buffer(miliseconds)
unsigned int Sample = 0;     // Sample number
volatile int counter = 0;   // B/W counter for sensor
volatile int counterbuff = 0;    // B/W counter buffer
unsigned int RPM = 0;       // Revolutions per minute


void setup()
{
  // Set the pins
  pinMode(2, INPUT);
  
  // sets the serial port to 115200
  Serial.begin(115200);
  
  attachInterrupt(0, addcount, CHANGE);
  
  // Splash screen
  Serial.println("Motor Encoder");
  Serial.println("**********");
  Serial.println("Based on QRD1114 IR sensor");
  Serial.println();
  Serial.print("Delay between readings: ");
  Serial.print(delaytime/1000);
  Serial.println(" seconds.");
  Serial.println();
}

void loop()
{
  Sample++;
  getdata();
  Serial.print(Sample);
  Serial.print(": Counter: ");
  Serial.print(counter);
  Serial.print(";  RPM: ");
  RPMcalc();
  Serial.print(RPM);
  Serial.print("; Time: ");
  Serial.print(Time);
  Serial.print("; Timebuff: ");
  Serial.print(Timebuff);
  Serial.print("; Counterbuff: ");
  Serial.print(counterbuff);
  Serial.println();
  Serial.println();
  delay(delaytime);
}

// Get data
void getdata(){
  counterbuff = counter;
  unsigned long millis();
  Timebuff = Time;
  Time = millis(); 
}

void RPMcalc(){
  RPM=(((counter-counterbuff)/4)*60)/(11.5*((Time-Timebuff)/1000));  // Calculate revolutions per minute (RPM)
}

void addcount(){
  counter++;
}
  unsigned long millis();

Please explain this.

both my counter and counterbuffer variables return the same values

How many interrupts occur between getdata(); where counterbuff is set to counter and RPMcalc(); where the expectation is that they are different?

unsigned long millis(); was a mistake...left over from some cut and paste code changes but not causing any problems. I just deleted it with no change in function.

The number of interrupts depends on how fast the motor is going. At my test speed, there are several hundred interrupts per second.

  RPM=(((counter-counterbuff)/4)*60)/(11.5*((Time-Timebuff)/1000));

Do Time and Timebuff show different values?

What is the 11.5? Names in place of magic numbers (4, 60, 11.5, 1000) would make that clear.

Yes, Time and Timebuff show different values and give me the time interval needed to do the RPM calculation.

11.5 is the gear ratio of the gear head motor I'm using. I have the disk attached to the motor shaft and I want the RPM of the output shaft.

There is a difference between integer math and floating point math.

In integer math, something like 70/71 is going to equal 0. Only with floating point math will it equal 0.986.

I'm hazarding a guess that the operation: (Time-Timebuff)/1000 (unless Time-Timebuff is larger than 1000) is returning zero, which will make the entire formula undefined, as you'll then be trying to divide by zero.