This season I have decided to step-up the programming on our robot and create code that will benefit us in driver control and autonomous. This deadband algorithm will specifically help in driver control. Here is a link to deadband on Wikipedia Basic joystick programming sets motor power equal to the joystick value. Unfortunately the joysticks don’t return to zero all the time, so when you think your joysticks are at 0, they may actually be hovering around 20 (I think), which will send 20 power to the motor. This is insufficient to move the robot, so the motors stall and create that horrible sound. Stalling the motor with this little power may not be too harmful, but it is drawing power from the battery, which is never good.
Unfortunately, I don’t have my robot with me, so I can’t test it out, but if anyone see any errors feel free to share. Also, do you think the deadband range is too small? Too large?
void leftDriveForward(int driveSpeed)
{
motor[port1]= -driveSpeed; //negative values are to simulate a reversed motor
motor[port10] = -driveSpeed;
}
while(true){
int y_posLJoyStk = vexRT[Ch3];
bool deadband = true;
int DB_range= 20; //range of values that will be registered as neutral
if(abs(vexRT[Ch3]< DB_range)// if the joystick is within the deadband range
{
y_posLJoyStk = 0; //store 0 in the y_posLJoystk integer
deadband = true; //set deadband to true
} else { //Joystick is out of deadband range
y_posLJoyStk= vexRT[Ch3]; //store actual value of the joystick in the y_posLJoystk integer
deadband = false; //set deadband to false
}
while(deadband = false)
{
leftDriveForward(y_posLJoyStk);
}
}