Having Problems Auto straightening scissor lift

I have been having problems regarding my Auto straightening code.

When the button is pressed to make the lift lift, it doesn’t per say skip, but as it moves the motors are very fidgety and it moves very slow. When it goes down on an identical but reversed code, it moves perfectly fine. My code for auto straightening is as follow;


if(vexRT[Btn6U] == 1)
		{

			//left slower than Right
			if(SensorValue((LeftLift) < (RightLift))&& (vexRT[Btn6U]==1))
			{

					motor[LeftLift1]=127;
					motor[LeftLift2]=127;
					motor[RightLift1]=60;
					motor[RightLift2]=60;



			}
			//Right slower than left
			if(SensorValue((LeftLift) > (RightLift))&& (vexRT[Btn6U]==1))
			{

					motor[RightLift1]=127;
					motor[RightLift2]=127;
					motor[LeftLift1]=60;
					motor[LeftLift2]=60;



			}
			//Motors are equal
			if(SensorValue((LeftLift) == (RightLift))&& (vexRT[Btn6U]==1))
			{

					motor[RightLift1]=80;
					motor[RightLift2]=80;
					motor[LeftLift1]=80;
					motor[LeftLift2]=80;

			}

		}
		else
		{
			motor[RightLift1]=0;
			motor[RightLift2]=0;
			motor[LeftLift1]=0;
			motor[LeftLift2]=0;
		}


		//down
		if(vexRT[Btn6D] == 1)
		{
			SensorValue(LeftLift)=0;
			SensorValue(RightLift)=0;

			//left slower than Right
			if(SensorValue((LeftLift) < (RightLift))&& (vexRT[Btn6D]==1))
			{

					motor[LeftLift1]=-40;
					motor[LeftLift2]=-40;
					motor[RightLift1]=-60;
					motor[RightLift2]=-60;

			}
			//Right slower than left
			if(SensorValue((LeftLift) > (RightLift))&& (vexRT[Btn6D]==1))
			{
					motor[RightLift1]=-40;
					motor[RightLift2]=-40;
					motor[LeftLift1]=-60;
					motor[LeftLift2]=-60;


			}
			//Motors are equal
			if(SensorValue((LeftLift) == (RightLift))&& (vexRT[Btn6D]==1))
			{

					motor[RightLift1]=-60;
					motor[RightLift2]=-60;
					motor[LeftLift1]=-60;
					motor[LeftLift2]=-60;
			}

		}
		else
		{
			motor[RightLift1]=0;
			motor[RightLift2]=0;
			motor[LeftLift1]=0;
			motor[LeftLift2]=0;
		}

Thanks in Advance!

The problem is probably that 60 vs 127 is too great of a difference and and a command of 60 is not enough to raise your lift. Furthermore, your motors are probably switching quickly between 60 and 127 as each side becomes slightly higher (then lower then higher again) than the other.

You should either try some kind of proportional code or at least allow for a small amount of difference in the sensor values before giving the motors different powers, and don’t make those different powers so different.

Also, why do set the sensor values to 0 when you go down? Wouldn’t that mean that the 2 sides would always be equal going down and the other if statements are not necessary?

Also, if your lift goes down quickly at -60, then 80 is probably not large enough to raise your lift. I would just give the motors something closer to 127 if your sides are level. (or add rubber bands perhaps)

I’m just guessing that because you don’t have a deadband defined for your sensor values, your code is almost always going to see one side being higher than the other, even if only by a tiny amount. Therefore the code will be switching the power from 127 to 60 from side to side quite fast, and perhaps that is not really averaging out the way you might hope it would, perhaps due to the way the Cortex actually handles such commands. But that’s just a guess.

EDIT: Oops, looks like Highwayman already said that: