Help with an analog adjustable delay

I am trying to replace the electronics in an old commercial vacuum packer to get it functional again, without modifying the hardware. To do this, I have an Arduino Duemilanove attached to a relay board.

I am having an issue with the timer portion. Previously potentiometers had been used to set the vacuum and seal times. I have these connected to the analog inputs. Heres the code I used for the timer:

start_time = millis();
  
  do{
    delay(10);
    current_time = millis();
    timer = current_time - start_time;
    seal_time_bytes = analogRead(seal_pot);
    seal_time_fraction = seal_time_bytes / analog_max;
    seal_time = seal_time_fraction * seal_time_max;
  }
  while(timer<seal_time);

The goal is to have it loop so that the timer can be adjusted on the fly. analog_max and seal_time_max are set earlier in code.

When I run this code, there is no delay. If I comment out this portion, and replace it with a simple delay(), the code seems to run fine.

I've gone over it looking for issues many times, but I am completely new to arduino's and have very little experience coding, so I am probably missing something obvious. Any suggestions would be appreciated.

Here's my complete code, just in case:

The existing start button for the cycle shorted the ground and wiper of the pot, so that is what the first loop checks. This seems to be working fine. Otherwise, its just two of the timers above along with the required relay switches at each phase.

int green = 5;
int orange = 6;
int motor = 1;
int seal = 2;
int bleed = 3;
int bladder = 4;
int hatch = 10;
int vac_pot = 5;
int seal_pot = 0;
int bleed_time = 1000;
int bladder_delay = 500;
int vac_time_bytes = 0;
int seal_time_bytes = 500;
float seal_time = 30000;
float vac_time = 30000;
float vac_time_fraction = .5;
float seal_time_fraction = .5;
int analog_max = 875;
int current_time = 0;
int start_time = 0;
int timer = 0;
int seal_time_max = 10000;
int vac_time_max = 60000;

void setup() {                
  pinMode(green, OUTPUT);
  pinMode(orange, OUTPUT);
  pinMode(motor, OUTPUT);
  pinMode(seal, OUTPUT);
  pinMode(bleed, OUTPUT);
  pinMode(bladder, OUTPUT);
  pinMode(hatch, INPUT);
  pinMode(seal_pot, INPUT);
  pinMode(vac_pot, INPUT);
  digitalWrite(green, LOW);
  digitalWrite(orange, HIGH);
  digitalWrite(motor, HIGH);
  digitalWrite(seal, HIGH);
  digitalWrite(bleed, HIGH);
  digitalWrite(bladder, HIGH);
}

void loop() {
  do{
    vac_time_bytes = analogRead(vac_pot);
    if(digitalRead(hatch)==LOW)
    {vac_time_bytes = vac_time_bytes + 1000;};
    delay(10);
  }
  while(
    vac_time_bytes>2
  );
  
  start_time = millis();
  digitalWrite(motor, LOW);
  digitalWrite(orange, LOW);
  digitalWrite(green, HIGH);
  
  do{
    delay(10);
    current_time = millis();
    timer = current_time - start_time;
    vac_time_bytes = analogRead(vac_pot);
    vac_time_fraction = vac_time_bytes / analog_max;
    vac_time = vac_time_fraction * vac_time_max;
  }
  while(timer<vac_time);
  
  digitalWrite(motor, HIGH);
  digitalWrite(orange, HIGH);
  digitalWrite(bladder, LOW);
  delay(bladder_delay);
  digitalWrite(seal, LOW);
  
  start_time = millis();
  
  do{
    delay(10);
    current_time = millis();
    timer = current_time - start_time;
    seal_time_bytes = analogRead(seal_pot);
    seal_time_fraction = seal_time_bytes / analog_max;
    seal_time = seal_time_fraction * seal_time_max;
  }
  while(timer<seal_time);
  
  digitalWrite(seal, HIGH);
  digitalWrite(bladder, HIGH);
  digitalWrite(bleed, LOW);
  delay(bleed_time);
  digitalWrite(bleed, HIGH);
  digitalWrite(green, LOW);
}

Again, many thanks for any help you can provide.

I see a couple of obvious problems.

All the variables associated with timing using millis() need to be defined as long rather than int because of their magnitude.
Even with that change the value of the timer variable in the do/while loop is going to increase very fast and will almost instantly be greater than seal_time causing the loop to finish

UKHeliBob:
I see a couple of obvious problems.

All the variables associated with timing using millis() need to be defined as long rather than int because of their magnitude.
Even with that change the value of the timer variable in the do/while loop is going to increase very fast and will almost instantly be greater than seal_time causing the loop to finish

Make that "unsigned long" rather than "long".

Thanks!

That makes sense to me, variable types are something rather new to me.
I also found that vac_time_fraction consistently took a value of 0, regardless of type, so I eliminated it. The code below runs fine in a troubleshooting sketch.

unsigned long current_time=0;
unsigned long start_time=0;
unsigned long timer = 0;
int vac_pot = A5;
int vac_time_max = 30;
int vac_time_bytes=500;
unsigned long vac_time = 0;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  start_time = millis();
  do{
    delay(10);
    current_time = millis();
    timer = current_time - start_time;
    vac_time_bytes = analogRead(vac_pot);
    vac_time = vac_time_bytes * vac_time_max;
  }
  while(timer<vac_time);
  Serial.println(timer);             
  Serial.println(vac_time_bytes);
  Serial.println(current_time);

}

I seem to have things working now, I just need to get my test code reintegrated with the rest of it.

Thanks Again!