Our team is having an issue with our lift tilting to one side, but only in autonomous.
We have an 8 bar lift and do not experience the same tilting issue in driver control. However, in autonomous, our lift leans towards the right side even without being under any load.
We are using ROBOTC 4.27 with updated firmware on our joystick and cortex.
Our entire code for the lift in driver control is as follows(ignore the lift balancing code in the middle of the program, that is no longer in use):
5U and 5D are the buttons being used for going up and down.
if(vexRT[Btn7D] == 1 && RightLower)//Automagic down
{
motor[RtFrontLift] = -50;
motor[LtFrontLift] = 17;
motor[RtBackLift] = -50;
motor[LtBackLift] = 17;
}
else if(vexRT[Btn7D] == 1 && !RightLower)
{
motor[RtFrontLift] = 17;
motor[LtFrontLift] = -50;
motor[RtBackLift] = 17;
motor[LtBackLift] = -50;
}
else if(vexRT[Btn7U] == 1 && !leftHigher)//Automagic up
{
motor[RtFrontLift] = 40;
motor[LtFrontLift] = 80;
motor[RtBackLift] = 40;
motor[LtBackLift] = 80;
}
else if(vexRT[Btn7U] == 1 && leftHigher)
{
motor[RtFrontLift] = 80;
motor[LtFrontLift] = 40;
motor[RtBackLift] = 80;
motor[LtBackLift] = 40;
}
else if(vexRT[Btn5D] == 1 && vexRT[Btn5U] == 1)//lifthold
{
motor[RtFrontLift] = 10;
motor[LtFrontLift] = 10;
motor[RtBackLift] = 10;
motor[LtBackLift] = 10;
}
else if(vexRT[Btn8L] == 1)//lift adjust
{
if((SensorValue(potentiometerLt) + offSet) > SensorValue(potentiometerRt)/* && threshold*/)
{
motor[RtFrontLift] = 127 - error;
motor[LtFrontLift] = 127;
motor[RtBackLift] = 127 - error;
motor[LtBackLift] = 127;
}
else if(SensorValue(potentiometerRt) > (SensorValue(potentiometerLt) + offSet)/* && threshold*/)
{
motor[RtFrontLift] = 127;
motor[LtFrontLift] = 127 - error;
motor[RtBackLift] = 127;
motor[LtBackLift] = 127 - error;
}
else
{
motor[RtFrontLift] = 127;
motor[LtFrontLift] = 127;
motor[RtBackLift] = 127;
motor[LtBackLift] = 127;
}
}
else if(vexRT[Btn5D] == 1)//lift down
{
motor[RtFrontLift] = -127;
motor[LtFrontLift] = -127;
motor[RtBackLift] = -127;
motor[LtBackLift] = -127;
}
else if(vexRT[Btn5U] == 1)//lift up
{
motor[RtFrontLift] = 127;
motor[LtFrontLift] = 127;
motor[RtBackLift] = 127;
motor[LtBackLift] = 127;
}
else if(vexRT[Btn7L] == 1)//autotap
{
if(SensorValue(potentiometerRt) > 2300)
{
if(SensorValue(potentiometerRt) > 2450)
{
motor[RtFrontLift] = 30;
motor[LtFrontLift] = 30;
motor[RtBackLift] = 30;
motor[LtBackLift] = 30;
}
else
{
motor[RtFrontLift] = 10;
motor[LtFrontLift] = 10;
motor[RtBackLift] = 10;
motor[LtBackLift] = 10;
}
}
else
{
if(SensorValue(potentiometerRt) < 2300)
{
motor[RtFrontLift] = -127;
motor[LtFrontLift] = -127;
motor[RtBackLift] = -127;
motor[LtBackLift] = -127;
}
else
{
motor[RtFrontLift] = 10;
motor[LtFrontLift] = 10;
motor[RtBackLift] = 10;
motor[LtBackLift] = 10;
}
}
}
else
{
motor[RtFrontLift] = 0;
motor[LtFrontLift] = 0;
motor[RtBackLift] = 0;
motor[LtBackLift] = 0;
}
Function being used to lift up:
void liftup(int distance, int speed)
{
while(SensorValue[potentiometerLt] > distance)
{
motor[LtFrontLift] = speed - 50;
motor[LtBackLift] = speed - 50;
motor[RtFrontLift] = speed;
motor[RtBackLift] = speed;
}
motor[LtFrontLift] = 10;
motor[LtBackLift] = 10;
motor[RtFrontLift] = 10;
motor[RtBackLift] = 10;
}
and is called in the program using:
liftup(1200,127);
This issue is still present if we lift using time instead of potentiometer values and set the power to 127:
void liftTime(int time)
{
motor[RtFrontLift] = 127;
motor[LtFrontLift] = 127;
motor[RtBackLift] = 127;
motor[LtBackLift] = 127;
wait1Msec(time);
motor[RtFrontLift] = 0;
motor[LtFrontLift] = 0;
motor[RtBackLift] = 0;
motor[LtBackLift] = 0;
}
called using:
liftTime(2000);
Does anyone have any ideas as to why this is only happening in autonomous and not driver control?
Things we have ruled out:
Physical issue- the lift lifts fine in driver control
Potentiometer issue- the lift is stopping fine once it reaches the target position and other parts of the program which use the potentiometer work fine.
We have also tried subtracting power from the side which is moving up faster(the left side). Even subtracting 30-40 power from that side does not get rid of the tilt.
COMPLETE ROBOT CODE: http://pastebin.com/T189tLUt
Lift functions start on line 157
The button used to activate autonomous(we lost our competition switch) and the autonomous code is on line 380
Buttons to lift up and down start on line 557
Thank you!