Hi my name is Zach and I am trying to program my robot to turn with integrated encoders, but when I put in the program the encoders do not stop at the specified values. The motors will keep on going indefenitly. Here is my code I am working on.
#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, in2, FIntakeLS, sensorReflection)
#pragma config(Sensor, in3, RIntakeLS, sensorReflection)
#pragma config(Sensor, in4, AutoPot, sensorPotentiometer)
#pragma config(Sensor, in5, AutoPot2, sensorPotentiometer)
#pragma config(Sensor, dgtl1, RUS, sensorSONAR_mm)
#pragma config(Sensor, dgtl3, FUS, sensorSONAR_mm)
#pragma config(Sensor, dgtl5, BLS, sensorTouch)
#pragma config(Sensor, dgtl6, SP, sensorDigitalOut)
#pragma config(Sensor, I2C_1, , sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Sensor, I2C_2, , sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Sensor, I2C_3, , sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Motor, port1, RRArmM, tmotorVex393, openLoop, encoder, encoderPort, I2C_1, 1000)
#pragma config(Motor, port2, LFArmM, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port3, RIntakeM, tmotorVex393, openLoop)
#pragma config(Motor, port4, RRDriveM, tmotorVex393, openLoop, reversed, encoder, encoderPort, I2C_2, 1000)
#pragma config(Motor, port5, RFDriveM, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port6, LIntakeM, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port7, LRDriveM, tmotorVex393, openLoop, encoder, encoderPort, I2C_3, 1000)
#pragma config(Motor, port8, LFDriveM, tmotorVex393, openLoop)
#pragma config(Motor, port9, LRArmM, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port10, RFArmM, tmotorVex393, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#pragma platform(VEX)
//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)
#include "Vex_Competition_Includes.c" //Main competition background code...do not modify!
// Sets all left drive motors to *value* and all right drive motors to *value2*
void SetDriveMotors (int value, int value2)
{
// these are on seperate lines incase some of the motors are flipped
motor[LFDriveM] = motor[LRDriveM] = value;
motor[RFDriveM] = motor[RRDriveM] = value2;
}
void pre_auton()
{
bStopTasksBetweenModes = true;
nMotorEncoder[RRArmM] = 0;
nMotorEncoder[RRDriveM] = 0;
nMotorEncoder[LRDriveM] = 0;
}
task autonomous()
{
while(nMotorEncoder[LRDriveM] < 1000)
while(nMotorEncoder[RRDriveM] > -1000)
{
SetDriveMotors(-63, 63);
}
}
I am not sure what I am doing wrong I have looked at sample programming to try to figure it out but I had no luck. If any one could help me that would be great.
Thank you,
Zach