Potentiometer feedback/ getvalue return time too long

Im programming a robot that uses an Arduino MEGA 2560. on the robot i have linear actuators running to a desired value from their internal potentiometer. Im using another (linear) pot attached to the end of the actuator that changes values when the actuator is extended. (the linear pot is pushed in as the actuator extends)... So the problem that i am having is the actuator continues to extend for about 2-3 seconds after the linear pot is pushed in completely. is there any way to receive the pot value more frequently or continuously so there is no delay between the pot reading and the actuator stoping?

Gluke900: Im programming a robot that uses an Arduino MEGA 2560. on the robot i have linear actuators running to a desired value from their internal potentiometer. Im using another (linear) pot attached to the end of the actuator that changes values when the actuator is extended. (the linear pot is pushed in as the actuator extends)... So the problem that i am having is the actuator continues to extend for about 2-3 seconds after the linear pot is pushed in completely. is there any way to receive the pot value more frequently or continuously so there is no delay between the pot reading and the actuator stoping?

That sounds like a software problem, perhaps a delay(xxxx) where it doesn't belong? I think you will have to post your program to get any meaningful help from anyone.

Lefty

For what it's worth .... I read on another post that it takes about 125 microseconds to perform an analogRead. I doubt that would be the problem, but I thought I'd throw that out as a spark to get the mental juices flowing.

Is there any way in your code that the analogRead time would be slow enough to cause timing problems?

Thanks for your responses. Here’s the code:

#include <Potentiometer.h>

//intializes motor and potentiometer
Potentiometer RHP = Potentiometer(A2);  //right horizontal actuator potentiometer
Potentiometer RVP = Potentiometer(A3);  //right vertical
Potentiometer LHP = Potentiometer(A4);  //left horizontal
Potentiometer LVP = Potentiometer(A5);  //left vertical
Potentiometer RL = Potentiometer(A6);   //linear potentiometer attached to right vertical
Potentiometer LL = Potentiometer(A7);   //linear potentiometer attached to left vertical
int RH[] = {2,3};    //right horizontal actuator
int RV[] = {4,5};    //right vertical
int LH[] = {6,7};    //left horizontal
int LV[] = {8,9};    //left vertical
int RRelayPin = 12;         //relay for right vertical
int LRelayPin = 13;         //relay for left vertical
int RHPValue = 0;    //sets initial value of 0
int RVPValue = 0;
int LHPValue = 0;
int LVPValue = 0;
int RLValue = 0;
int LLValue = 0;


void setup()
{
  Serial.begin(9600); //sets up serial
  pinMode(RRelayPin, OUTPUT);
  pinMode(LRelayPin, OUTPUT);
}

