2 Pot speed control

Hello everyone looking to see if anyone can help figure out a way to make this work.

This is on a milling machine, currently i have 1 potentiometer to control the speed of a stepper motor in clockwise and counterclockwise directions. I want to add a second potentiometer to split up the directions to their own speeds. Pot 1 will control speed clockwise, pot 2 will control speed counter clockwise.

This is the part of the code currently with one Potentiometer

  static float current_speed = 0.0;         // Holds current motor speed in steps/second
  static int analog_read_counter = 1000;    // Counts down to 0 to fire analog read
  static int sign = 0;                     // Holds -1, 1 or 0 to turn the motor on/off and control direction
  int analog_value = 0;              // Holds raw analog value.
  static float previouscurrent_speed = 0.05; //declares "currentMillis" as to reflect Arduino millis
  unsigned long currentMillis = millis();


  if (digitalRead(LEFT_PIN) == 0) {
    sign = 1; lcd.setCursor(12, 0);
    lcd.print(" CW ");
  }
  else if (digitalRead(RIGHT_PIN) == 0) {
    sign = -1; lcd.setCursor(12, 0);
    lcd.print(" CCW");
  }
  else if (digitalRead(STOP_PIN) == 0) {
    sign = 0; lcd.setCursor(12, 0);
    lcd.print("STOP");
  }

  // We only want to read the pot every so often (because it takes a long time we don't
  // want to do it every time through the main loop).
  if (analog_read_counter > 0) {
    analog_read_counter--;
  }
  else {
    analog_read_counter = 3000;

    // Now read the pot (from 0 to 1023)
    analog_value = analogRead(A1);

    // Give the stepper a chance to step if it needs to
    stepper1.runSpeed();

    //  And scale the pot's value from min to max speeds
    current_speed = sign * (((analog_value / 1023.0) * (MAX_SPEED - MIN_SPEED)) + MIN_SPEED);

    // Update the stepper to run at this new speed
    stepper1.setSpeed(current_speed);
  }

Here is how im trying to implement the second potentiometer, ive tried this code and it dont work.. maybe someone has a better idea on how to implement this?

     static float current_speed2 = 0.0; static float current_speed = 0.0;

  static int analog_read_counter2 = 1000;    
static int analog_read_counter = 1000; 


  static int sign = 0;                    

int analog_value2 = 0;  
int analog_value = 0;  

           previouscurrent_speed2 = 0.05; 
previouscurrent_speed = 0.05; 

  unsigned long currentMillis = millis();


  if (digitalRead(LEFT_PIN) == 0) {
    sign = 1; lcd.setCursor(12, 0);
    lcd.print(" CW ");
  }
  else if (digitalRead(RIGHT_PIN) == 0) {
    sign = -1; lcd.setCursor(12, 0);
    lcd.print(" CCW");
  }
  else if (digitalRead(STOP_PIN) == 0) {
    sign = 0; lcd.setCursor(12, 0);
    lcd.print("STOP");
  }

  
  if (analog_read_counter2 > 0) {
    analog_read_counter2--;
  }
  else {
    analog_read_counter2 = 3000;

    analog_value2 = analogRead(A2);

    stepper1.runSpeed();

    current_speed2 = -1 * (((analog_value2 / 1023.0) * (MAX_SPEED - MIN_SPEED)) + MIN_SPEED);

stepper1.setSpeed(current_speed2);
  }


if (analog_read_counter > 0) {
    analog_read_counter--;
  }
  else {
    analog_read_counter = 3000;

    analog_value = analogRead(A1);

    stepper1.runSpeed();

    current_speed = 1 * (((analog_value / 1023.0) * (MAX_SPEED - MIN_SPEED)) + MIN_SPEED);


    
    stepper1.setSpeed(current_speed);
  }

king6fab:
ive tried this code and it dont work

We are going to need a bit more information than this fact.

What did you expect the code to do?
What did the code actually do that was different that what you expected?

Ah yes, the motor would only run clockwise , both pots were fighting each other to control the speed while it ran, the buttons wouldnt change the direction or stop the motor

How about:

else if (digitalRead(RIGHT_PIN) == 0) {
  sign = -1; lcd.setCursor(12, 0);
  lcd.print(" CCW");
}
else if (digitalRead(STOP_PIN) == 0) {
  sign = 0; lcd.setCursor(12, 0);
  lcd.print("STOP");
}

if (analog_read_counter > 0) {
  analog_read_counter--;
}
else {
  analog_read_counter = 3000;
  if (sign == -1) {
    analog_value = analogRead(A1);
  }
  else if (sign == 1) {
    analog_value = analogRead(A2);
  }
  stepper1.runSpeed();

  current_speed = 1 * (((analog_value / 1023.0) * (MAX_SPEED - MIN_SPEED)) + MIN_SPEED);
}

Why not just use the one pot and if the motor controller gets a signal to go (A) direction, then speed (x).

If not, speed (x +)

king6fab:
Here is how im trying to implement the second potentiometer, ive tried this code and it dont work..

First off, always post a complete program. Problems are usually in the other part of the program.

Second, you would make life much easier for your self (and us) if you used variable names that reflect what they do. For example
CW_analog_value and CCW_analog_value rather than analog_value and analog_value2.

Then, I would have something like this

if (direction == clockwise) { // assumes clockwise is the name of a variable
   stepper1.setSpeed(CW_speed);
}
else {
   stepper1.setSpeed(CCW_speed);
}

...R