|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools |
Rating:
|
Display Modes |
|
#1
|
|||
|
|||
|
Hello,
My team currently uses an elevator mechanism to raise and stack totes. Earlier we implemented PID and created set points to automatically stack totes for the our drive team. We measured potentiometer values in order to obtain these set points then subtract the bottom potentiometer value from the set points in order to find the difference. This was done in order to allow us to reset the set points, if the potentiometer does shift, each time the elevator trips our bottom limit switch. Currently the elevator correctly cycles through the set points, forwards and backwards, without the totes. The elevator also correctly cycles downwards with the totes on the elevator; however, the elevator cannot cycle upwards while it is holding totes. I believe this is due to the way PID works. PID detects the distance needed to travel, and calculates the necessary speed in order to quickly reach the set point without overshooting. The problem is that totes introduce a second dynamic, weight. The more weight the elevator must move, the greater speed/current is needed to move the elevator arm up. PID however, cannot calculate this. The PID is still calculating a speed based on the distance, though it notices that the distance is not decreasing at the desired speed. The PID does not adapt by increasing the speed; rather it recalculates the speed based on the distance again. Here is the code we have implemented. public class ElevatorNextSetpoint extends Command { public ElevatorNextSetpoint() { // Use requires() here to declare subsystem dependencies // eg. requires(chassis); // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUIRES requires(Robot.elevator); // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUIRES } // Called just before this Command runs the first time protected void initialize() { //Go to next setpoint Robot.elevator.incrementSetpoint(); } // Called repeatedly when this Command is scheduled to run protected void execute() { } // Make this return true when this Command no longer needs to run execute() protected boolean isFinished() { return true; } // Called once after isFinished returns true protected void end() { } // Called when another command which requires one or more of the same // subsystems is scheduled to run protected void interrupted() { } \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ public static final int POTENTIOMETER_NOISE = 30; public void incrementSetpoint() { for (int i = 0; i < setpointArray.length; i++) { if (setpointArray[i] >= potentiometer.get() + POTENTIOMETER_NOISE) { //setpointArray[] contains our setSetpoint(setpointArray[i]); break; } } } \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ public void decrementSetpoint() { for (int i = setpointArray.length - 1; i >= 0; i--) { if (setpointArray[i] < potentiometer.get() - POTENTIOMETER_NOISE) { setSetpoint(setpointArray[i]); break; } } } \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ public void resetPotentiometerValues(){ BOTTOM = returnPIDInput(); STAGING_HEIGHT = BOTTOM + STAGING_DIFF_FROM_BOTTOM; ONE_TOTE_HIGH = STAGING_HEIGHT + ONE_TOTE_DIFF_FROM_STAGING; TWO_TOTE_HIGH = ONE_TOTE_HIGH + TWO_TOTE_DIFF_FROM_ONE_TOTE; TOP = TWO_TOTE_HIGH + TOP_DIFF_FROM_TWO_TOTE; } |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|