Problem in reading engine RPM

Updates ;- Resolved

Hello everyone thank you for taking interest in my topic. From the below code I am able to get data easily and accurately before but now it seems to look difficult now, the main problem is that it is giving some garbage value in between and almost 40% is all I am getting is garbage value. Hope you can help me in using Interrupt command on pin 13 only or else suggest me some good suggestion. Actually we are getting data from a Crank Position sensor present in a KTM 390 Engine. I know this program is poorly developed because I am a Mechanical Engineering Student so please try to correct me.
Thank you.

const int rpmPin = 13;
int engineRpm;
float Htime;
bool state1;
bool state2;
bool state3;
bool state4;
bool state5;
bool state6;
const int latchPin2 = 3;
const int dataPin2 = 5;
const int clockPin2 = 4;
const int latchPin3 = 11;
const int clockPin3 = 6;
const int dataPin3 = 9;
const int latchPin = 8;
const int dataPin = 7;
const int clockPin = 2;
const int gear1 = A0;
const int gear2 = A1;
const int gear3 = A2;
const int gear4 = A3;
const int gear5 = A4;
const int gear6 = A5;
int led1[] = {128, 192, 224, 240, 248, 252, 254, 255};//this is a array of led to glow on the base of engine rpm using shift register
int led2[] = {128, 192, 224, 240, 248, 252, 254, 255};
int led7Seg[] = {0, 4, 6, 14, 46, 110, 238, 254};
int led1Test[] = {0, 128, 192, 224, 240, 248, 252, 254, 255};
int led2Test[] = {128, 192, 224, 240, 248, 252, 254, 255};
int led1Tp[] = {128, 64, 32, 16, 8, 4, 2, 0};
int led2Tp[] = {128, 64, 32, 16, 8, 4, 2, 0};
int i = 0;
void blinkLed() {
  if (engineRpm > 9000) {
    digitalWrite(latchPin2, LOW);
    shiftOut(dataPin2, clockPin2, MSBFIRST, 255);
    digitalWrite(latchPin2, HIGH);
    digitalWrite(latchPin3, LOW);
    shiftOut(dataPin3, clockPin3, MSBFIRST, 255);
    digitalWrite(latchPin3, HIGH);
    delay(100);
    digitalWrite(latchPin2, LOW);
    shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
    digitalWrite(latchPin2, HIGH);
    digitalWrite(latchPin3, LOW);
    shiftOut(dataPin3, clockPin3, MSBFIRST, 0);
    digitalWrite(latchPin3, HIGH);
    delay(100);
  }
  else {
    if (i > 7 ) {
      int k = i - 8;
      digitalWrite(latchPin2, LOW);
      shiftOut(dataPin2, clockPin2, MSBFIRST, 255);
      digitalWrite(latchPin2, HIGH);
      digitalWrite(latchPin3, LOW);
      shiftOut(dataPin3, clockPin3, MSBFIRST, led2[k]);
      digitalWrite(latchPin3, HIGH);
    }
    else {
      digitalWrite(latchPin2, LOW);
      shiftOut(dataPin2, clockPin2, MSBFIRST, led1[i]);
      digitalWrite(latchPin2, HIGH);
      digitalWrite(latchPin3, LOW);
      shiftOut(dataPin3, clockPin3, MSBFIRST, 0);
      digitalWrite(latchPin3, HIGH);
    }
  }


}
void gear() {
  state1 = digitalRead(gear1);
  state2 = digitalRead(gear2);
  state3 = digitalRead(gear3);
  state4 = digitalRead(gear4);
  state5 = digitalRead(gear5);
  state6 = digitalRead(gear6);

  if (state1 == LOW)
  {
    //1st Gear
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 40 );
    digitalWrite(latchPin, HIGH);
  }
  else if (state2 == LOW)
  {
    //2nd Gear
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 218);
    digitalWrite(latchPin, HIGH);
  }
  else if (state3 == LOW)
  {
    //3rd Gear
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 122);
    digitalWrite(latchPin, HIGH);
  }
  else if (state4 == LOW)
  {
    //4th Gear
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 60);
    digitalWrite(latchPin, HIGH);
  }
  else if (state5 == LOW)
  {
    //5th Gear
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 118);
    digitalWrite(latchPin, HIGH);
  }
  else if (state6 == LOW)
  {
    //6th Gear
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 246);
    digitalWrite(latchPin, HIGH);
  }
  else
  {
    //Neutral
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 238);
    digitalWrite(latchPin, HIGH);
  }

}

