issue with output given by motor encoder encoder

i have a hall effect encoder motor
encoder_motor

pulse per minute =827.1
i am using the following code for getting no of pulse per sec then converting it to rpm

volatile  int  count=0;
 float rpm=0.00;


void setup() {
  // put your setup code here, to run once:
pinMode(2,INPUT);
Serial.begin(9600);
}

void loop() {
  
  //interrupts();
  attachInterrupt(0,countf,RISING);
  delay(1000);// use delay to give time to motor to count no of pulse in 1 sec.
  Serial.println(count);
  detachInterrupt(0);
  
   rpm=count*(60.000/823.10000); //converting pulse per sec to rpm
  Serial.print("rpm=");
  Serial.println(rpm);
   
  count=0;
}
void countf()
{
  count=count+1;
}

but i am getting a weird output
its rpm value is not stable it is getting decreasing
please see attached file for output
please help me here

Why is count a float when what you do in the ISR is to add 1 to it ?

Why is count a float when what you do in the ISR is to add 1 to it ?

@UKHELLBOb even if i change the the data type of count to int does it change the output that i am getting?

i am using the following code for getting no of pulse per sec

That is the worst possible way to count interrupts per second.

  count=0;

Count is not a byte sized variable, so resetting it is not an atomic operation. An interrupt could occur between setting the high order byte to 0 and setting the low order byte to 0. If the low order byte is 255 when that happens, the resulting value in count will be all hosed up.

An interrupt could occur between setting the high order byte to 0

thats why i have used detachinterrupt() before setting the count to zero.

Give this a try, untested.

unsigned long start;
const byte encoderPinA = 2;//A pin -> the interrupt pin 0
volatile long pulse;//the number of the pulses
int fin = 250, rpm;

void setup() {
  // initialize serial:
  Serial.begin(9600);
  attachInterrupt(0, readEncoder, FALLING);
  pinMode(encoderPinA,INPUT);
}

void loop() {
  if(millis() - start > fin){
  noInterrupts();  
  rpm = pulse * 240 / 11;
  interrupts();
  Serial.print(rpm);Serial.print(" \t"); // motor RPM
  Serial.println(rpm / 74.83);           // shaft RPM
  pulse = 0;
  start = millis();
  }
}

void readEncoder()
{
  ++pulse;

}