Go to Post I highly doubt the game has anything to do with water... - rotolomi [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 11 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 02-03-2015, 20:11
ashaylok ashaylok is offline
Registered User
FRC #2876
 
Join Date: Feb 2015
Location: Burlington
Posts: 2
ashaylok is an unknown quantity at this point
Exclamation PID Controller Help on Tote Lifting Mechanism

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;
}
Reply With Quote
  #2   Spotlight this post!  
Unread 02-03-2015, 20:51
TFleig78's Avatar
TFleig78 TFleig78 is offline
Registered User
AKA: Tyler
FRC #0078 (Air Strike)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Rhode Island
Posts: 58
TFleig78 will become famous soon enoughTFleig78 will become famous soon enough
Re: PID Controller Help on Tote Lifting Mechanism

The PID does not calculate output based solely on distance to the setpoint(error). The I gain accumulates the error over time and the D gain adds to the output based on the rate of change of the error. Are your I and D gains currently set to 0? If so, you should try giving them a nonzero value and go from there.
Reply With Quote
  #3   Spotlight this post!  
Unread 02-03-2015, 21:21
dellagd's Avatar
dellagd dellagd is offline
Look for me on the field!
AKA: Griffin D
FRC #2590 (Nemesis) #2607 (The Fighting Robovikings)
Team Role: Mentor
 
Join Date: Sep 2011
Rookie Year: 2011
Location: PA
Posts: 890
dellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond repute
Re: PID Controller Help on Tote Lifting Mechanism

It seems what you described is not PID control, but more simply just P control, which will most likely not get to a set point on an elevator that would fall by gravity if the motor was sent a zero voltage.

The I value of PID will allow the controller to accumulate the error over time, such that the longer the elevator is away from its set point, the more error that will accumulate, and the harder the controller will consequently drive the motor to get to said setpoint. With more load, the I value will take longer to accumulate the error required, so it probably wouldn't reach the set point as fast, but regardless of weight, it should lift it fully, as long as the elevator is physically capable of it.

As the elevator is at its set point, this I value persists (unless intentionally reset), and will hold your elevator at that point. If you do this though, be careful about it, as you are stalling the motors, which is pretty bad unless you're using something sealed like a CIM (and you're careful about it).


However, more of the code would help, such as for the elevator itself and what class contains the setSetpoint() method so we can all see how you define the PID controller.
__________________
Check out some cool personal projects in computers, electronics, and RC vehicles on my blog!

2016 MAR DCMP Engineering Excellence Award
2016 MAR Westtown Innovation in Control Award
2016 MAR Hatboro-Horsham Industrial Design Award
2015 Upper Darby District Winners - Thanks 225 and 4460!
2015 Upper Darby District Industrial Design Award
2015 Hatboro-Horsham District Winners - Thanks 2590 and 5407!
2014 Virginia Regional Winners - Thanks so much 384 and 1610, I will never forget that experience!
2014 Virginia Quality Award
2014 MAR Bridgewater-Raritan Innovation in Control Award
2014 MAR Hatboro-Horsham Gracious Professionalism Award
2013 MAR Bridgewater-Raritan Innovation in Control Award
2012 MAR Lenape Quality Award

Last edited by dellagd : 02-03-2015 at 21:26.
Reply With Quote
  #4   Spotlight this post!  
Unread 02-03-2015, 22:01
loafdog loafdog is offline
Registered User
AKA: Maciej
FRC #2876 (DevilBotz)
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2009
Location: Burlington, MA
Posts: 33
loafdog is an unknown quantity at this point
Re: PID Controller Help on Tote Lifting Mechanism

You can view our code here:

https://code.google.com/p/frc2876/so...ecycleRush2876
Reply With Quote
  #5   Spotlight this post!  
Unread 02-03-2015, 22:47
TFleig78's Avatar
TFleig78 TFleig78 is offline
Registered User
AKA: Tyler
FRC #0078 (Air Strike)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Rhode Island
Posts: 58
TFleig78 will become famous soon enoughTFleig78 will become famous soon enough
Re: PID Controller Help on Tote Lifting Mechanism

Code:
super("Elevator", 0.008, 0.0, 0.008);
It looks like you don't have an I value. Try adding adding a value and the cycles up should be better.

Last edited by TFleig78 : 03-03-2015 at 14:46.
Reply With Quote
  #6   Spotlight this post!  
Unread 02-03-2015, 23:08
dellagd's Avatar
dellagd dellagd is offline
Look for me on the field!
AKA: Griffin D
FRC #2590 (Nemesis) #2607 (The Fighting Robovikings)
Team Role: Mentor
 
Join Date: Sep 2011
Rookie Year: 2011
Location: PA
Posts: 890
dellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond repute
Re: PID Controller Help on Tote Lifting Mechanism

Code:
super("Elevator", 0.008, 0.0, 0.008);
__________________
Check out some cool personal projects in computers, electronics, and RC vehicles on my blog!

2016 MAR DCMP Engineering Excellence Award
2016 MAR Westtown Innovation in Control Award
2016 MAR Hatboro-Horsham Industrial Design Award
2015 Upper Darby District Winners - Thanks 225 and 4460!
2015 Upper Darby District Industrial Design Award
2015 Hatboro-Horsham District Winners - Thanks 2590 and 5407!
2014 Virginia Regional Winners - Thanks so much 384 and 1610, I will never forget that experience!
2014 Virginia Quality Award
2014 MAR Bridgewater-Raritan Innovation in Control Award
2014 MAR Hatboro-Horsham Gracious Professionalism Award
2013 MAR Bridgewater-Raritan Innovation in Control Award
2012 MAR Lenape Quality Award
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:27.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi