Setting up a two-stage lift process in vexcode text

I’m trying to make it so that when tilting up the cube tray, it goes fast at first (ex: 50 deg/sec), then slows down when approaching vertical to allow for finer adjustments to the stack.
Currently i have this set up in main():

//set the cubetilt motor's 0 position to the starting position
    cubeTilt.resetRotation();

    //Set up callbacks for autonomous and driver control periods.
    Competition.autonomous( autonomous );
    Competition.drivercontrol( usercontrol );

and then in driver control:

if(cubeTilt.rotation(vex::rotationUnits::deg) < 90) {
     cubeTilt.spin(vex::directionType::fwd, 50, vex::velocityUnits::dps);
}
else {
     cubeTilt.spin(vex::directionType::fwd, 10, vex::velocityUnits::dps);
}

this currently does nothing. the speed never changes. Any ideas on how to fix this?

Make sure the tray motor is spinning in a positive direction it may be approaching -90 degrees so that the if statement is never false. 2nd Make sure it passes that 90 degree angle or condition is never false. Finally make sure it sets the zero position when the trays at the zero value so the degree value is consistent each time

2 Likes

yeah i was trying to figure out when would be the best time to set the zero position. After auton won’t work cuz the tray isnt all the way down

A potentiometer works great for this situation. We are using one for this same purpose

a what now?
20 characters

https://renegaderobotics.org/vex-sensors-potentiometer/

2 Likes