loop only run once or twice

Hi
i'm trying to get a code running.
for some reason i cannot get it to run stable. it keeps on freezing.
i'm using arduino Uno. maybe a memory issue?
please help

#include <LiquidCrystal.h>
LiquidCrystal lcd(11, 10, 6, 5, 4, 3);

int RxCell1 = A0;
int RxCell2 = A1;
int IgnPack = A2;
int RunningLed = 12;
int MotorRevLed = 13;
double curmicros = 0;
double lastmicros = 0;
int deltamicros = 0;
double lastmillis = 0;
int MotorRpmVal = 0;
boolean Running = false;
boolean MotorRev = false;

void setup() {
pinMode(RunningLed, OUTPUT);
pinMode(MotorRevLed, OUTPUT);
digitalWrite(MotorRevLed, LOW);
digitalWrite(RunningLed, LOW);
lcd.begin(16, 2);
attachInterrupt(0, motor_rpm, FALLING);
}

void loop() {
if (millis() - lastmillis == 1000){
detachInterrupt(0);
MotorRpmVal = (( (double)(1000000) / (double)(deltamicros))) *60;
lcd.clear();
lcd.print (MotorRpmVal);
digitalWrite(RunningLed, Running);
Running = !Running;
lastmillis = millis();
attachInterrupt(0, motor_rpm, FALLING);

}
}

void motor_rpm(){
curmicros = micros();
//deltamicros = 4000;
deltamicros = curmicros - lastmicros;
lastmicros = curmicros;
digitalWrite(MotorRevLed, MotorRev);
MotorRev = !MotorRev;

}

tried this loop with the same results:
void loop() {
if (millis() - lastmillis == 1000){
detachInterrupt(0);
MotorRpmVal = (1000000 / deltamicros) * 60;
lcd.clear();
lcd.print (MotorRpmVal);
digitalWrite(RunningLed, Running);
Running = !Running;
lastmillis = millis();
attachInterrupt(0, motor_rpm, FALLING);

}
}

  if (millis() - lastmillis == 1000){

And if it misses a millisecond?

hmmm.. never thought of that.

what do you suggest?

you nailed it.

got it. thanks!

Generally for time, ">=" is better than "==".

double curmicros = 0;
double lastmicros = 0;

micros does not return a double. Storing the unsigned long that it does return in a double is not smart.

double lastmillis = 0;

Ditto for millis().

Hey sorry being nosy, but i am looking for a function that will run a stepper for a duration then stop - maybe even ramp speed up and then down.

What exactly does this do?

void loop() {
  if (millis() - lastmillis == 1000){
    detachInterrupt(0);
    MotorRpmVal = (1000000 / deltamicros) * 60;
    lcd.clear();
    lcd.print (MotorRpmVal);
    digitalWrite(RunningLed, Running);
    Running = !Running;
    lastmillis = millis();
    attachInterrupt(0, motor_rpm, FALLING);
    
  }
}