Drive Train Problems

I am testing out drive trains and right now I am testing out a tank drive, but whenever I tried driving the drive train it does not work.

Code:

#pragma config(Motor, port2, RightFrontDrive, tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port3, LeftFrontDrive, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port4, RightBackDrive, tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port5, LeftBackDrive, tmotorVex393HighSpeed_MC29, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

void driveRobot()
{
motor[RightFrontDrive] = motor[RightBackDrive] = vexRT[Ch2];
motor[LeftFrontDrive] = motor[LeftBackDrive] = vexRT[Ch3];
}
task main()
{
driveRobot();
}


task main()
{
while(true)
{
driveRobot();
}
}

I forgot about the “while(true)” part, but the robot does not move. I think it could be something else, and I also know that the controller and cortex are up to date.

Did you try adding the while true? Without it, the task main will complete in a tiny fraction of a second and your program will be over.

Yes. it won’t work. Would you like me to send you some pictures?

There is nothing wrong with the code other than the while loop.

You may find the answer by working through this flowchart.

I got a new brain and new motor controllers, and only ports 1 and 10 work.

You may want to make the function driveRobot() into a task instead, and put a while(true) inside of it.

Also, I’m not familiar with C syntax and what you’re doing is probably ok, but just to be sure, it might be worth it to just out to split those two motor assignments into four.

Try this code maybe:


#pragma config(Motor, port2, RightFrontDrive, tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port3, LeftFrontDrive, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port4, RightBackDrive, tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port5, LeftBackDrive, tmotorVex393HighSpeed_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task driveRobot
{
motor[RightFrontDrive] =  vexRT[Ch2];
motor[RightBackDrive] = vexRT[Ch2];
motor[LeftFrontDrive] = vexRT[Ch3];
motor[LeftBackDrive] = vexRT[Ch3];
}
task main()
{
   startTask(driveRobot);
   while (true){
       wait1Msec(10);
   }
}

I’m not sure if the program is wrong, but if I change the ports to 1 and 10 only those motors will work.

@fruitarian This sounds like motor controllers are wired wrong to me honestly or something else funky, because the code is fine … unless of course the cortex is dead on ports 2-9, which is highly unlikely. Pictures?