Hello,
I am having problems with my potentiometer on my arm. When I set a x value for the potentiometer in my autonomous program and run it the arm on the robot will always go past the value I set in the program. I have down loaded new firmware and put a different potentiometer and I am still having the same effects.
Here is the code I have made. It is having problems at the first if else statement for the arm where I have set the value for 800. If anyone could help me I would be very grateful.
#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, in1, AutoPot, sensorPotentiometer)
#pragma config(Sensor, in2, ArmPot, sensorPotentiometer)
#pragma config(Sensor, dgtl1, RFP, sensorDigitalOut)
#pragma config(Sensor, dgtl2, LFP, sensorDigitalOut)
#pragma config(Sensor, I2C_1, , sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Sensor, I2C_2, , sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Motor, port1, RTLArmM, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port2, RTRArmM, tmotorVex393, openLoop)
#pragma config(Motor, port3, RFDriveM, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port4, RRDriveM, tmotorVex393, openLoop, reversed, encoder, encoderPort, I2C_2, 1000)
#pragma config(Motor, port5, RIntakeM, tmotorVex393HighSpeed, openLoop)
#pragma config(Motor, port6, LIntakeM, tmotorVex393HighSpeed, openLoop, reversed)
#pragma config(Motor, port7, LRDriveM, tmotorVex393, openLoop, encoder, encoderPort, I2C_1, 1000)
#pragma config(Motor, port8, LFDriveM, tmotorVex393, openLoop)
#pragma config(Motor, port9, LTLArmM, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port10, LTRArmM, 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!
void SetDriveMotors (int value, int value2) //Sets The Drive Motors To A Value, Value2 To get Rid Of Repetitive Code
{
motor[LFDriveM] = motor[LRDriveM] = value;
motor[RFDriveM] = motor[RRDriveM] = value2;
}
void SetDriveEncoders (int value)
{
nMotorEncoder[LRDriveM] = nMotorEncoder[RRDriveM] = value;
}
void SetArmMotors (int value, int value2) //Sets The Arm Motors To A Value, Value2 To get Rid Of Repetitive Code
{
motor[LTLArmM] = motor[LTRArmM] = value;
motor[RTLArmM] = motor[RTRArmM] = value2;
}
void SetIntakeMotors (int value) //Sets The Intake Motors To A Value To get Rid Of Repetitive Code
{
motor[LIntakeM] = motor[RIntakeM] = value;
}
void pre_auton()
{
SetDriveEncoders (0);
}
task autonomous()
{
if(SensorValue[AutoPot] > 1 && SensorValue[AutoPot] < 250) //Tells The Robot To Run The Barrier Side Autonomous
{
SetIntakeMotors(127); //Turns Intake Motors On To Drop The Intake Motors
if(SensorValue[ArmPot] < 800) //Moves The Arm Up To The Height Of The Ball
SetArmMotors(127, 127);
else if(SensorValue[ArmPot] == 800) //Stops The Arm Wen It Equals 200
SetArmMotors(0, 0);
else if(SensorValue[ArmPot] > 800) //Moves The Arm Down If It Raises More Than 200
SetArmMotors(-100, -100);
SetIntakeMotors(0);
SetDriveEncoders(0); //Clears Drive Encoders
while(nMotorEncoder[LRDriveM] && nMotorEncoder[RRDriveM] < 800) //Moves The Robot Forward To Push The Ball Off The Barrier
SetDriveMotors(127, 127);
SetDriveMotors(0, 0);
SetDriveEncoders(0); //Clears Drive Encoders
while(nMotorEncoder[LRDriveM] && nMotorEncoder[RRDriveM] < 800) //Moves The Robot Backward Back To The Starting Square
SetDriveMotors(-127, -127);
SetDriveMotors(0, 0);
wait1Msec(500); //A half Second Wait To Position The Robot For The Second Big Ball
SetDriveEncoders(0); //Clears Drive Encoders
while(nMotorEncoder[LRDriveM] && nMotorEncoder[RRDriveM] < 850) //Moves The Robot Forward To Push The Second Ball Off The Barrier
SetDriveMotors(127, 127);
SetDriveMotors(0, 0);
SetDriveEncoders(0); //Clears Drive Encoders
while(nMotorEncoder[LRDriveM] && nMotorEncoder[RRDriveM] < 850) //Moves The Robot Backward Back To The Starting Square
SetDriveMotors(-127, -127);
SetDriveMotors(0, 0);
if(SensorValue[ArmPot] > 1) //Moves The Arm Down To The Starting Position
SetArmMotors(-127, -127);
else if(SensorValue[ArmPot] < 1) //Moves The Arm Up If It Lowers Less Than 1
SetArmMotors(100, 100);
else if(SensorValue[ArmPot] == 1) //Stops The Arm Wen It Equals 1
SetArmMotors(0, 0);
wait1Msec(500); //A half Second Wait To Position The Robot For The Second Big Ball
SetDriveEncoders(0); //Clears Drive Encoders
while(nMotorEncoder[LRDriveM] && nMotorEncoder[RRDriveM] < 1000) //Moves The Robot Forward To Goal
SetDriveMotors(127, 127);
SetDriveMotors(0, 0);
if(SensorValue[ArmPot] < 300) //Moves The Arm Up To The Height Of The Goal
SetArmMotors(127, 127);
else if(SensorValue[ArmPot] > 300) //Moves The Arm Down If It Raises More Than 200
SetArmMotors(-100, -100);
else if(SensorValue[ArmPot] == 300) //Stops The Arm Wen It Equals 200
SetArmMotors(0, 0);
SetDriveEncoders(0); //Clears Drive Encoders
while(nMotorEncoder[LRDriveM] && nMotorEncoder[RRDriveM] < 100) //Moves The Robot Slowly Over The Goal
SetDriveMotors(90, 90);
SetDriveMotors(0, 0);
SetIntakeMotors(127); //Turns The Intake Motors On To Drop The Ball In The Goal
SetDriveEncoders(0); //Clears Drive Encoders
while(nMotorEncoder[LRDriveM] && nMotorEncoder[RRDriveM] < 100) //Moves The Robot Slowly Away From The Goal
SetDriveMotors(-90, -90);
SetDriveMotors(0, 0);
if(SensorValue[ArmPot] > 1) //Moves The Arm Down To The Starting Position
SetArmMotors(-127, -127);
else if(SensorValue[ArmPot] < 1) //Moves The Arm Up If It Lowers Less Than 1
SetArmMotors(100, 100);
else if(SensorValue[ArmPot] == 1) //Stops The Arm Wen It Equals 1
SetArmMotors(0, 0);
}
if(SensorValue[AutoPot] > 600 && SensorValue[AutoPot] < 1200 ) //Tells The Robot To Run The Hanging Side Autonomous
{
SetIntakeMotors(127); //Turns Intake Motors On To Drop The Intake Motors
SetDriveEncoders(0);
while(nMotorEncoder[LRDriveM] && nMotorEncoder[RRDriveM] < 300) //Moves The Robot Forward To Pick Up The Big Ball
SetDriveMotors(127, 127);
SetDriveMotors(0, 0);
SetIntakeMotors(0);
SetDriveEncoders(0);
while(nMotorEncoder[LRDriveM] && nMotorEncoder[RRDriveM] < 300) //Moves The Robot Backward To The Starting Position
SetDriveMotors(-127, -127);
SetDriveMotors(0, 0);
wait1Msec(500); //Half Second Wait To Position The Robot
if(SensorValue[ArmPot] < 200) //Moves The Arm Up To Catapult The Ball
SetArmMotors(127, 127);
else if(SensorValue[ArmPot] > 200) //Moves The Arm Down If It Raises More Than 200
SetArmMotors(-100, -100);
else if(SensorValue[ArmPot] == 200) //Stops The Arm Wen It Equals 200
SetArmMotors(0, 0);
if(SensorValue[ArmPot] > 1) //Moves The Arm Down To The Starting Position
SetArmMotors(-127, -127);
else if(SensorValue[ArmPot] < 1) //Moves The Arm Up If It Lowers Less Than 1
SetArmMotors(100, 100);
else if(SensorValue[ArmPot] == 1) //Stops The Arm Wen It Equals 1
SetArmMotors(0, 0);
wait1Msec(500); //Half Second Wait To Position The Robot
SetIntakeMotors(127); //Turns Intake Motors On To Intake The Bucky Balls
SetDriveEncoders(0);
while(nMotorEncoder[LRDriveM] && nMotorEncoder[RRDriveM] < 300) //Moves The Robot Forward To Pick Up The Bucky Balls
SetDriveMotors(127, 127);
SetDriveMotors(0, 0);
SetDriveEncoders(0);
while(nMotorEncoder[LRDriveM] && nMotorEncoder[RRDriveM] < 300) //Moves The Robot Backward To The Starting Position
SetDriveMotors(-127, -127);
SetDriveMotors(0, 0);
}
}