Help with actuators + feedback

Hi, I am not sure if this is the right part of the forum to post this but I will give it a shot.
I am working on a project involving two firgelli linear actuators that have built in feedback potentiometers. I basically want them to alternately extend and retract continuously. I need them to repeatedly move to the same position each time. I have gotten it to work but the problem is that they get stuck at certain points. I think there may be a problem with my logic but there may also be some other ways of dealing with the problem which I am not familiar with. So, I am trying to do two things

  1. make them move back and forth in opposing directions to the same alternating points, without going out of phase or getting stuck in a static position (i.e. one is extending while the other is retracting then vise vera, forever)
  2. make the whole sequence pause for a few seconds every X number of cycles in order to let the actuators cool since they are not meant to run at 100% duty cycles.

I am supposed to install this project tomorrow so any help would be greatly appreciated.

I am using a SainSmart L298N motor driver board and an arduino uno.
Here is the code so far…

// Actuator A
const int enA = 10;
const int in1 = 9;
const int in2 = 8;
const int potA = A0;
// Actuator B
const int enB = 5;
const int in3 = 7;
const int in4 = 6;
const int potB = A1;
// Settings
int goalExt = 400;
int goalRet = 600;
int spd = 150;

void setup()
{
pinMode(enA, OUTPUT); //enable pin on driver board for actuator A
pinMode(enB, OUTPUT); //enable pin on driver board for actuator B
pinMode(in1, OUTPUT); //actuator A
pinMode(in2, OUTPUT); //actuator A
pinMode(in3, OUTPUT); //actuator B
pinMode(in4, OUTPUT); //actuator B
pinMode(potA, INPUT); //feedback pot on actuator A
pinMode(potB, INPUT); //feedback pot on actuator B
Serial.begin(9600);
}
void loop()
{
int sensorValueA = analogRead(A0);
int sensorValueB = analogRead(A1);
Serial.print("A: ");
Serial.println(sensorValueA);
Serial.print("B: ");
Serial.println(sensorValueB);

{
if (goalExt > sensorValueA) {
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
analogWrite(enA, spd);
}
else if (goalExt < sensorValueA) {
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
analogWrite(enA, spd);
}
if (goalRet > sensorValueB) {
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
analogWrite(enB, spd);
}
else if (goalRet < sensorValueB) {
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
analogWrite(enB, spd);
}
delay(3000);

if (goalRet > sensorValueA) {
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
analogWrite(enA, spd);
}
else if (goalRet < sensorValueA) {
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
analogWrite(enA, spd);
}
if (goalExt > sensorValueB) {
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
analogWrite(enB, spd);
}
else if (goalExt < sensorValueB) {
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
analogWrite(enB, spd);
}
}
delay(3000);
}

Do both actuators have exactly the same readings at end of stroke? Do they both move at exactly the same speed in both directions? Is there any kind of mechanical linkage between them? You may need to devise a master/slave arrangement with PID control on the slave.

You should put every { on a line by itself. You should use Tools + Auto Format. That way, you'll see that you have useless curly braces in places.

  1. make the whole sequence pause for a few seconds every X number of cycles in order to let the actuators cool since they are not meant to run at 100% duty cycles.

That's easily done with a for statement and a delay() statement.

  1. make them move back and forth in opposing directions to the same alternating points, without going out of phase or getting stuck in a static position (i.e. one is extending while the other is retracting then vise vera, forever)

You'll need to tell us more about how/where you have a problem now. You also need to deal with the case where the actuator position readings are the same. It seems to me that "stand on the gas pedal" and "stomp the brakes" are probably NOT the best way to get the actuators to move in sync. Making the difference between the speeds proportional to the difference in positions seems like a much better idea.