Hello, I’m a new user of VEX robotics. Saturday, I have a tournament on Saturday,
My base does with encoder does not go straight during the autonomous mode, so I used the PID control from this site. http://www.robotc.net/wikiarchive/Tutorials/Arduino_Projects/Mobile_Robotics/VEX/Using_encoders_to_drive_straight,
However, the motor does not stop; it infinitely goes forward; I cannot figure out.
This is my motor setting
I try to change some code, and the code now looks like this. but it also does not work.
void forwardStraight(int distance, int masterPower)
{
int tickGoal = 6.94*distance; // circumference_cm * distance
//This will count up the total encoder ticks despite the fact that the encoders are constantly reset.
//int totalTicks = 0;
//Initialise slavePower as masterPower - 5 so we don’t get huge error for the first few iterations. The
//-5 value is based off a rough guess of how much the motors are different, which prevents the robot from
//veering off course at the start of the function.
int slavePower = masterPower - 10;
int error = 0;
int kp = 3;
SensorValue[LMIDEN] = 0;
SensorValue[RMIDEN] = 0;
//Monitor ‘totalTicks’, instead of the values of the encoders which are constantly reset.
while(abs(SensorValue[LMIDEN])<tickGoal&&abs(SensorValue[RMIDEN])<tickGoal)
{
//Proportional algorithm to keep the robot going straight.
motor[LMID] = masterPower;
motor[RMID] = -slavePower;
error = SensorValue[LMIDEN] - SensorValue[RMIDEN];
slavePower += error / kp;
wait1Msec(100);
//Add this iteration's encoder values to totalTicks.
// totalTicks+= SensorValue[LMIDEN];
}
motor[LMID] = 0; // Stop the loop once the encoders have counted up the correct number of encoder ticks.
motor[RMID] = 0;
}
task autonomous(){
forwardStraight(190,110)
}
I am so desperately need a help