We are using ROBOTC version 3.54 and the Cortex. We wrote a very simple function for autonomously driving straight.
Our robot has four wheels, each with a quadrature shaft encoder.
The issue we found was that only one of the three encoders were functioning. When we first ran our program, the left encoders went up to around 250, then froze (and would flicker back and forth up to 10 encoder ticks, even though we were powering the motors to which they were connected on full). One of the right encoders worked (the back one), however, the front one remained stuck at 0. We know this from running it in the ROBOTC debugger.
We cannot seem to get past these values. For the most part, all the encoder values seem to freeze, or just flicker back and forth a couple of ticks (even when we’re turning it fully, multiple times over). Only the port in which the back right motor was initially connected seems to function.
While we could theoretically make our drive straight function work, we also have a turning function, which depends on all four encoders.
Here is our code, however, I do not believe there are any issues with it (and it compiles fine, so there shouldn’t be any syntax errors):
void driveStraight(int distance, int speed) {
SensorValue[driveRightFront] = 0;
SensorValue[driveRightBack] = 0;
SensorValue[driveLeftFront] = 0;
SensorValue[driveLeftBack] = 0;
distanceTicks = distance * ENCODER_REVOLUTION / WHEEL_CIRCUMFERENCE;
motor[driveRightFront] = speed;
motor[driveRightBack] = speed;
motor[driveLeftFront] = speed;
motor[driveLeftBack] = speed;
if (distanceTicks > 0) {
while (SensorValue[driveLeftFront] < distanceTicks);
}
else if (distanceTicks < 0) {
while (SensorValue[driveLeftFront] > distanceTicks);
}
motor[driveRightFront] = 0;
motor[driveRightBack] = 0;
motor[driveLeftFront] = 0;
motor[driveLeftBack] = 0;
}
My team and I have been trying to debug the issue for a while now (at least a couple hours straight, and we have a competition tomorrow). We’ve tried everything we can think of.
We have confirmed all the settings/configuration for the motors/sensors are correct.
We have tried swapping encoders.
We have tried different ports.
We have tried restarting everything, multiple times.
We have tried redownloading firmware.
We have eliminated any kind of cabling issue (we ensured each was connected properly, and we even went through with an encoder one at a time).
If we were to guess, we’d guess that it’s an error with the Cortex.
Any ideas would be appreciated, it’s getting late, and we have a competition first thing tomorrow morning. Thanks.