Stuttering wheels / code

My Vex Robotics Team has been having trouble lately with our base wheels. The left side is stuttering and not really working and the right side was not working at all. The program that was specific to this was

while (1 == 1)
{
motor[RightMotor] = vexRT[Ch2] / 1;
motor[LeftMotor] = vexRT[Ch3] / 1;

, then followed by a lot of other code and I’m not sure why they’re stuttering/not working but I’m pretty sure it’s not the robot because it was working before.

“Stuttering” happens because you are sending multiple values to your motors at the same time, probably happening in the other code. Please post all of it with the code tags.

Any chance you could post all of the code?

Also, why are you dividing by 1?

Is there any place in your code where you command the motors to turn off? If those commands aren’t properly wrapped inside IF statements or whatever, then your code might be accidentally turning off the motors.

#pragma config(Motor, port1, RightMotor, tmotorVex393_HBridge, openLoop, driveRight)
#pragma config(Motor, port2, LeftMotor, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port3, LauncherR, tmotorVex393HighSpeed_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port4, LauncherL, tmotorVex393HighSpeed_MC29, openLoop, driveLeft)
#pragma config(Motor, port5, ARight, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, AB, tmotorVex393_MC29, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

#pragma platform(VEX)

//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)

#include “Vex_Competition_Includes.c” //Main competition background code…do not modify!

/////////////////////////////////////////////////////////////////////////////////////////
//
// Pre-Autonomous Functions
//
// You may want to perform some actions before the competition starts. Do them in the
// following function.
//
/////////////////////////////////////////////////////////////////////////////////////////

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

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

}

/////////////////////////////////////////////////////////////////////////////////////////
//
// 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()
{
motor[RightMotor] = 127;
motor[LeftMotor] = 127;
wait1Msec(5000);
motor[RightMotor] = 0;
motor[LeftMotor] = 0;
wait1Msec(4500);
motor[LauncherR] = 127;
motor[LauncherL] = 127;
motor[ARight] = 127;
wait1Msec(7000);
motor[LauncherR] = 0;
motor[LauncherL] = 0;
motor[ARight] = 0;
AutonomousCodePlaceholderForTesting(); // Remove this function call once you have “real” code.
}

/////////////////////////////////////////////////////////////////////////////////////////
//
// 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)
{
  // This is the main execution loop for the user control program. Each time through the loop
  // your program should update motor + servo values based on feedback from the joysticks.

  // .....................................................................................
  // Insert user code here. This is where you use the joystick values to update your motors, etc.
  // .....................................................................................

  UserControlCodePlaceholderForTesting(); // Remove this function call once you have "real" code.

while (1 == 1)
{
motor[RightMotor] = vexRT[Ch2] / 1;
motor[LeftMotor] = vexRT[Ch3] / 1;

	if(vexRT[Btn6D] == 1)
	{
		motor[LauncherR] = 127;
	}
	else{
		motor[LauncherR] = 0;
	}
	//LauncherRight motor is on Btn 7u*//
	if(vexRT[Btn5D] == 1)
	{
		motor[LauncherL] = 127;
	}
	else{
		motor[LauncherL] = 0;
	}
	//LauncherLeft motor is on Btn 8u*//
	if(vexRT[Btn6U] == 1)
	{
		motor[ARight] = 127;
	}
	else{
		motor[ARight] = 0;
	}
	//Accumulator is on 6U*//
	if(vexRT[Btn7U] == 1)
	{
		motor[LeftMotor] = 63;
	}
	else{
		motor[LeftMotor] = 0;
	}
	//Left motor half speed on 7u*//
	if(vexRT[Btn8U] == 1)
	{
		motor[RightMotor] = 63;
	}
	else{
		motor[RightMotor] = 0;
	}
	//Right motor half speed on 8u*//
	if(vexRT[Btn7D] == 1)
	{
		motor[LeftMotor] = -63;
	}
	else{
		motor[LeftMotor] = 0;
	}
	//Left motor - half speed on 7d*//
	if(vexRT[Btn8D] == 1)
	{
		motor[RightMotor] = -63;
	}
	else{
		motor[RightMotor] = 0;
	}
	//Right motor - half speed on 8d*//
	if(vexRT[Btn5U] == 1)
	{
		motor[port6] = -63;
	}
	else{
		motor[port6] = 0;
	}
	//Accumulator base on 5u*//

	//collecterRight motor is on Btn 6u*//
	}
}

}