void loop()
{
  RHPValue = RHP.getValue();    //gets the potentiometer value for the linear actuators
  RVPValue = RVP.getValue();     
  LHPValue = LHP.getValue();     
  LVPValue = LVP.getValue();
  RLValue = RL.getValue();
  LLValue = LL.getValue();  
  int minVal = 110;           //sets the minimum value for actuators
  int maxVal = 900;           
  int linminVal = 0;
  int linmaxVal = 900;
  Serial.print("RHP, RVP = ");
  Serial.print(RHPValue);
  Serial.print(", ");
  Serial.println(RVPValue);
  Serial.print("LHP, LVP = ");
  Serial.print(LHPValue);
  Serial.print(", ");
  Serial.println(LVPValue);
  Serial.print("Linear: ");
  Serial.print(RLValue);
  Serial.print(", ");
  Serial.println(LLValue);
  
  //horizontal actuator drives forward
  if(RHPValue<=maxVal && RLValue==linminVal && LHPValue<=maxVal && LLValue==linminVal)
  {
    rvmotor_stop();
    lvmotor_stop();
    drive_forward();
    Serial.println("forward");
    RHPValue = RHP.getValue();    //gets the potentiometer value for the linear actuators
    RLValue = RL.getValue();     
    LHPValue = LHP.getValue();     
    LLValue = LL.getValue();
    if(RHPValue>maxVal && LHPValue>maxVal)
    {
      digitalWrite(RRelayPin, HIGH);
      digitalWrite(LRelayPin, HIGH);
      motor_stop();
      delay(5000);
      rvmotor_stop();
      lvmotor_stop();
      delay(10000);
    }
  }
  
  //vertical actuator moves down
  else if(RHPValue>=maxVal && RLValue<=linmaxVal && LHPValue>=maxVal && LLValue<=linmaxVal)
  {
    motor_stop();
    rvmove_down();
    lvmove_down();
    Serial.println("down");
    RHPValue = RHP.getValue();    //gets the potentiometer value for the linear actuators
    RLValue = RL.getValue();     
    LHPValue = LHP.getValue();     
    LLValue = LL.getValue();
    if(RLValue>linmaxVal)
    {
      rvmotor_stop();
      //delay(1000);
      digitalWrite(RRelayPin, LOW);
    }
    if(LLValue>linmaxVal)
    {
      lvmotor_stop();
      //delay(1000);
      digitalWrite(LRelayPin, LOW);
    }
  }
  
  //horizontal actuator drives backward
  else if(RHPValue>=minVal && RLValue>=linmaxVal && LHPValue>=minVal && LLValue>=linmaxVal)
  {
    rvmotor_stop();
    lvmotor_stop();
    drive_backward();
    Serial.println("backward");
    RHPValue = RHP.getValue();    //gets the potentiometer value for the linear actuators
    RLValue = RL.getValue();     
    LHPValue = LHP.getValue();     
    LLValue = LL.getValue();
    if(RHPValue<minVal && LHPValue<minVal)
    {
      digitalWrite(RRelayPin, HIGH);
      digitalWrite(LRelayPin, HIGH);
      delay(15000);
      digitalWrite(RRelayPin, LOW);
      digitalWrite(LRelayPin, LOW);
      motor_stop();
    }
  }
  
  //vertical actuator moves up
  else if(RHPValue<=minVal && RVPValue>minVal && RLValue>=linminVal && LHPValue<=minVal && LVPValue>minVal && LLValue>=linminVal)
  {
    motor_stop();
    move_up();
    Serial.println("up");
    RHPValue = RHP.getValue();    //gets the potentiometer value for the linear actuators
    RVPValue = RVP.getValue();     
    LHPValue = LHP.getValue();     
    LVPValue = LVP.getValue();
    if(RVPValue<minVal && LVPValue<minVal)
    {
      rvmotor_stop();
      lvmotor_stop();
      //delay(1000);
    }
  }
}

//stop horizontal actuators
void motor_stop()
{
  digitalWrite(RH[0], LOW);
  digitalWrite(RH[1], LOW);
  delay(1500);
  
  digitalWrite(LH[0], LOW);
  digitalWrite(LH[1], LOW);
  delay(1500);  
}

//stop vertical actuators
void rvmotor_stop()
{
  digitalWrite(RV[0], LOW);
  digitalWrite(RV[1], LOW);
  delay(500);
}

void lvmotor_stop()
{
  digitalWrite(LV[0], LOW);
  digitalWrite(LV[1], LOW);
  delay(500);
}

//horizontals forward
void drive_forward()
{
  digitalWrite(RH[0], HIGH);
  digitalWrite(RH[1], LOW);
  
  digitalWrite(LH[0], HIGH);
  digitalWrite(LH[1], LOW);
}

//verticals down
void rvmove_down()
{
  digitalWrite(RV[0], HIGH);
  digitalWrite(RV[1], LOW);
}

void lvmove_down()
{
  digitalWrite(LV[0], HIGH);
  digitalWrite(LV[1], LOW);
}

//horizontals backward
void drive_backward()
{
  digitalWrite(RH[0], LOW);
  digitalWrite(RH[1], HIGH);
  
  digitalWrite(LH[0], LOW);
  digitalWrite(LH[1], HIGH);
}

//verticals up
void move_up()
{  
  digitalWrite(RV[0], LOW);
  digitalWrite(RV[1], HIGH);
  
  digitalWrite(LV[0], LOW);
  digitalWrite(LV[1], HIGH);
}

10 seconds delays, wow, never seen such a huge value! You have delays everywhere! Even in motor stop, really? You stop one motor and then just sit and wait 1.5s to stop the other, wow.

So the description of this section says:-

For problems with Arduino itself, NOT your project

In what way is this NOT a problem with your project?

Thanks for all your input and time on trying to help. The program was extensively revamped and is operating the way it's supposed to. ^_^