Go to Post FIRST robotics: Not just for nerds. - Koko Ed [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 25-11-2015, 20:24
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,574
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Oscillating Motor - PID Subsystem

I haven't looked at your details yet, but in general a larger magnitude for D (that is, derivative of the error, or velocity for a mechanical system going for a position) will act like a dashpot/shock absorber and dampen your system.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #2   Spotlight this post!  
Unread 25-11-2015, 20:53
Asymons Asymons is offline
Registered User
FRC #4716 (Purple Raiders)
Team Role: Driver
 
Join Date: Apr 2013
Rookie Year: 2013
Location: Ontario
Posts: 33
Asymons is an unknown quantity at this point
Re: Oscillating Motor - PID Subsystem

Quote:
Originally Posted by GeeTwo View Post
I haven't looked at your details yet, but in general a larger magnitude for D (that is, derivative of the error, or velocity for a mechanical system going for a position) will act like a dashpot/shock absorber and dampen your system.
Thanks for the advice. Once you read the details, I have a couple of questions: Are you suggesting I should add in the derivative of error to fix the oscillation of the motor?
How would the tuning work if the system has an issue with just a P-closed loop essentially? Would that not continue having error in the sense of a continued oscillation?

Last edited by Asymons : 25-11-2015 at 20:56.
Reply With Quote
  #3   Spotlight this post!  
Unread 25-11-2015, 21:30
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,574
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Oscillating Motor - PID Subsystem

Quote:
Originally Posted by Asymons View Post
Thanks for the advice. Once you read the details, I have a couple of questions: Are you suggesting I should add in the derivative of error to fix the oscillation of the motor?
No, just to use a non-zero, probably constant value of D. It is convenient to think of D as standing for dampening as well as derivative.

Quote:
Originally Posted by Asymons View Post
How would the tuning work if the system has an issue with just a P-closed loop essentially? Would that not continue having error in the sense of a continued oscillation?
A P-only PID feedback system is (assuming that the mechanical system is linear) is mathematically identical to an undamped spring-and-mass; you would expect it to oscillate for a long time. When the system is far from the target, it is accelerated towards the target. By the time it reaches the target, it has significant speed, but there is no frictional term to slow it down, so it overshoots. You have essentially made a system in which F=kx (Hooke's Law). In terms of a differential equation, it becomes the simple x''=(k/m)x, where k/m is proportional to your P term. If you have done calculus 1 it is easy to verify that one solution to this equation is x=sin(sqrt(k/m)t), that is displacement is described as an undamped sine wave. Some sort of friction term is required to dissipate the initial "potential energy"; neither P nor I do this. Both D and mechanical friction will dampen the oscillations.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.

Last edited by GeeTwo : 25-11-2015 at 21:32.
Reply With Quote
  #4   Spotlight this post!  
Unread 25-11-2015, 21:48
Asymons Asymons is offline
Registered User
FRC #4716 (Purple Raiders)
Team Role: Driver
 
Join Date: Apr 2013
Rookie Year: 2013
Location: Ontario
Posts: 33
Asymons is an unknown quantity at this point
Re: Oscillating Motor - PID Subsystem

Quote:
Originally Posted by GeeTwo View Post
No, just to use a non-zero, probably constant value of D. It is convenient to think of D as standing for dampening as well as derivative.

A P-only PID feedback system is (assuming that the mechanical system is linear) is mathematically identical to an undamped spring-and-mass; you would expect it to oscillate for a long time. When the system is far from the target, it is accelerated towards the target. By the time it reaches the target, it has significant speed, but there is no frictional term to slow it down, so it overshoots. You have essentially made a system in which F=kx (Hooke's Law). In terms of a differential equation, it becomes the simple x''=(k/m)x, where k/m is proportional to your P term. If you have done calculus 1 it is easy to verify that one solution to this equation is x=sin(sqrt(k/m)t), that is displacement is described as an undamped sine wave. Some sort of friction term is required to dissipate the initial "potential energy"; neither P nor I do this. Both D and mechanical friction will dampen the oscillations.
Thank you for this excellent response! As soon as I get access to the robot again, I'll try adjusting the variables and add a D constant. Hopefully this is the only issue, otherwise I'll be back here. Would it be acceptable to private message you if another issue arises as it seems you have some experience dealing with PID loops? I'll try not to be too bothersome
Reply With Quote
  #5   Spotlight this post!  
Unread 25-11-2015, 22:02
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,574
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Oscillating Motor - PID Subsystem

Quote:
Originally Posted by Asymons View Post
Thank you for this excellent response! As soon as I get access to the robot again, I'll try adjusting the variables and add a D constant. Hopefully this is the only issue, otherwise I'll be back here. Would it be acceptable to private message you if another issue arises as it seems you have some experience dealing with PID loops? I'll try not to be too bothersome
Certainly, though my PID knowledge is far more theoretical than practical. If you don't mind, though, it probably makes more sense to put this on the open forum where someone else may benefit. I know there are a lot of "lurkers" who never post answers and rarely ask questions themselves, but find answers on CD regularly. CD is here for them, too!

--Gus
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #6   Spotlight this post!  
Unread 26-11-2015, 08:31
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 429
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Oscillating Motor - PID Subsystem

Regarding the command continuing to run between the robot being enabled/disabled:

Your command will only finish if the onTarget method returns true.
Code:
protected boolean isFinished() {
    	return Robot.pidelevator.onTarget();
    }
When the robot is disabled commands aren't automatically disabled, the command is still trying to move the motors, the outputs to the motor controllers are disabled. So when you re-enable, the command continues to try to get the elevator to the setpoint.

Add something like:
Code:
Scheduler.getInstance().removeAll();
Scheduler.getInstance().disable();
in your disabled periodic() method inside your main robot class. This will disable any command that's active when the robot is disabled.
__________________
http://team2168.org
Reply With Quote
  #7   Spotlight this post!  
Unread 26-11-2015, 12:09
Asymons Asymons is offline
Registered User
FRC #4716 (Purple Raiders)
Team Role: Driver
 
Join Date: Apr 2013
Rookie Year: 2013
Location: Ontario
Posts: 33
Asymons is an unknown quantity at this point
Re: Oscillating Motor - PID Subsystem

In that case, Gus' suggestion, as well as James worked!

So my solution was as followed:
-Added the D value, set it to 1.0 and eventually lowered this value to 0.1 due to the lift "skipping".
-Absolute Tolerance was adjusted from 200 to 20, which it finally remained at 50 to keep the lift moving smoothly.
-P value was adjusted to 0.05
-Added Robot.elevator.disable(); at end of command

Doing all this, I was able to get the lift to stop at a set point, or have it skip once and get to the set point.

I'm most likely going to learn common tuning practices;however, I've mostly seen people use the "guess and check" method.

Last edited by Asymons : 26-11-2015 at 12:11.
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:16.

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