Claw Doesn't Stay Put

Hi! We’re a new team and this is our third competition so far. We’ve developed our robot and had a really nice conveyor belt going but it was too heavy, so we switched to the claw. Since we have an eight bar design, we attached axles and mounted the claw in there. Unfortunately, the claw doesn’t seem to stay idle when we don’t press the trigger. We suspect that it’s a problem with the program. Any ideas?

task usercontrol()
{
	while (true)
	{
		motor[flm] = vexRT[Ch3];
		motor[blm] = vexRT[Ch3];
		motor[frm] = vexRT[Ch2];
		motor[brm] = vexRT[Ch2];
		
		if(vexRT[Btn6U] == 1)
		{
			motor[liftright] = 127;
			motor[liftleft] = 127;
			motor[liftright2] = 127;
			motor[liftleft2] = 127;
		}
		else
		{
			motor[liftright] = 0;
			motor[liftleft] = 0;
			motor[liftright2] = 0;
			motor[liftleft2] = 0;
		}

		if(vexRT[Btn5U] == 1)
		{
			motor[liftleft] = -30;
			motor[liftright] = -30;
			motor[liftleft2] = -30;
			motor[liftright2] = -30;
		}
		else
		{
			motor[liftright] = 0;
			motor[liftleft] = 0;
			motor[liftright2] = 0;
			motor[liftleft2] = 0;
		}
		if(vexRT[Btn5D] == 1)
		{
			motor[claw] = 127;
		}
		else
		{
			motor[claw] = 0;
		}
		if(vexRT[Btn6D] == 1)
		{
			motor[claw] = -127;
		}
		else
		{
			motor[claw] = 0;
		}
		if(vexRT[Btn8D] == 1)
		{
			motor[elbow] = 70;
		}
		else
		{
			motor[elbow] = -5;

		}
		if(vexRT[Btn8U] == 1)
		{
			motor[elbow] = -110;
		}
		else
		{
			motor[elbow] = -5;
		}
	}
}

Not sure what you mean by “doesn’t stay idle” but this code has the common problem of sending more than one value to the motor each time around the while loop. The claw should have no power when neither button is pressed, but may have “jittered” when moving.

if(vexRT[Btn5D] == 1)
		{
			motor[claw] = 127;
		}
		else
		{
			motor[claw] = 0;
		}
		if(vexRT[Btn6D] == 1)
		{
			motor[claw] = -127;
		}
		else
		{
			motor[claw] = 0;
		}

try as follows.

if(vexRT[Btn5D] == 1)
    motor[claw] = 127;
else
if(vexRT[Btn6D] == 1)
    motor[claw] = -127;
else
    motor[claw] = 0;

The elbow code has the same issue.

have a look at this post for an explanation.
https://vexforum.com/showpost.php?p=373181&postcount=4

Thank you for fixing it! What I mean’t buy not staying idle is that the claw doesn’t stay still and is loose. I think it’s going to work now.

When you remove all power from the claw, by sending a motor value of 0, it will be “loose”. If you need it to hold an object then send a small value such as 10 (or -10 depending on which way it is wired) instead.

If you ever have any problems with the programming, I would recommend regearing the claw so the friction between all the gears keeps is held at the point you stop no matter what.

Basically like what we have on our lift, it won’t move until power is sent to motors, you will break the gears before you make our lift go up or down by using force.