Jittery Wheels

The wheels on our team’s robot are jittery and currently everyone is blaming the program. Can someone help me out or give me some advice? I would appreciate it. Thank you.

It most likely is that your program is setting your motors to different values at different spots.

Post your code so we can take a look.

#pragma config(Sensor, in1, amar, sensorPotentiometer)
#pragma config(Sensor, dgtl1, quadomono, sensorQuadEncoder)
#pragma config(Sensor, dgtl3, quadotrio, sensorQuadEncoder)
#pragma config(Sensor, dgtl5, miniavian, sensorDigitalIn)
#pragma config(Motor, port2, leftm, tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor, port3, rightm, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port4, lift2on1, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port5, lift1on2, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port6, lift2on2, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port9, arm, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port8, claw, tmotorServoContinuousRotation, openLoop, reversed)
//!!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()
{
//skyrise side

backward(127);
wait1Msec(200);
stop();

motor[arm] = 50;
wait1Msec(350);
stop();

motor[claw] = 127;
wait1Msec(250);
stop();

forward(127);
wait1Msec(850);
stop();

motor[claw] = -127;
wait1Msec(250);
stop();

motor[arm]=50;
wait1Msec(500);
stop();

pointTurn(right, 127);
wait1Msec(200);

motor[arm]=-50;
wait1Msec(500);
stop();

motor[claw]=127;
wait1Msec(250);
stop();

}

/////////////////////////////////////////////////////////////////////////////////////////
//
// 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)
{
	//base code
	if(vexRT[Ch2] > 20)
	{
		motor[rightm] = 127;
	}

	else if(vexRT[Ch2] < -20)
	{
		motor[rightm] = -127;
	}


	if(vexRT[Ch3] > 20)
	{
		motor[leftm] = 127;
	}

	else if(vexRT[Ch3] < -20)
	{
		motor[leftm] = -127;
	}


	//mechanism code
	if(vexRT[Btn6U] == 1) //shoulders lift lifts
	{
		motor[lift2on1] = 127;
		motor[lift1on2] = 127;
		motor[lift2on2] = 127;
	}

	else if(vexRT[Btn6D] == 1)  //shoulders un-lift lifts
	{
		motor[lift2on1] = -127;
		motor[lift1on2] = -127;
		motor[lift2on2] = -127;
	}


	if(vexRT[Btn5UXmtr2] == 1) //8U and 8D up and down the arm
	{
		motor[arm] = 50;
	}

	else if(vexRT[Btn5DXmtr2] == 1) //8U and 8D up and down the arm
	{
		motor[arm] = -50;
	}


	if(vexRT[Btn8RXmtr2] == 1) //8R and 8L open and close the claw
	{
		motor[claw] = 127;
	}

	else if(vexRT[Btn8LXmtr2] == 1)
	{
		motor[claw] = -127;
	}


	//main else command
	else
	{
		motor[rightm] = 0;
		motor[leftm] = 0;
		motor[lift2on1] = 0;
		motor[lift1on2] = 0;
		motor[lift2on2] = 0;
		motor[arm] = 0;
		motor[claw] = 0;
	}



}

}

This would be your problem.

//main else command
else
{
motor[rightm] = 0;
motor[leftm] = 0;
motor[lift2on1] = 0;
motor[lift1on2] = 0;
motor[lift2on2] = 0;
motor[arm] = 0;
motor[claw] = 0;
}

That else goes with your claw control which was I imagine the only thing that worked.

I think the problem is in your “main else command” at the end. It is definitely not acting as an “else” for the whole program, but most likely only an else for the switch it follows, making it a part of this switch:

You will need to put else statements for each of your switches to set motors to 0, i.e. one for the drive, one for the lift, etc.

Edit: Jpearman beat me to it. :slight_smile:

This should solve your problem:

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

while(true)
{
//base code
if(vexRT[Ch2] > 20)
{
motor[rightm] = 127;
}

else if(vexRT[Ch2] < -20)
{
motor[rightm] = -127;
}

else
motor[rightm] = 0;


if(vexRT[Ch3] > 20)
{
motor[leftm] = 127;
}

else if(vexRT[Ch3] < -20)
{
motor[leftm] = -127;
}

else
motor[leftm] = 0;


//mechanism code
if(vexRT[Btn6U] == 1) //shoulders lift lifts
{
motor[lift2on1] = 127;
motor[lift1on2] = 127;
motor[lift2on2] = 127;
}

else if(vexRT[Btn6D] == 1) //shoulders un-lift lifts
{
motor[lift2on1] = -127;
motor[lift1on2] = -127;
motor[lift2on2] = -127;
}

else
{
motor[lift2on1] = 0;
motor[lift1on2] = 0;
motor[lift2on2] = 0;
}


if(vexRT[Btn5UXmtr2] == 1) //8U and 8D up and down the arm
{
motor[arm] = 50;
}

else if(vexRT[Btn5DXmtr2] == 1) //8U and 8D up and down the arm
{
motor[arm] = -50;
}

else
motor[arm] = 0;


if(vexRT[Btn8RXmtr2] == 1) //8R and 8L open and close the claw
{
motor[claw] = 127;
}

else if(vexRT[Btn8LXmtr2] == 1)
{
motor[claw] = -127;
}

else
motor[claw] = 0;

}



}
}

As a side note, when you have only a single line in your if statement, it is not necessary to put it into brackets (you can see the way I did it). The brackets are only needed if multiple lines are part of the if.

The way you have your drive setup write now, the motors only are stopped or full speed. In case you want to do it so that the more you push the joystick the faster it goes, it is really simple to do.


motor[rightm] = vexRT[Ch2];
motor[leftm] = vexRT[Ch3];

I just wanted to second jpearman and Kevin. That definitely seems like the cause of your problem. Kevins’ fix also looks like it should fully resolve it, but I’m fairly new to VEX programming myself.

Thank you, the robot is running much smoother now.