FRC Team CC
21-12-2014, 13:24
Hello,
We are trying to program our Autonomous portion using distance with
TETRIX DC Motor encoders. The following is our program:
#pragma config(Hubs, S1, HTMotor, HTMotor, HTServo, HTMotor)
#pragma config(Motor, mtr_S1_C1_2, leftBottomDrive, tmotorTetrix, openLoop, encoder)
#pragma config(Motor, mtr_S1_C4_1, rightBottomDrive, tmotorTetrix, openLoop, reversed, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
float diameterOfWheel = 3.96;//set the diameter of wheel to 3.96 inches
float circumfirence = diameterOfWheel*PI;
int distanceToGo = 12;//we want the robot to go one foot, or 12 inches
float rotations = distanceToGo/circumfirence;
int degreesToTurn = rotations*360;
int encoderCounts = degreesToTurn*4;//encoder counts are in quarter degrees, so 4 encoder counts = 1 degree
nMotorEncoder[leftBottomDrive] = 0;//motors do not run
nMotorEncoder[rightBottomDrive] = 0;
nMotorEncoderTarget[leftBottomDrive] = encoderCounts;//tell motors to go a foot
nMotorEncoderTarget[rightBottomDrive] = encoderCounts;
motor[leftBottomDrive] = 50;//go at power 50
motor[rightBottomDrive] = 50;
while(nMotorRunState[leftBottomDrive] != runStateIdle)
{
}
motor[leftBottomDrive] = 0;//turn motors off
motor[rightBottomDrive] = 0;
}
When testing the program, the motors drove unlimited instead of stopping after one foot.
Regards,
The Charging Champions
We are trying to program our Autonomous portion using distance with
TETRIX DC Motor encoders. The following is our program:
#pragma config(Hubs, S1, HTMotor, HTMotor, HTServo, HTMotor)
#pragma config(Motor, mtr_S1_C1_2, leftBottomDrive, tmotorTetrix, openLoop, encoder)
#pragma config(Motor, mtr_S1_C4_1, rightBottomDrive, tmotorTetrix, openLoop, reversed, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
float diameterOfWheel = 3.96;//set the diameter of wheel to 3.96 inches
float circumfirence = diameterOfWheel*PI;
int distanceToGo = 12;//we want the robot to go one foot, or 12 inches
float rotations = distanceToGo/circumfirence;
int degreesToTurn = rotations*360;
int encoderCounts = degreesToTurn*4;//encoder counts are in quarter degrees, so 4 encoder counts = 1 degree
nMotorEncoder[leftBottomDrive] = 0;//motors do not run
nMotorEncoder[rightBottomDrive] = 0;
nMotorEncoderTarget[leftBottomDrive] = encoderCounts;//tell motors to go a foot
nMotorEncoderTarget[rightBottomDrive] = encoderCounts;
motor[leftBottomDrive] = 50;//go at power 50
motor[rightBottomDrive] = 50;
while(nMotorRunState[leftBottomDrive] != runStateIdle)
{
}
motor[leftBottomDrive] = 0;//turn motors off
motor[rightBottomDrive] = 0;
}
When testing the program, the motors drove unlimited instead of stopping after one foot.
Regards,
The Charging Champions