IME's Keep on Running

I am having a problem where in autonomous my ime’s won’t stop driving backwards. We have tried troubleshooting and I have honestly no idea what the problem is. We have the ime’s programmed in a function called in autonomous. Here is my code:

#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, in1,    armPot,         sensorPotentiometer)
#pragma config(Sensor, dgtl10, sol3,           sensorDigitalOut)
#pragma config(Sensor, dgtl11, sol1,           sensorDigitalOut)
#pragma config(Sensor, dgtl12, sol2,           sensorDigitalOut)
#pragma config(Sensor, I2C_1,  ,               sensorQuadEncoderOnI2CPort,    , AutoAssign )
#pragma config(Sensor, I2C_2,  ,               sensorQuadEncoderOnI2CPort,    , AutoAssign )
#pragma config(Motor,  port1,           right1,        tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor,  port2,           right2,        tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port3,           right3,        tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port4,           rightfront,    tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor,  port5,           rightback,     tmotorVex393_MC29, openLoop, reversed, driveRight, encoderPort, I2C_2)
#pragma config(Motor,  port6,           left1,         tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port7,           left2,         tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor,  port8,           left3,         tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor,  port9,           leftback,      tmotorVex393_MC29, openLoop, driveLeft, encoderPort, I2C_1)
#pragma config(Motor,  port10,          leftfront,     tmotorVex393_HBridge, openLoop, driveLeft)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*        Description: Competition template for VEX EDR                      */
/*                                                                           */
/*---------------------------------------------------------------------------*/

// This code is for the VEX cortex platform
#pragma platform(VEX2)

// Select Download method as "competition"
#pragma competitionControl(Competition)

//Main competition background code...do not modify!
#include "Vex_Competition_Includes.c"

void autoforward(int value)
{
	while(getMotorEncoder(rightback) < value){
	motor [leftfront] = 127;
  motor [leftback] = 127;
  motor [rightfront] = 127;
  motor [rightback] = 127;
}
  motor [leftfront] = 0;
  motor [leftback] = 0;
  motor [rightfront] = 0;
  motor [rightback] = 0;
}

void autobackward(int value)
{
	while(getMotorEncoder(rightback) > value){
	motor [leftfront] = -127;
  motor [leftback] = -127;
  motor [rightfront] = -127;
  motor [rightback] = -127;
}
  motor [leftfront] = 0;
  motor [leftback] = 0;
  motor [rightfront] = 0;
  motor [rightback] = 0;
}

void autoturnleft(int value)
{
	while(getMotorEncoder(rightback) < value){
	motor [leftfront] = -127;
  motor [leftback] = -127;
  motor [rightfront] = 127;
  motor [rightback] = 127;
  }
  motor [leftfront] = 0;
  motor [leftback] = 0;
  motor [rightfront] = 0;
  motor [rightback] = 0;
}
void autoturnright(int value)
{
	while(getMotorEncoder(leftback) < value){
	motor [leftfront] = 127;
  motor [leftback] = 127;
  motor [rightfront] = -127;
  motor [rightback] = -127;
}
  motor [leftfront] = 0;
  motor [leftback] = 0;
  motor [rightfront] = 0;
  motor [rightback] = 0;
}
void autoclawclose()
{
	SensorValue[sol1] = 0;
  SensorValue[sol2] = 0;
}
void autoclawopen()
{
	SensorValue[sol1] = 1;
  SensorValue[sol2] = 1;
}
void armPow( int pwr ) {
	motor [left1] = pwr;
  motor [left2] = pwr;
  motor [right1] = pwr;
  motor [right2] = pwr;
  motor [left3] = pwr;
  motor [right3] = pwr;
}
void armUp( int val, int pwr ) {
	armPow(-pwr);
	while( SensorValue[armPot] < val ) {}
	armPow(0);
	}

void armDown( int val, int pwr ) {
	armPow(pwr);
	while( SensorValue[armPot] > val ) {}
	armPow(0);
	}

/*---------------------------------------------------------------------------*/
/*                          Pre-Autonomous Functions                         */
/*                                                                           */
/*  You may want to perform some actions before the competition starts.      */
/*  Do them in the following function.  You must return from this function   */
/*  or the autonomous and usercontrol tasks will not be started.  This       */
/*  function is only called once after the cortex has been powered on and    */
/*  not every time that the robot is disabled.                               */
/*---------------------------------------------------------------------------*/

