0
$\begingroup$

I am trying to get my robot to drive straight and am having trouble. I find that when running the motors with no load they run fine. If I put a load on one motor it accelerates. The other performs as expected, it tries to maintain speed. I am running 393 motors with encoders and PID selected. I am running robot C.

See the following video: https://youtu.be/u3P0Wectwco

program is as follows;

#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, dgtl12, killB,          sensorTouch)
#pragma config(Sensor, I2C_1,  ,               sensorQuadEncoderOnI2CPort,    , AutoAssign )
#pragma config(Sensor, I2C_2,  ,               sensorQuadEncoderOnI2CPort,    , AutoAssign )
#pragma config(Sensor, I2C_3,  ,               sensorQuadEncoderOnI2CPort,    , AutoAssign )
#pragma config(Motor,  port2,           rmotor,        tmotorVex393_MC29, PIDControl, reversed, driveRight, encoderPort, I2C_1)
#pragma config(Motor,  port3,           lmotor,        tmotorVex393_MC29, PIDControl, driveLeft, encoderPort, I2C_2)
#pragma config(Motor,  port4,           topmotor,      tmotorVex393_MC29, openLoop, encoderPort, I2C_3)
#pragma config(Motor,  port5,           pmotor,        tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

void StopAll(){
    motor[rmotor] = 0;
    motor[lmotor] = 0;
    motor[topmotor] = 0;
    motor[pmotor] = 0;
}

//Stops the program at the push of a button
task eStop(){
    while (SensorValue(killB) == 0){
        wait1Msec(10);
    }
    StopAll();
    stopAllTasks();
}


task main()
{
    startTask(eStop);

    nMotorEncoder[rmotor] = 0;
    nMotorEncoder[lmotor] = 0;

    motor[rmotor] = 15;
    motor[lmotor] = 15;
    wait1Msec(20000);
    motor[rmotor] = 0;
    motor[lmotor] = 0;
    StopAll();


}

Thank you,

Mark

$\endgroup$
2
  • $\begingroup$ That video is helpful. I don't see a coding error. s it possible that one of your PID error terms has a sign error? $\endgroup$
    – SteveO
    Mar 15, 2016 at 2:13
  • $\begingroup$ I am using the RobotC PID controller. I don't believe that I have access to the gains. The other motor is configured exactly the same way and it operates just as expected. I've swapped out pretty much everything and the problem seems to stay with the motor/encoder. We will just swap out the motor and encoder and see if that works. $\endgroup$ Mar 15, 2016 at 10:53

1 Answer 1

1
$\begingroup$

The problem was with the motor encoder. Upon disassembly, I discovered that the encoder was installed improperly. For whatever reason, the encoder gear was installed without an axle. Under no load, it worked. When under load apparently it would shift enough to cause it to miss counts causing the encoder to under sense speed, thus speeding up to motor.

$\endgroup$
1
  • $\begingroup$ Glad you figured out the problem! Thanks for posting a specific question with good background information. Would you be open to showing another video of it working properly? $\endgroup$
    – SteveO
    Mar 17, 2016 at 2:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.