Ramps 1.4 and BMP 180 for other projects

Hi,
im fairly new to this forum, i have created 2 posts in the past with no reply to it at all, hopefully atleast this one will have a response -_-

im using a ramps 1.4 with arduino mega to control 2 stepper motors for a project of mine, i connected a BMP180 pressure sensor to it.

the problem im facing is when i run the stepper alone on a seperate function all works fine its smooth and fast and i can easily control the speed, but when i try to turn on an off the motors depending on the pressure reading the motors starts to go slow, like really really slow.

i want to turn off motors if the pressure in the chamber drops so can anyone help me solve the problem with my code?

#include <SFE_BMP180.h>
#include <Wire.h>


#define Y_STEP_PIN         60
#define Y_DIR_PIN          61
#define Y_ENABLE_PIN       56
#define Y_MIN_PIN          14
#define Y_MAX_PIN          15

#define Z_STEP_PIN         46
#define Z_DIR_PIN          48
#define Z_ENABLE_PIN       62
#define Z_MIN_PIN          18
#define Z_MAX_PIN          19
#define LED_PIN            13
#define ALTITUDE 1655.0

SFE_BMP180 pressure;
int LIMIT, STOP;
char status;
double T,P,p0,a;
  
void presurecheck()
{
  if (status != 0)
  {
    status = pressure.getTemperature(T);
    status = pressure.startPressure(1);
    delay(status);
        status = pressure.getPressure(P,T);
        if (status != 0)
        {
          Serial.print("absolute pressure: ");
          Serial.print(P);
          Serial.print("\n\n");
        }
  }
  else Serial.println("error BMP180 sensor\n");
}

void moveup()
{digitalWrite(Y_DIR_PIN    , HIGH);
 digitalWrite(Z_DIR_PIN    , HIGH);
  //move up until the limit switch on top is hit
    while(LIMIT == HIGH)
    { 
      LIMIT = digitalRead(14);
      digitalWrite(13, HIGH);
      
      digitalWrite(Y_STEP_PIN    , HIGH);
      digitalWrite(Z_STEP_PIN    , HIGH);
      delayMicroseconds(500);
    
      digitalWrite(Y_STEP_PIN    , LOW);
      digitalWrite(Z_STEP_PIN    , LOW); 
    }
    delay(100);
    movesdown();
}

void movedown()
{
 digitalWrite(Y_DIR_PIN    , LOW);
 digitalWrite(Z_DIR_PIN    , LOW);
    while(P  >= 1200)
    {pressure.getTemperature(T);
     pressure.startPressure(1);
     pressure.getPressure(P,T);
     Serial.println(P);
      STOP = digitalRead(19);
      
      digitalWrite(Y_STEP_PIN    , HIGH);
      digitalWrite(Z_STEP_PIN    , HIGH);
      delayMicroseconds(500);
    
      digitalWrite(Y_STEP_PIN    , LOW);
      digitalWrite(Z_STEP_PIN    , LOW); 
    }
}


void setup() {
  //-------------------------------------------------------
  Serial.begin(9600);
  if (pressure.begin())
    Serial.println("BMP180 init success");
  else
  { Serial.println("BMP180 init fail\n\n");    while(1);   }

  //-------------------------------------------------------
  pinMode(LED_PIN  , OUTPUT);
  
  pinMode(Y_STEP_PIN  , OUTPUT);
  pinMode(Y_DIR_PIN    , OUTPUT);
  pinMode(Y_ENABLE_PIN    , OUTPUT);
  pinMode(Y_MIN_PIN    , INPUT_PULLUP);
  pinMode(Y_MAX_PIN    , INPUT_PULLUP);
  
  pinMode(Z_STEP_PIN  , OUTPUT);
  pinMode(Z_DIR_PIN    , OUTPUT);
  pinMode(Z_ENABLE_PIN    , OUTPUT);
  pinMode(Z_MAX_PIN    , INPUT_PULLUP);
  
  digitalWrite(Y_ENABLE_PIN    , LOW);
  digitalWrite(Z_ENABLE_PIN    , LOW);
  
  status = pressure.startTemperature();
}


void loop () 
{ int START = digitalRead(15);
  LIMIT = digitalRead(14);
  STOP = digitalRead(19);
  if (START == LOW && LIMIT == HIGH) 
  {
    moveup();
  }
  
  if (START == LOW && LIMIT == LOW) 
  {
    movesdown();
  }
  presurecheck();
}

Have you timed how long it takes to read temperature and pressure from the sensor? You are adding that time between every step. No wonder things get slow.

It’s got me beat how this code compiles at all, for you to even find out that it runs slowly.
You define a function called ‘moveDown()’, then call ‘movesDown()’

int LIMIT, STOP;

Generally, it’s a good idea to stick to standards, and keep ‘all-uppercase’ names for constants instead of variables.

    status = pressure.getTemperature(T);
    status = pressure.startPressure(1);
    delay(status);

Why on earth would there be a delay() that is set by a temperature or pressure? And what is the point of reading a value into status and then over-writing it with a different reading.

In any case I would guess that it is the use of delay() that is causing your problem. Use millis() to manage timing everywhere as illustrated in Several Things at a Time and in the second example in this Simple Stepper Code

...R