void pre_auton()
{
  // Set bStopTasksBetweenModes to false if you want to keep user created tasks
  // running between Autonomous and Driver controlled modes. You will need to
  // manage all user created tasks if set to false.
  bStopTasksBetweenModes = true;

    // Set bDisplayCompetitionStatusOnLcd to false if you don't want the LCD
    // used by the competition include file, for example, you might want
    // to display your team name on the LCD in this function.
    // bDisplayCompetitionStatusOnLcd = false;

  // All activities that occur before the competition starts
  // Example: clearing encoders, setting servo positions, ...

      SensorValue[sol1] = 0;
      SensorValue[sol2] = 0;

}

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*                              Autonomous Task                              */
/*                                                                           */
/*  This task is used to control your robot during the autonomous phase of   */
/*  a VEX Competition.                                                       */
/*                                                                           */
/*  You must modify the code to add your own robot specific commands here.   */
/*---------------------------------------------------------------------------*/

task autonomous()
{

	resetMotorEncoder(leftback);
	resetMotorEncoder(rightback);
	autobackward(500);

}
/*---------------------------------------------------------------------------*/
/*                                                                           */
/*                              User Control Task                            */
/*                                                                           */
/*  This task is used to control your robot during the user control phase of */
/*  a VEX Competition.                                                       */
/*                                                                           */
/*  You must modify the code to add your own robot specific commands here.   */
/*---------------------------------------------------------------------------*/

task usercontrol()
{
  // User control code here, inside the loop

  while (true)
  {
while (1==1)
    {
        motor [leftfront] = vexRT [Ch3];
        motor [leftback] = vexRT [Ch3];
        motor [rightfront] = vexRT [Ch2];
        motor [rightback] = vexRT [Ch2];

        if (vexRT [Btn5D] == 1 )
        {
            motor [left1] = 70;
            motor [left2] = 70;
            motor [left3] = 70;
            motor [right1] = 70;
            motor [right2] = 70;
            motor [right3] = 70;
        }
        else if (vexRT [Btn5U] == 1 )

        {
            motor [left1] = -127;
            motor [left2] = -127;
            motor [left3] = -127;
            motor [right1] = -127;
            motor [right2] = -127;
            motor [right3] = -127;
        }
        else if (vexRT [Btn6D] == 1)
        	{
           	motor [left1] = -50;
            motor [left2] = -50;
            motor [left3] = -50;
            motor [right1] = -50;
            motor [right2] = -50;
            motor [right3] = -50;

        	}
        else
        {
            motor [left1] = -15;
            motor [left2] = -15;
            motor [left3] = -15;
            motor [right1] = -15;
            motor [right2] = -15;
            motor [right3] = -15;
        }
        if (vexRT [Btn6U] == 1)
        {
            SensorValue[sol1] = 0;
            SensorValue[sol2] = 0;
        }
        else
        {
            SensorValue[sol1] = 1;
            SensorValue[sol2] = 1;
        }
        if (vexRT [Btn7D] == 1)
        {
            SensorValue[sol3] = 1;
        }
        else
        {
            SensorValue[sol3] = 0;
        }
    }
  }
}

I would swap the comparators (greater than or less than) on the while loops in your functions. what is forward for the motor and what is forward for the encoder have been different for us.

Why do you have an infinite while loop inside of your infinite while loop in driver control?

Test for the absolute value of the encoder being less than the value, and the sign of the encoder value becomes irrelevant. You can also use one function for straight drive, with the sign of value determining direction:


void autoDrive(int value) // - value for backward, + for forward
{
  while(abs(nMotorEncoder[rightback]) < value){
  motor [leftfront] = 127 * sgn(value); // sign of value determines motor direction
  motor [leftback] = 127 * sgn(value);
  motor [rightfront] = 127 * sgn(value);
  motor [rightback] = 127 * sgn(value);
}
  motor [leftfront] = 0;
  motor [leftback] = 0;
  motor [rightfront] = 0;
  motor [rightback] = 0;
}