Our Robot keeps stuttering after driving for a little while. The motors are regular motors but I have tried to make the base work with all 3 types of motors. There are four REGULAR motors on the base and the gear ratio being used is 36:12. The motors work for a few seconds but then they start stuttering after a while. This has been happening to us since last year. Any solution would be much appreciated. We tried to divide the task joystick controller by 2 and the stuttering went away, but the motors lost power eventually and just stopped working. The video of the base glitching can be seen in the link Bergen STEM Robotics, to better understand the problem.
The code for the robot and the arm is as follows:
CODE BEGINS***
#pragma config(Sensor, in1, pot1, sensorPotentiometer)
#pragma config(Motor, port2, FRwheel, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port3, BRwheel, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port4, FLwheel, tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor, port5, BLwheel, tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor, port6, FRarm, tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor, port7, FLarm, tmotorVex393_MC29, openLoop, reversed, driveLeft)
#pragma config(Motor, port8, BRarm, tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port9, BLarm, tmotorVex393_MC29, openLoop, driveLeft)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//
//*FACE IN THE DIRECTION OF THE ROBOT TO ATTACH THE WIRES CORRECTLY
float pidSensorCurrentValue; //Monitors PID value
//PID Controll Variable
static float pid_Kp = 0.7;
static float pidRequestedValue;
//Task Prototypes
task pidController(); //Task for PID controll
task joy_stick_control(); //Task for Joy Stick (Base)
//task basicArm();
int potMax = 2600; //Max PID requested value
int potMin = 4050; //Lowest PID requested value
task main()
{
pidRequestedValue = SensorValue[pot1];
startTask(pidController);
startTask(joy_stick_control);
while(true)
{
if(vexRT Btn6U ] == 1 )
{
startTask(pidController);
pidRequestedValue = potMax;
}
else if(vexRT Btn5U ] == 1 )
{
startTask(pidController);
pidRequestedValue = potMin;
}
wait1Msec(50);
}
}
task joy_stick_control()
{
//Create “deadzone” variables. Adjust threshold value to increase/decrease deadzone
int X2 = 0, Y1 = 0, X1 = 0, threshold = 15;
//Loop Forever
while(1 == 1)
{
//Create "deadzone" for Y1/Ch3
if(abs(vexRT[Ch3]) > threshold)
Y1 = -vexRT[Ch3]/2;
else
Y1 = 0;
//Create "deadzone" for X1/Ch4
if(abs(vexRT[Ch4]) > threshold)
X1 = -vexRT[Ch4]/2;
else
X1 = 0;
//Create "deadzone" for X2/Ch1
if(abs(vexRT[Ch1]) > threshold)
X2 = vexRT[Ch1]/2;
else
X2 = 0;
//Remote Control Commands
motor[port2] = Y1 - X2 - X1;
motor[port3] = Y1 - X2 + X1;
motor[port4] = Y1 + X2 + X1;
motor[port5] = Y1 + X2 - X1;
}
wait1Msec(15);
}
task pidController() //PID controller task
{
float pidError;
float pidDrive;
while( true )
{
// Read the sensor value and scale
pidSensorCurrentValue = SensorValue pot1 ];
// calculate error
pidError = pidRequestedValue - pidSensorCurrentValue;
// calculate drive
pidDrive = (pid_Kp * pidError);
// limit drive
if( pidDrive > 127 )
pidDrive = 127;
if( pidDrive < (-127) )
pidDrive = (-127);
//send to motor
motor port6 ] = pidDrive;
motor port7 ] = pidDrive;
motor port8 ] = pidDrive;
motor port9 ] = pidDrive;
}
}
CODE ENDS******