I’m working on some functions for my lift. I have a function that runs the lift all the way down and uses a potentiometer. However, when I call it, it doesn’t run. Things you need to know: the potentiometer value decreases as I go up, positive speeds run the lift up, negative down, and I have a ‘break-out’ just in case the lift gets stuck or if the driver wants to just stop the process. Code below:
void driveMainLift(int speed) {
motor[leftMainLift] = speed;
motor[rightMainLift] = speed;
}
void driveLiftToSpecificPotentValue(int setPoint, int speed) {
if(setPoint < SensorValue[mainLiftPotent]) { //if true that means lift must run up, giving a postive value
while(SensorValue[mainLiftPotent] > setPoint) { //keep lifting up until reach setPoint
driveMainLift(fabs(speed));
wait1Msec(cycleTime); //buffer time
}
}
else if (setPoint > SensorValue[mainLiftPotent]) { //if true that means lift must run dowm, giving a negative value
while(SensorValue[mainLiftPotent] < setPoint) { //keep lifting up until reach setPoint
driveMainLift(-fabs(speed));
wait1Msec(cycleTime); //buffer time
}
}
else { //if there is a special case or something went wrong then set to 0 (its a safety check really)
driveMainLift(0);
}
driveMainLift(0); //another safety check after the process of moving is down because I have ocd
}
void moveLiftAllTheWayDown() { //used during driving period
if(vexRT[Btn6UXmtr2]) { //if button six up is pressed
bool quitLiftFunction = false; //quit function bool
while((SensorValue[mainLiftPotent] > 3400) && !quitLiftFunction) { //keep looping (3400 is a good 'low' point I chose)
driveLiftToSpecificPotentValue(3400, 120);
if(vexRT[Btn6DXmtr2]) { //if you want to quit function press button 6 down
quitLiftFunction = true;
}
chassisDriverControl(); //other driver functions so that they aren't cut off while lift doing its thing
mainLiftDriverControl();
intakeMoverDriverControl();
wait1Msec(cycleTime); //buffer time
}
driveMainLift(0); //ocd
quitLiftFunction = false; //ocd
}
}