void rpmRead() {
  Htime = pulseIn(rpmPin, HIGH);   //read high time




  engineRpm = 1000000 / Htime; //getting frequency with Ttime is in Micro seconds
  // Serial.print("engineRpm");
  //Serial.print(engineRpm);
  //Serial.print("\t");
  //Serial.print("i");
  //Serial.println(i);
  if (engineRpm >= 10000) {
    engineRpm = 10000;
  }
  i = map(engineRpm, 1500, 10000, 0, 15);
}
void setup()
{
  Serial.begin(2000000);
  pinMode(latchPin2, OUTPUT);
  pinMode(dataPin2, OUTPUT);
  pinMode(clockPin2, OUTPUT);
  pinMode(latchPin3, OUTPUT);
  pinMode(dataPin3, OUTPUT);
  pinMode(clockPin3, OUTPUT);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  digitalWrite(latchPin2, LOW);
  shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
  digitalWrite(latchPin2, HIGH);
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin3, clockPin3, MSBFIRST, 0);
  digitalWrite(latchPin3, HIGH);
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 255);
  digitalWrite(latchPin, HIGH);
  pinMode(gear1, INPUT);
  pinMode(gear2, INPUT);
  pinMode(gear3, INPUT);
  pinMode(gear4, INPUT);
  pinMode(gear5, INPUT);
  pinMode(gear6, INPUT);
  digitalWrite(gear1, HIGH);
  digitalWrite(gear2, HIGH);
  digitalWrite(gear3, HIGH);
  digitalWrite(gear4, HIGH);
  digitalWrite(gear5, HIGH);
  digitalWrite(gear6, HIGH);
  pinMode(rpmPin, INPUT);
  for (i = 0; i <= 16; i++) {
    int z = map(i, 0, 16, 0, 7);
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, led7Seg[z] );
    digitalWrite(latchPin, HIGH);
    if (i > 8 ) {
      int k = i - 9;
      digitalWrite(latchPin2, LOW);
      shiftOut(dataPin2, clockPin2, MSBFIRST, 255);
      digitalWrite(latchPin2, HIGH);
      digitalWrite(latchPin3, LOW);
      shiftOut(dataPin3, clockPin3, MSBFIRST, led2Test[k]);
      digitalWrite(latchPin3, HIGH);
    }
    else {
      digitalWrite(latchPin2, LOW);
      shiftOut(dataPin2, clockPin2, MSBFIRST, led1Test[i]);
      digitalWrite(latchPin2, HIGH);
      digitalWrite(latchPin3, LOW);
      shiftOut(dataPin3, clockPin3, MSBFIRST, 0);
      digitalWrite(latchPin3, HIGH);
    }
    delay(50);
  }
  for (i = 16; i >= 0; i--) {
    int z = map(i, 0, 16, 0, 7);
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, led7Seg[z] );
    digitalWrite(latchPin, HIGH);
    if (i > 8 ) {
      int k = i - 9;
      digitalWrite(latchPin2, LOW);
      shiftOut(dataPin2, clockPin2, MSBFIRST, 255);
      digitalWrite(latchPin2, HIGH);
      digitalWrite(latchPin3, LOW);
      shiftOut(dataPin3, clockPin3, MSBFIRST, led2Test[k]);
      digitalWrite(latchPin3, HIGH);
    }
    else {
      digitalWrite(latchPin2, LOW);
      shiftOut(dataPin2, clockPin2, MSBFIRST, led1Test[i]);
      digitalWrite(latchPin2, HIGH);
      digitalWrite(latchPin3, LOW);
      shiftOut(dataPin3, clockPin3, MSBFIRST, 0);
      digitalWrite(latchPin3, HIGH);
    }

    delay(50);
  }
}
void loop()
{


  rpmRead();
  if (i >= 0) {
    blinkLed();
  }
  else {
    for (int p = 0; p <= 15; p++) {
      /*if(i>=0){
        break;
        }*/
      if (p > 7 ) {
        int k = p - 8;
        digitalWrite(latchPin2, LOW);
        shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
        digitalWrite(latchPin2, HIGH);
        digitalWrite(latchPin3, LOW);
        shiftOut(dataPin3, clockPin3, MSBFIRST, led1Tp[k]);
        digitalWrite(latchPin3, HIGH);
      }
      else {
        digitalWrite(latchPin2, LOW);
        shiftOut(dataPin2, clockPin2, MSBFIRST, led1Tp[p]);
        digitalWrite(latchPin2, HIGH);
        digitalWrite(latchPin3, LOW);
        shiftOut(dataPin3, clockPin3, MSBFIRST, 0);
        digitalWrite(latchPin3, HIGH);
      }
      delay(50);
    }
    for (int p = 15; p >= 0; p--) {
      /*if(i>=0){
        break;
        }*/
      if (p > 7 ) {
        int k = p - 8;
        digitalWrite(latchPin2, LOW);
        shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
        digitalWrite(latchPin2, HIGH);
        digitalWrite(latchPin3, LOW);
        shiftOut(dataPin3, clockPin3, MSBFIRST, led2Tp[k]);
        digitalWrite(latchPin3, HIGH);
      }
      else {
        digitalWrite(latchPin2, LOW);
        shiftOut(dataPin2, clockPin2, MSBFIRST, led1Tp[p]);
        digitalWrite(latchPin2, HIGH);
        digitalWrite(latchPin3, LOW);
        shiftOut(dataPin3, clockPin3, MSBFIRST, 0);
        digitalWrite(latchPin3, HIGH);
      }
      delay(50);
    }
  }
  gear();
  delay(1);// time for microcontroller
}

What, exactly, is supposed to supply the engine RPM data?

pulseIn does NOT return a float, so you should NOT be storing the value in a float.

  i = map(engineRpm, 1500, 10000, 0, 15);

One letter global names are not a good idea.

  for (i = 0; i <= 16; i++) {

Now, why would you want to do that, when i is supposed to contain some mapped value?

Abhishek_Kuksal: From the below code I am able to get data easily and accurately before

If it was working before and it is not working now something must have changed. What?

...R

  for (i = 0; i <= 16; i++) {

Now, why would you want to do that, when i is supposed to contain some mapped value?

well this value will lit led bulbs from 0 to 16 as the engine rpm increases.

Robin2: If it was working before and it is not working now something must have changed. What?

...R

Well I have further noted that this because of noise of high voltage line of spark plug is creating interference and on further that the rpm sensor is on encoder wheel which does not have uniform teeth I mean two teeth were missing (that's because to indicate ECU that piston has reached TDC time to fire spark plug) so the Arduino was making a glitch when those missing teeth comes in under scanning.