Motor rotation issue

Our robot’s motors move in a stuttering manner when we push a button on the joystick for it to lift up. However, when we use a channel on the joystick it moves regularly with an occasional repetition of involuntary motions (stutters). Any suggestions referring to how to solve this issue are greatly appreciated.

Can you post your code? Usually when this happens it means that you have conflicting statements in your code setting the motors to 0 and another power at the same time.

Actually, it might be our deadband in our code. Thanks.

Its still not working
what is your email evan10s. Can we email you our code??

You can post it here on the forums. It’s easier that way. Like @evan10s said, it sounds like there’s conflicting statements in the code.

You can send it as a private message using the link at the top right of my profile, or you could post a link to the code after pasting it in a service like GitHub Gist.

Or like @AppleDavidJeans said, you can always just paste the code here.

By the way, if you put your code here, then this post will be more helpful for anyone who finds this thread in the future and is having the same problem.

Oh ok. Thanks for the help!

Our robot’s motors move in a stuttering manner when we push a button on the joystick for it to lift up. However, when we use a channel on the joystick it moves regularly with an occasional repetition of involuntary motions (stutters). Someone suggested that the problem might be in the code. Any suggestions referring to how to solve this issue are greatly appreciated.

Here is our code:

#pragma config(Motor, port1, LeftMotorBack, tmotorVex393_HBridge, openLoop, driveLeft)
#pragma config(Motor, port2, LeftMotorLift2, tmotorVex393_MC29, openLoop, reversed, driveLeft)
#pragma config(Motor, port3, RightMotorFront, tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port4, RightMotorLift1, tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port5, LeftMotorFront, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port6, RightMotorFork, tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor, port7, LeftMotorFork, tmotorVex393_MC29, openLoop, reversed, driveLeft)
#pragma config(Motor, port8, RightMotorLift2, tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor, port9, LeftMotorLift1, tmotorVex393_MC29, openLoop, reversed, driveLeft)
#pragma config(Motor, port10, RightMotorBack, tmotorVex393_HBridge, openLoop, reversed, driveRight)
//!!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()
{
// …
// Insert user code here.
// …

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()
{
int deadband = 20;

while (true)
{
if(abs(vexRT[Ch3]) && abs(vexRT[Ch4])>deadband)
{motor[LeftMotorFront] = vexRT[Ch3] + vexRT[Ch4];
motor[RightMotorFront] = vexRT[Ch3] - vexRT[Ch4];
motor[LeftMotorBack] = vexRT[Ch3] + vexRT[Ch4];
motor[RightMotorBack] = vexRT[Ch3] - vexRT[Ch4];
}
else
{motor[LeftMotorFront] = 0;
motor[RightMotorFront] = 0;
motor[LeftMotorBack] = 0
; motor[RightMotorBack] = 0;
}

if(abs(vexRT[Ch1]) || abs(vexRT[Ch2]) || abs(vexRT[Ch3])>deadband)
{ motor[LeftMotorLift1]= vexRT[Ch1];
motor[RightMotorLift1]= vexRT[Ch1];
motor[LeftMotorFork] = vexRT[Ch2];
motor[RightMotorFork] = vexRT[Ch2];

}
else
{
motor[LeftMotorLift2] = 0;
motor[RightMotorLift2] = 0;
motor[LeftMotorFork] = 0;
motor[RightMotorFork] = 0;
}

if(vexRT[Btn6U]==1 && vexRT[Btn5U]==1)
{ motor[LeftMotorLift1] = 124;
motor[RightMotorLift1] = 124;
}

if(vexRT[Btn6D]==1 && vexRT[Btn5D] ==1)
{ motor[LeftMotorLift1]= -124;
motor[RightMotorLift1]=-124;
}
}

}

You are testing the joysticks for deadband on CH1, 2 and 3, and setting lift motors to 0 if they are < deadband. (well sort of, “if(abs(vexRT[Ch1]) || abs(vexRT[Ch2]) || abs(vexRT[Ch3])>deadband)” is only testing channel 3)

Outside that test you are checking for 5+6U and assigning a different value to the lift motors.

Basically, you are sending 0 and 124 to the same motors at once, thus the stutter.

Here is a trick that uses the fact that the buttons on the controller are always sending 0 when not pressed:
motor[LeftMotorLift1]= (vexRT[Btn6U] - vexRT[Btn6D]) * 124;
motor[RightMotorLift1]= (vexRT[Btn6U] - vexRT[Btn6D]) * 124;

Replace all your lift code with those two lines and you lift will run on 6U+D.
When you are not pressing either button, those lines result in (0 - 0) * 124 = 0.
If you are pressing 6U, its (1-0)*124 = 124.
If you are pressing 6D, its (0-1)*124 = -124.
If you press both, its (1-1)*124 = 0.

(I’m not sure why you want to press two buttons to run the lift, so eliminated 5U+D).