Maybe I’m mistaken, but won’t this sort of thing momentarily kill your left motor if button 7U isn’t pushed when you’re driving? Is that what it’s supposed to do?

if(vexRT[Btn7U] == 1)
{
motor[LeftMotor] = 63;
}
else{
motor[LeftMotor] = 0;
}

When you have

if(vexRT[Btn7U] == 1)
{
motor[LeftMotor] = 63;
}
else{
motor[LeftMotor] = 0;
}

, you are setting the motors both to the joystick channels as well as 63 and/or 0. Same with rightMotor.

Try replacing the else statement with setting the motors to the joystick, like:

if(vexRT[Btn7U] == 1)
{
motor[LeftMotor] = 63;
}
else{
motor[LeftMotor] = vexRT[Ch3];
}

Remove the top where it reads motor[LeftMotor] = vexRT[Ch3];

Same goes for the right motor.

The complete task userControl would look like this:


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

while (true)
{
// This is the main execution loop for the user control program. Each time through the loop
// your program should update motor + servo values based on feedback from the joysticks.

// .....................................................................................
// Insert user code here. This is where you use the joystick values to update your motors, etc.
// .....................................................................................

UserControlCodePlaceholderForTesting(); // Remove this function call once you have "real" code.
while (1 == 1)
{

if(vexRT[Btn6D] == 1)
{
motor[LauncherR] = 127;
}
else{
motor[LauncherR] = 0;
}
//LauncherRight motor is on Btn 7u*//
if(vexRT[Btn5D] == 1)
{
motor[LauncherL] = 127;
}
else{
motor[LauncherL] = 0;
}
//LauncherLeft motor is on Btn 8u*//
if(vexRT[Btn6U] == 1)
{
motor[ARight] = 127;
}
else{
motor[ARight] = 0;
}
//Accumulator is on 6U*//
if(vexRT[Btn7U] == 1)
{
motor[LeftMotor] = 63;
}
else{
motor[LeftMotor] = 0;
}
//Left motor half speed on 7u*//
if(vexRT[Btn8U] == 1)
{
motor[RightMotor] = 63;
}
else{
motor[RightMotor] = 0;
}
//Right motor half speed on 8u*//
if(vexRT[Btn7D] == 1)
{
motor[LeftMotor] = -63;
}
else{
motor[LeftMotor] = vexRT[Ch2];
}
//Left motor - half speed on 7d*//
if(vexRT[Btn8D] == 1)
{
motor[RightMotor] = -63;
}
else{
motor[RightMotor] = vexRT[Ch3];
}
//Right motor - half speed on 8d*//
if(vexRT[Btn5U] == 1)
{
motor[port6] = -63;
}
else{
motor[port6] = 0;
}
//Accumulator base on 5u*//

//collecterRight motor is on Btn 6u*//
}
}
}

what he said

k

okay thanks so much!

You should probably get rid of the extra while loop you have in your drive control code for the sake of clarity and preventing any future problems. Remove the default comments too to make it easier to read your code.

Instead of:


while (true)
{
// This is the main execution loop for the user control program. Each time through the loop
// your program should update motor + servo values based on feedback from the joysticks.

// .....................................................................................
// Insert user code here. This is where you use the joystick values to update your motors, etc.
// .....................................................................................

UserControlCodePlaceholderForTesting(); // Remove this function call once you have "real" code.
while (1 == 1)
{

Try:


while (true) 
{
// Default comments and extra while loop removed