Vexcode DR4B Lift error

I was using my DR4B and the lift was really smooth going up but when I tried to move it down a little (its in the Right JStick), the lift starts to move up. and when I pull it down more it starts to fight and starts to jostle. and even more than that it come crashing. please help
Here ismy code that pertains to the Lift:

LLift.spin(vex::directionType::fwd, (Controller1.Axis1.value() + Controller1.Axis2.value()), vex::velocityUnits::pct);
RLift.spin(vex::directionType::fwd, (Controller1.Axis1.value() + Controller1.Axis2.value()), vex::velocityUnits::pct);

And

//Making sure the Lift doesn’t go too low

    if(LLift.rotation(rotationUnits::deg) >= 30)
    {
      LLift.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
      RLift.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);    
    }
    else
    {
       LLift.spin(vex::directionType::fwd, (Controller1.Axis1.value() + Controller1.Axis2.value()), vex::velocityUnits::pct);
    RLift.spin(vex::directionType::fwd, (Controller1.Axis1.value() + Controller1.Axis2.value()), vex::velocityUnits::pct);
    }
    
    //Making the lift stop when nobody moves the Jstick
    
    if((Controller1.Axis1.value() + Controller1.Axis2.value()) == 0)
    {
      Lift.stop(brakeType::brake);
    }

    else
    {
      LLift.spin(vex::directionType::fwd, (Controller1.Axis1.value() + Controller1.Axis2.value()), vex::velocityUnits::pct);
    RLift.spin(vex::directionType::fwd, (Controller1.Axis1.value() + Controller1.Axis2.value()), vex::velocityUnits::pct);

    }
    
    //Height Control
    Controller1.ButtonUp.pressed(HeightUp);
    
    Controller1.ButtonDown.pressed((HeightDown));

  if(Left_Value < Right_Value)
  {
    LLift.spin(vex::directionType::fwd, (Controller1.Axis1.value() + Controller1.Axis2.value()), vex::velocityUnits::pct);
    RLift.spin(vex::directionType::fwd, (Controller1.Axis1.value() + Controller1.Axis2.value())/2, vex::velocityUnits::pct);

  }
  else if(Right_Value < Left_Value)
  {
    LLift.spin(vex::directionType::fwd, (Controller1.Axis1.value() + Controller1.Axis2.value())/2, vex::velocityUnits::pct);
    RLift.spin(vex::directionType::fwd, (Controller1.Axis1.value() + Controller1.Axis2.value()), vex::velocityUnits::pct);

  }
  else 
  {
    LLift.spin(vex::directionType::fwd, (Controller1.Axis1.value() + Controller1.Axis2.value()), vex::velocityUnits::pct);
    RLift.spin(vex::directionType::fwd, (Controller1.Axis1.value() + Controller1.Axis2.value()), vex::velocityUnits::pct);

  }

Well, the way you’ve programmed it, it takes the value from both the horizontal and vertical axis, so maybe try having it only take value from axis 2.

Thank you, I will try that

If this is part of the code from the inside of the while(1) loop, please do not call button.pressed() there. It has to be called only once outside of the loop where you setup your callback functions.

Have you considered using rotateTo() function to let V5 builtin PID to take care of the holding the lift. Then you just adjust target position with joystick.

If not, then it is very best to use axle connecting pinion gears on the left and right side of the lift to ensure both sides stay level.

2 Likes