Code problems-claw tilt

void usercontrol(void) {
while (true) {
Lift.setStopping(hold);
Lift2.setStopping(hold);
Tilt.setStopping(hold);
RightWheel.spin(vex::directionType::fwd, (Controller1.Axis3.value()*0.75),vex::velocityUnits::pct);
LeftWheel.spin(vex::directionType::fwd, (Controller1.Axis2.value()*0.75), vex::velocityUnits::pct);

if (Controller2.ButtonDown.pressing()) {
  Lift.setVelocity(127,percent);
  Lift2.setVelocity(127,percent);
  Lift2.spin(forward);
  Lift.spin(forward);
  Tilt.setVelocity(-30,percent);
  Tilt.spin(forward);
} 
else if (Controller2.ButtonUp.pressing()) {
  Lift.setVelocity(-127,percent);
  Lift2.setVelocity(-127,percent);
  Lift2.spin(forward);
  Lift.spin(forward);
  Tilt.setVelocity(40,percent);
  Tilt.spin(forward);
} 
else {
  Lift.stop();
  Lift2.stop();
  Tilt.stop();
}
if (Controller2.ButtonR2.pressing()) {
  Claw.setVelocity(127,percent);
  Claw.spin(forward);
} 
else if (Controller2.ButtonR1.pressing()) {
  Claw.setVelocity(127,percent);
  Claw.spin(reverse);
}
else {
  Claw.setVelocity(0,percent);
}

This is our code, we are currently having problems with the motor called Tilt, we are trying to get it to move in sync with the motors called, Lift, and Lift2. If anybody could find the problem and help us fix it, that would be greatly appreciated. We use VEXcode V5 Text.

What happens, if anything, when this is run? Also percent values go -100 to 100.

It could be you setting the speed in different areas. Like when you push the up button it has to read from top to bottom. So it sets the first speeds of the system then starts the lifts and then has to set speed of tilt and then run it and repeats this over and over. Maybe try to move the speed settings all to the top so when you click the button it sets all the speeds then moves everything.

2 Likes

When we run the code whenever the tilt goes up it gets very jerky but when it goes down it starts to coast. Also, in our other codes we have it set up the same way, just without the brakes and it works perfectly fine, we are wondering if it might be because of the brakes. Our claw also has the same problem of coasting when closing and jerking when opening. We also want to let you know that our claw and tilt motors are torque motors and were wondering if that could be a problem too.

For your Claw you never tell it to stop, you only set the velocity to zero. Try using a brake type and a stop command instead. I would not recommend re-setting your velocity every couple msec that the button is held down. Instead set the velocity before your main driver loop and change the direction the motors are spinning instead of switching from positive to negative velocities. Aside from trying to condense your code (a lot of your if statements can be condensed to 1 or 2 lines) I don’t know what more to do.

Our claw and tilt only started malfunctioning when we put a brake on either of them and even though we took the brakes off they still aren’t working properly.

You could try a simpler method and set the velocity in the .spin() function. Also, the software probably handles this but, I don’t know if you can set the motor speed to 127%. You might be thinking Cortex.

if (Controller2.ButtonDown.pressing()) {
  Lift2.spin(forward, 100,percent);
  Lift.spin(forward, 100, percent);
  Tilt.spin(forward, -30, percent);
} 
else if (Controller2.ButtonUp.pressing()) {
  Lift2.spin(forward, -100,percent);
  Lift.spin(forward, -100, percent);
  Tilt.spin(forward, 40, percent);
} 
else {
  Lift.stop(hold);
  Lift2.stop(hold);
  Tilt.stop(hold);
}
3 Likes

Nothing changed the claw is still jerking and coasting. We are trying to get the tilt to move in sync with the lift so that whenever the lift goes up or down the tilt will keep the claw level. Is there any that you know of to be able to make this happen?

Just curious, are you using a gear ratio to move your lift or is the lift directly connected to your motor? Perhaps a photo of your robot might help.

1 Like

IMG_20200224_160526419 (1)
IMG_20200224_160521554

Are there 2 motors holding the lift up or 1. And what type of cartridge/s are in there?’

we have two torque motors holding up the lift, by the way, we have a wooden lizard named pigeon

wait, If you built a 6 bar doesn’t one of the bars stay level all the time? couldn’t you attach the claw to that bar and not worry about a motor tilt?

well our robot can reach all of the towers and right now we are trying to get the claw to stay level whenever we go to a different tower

What I am trying to say is six-bar lifts are built in such a way that the vertical bar at the end of the lift remains vertical and perpendicular to the ground. Like this. You can mount the claw to this bar and it will remain parallel to the ground.

Could you try adding a new Variable for claw and lift and program it so that a button turns both motors at a different rate?

Our original code was set like this, our tilt set to the same button as the lift. We decided to add a brake to the lift because it would drift because of the weight on the end of the lift being the claw and the claw tilt motors and thats when our problems started occuring. Our problems being the claw jerking when opening and coasting when closing and our tilt jerking when moving up and coasting when moving down.

But can’t you have 2 if else statements programmed to the same button?

We tried this too and it still didn’t work. Also do you mean else if statements?

1 Like

Yes, my bad. I am very sorry for my mistake. I do wish that you shall forgive me